tui

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() engine.Plugin

New creates a new terminal IO plugin.

Types

type Adapter

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

Adapter implements ui.UIAdapter using a BubbleTea program.

func NewAdapter

func NewAdapter(session *engine.SessionWorkspace, capabilities map[string][]string) *Adapter

NewAdapter creates a TUI adapter backed by BubbleTea. capabilities is the boot-time capability → provider-IDs map so the TUI can enable affordances (e.g. cancel) by capability rather than by specific plugin ID.

func (*Adapter) OnApprovalResponse

func (a *Adapter) OnApprovalResponse(handler func(ui.ApprovalResponseMessage))

OnApprovalResponse registers the callback for approval responses.

func (*Adapter) OnCancel

func (a *Adapter) OnCancel(handler func())

OnCancel registers the callback for cancel requests.

func (*Adapter) OnExit added in v0.31.0

func (a *Adapter) OnExit(handler func())

OnExit registers the callback run when the user quits the TUI (the program exits for any reason other than Stop).

func (*Adapter) OnInput

func (a *Adapter) OnInput(handler func(ui.InputMessage))

OnInput registers the callback for user input.

func (*Adapter) OnResume

func (a *Adapter) OnResume(handler func())

OnResume registers the callback for resume requests.

func (*Adapter) RequestApproval

func (a *Adapter) RequestApproval(msg ui.ApprovalRequestMessage) (ui.ApprovalResponseMessage, error)

RequestApproval sends an approval request and blocks until the user responds.

func (*Adapter) RequestHumanInput

func (a *Adapter) RequestHumanInput(msg ui.HITLRequestMessage) (ui.HITLResponseMessage, error)

RequestHumanInput sends a hitl request to the user and blocks until they respond. The TUI renders Prompt and (when present) Choices; the returned HITLResponseMessage carries the picked ChoiceID and/or FreeText answer.

func (*Adapter) SendCancelComplete

func (a *Adapter) SendCancelComplete(turnID string, resumable bool) error

SendCancelComplete notifies the TUI that a cancellation completed.

func (*Adapter) SendCodeExecStdout

func (a *Adapter) SendCodeExecStdout(msg ui.CodeExecStdoutMessage) error

SendCodeExecStdout streams a chunk of run_code script stdout to the TUI.

func (*Adapter) SendFileChanged

func (a *Adapter) SendFileChanged(path, action string) error

SendFileChanged notifies the TUI that a session file changed.

func (*Adapter) SendOutput

func (a *Adapter) SendOutput(msg ui.OutputMessage) error

SendOutput sends a complete output message to the TUI.

func (*Adapter) SendPlanDisplay

func (a *Adapter) SendPlanDisplay(msg ui.PlanDisplayMessage) error

SendPlanDisplay sends a plan display to the TUI.

func (*Adapter) SendPlanStepStatus

func (a *Adapter) SendPlanStepStatus(msg planStepStatusMsg) error

SendPlanStepStatus sends a single-step status delta to the TUI, the shape emitted by plan.progress. Right rail matches by StepID.

func (*Adapter) SendPlanUpdate

func (a *Adapter) SendPlanUpdate(turnID string, steps []planUpdateStep) error

SendPlanUpdate sends an updated plan with step statuses to the TUI.

func (*Adapter) SendStatus

func (a *Adapter) SendStatus(msg ui.StatusMessage) error

SendStatus sends a status update to the TUI.

func (*Adapter) SendStreamChunk

func (a *Adapter) SendStreamChunk(msg ui.StreamChunkMessage) error

SendStreamChunk sends a streaming chunk to the TUI.

func (*Adapter) SendStreamEnd

func (a *Adapter) SendStreamEnd(msg ui.StreamEndMessage) error

SendStreamEnd signals the end of a stream.

func (*Adapter) SendStreamHold

func (a *Adapter) SendStreamHold(msg ui.StreamHoldMessage) error

SendStreamHold tells the TUI a gate suspended or released the stream.

func (*Adapter) SendStreamRetract

func (a *Adapter) SendStreamRetract(msg ui.StreamRetractMessage) error

SendStreamRetract tells the TUI to erase the text rendered for a blocked turn.

