Documentation
¶
Overview ¶
Package tui implements the Bubble Tea TUI for conduit.
Index ¶
- func RebuildStyles()
- func Run(version, modelName string, loop *agent.Loop, extras ...any) error
- func SummarizeMessages(history []api.Message, n int) string
- type Config
- type LiveState
- func (s *LiveState) AppendTurnCost(delta float64)
- func (s *LiveState) EffortLevel() string
- func (s *LiveState) FastMode() bool
- func (s *LiveState) ModelName() string
- func (s *LiveState) PermissionMode() permissions.Mode
- func (s *LiveState) RateLimitWarning() string
- func (s *LiveState) SessionFile() string
- func (s *LiveState) SessionID() string
- func (s *LiveState) SetEffortLevel(level string)
- func (s *LiveState) SetFastMode(on bool)
- func (s *LiveState) SetModelName(name string)
- func (s *LiveState) SetPermissionMode(m permissions.Mode)
- func (s *LiveState) SetRateLimitWarning(w string)
- func (s *LiveState) SetSessionFile(path string)
- func (s *LiveState) SetSessionID(id string)
- func (s *LiveState) SetTokens(input, output int, costUSD float64)
- func (s *LiveState) Tokens() (input, output int, costUSD float64)
- func (s *LiveState) TurnCosts() []float64
- type Message
- type Model
- func (m Model) AllBindings() []keybindings.Binding
- func (m *Model) CopyLastResponse() string
- func (m *Model) CostSummary() string
- func (m Model) Init() tea.Cmd
- func (m *Model) LastThinking() string
- func (m *Model) TasksSummary() string
- func (m *Model) TurnCosts() []float64
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() tea.View
- type Role
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RebuildStyles ¶
func RebuildStyles()
RebuildStyles regenerates every package-level style from theme.Active(). Called at init() and after every theme switch via theme.OnChange.
func Run ¶
Run starts the full-screen TUI and blocks until the user exits. Variadic tail accepts: *api.Client, *permissions.Gate, *settings.HooksSettings, RunOptions (in any order).
func SummarizeMessages ¶
SummarizeMessages renders the last n model-visible messages as a plain-text transcript for /memory extract. Tool blocks are flattened so the sub-agent sees a readable conversation, not raw JSON. Exported because cmd/conduit/main.go's auto-extract path also needs it.
Types ¶
type Config ¶
type Config struct {
Version string
ModelName string
Loop *agent.Loop
Program **tea.Program
Commands *commands.Registry
APIClient *api.Client
MCPManager *mcp.Manager
Gate *permissions.Gate
// AuthErr is non-nil when the TUI started without valid credentials.
AuthErr error
// Profile is the user's subscription/account info fetched at startup.
Profile profile.Info
// Session is the active transcript session (nil if persistence unavailable).
Session *session.Session
// ResumedHistory is pre-loaded history from a --continue session.
ResumedHistory []api.Message
// Resumed is true when --continue loaded a prior session.
Resumed bool
// LoadAuth reloads credentials + profile after /login.
LoadAuth func(ctx context.Context) (string, *profile.Info, error)
// NewAPIClient constructs a fresh client for the given bearer.
NewAPIClient func(bearer string) *api.Client
// Live is the shared state bag readable from command callbacks outside
// the Bubble Tea event loop. Populated by the model on each Update.
Live *LiveState
}
Config is passed from main to the TUI.
type LiveState ¶
type LiveState struct {
// contains filtered or unexported fields
}
LiveState holds a small set of frequently-read Model fields that command callbacks need to access from outside the Bubble Tea event loop. All methods are safe to call from any goroutine.
func (*LiveState) AppendTurnCost ¶
func (*LiveState) EffortLevel ¶
func (*LiveState) PermissionMode ¶
func (s *LiveState) PermissionMode() permissions.Mode
func (*LiveState) RateLimitWarning ¶
func (*LiveState) SessionFile ¶
func (*LiveState) SetEffortLevel ¶
func (*LiveState) SetFastMode ¶
func (*LiveState) SetModelName ¶
func (*LiveState) SetPermissionMode ¶
func (s *LiveState) SetPermissionMode(m permissions.Mode)
func (*LiveState) SetRateLimitWarning ¶
func (*LiveState) SetSessionFile ¶
func (*LiveState) SetSessionID ¶
type Message ¶
type Message struct {
Role Role
Content string
ToolName string
WelcomeCard bool // render as the two-panel welcome banner
}
Message is one entry in the displayed conversation.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubble Tea model.
func (Model) AllBindings ¶
func (m Model) AllBindings() []keybindings.Binding
AllBindings returns the flat binding list from the active resolver, suitable for /keybindings display. Falls back to Defaults() when the resolver is nil.
func (*Model) CopyLastResponse ¶
CopyLastResponse copies the last assistant text to clipboard. Returns "" on success, error message otherwise.
func (*Model) CostSummary ¶
CostSummary returns a human-readable cost/token summary for the /cost command.
func (Model) Init ¶
Init starts the blink + spinner tick. Also kicks off the MCP approval picker if any project-scope servers are awaiting consent, and the coordinator-panel tick that drives the active-task footer.
func (*Model) LastThinking ¶
func (*Model) TasksSummary ¶
TasksSummary returns the list of active tasks for /tasks. Tasks are tracked by the TaskTool — for now we surface the tool messages.
func (*Model) TurnCosts ¶
LastThinking returns the last thinking block text from the assistant. TurnCosts returns a copy of the per-turn cost deltas recorded this session.
func (Model) View ¶
View renders the full TUI frame. v2 returns tea.View — internally we still build a string and wrap it via mkView so all the existing rendering/paint logic stays unchanged.
Basic keyboard disambiguation (shift+enter, ctrl+i, etc) is enabled by default in bubbletea v2 — no opt-in required for those keys. The KeyboardEnhancements field below opts into more advanced features: ReportAlternateKeys lets terminals report alternate key values (helps international keyboards), and we leave ReportEventTypes off because we don't need key release events.
type RunOptions ¶
type RunOptions struct {
// AuthErr is non-nil when no credentials were found at startup.
AuthErr error
// Profile is the user's account/subscription info fetched at startup.
Profile profile.Info
// Session is the active session for transcript persistence.
Session *session.Session
// ResumedHistory is the message history loaded from a previous session.
ResumedHistory []api.Message
// Resumed is true when --continue loaded a prior session.
Resumed bool
// MCPManager is the live MCP connection manager (may be nil).
MCPManager *mcp.Manager
// LoadAuth reloads credentials + profile after a successful /login.
LoadAuth func(ctx context.Context) (string, *profile.Info, error)
// NewAPIClient constructs a fresh API client for the given bearer token.
NewAPIClient func(bearer string) *api.Client
// Interactive tool stubs — the TUI wires their callbacks after startup.
EnterPlan *planmodetool.EnterPlanMode
ExitPlan *planmodetool.ExitPlanMode
AskUser *askusertool.AskUserQuestion
// InitialOutputStyle is the style name to activate at startup (from settings).
InitialOutputStyle string
// PluginDirs is the list of installed plugin root directories, used to
// load plugin-provided output styles (lowest priority — overridden by user/project).
PluginDirs []string
}
RunOptions carries optional TUI startup parameters passed from main.