tui

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tui style tokens: single source of truth for visual language. Direction: cool chrome, warm content — colour alone distinguishes UI from output.

Package tui theme: single source of truth for colour. v2 has no AdaptiveColor; palette is resolved once from background.

Index

Constants

View Source
const (
	MotionAuto    = "auto"
	MotionReduced = "reduced"
	MotionOff     = "off"
)

Motion settings accepted by tui motion.

Variables

This section is empty.

Functions

func NewCommandPalette added in v0.7.5

func NewCommandPalette(specs []agent.CommandSpec, width, height int) list.Model

NewCommandPalette builds the Ctrl+K overlay: a fuzzy list over the same registry dispatch and /help read.

func NewModelPicker added in v0.2.0

func NewModelPicker(items []list.Item, width, height int) list.Model

Caller frames with modalOverlayStyle, so no border here.

func NewSessionPicker added in v0.7.5

func NewSessionPicker(items []list.Item, width, height int) list.Model

NewSessionPicker builds the /sessions overlay. Same list mechanics as the model picker, so filtering and cursor keys behave identically.

func Run

func Run(
	ctx context.Context,
	registry *provider.Registry,
	session *agent.Session,
	toolRegistry *tools.Registry,
	approval *tools.ApprovalGate,
	version string,
	workspaceRoot string,
	guardCfg agent.LoopGuardConfig,
	maxContextTokens int,
	autoCompact bool,
	keepRecentTokens int,
	plan *tools.PlanStore,
	scratchpad *tools.ScratchpadStore,
	verifyCommand string,
	verifyTimeout time.Duration,
	motion MotionSettings,
) error

Run starts the Bubble Tea interface; agent behaviour lives in agent.AgentLoop.

Types

type ApprovalBridge

type ApprovalBridge struct {
	RequestCh chan ApprovalRequest
}

func NewApprovalBridge

func NewApprovalBridge() *ApprovalBridge

func (*ApprovalBridge) RequestApproval

func (b *ApprovalBridge) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)

RequestApproval is the legacy yes/no request. Grant and read-only choices still approve the pending call; only the additional scope is dropped.

func (*ApprovalBridge) RequestApprovalChoice added in v0.7.4

func (b *ApprovalBridge) RequestApprovalChoice(toolName string, args json.RawMessage, preview string) (tools.ApprovalChoice, error)

RequestApprovalChoice asks the TUI for a full decision. The gate installs this as OnPresentChoice so grants and the per-turn read-only flag can be expressed from the modal.

Limitation: the TUI has no argument editor, so ApprovalChoice.ApprovalEdit is never produced here. The plain loop wires tools.ApprovalGate.EditArgs; the TUI deliberately offers only y/a/r/n to avoid claiming parity.

type ApprovalRequest

type ApprovalRequest struct {
	ToolName string
	Args     json.RawMessage
	Preview  string
	// ReplyCh carries the legacy yes/no answer. It is nil when the requester
	// made a choice-aware request.
	ReplyCh chan bool
	// ChoiceCh carries the full decision for choice-aware requesters.
	ChoiceCh chan tools.ApprovalChoice
}

type ChatMessage

type ChatMessage struct {
	Role    ChatRole
	Label   string
	Content string
	Diff    string
	// Done marks a successful tool result, so its settled label uses the
	// success style. RoleError already carries failure styling.
	Done bool
}

type ChatRole

type ChatRole int
const (
	RoleUser ChatRole = iota
	RoleAssistant
	RoleTool
	RoleSystem
	RoleError
)

type Model

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

func NewModel

func NewModel(providerName, modelName, version, workspaceRoot string, bridge *ApprovalBridge, inputCh chan string, steerCh chan string, outputCh chan tea.Msg, cancelCh chan struct{}, pickerItems []list.Item, motion MotionSettings) Model

func (Model) Init

func (m Model) Init() tea.Cmd

Init arms only the commands that must run at startup. There is deliberately no mascot tick: the idle pose is static, and animation chains arm when a turn starts, so an open session costs no CPU while nothing moves.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() tea.View

View renders the whole UI.

v2 view is declarative: AltScreen/MouseMode must be set on every return. Routing through newView guarantees that.

type ModelItem added in v0.2.0

type ModelItem struct {
	Provider string
	Model    string
}

ModelItem is a selectable model in the fuzzy picker.

func (ModelItem) Description added in v0.2.0

func (i ModelItem) Description() string

func (ModelItem) FilterValue added in v0.2.0

func (i ModelItem) FilterValue() string

func (ModelItem) Title added in v0.2.0

func (i ModelItem) Title() string

type MotionSettings added in v0.7.5

type MotionSettings struct {
	// Mode is "auto", "reduced" or "off"; empty behaves as "auto".
	Mode string
	// SmoothStreaming paces streamed text and tool-argument previews into the
	// transcript instead of appending raw provider bursts.
	SmoothStreaming bool
}

MotionSettings is the tui animation configuration handed to the UI.

type SessionItem added in v0.7.5

type SessionItem struct {
	ID        string
	Excerpt   string
	Provider  string
	Model     string
	UpdatedAt time.Time
	Messages  int
}

SessionItem is one resumable session in the session picker. The full ID is what /resume receives; the row shows the generated suffix plus the same fields the text listing prints (title, updated time, message count), so the picker and `/sessions` describe a session the same way. The stored title is an excerpt of the first user message; Excerpt avoids colliding with the list.Item Title() method.

func (SessionItem) Description added in v0.7.5

func (s SessionItem) Description() string

func (SessionItem) FilterValue added in v0.7.5

func (s SessionItem) FilterValue() string

FilterValue includes the whole ID so a user who knows it can paste it into the filter instead of scrolling.

func (SessionItem) Title added in v0.7.5

func (s SessionItem) Title() string

Jump to

Keyboard shortcuts

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