func (*Adapter) SendThinking

func (a *Adapter) SendThinking(msg ui.ThinkingMessage) error

SendThinking sends a thinking step to the TUI.

func (*Adapter) SendWorkflowStatus

func (a *Adapter) SendWorkflowStatus(msg ui.WorkflowStatusMessage) error

SendWorkflowStatus sends a structured workflow progress update to the TUI. The TUI renders the message as a dedicated workflow status panel in the right rail and as a one-line status indicator in the chat header.

func (*Adapter) Sessions

func (a *Adapter) Sessions() []ui.SessionInfo

Sessions returns info about the current terminal session.

func (*Adapter) Start

func (a *Adapter) Start(ctx context.Context) error

Start creates and runs the BubbleTea program.

func (*Adapter) Stop

func (a *Adapter) Stop(_ context.Context) error

Stop signals the BubbleTea program to quit and waits for it to fully tear down (restoring the terminal from alt screen mode).

func (*Adapter) Wait

func (a *Adapter) Wait()

Wait blocks until the BubbleTea program exits.

type Plugin

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

Plugin is the terminal IO plugin that bridges a BubbleTea TUI to the event bus.

func (*Plugin) Capabilities

func (p *Plugin) Capabilities() []engine.Capability

func (*Plugin) Dependencies

func (p *Plugin) Dependencies() []string

func (*Plugin) Emissions

func (p *Plugin) Emissions() []string

func (*Plugin) ID

func (p *Plugin) ID() string

func (*Plugin) Init

func (p *Plugin) Init(ctx engine.PluginContext) error

Init creates the adapter and wires callbacks to the event bus.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Ready

func (p *Plugin) Ready() error

Ready starts the BubbleTea program.

func (*Plugin) Requires

func (p *Plugin) Requires() []engine.Requirement

func (*Plugin) Shutdown

func (p *Plugin) Shutdown(ctx context.Context) error

Shutdown stops the adapter and unsubscribes from events.

func (*Plugin) Subscriptions

func (p *Plugin) Subscriptions() []engine.EventSubscription

func (*Plugin) Version

func (p *Plugin) Version() string

type Styles

type Styles struct {
	Theme Theme

	// Layout
	Sidebar       lipgloss.Style
	MainPanel     lipgloss.Style
	RightRail     lipgloss.Style
	StatusBar     lipgloss.Style
	InputArea     lipgloss.Style
	SidebarHeader lipgloss.Style

	// Chat bubbles
	UserBubble      lipgloss.Style
	AssistantBubble lipgloss.Style
	SystemBubble    lipgloss.Style
	ToolBubble      lipgloss.Style
	ErrorBubble     lipgloss.Style

	// Labels
	UserLabel      lipgloss.Style
	AssistantLabel lipgloss.Style
	SystemLabel    lipgloss.Style
	ToolLabel      lipgloss.Style
	ErrorLabel     lipgloss.Style

	// Components
	TabActive   lipgloss.Style
	TabInactive lipgloss.Style
	FileItem    lipgloss.Style
	PluginItem  lipgloss.Style
	PlanStep    lipgloss.Style
	ThinkStep   lipgloss.Style
	ApprovalBox lipgloss.Style
	RiskHigh    lipgloss.Style
	RiskNormal  lipgloss.Style

	// Misc
	Dim      lipgloss.Style
	Bold     lipgloss.Style
	Spinner  lipgloss.Style
	Accent   lipgloss.Style
	Selected lipgloss.Style
}

Styles holds computed lipgloss styles derived from a theme.

type Theme

type Theme struct {
	Name string

	// Base colors
	Primary    lipgloss.Color
	Background lipgloss.Color
	Surface    lipgloss.Color
	Border     lipgloss.Color
	Text       lipgloss.Color
	TextDim    lipgloss.Color

	// Role colors
	Assistant lipgloss.Color
	User      lipgloss.Color
	System    lipgloss.Color
	Tool      lipgloss.Color
	Error     lipgloss.Color

	// Semantic
	Success lipgloss.Color
	Warning lipgloss.Color
	Danger  lipgloss.Color
}

Theme holds all lipgloss styles for the TUI.

Jump to

Keyboard shortcuts

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