tui

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Overview

Package tui presents the Coding Runtime as a terminal-first chat interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, options Options) (returnErr error)

Run owns the terminal Program and closes any acquired Controller after the terminal has been restored.

Types

type Bootstrap

type Bootstrap func(context.Context, bool) (Controller, error)

Bootstrap loads configuration and opens the first Runtime. trustProject is the user's explicit Workspace trust decision.

type Controller

type Controller interface {
	Prompt(context.Context, ...ai.Message) iter.Seq2[coding.Event, error]
	Continue(context.Context) iter.Seq2[coding.Event, error]
	Resolve(context.Context, approval.Resolution) iter.Seq2[coding.Event, error]
	ResolveQuestion(context.Context, question.Resolution) iter.Seq2[coding.Event, error]
	RejectQuestion(context.Context, string, string) iter.Seq2[coding.Event, error]
	Tree(context.Context) (coding.SessionTree, error)
	PreviewCompaction(context.Context) (coding.CompactionPreview, error)
	Navigate(context.Context, string, bool) iter.Seq2[coding.Event, error]
	Compact(context.Context, coding.CompactionRequest) iter.Seq2[coding.Event, error]
	Steer(...ai.Message) error
	FollowUp(...ai.Message) error
	Cancel() error
	Reload(context.Context) error
	ListWorkspaceFiles(context.Context) (attachment.Snapshot, error)
	ResolveWorkspaceFile(context.Context, attachment.Reference) (attachment.Resolved, error)
	Snapshot() coding.State
	SessionID() string
	Model() runtimecontrol.ModelState
	Capabilities() ai.Capabilities
	Mode() runtimecontrol.ModeState
	SetMode(context.Context, coding.OperatingMode) error
	Permissions() runtimecontrol.PermissionState
	NewFullAccessConfirmation(context.Context, runtimecontrol.PermissionUpdate) (*runtimecontrol.FullAccessConfirmation, error)
	SetPermissions(context.Context, runtimecontrol.PermissionUpdate, ...*runtimecontrol.FullAccessConfirmation) error
	WorkspaceStatus(context.Context) (changes.WorktreeStatus, error)
	Models() []modelcatalog.Entry
	Config() config.Config
	Detached() bool
	ListSessions(context.Context) ([]session.Metadata, error)
	ListSessionSummaries(context.Context) ([]runtimecontrol.SessionSummary, error)
	ListSubagents(context.Context) ([]subagent.Summary, error)
	InspectSubagent(context.Context, string) (subagent.Detail, error)
	InspectSubagentState(context.Context, string) (coding.State, error)
	GenerateTeamProposal(context.Context, coding.TeamProposalPrompt) (coding.TeamProposal, error)
	ReviseTeamProposal(context.Context, string, string) (coding.TeamProposal, error)
	DeclineTeam(context.Context, string) error
	ConfirmTeam(context.Context, coding.TeamConfirmation) (coding.TeamReference, error)
	ReadTeam(context.Context, coding.TeamReadRequest) (coding.TeamView, error)
	SubmitTeamControl(context.Context, coding.TeamControlRequest) (coding.TeamControlReference, error)
	ResolveTeamWorkerApproval(
		context.Context,
		coding.TeamWorkerTarget,
		approval.Resolution,
	) (coding.TeamControlReference, error)
	ResolveTeamWorkerQuestion(
		context.Context,
		coding.TeamWorkerTarget,
		question.Resolution,
	) (coding.TeamControlReference, error)
	RejectTeamWorkerQuestion(
		context.Context,
		coding.TeamWorkerTarget,
		string,
		string,
	) (coding.TeamControlReference, error)
	ObserveTeamWorker(context.Context, coding.TeamWorkerTarget) (coding.EventObservation, error)
	InspectTeamWorkerState(context.Context, coding.TeamWorkerTarget) (coding.State, error)
	DiscoverTeamRecovery(context.Context) ([]coding.TeamRecoveryCandidate, error)
	ResumeTeam(
		context.Context,
		team.ID,
		coding.TeamResumeDecision,
	) (coding.TeamReference, error)
	PrepareTeamIntegration(
		context.Context,
		coding.TeamIntegrationRequest,
	) (coding.TeamIntegrationPreview, error)
	ApplyTeamIntegration(
		context.Context,
		coding.TeamIntegrationApproval,
	) (coding.TeamIntegrationResult, error)
	RejectTeamIntegration(context.Context, coding.TeamIntegrationApproval) error
	TeamIntegrationRecoveries(context.Context) ([]coding.TeamIntegrationRecovery, error)
	RecoverTeamIntegration(
		context.Context,
		coding.TeamIntegrationRecoveryRequest,
	) (coding.TeamIntegrationResult, error)
	CleanupTeam(context.Context, coding.TeamCleanupRequest) (coding.TeamCleanupResult, error)
	Skills(context.Context) (coding.SkillSnapshot, error)
	SetSkillEnabled(context.Context, coding.SkillID, bool) error
	WaitSubagent(context.Context, string) (subagent.Result, error)
	CancelSubagent(context.Context, string) error
	NewSession(context.Context) error
	ResumeSession(context.Context, string) error
	ForkSession(context.Context, string) error
	SwitchModel(context.Context, modelcatalog.Selection) error
	Close(context.Context) error
}

Controller is the application control surface consumed by the TUI.

type ExitHandler

type ExitHandler func(ExitInfo) error

ExitHandler runs after terminal restoration and Controller release.

type ExitInfo

type ExitInfo struct {
	SessionID string
	Resumable bool
}

ExitInfo is the resumable conversation left by one normal TUI exit.

type ImageClipboard

type ImageClipboard interface {
	ReadImage(context.Context) ([]byte, error)
}

ImageClipboard is the one-method clipboard boundary consumed by the TUI.

type ImageIngress

type ImageIngress interface {
	Receive(context.Context) (attachment.Image, error)
}

ImageIngress receives validated immutable images from an application-owned bridge such as one remote SSH session.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the root Bubble Tea state machine.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init starts bootstrap immediately for an already trusted Workspace.

func (*Model) Update

func (m *Model) Update(message tea.Msg) (tea.Model, tea.Cmd)

Update applies terminal input and asynchronous bootstrap results.

func (*Model) View

func (m *Model) View() tea.View

View renders the inline lifecycle shell or ready chat layout.

type Options

type Options struct {
	Input          io.Reader
	Output         io.Writer
	Environment    []string
	Workspace      string
	ThemeDirectory string
	Trusted        bool
	NoColor        bool
	Bootstrap      Bootstrap
	Clipboard      ImageClipboard
	ImageIngress   ImageIngress
	OnExit         ExitHandler
	StatusLine     []statusline.Item
	SaveStatusLine StatusLineSaver
	SaveTheme      ThemeSaver
}

Options contain the CLI-owned resources used by one TUI Program.

type StatusLineSaver

type StatusLineSaver func(context.Context, []statusline.Item) error

StatusLineSaver atomically persists one complete ordered field selection.

type ThemeSaver

type ThemeSaver func(context.Context, string) error

ThemeSaver persists only the requested theme ID in the active config file.

type TrustError

type TrustError struct {
	Err error
}

TrustError means persisting an explicit Workspace trust decision failed and the Trust Overlay should remain available for retry.

func (*TrustError) Error

func (e *TrustError) Error() string

func (*TrustError) Unwrap

func (e *TrustError) Unwrap() error

Unwrap returns the persistence failure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL