Documentation
¶
Index ¶
- Variables
- func FormatProgressLine(result json.RawMessage) string
- func FormatSubagentOutput(result json.RawMessage) string
- func FormatTokens(n int) string
- func FormatToolArgs(args json.RawMessage) string
- func FormatToolResult(result json.RawMessage, isError bool) string
- func NewGlamourRenderer(width int) *glamour.TermRenderer
- func RenderEditResult(result json.RawMessage) string
- func RenderStreamingOutput(full string, maxLines int) string
- func SendCommandResult(text string) tea.Cmd
- func TruncateLines(s string, maxLines int) string
- type AgentEventMsg
- type AskUserMsg
- type CommandResultMsg
- type Config
- type Driver
- type ImageAttachedMsg
- type Model
- func (m Model) HandleAgentEvent(ev agentcore.Event) (Model, tea.Cmd)
- func (m Model) Init() tea.Cmd
- func (m *Model) RenderContextBar() string
- func (m *Model) RenderMarkdown(content string) string
- func (m *Model) RenderPlanBar() string
- func (m Model) RenderPromptOutput(text string) string
- func (m *Model) RenderStatusBar() string
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
- type PasteErrorMsg
- type PasteTextMsg
- type PlanBarInfo
- type PromptMsg
- type TaskListUpdateMsg
Constants ¶
This section is empty.
Variables ¶
var ( ColorAccent = lipgloss.Color("#7C6FE0") // soft purple, primary accent ColorUser = lipgloss.Color("#5FAFFF") // bright blue ColorAssistant = lipgloss.Color("#C792EA") // soft purple/magenta ColorTool = lipgloss.Color("#FFCB6B") // amber/yellow ColorError = lipgloss.Color("#FF5370") // soft red ColorSuccess = lipgloss.Color("#C3E88D") // green ColorMuted = lipgloss.Color("243") // medium gray ColorThinking = lipgloss.Color("240") // dim gray, distinctly muted vs assistant text ColorToken = lipgloss.Color("249") // light gray ColorCommand = lipgloss.Color("#89DDFF") // cyan ColorStatusBg = lipgloss.Color("236") // dark background ColorSeparator = lipgloss.Color("249") // light gray, match welcome detail )
Color palette — dark terminal optimized.
var ( ToolIconStyle = lipgloss.NewStyle().Foreground(ColorTool) ToolNameStyle = lipgloss.NewStyle().Foreground(ColorTool).Bold(true) ToolArgsStyle = lipgloss.NewStyle().Foreground(ColorMuted) ToolResultStyle = lipgloss.NewStyle().Foreground(ColorMuted) )
Tool blocks
var ( WelcomeTitleStyle = lipgloss.NewStyle().Foreground(ColorAccent).Bold(true) WelcomeDetailStyle = lipgloss.NewStyle().Foreground(ColorMuted) )
Welcome banner
var ( ChoiceActiveStyle = lipgloss.NewStyle().Foreground(ColorAccent).Bold(true) ChoiceInactiveStyle = lipgloss.NewStyle().Foreground(ColorMuted) )
Selection menu (plan approval, etc.)
var ( MutedStyle = lipgloss.NewStyle().Foreground(ColorMuted) QueuedMsgStyle = lipgloss.NewStyle().Foreground(ColorMuted).Italic(true) TokenStyle = lipgloss.NewStyle().Foreground(ColorToken) DiffAddStyle = lipgloss.NewStyle().Foreground(ColorSuccess) DiffRemoveStyle = lipgloss.NewStyle().Foreground(ColorError) DiffInverseAddStyle = lipgloss.NewStyle().Foreground(ColorSuccess).Reverse(true) DiffInverseRemoveStyle = lipgloss.NewStyle().Foreground(ColorError).Reverse(true) )
General purpose
var AssistantIconStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("252"))
Assistant icon
var CommandStyle = lipgloss.NewStyle(). Foreground(ColorCommand)
Command / system output
var ErrorStyle = lipgloss.NewStyle(). Foreground(ColorError). Bold(true)
Error
Foreground(lipgloss.Color("235")). Background(lipgloss.Color("#b5e6b5")). Padding(0, 1)
Footer
var ImageSelectedStyle = lipgloss.NewStyle().Reverse(true)
Image tag selected (reverse video highlight)
var PlanBoxStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(ColorAccent). Padding(0, 1)
Plan box
var PlanTagStyle = lipgloss.NewStyle().Foreground(ColorAccent)
Plan mode tag
var SeparatorStyle = lipgloss.NewStyle(). Foreground(ColorSeparator)
Separator
var SubagentCardStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(ColorTool). Padding(0, 1)
Subagent result card
var ThinkingBodyStyle = lipgloss.NewStyle(). Foreground(ColorThinking). Italic(true)
Thinking body
Functions ¶
func FormatProgressLine ¶
func FormatProgressLine(result json.RawMessage) string
FormatProgressLine formats a tool progress update for display.
func FormatSubagentOutput ¶
func FormatSubagentOutput(result json.RawMessage) string
FormatSubagentOutput extracts the full output from a subagent result, appending usage stats as a footer. Returns content for card display.
func FormatTokens ¶
FormatTokens formats a token count with k/M suffix for readability.
func FormatToolArgs ¶
func FormatToolArgs(args json.RawMessage) string
FormatToolArgs formats tool arguments for display, truncating if needed.
func FormatToolResult ¶
func FormatToolResult(result json.RawMessage, isError bool) string
FormatToolResult formats a tool result for display.
func NewGlamourRenderer ¶
func NewGlamourRenderer(width int) *glamour.TermRenderer
NewGlamourRenderer creates a glamour markdown renderer with the given width.
func RenderEditResult ¶
func RenderEditResult(result json.RawMessage) string
RenderEditResult renders the edit tool result with colored diff output. Single-line changes (1 removed + 1 added) get intra-line highlighting where only the changed portion is rendered in inverse color.
func RenderStreamingOutput ¶
RenderStreamingOutput shows the last N lines of streaming tool output.
func SendCommandResult ¶
SendCommandResult is a helper that wraps text into a CommandResultMsg tea.Cmd.
func TruncateLines ¶
TruncateLines truncates text to maxLines, appending "..." if truncated.
Types ¶
type AgentEventMsg ¶
AgentEventMsg bridges agentcore events into the bubbletea Elm loop.
type AskUserMsg ¶
type AskUserMsg struct {
Questions []tools.Question
RespCh chan<- *tools.AskUserResponse
}
AskUserMsg is sent by the AskUser handler to show questions in the TUI.
type CommandResultMsg ¶
type CommandResultMsg struct {
Text string
Quit bool // true for /exit
Clear bool // true for /clear
NewModel string // non-empty if model was switched
}
CommandResultMsg carries the result of a slash command back to the model.
type Config ¶
type Config struct {
Placeholder string
Cwd string
GitBranch string
History *storage.History // input history (Up/Down navigation)
OnKey func(m *Model, msg tea.KeyMsg) (handled bool, cmd tea.Cmd)
OnEvent func(m *Model, ev agentcore.Event) tea.Cmd
OnPaste func(m *Model) tea.Cmd // Ctrl+V: read clipboard image, return ImageAttachedMsg
OnDrop func(m *Model, text string) tea.Cmd // Drag-drop: if text is image path, return cmd; else nil
StatusRight func(m *Model) string
StatusPlan func(m *Model) *PlanBarInfo
}
Config provides hooks for extending the base TUI behavior.
type Driver ¶
type Driver interface {
Prompt(text string) error
PromptWithBlocks(blocks []agentcore.ContentBlock) error
Steer(text string)
Abort()
}
Driver defines the minimal conversation operations required by the TUI.
type ImageAttachedMsg ¶
type ImageAttachedMsg struct {
Block agentcore.ContentBlock // pre-built ImageBlock (base64 + mime)
}
ImageAttachedMsg notifies the Model that an image has been pasted from clipboard.
type Model ¶
type Model struct {
Driver Driver
ModelName string
Input textarea.Model
Spinner spinner.Model
ToolSpinner spinner.Model // breathing-dot spinner for tool execution
Streaming *strings.Builder
Thinking *strings.Builder
IsStream bool
Running bool
TurnCount int
PendingTools map[string]string // toolID -> tool name
ToolOutputBuf map[string]*strings.Builder // toolID -> streaming output
Width int
Height int
Ready bool
Cwd string
GitBranch string
ShowWelcome bool
ShowSummary bool
RunStats runStats
Images []agentcore.ContentBlock // attached images (from Ctrl+V clipboard paste)
ImageCursor int // -1 = not selecting; 0+ = selected image index
Pasting int // number of async image reads in progress (clipboard paste or drag-drop)
Glamour *glamour.TermRenderer
AskUser *askUserState // non-nil when ask-user UI is active
Tasks *tools.TaskSnapshot // non-nil when tasks exist; displayed above input
QueuedMsgs []string // messages queued while agent is running (display only)
QuitPending bool // true after first Ctrl+C, waiting for second to quit
// contains filtered or unexported fields
}
Model is the bubbletea Model for the agent TUI. Completed content is printed to terminal scrollback via tea.Println; View() only renders the live area (status + streaming + input).
func (Model) HandleAgentEvent ¶
HandleAgentEvent processes agent events. Completed content is printed to terminal scrollback via tea.Println. In-progress content (streaming, tool output) is shown in the live View().
func (*Model) RenderContextBar ¶
RenderContextBar renders the context line below the input (env info).
func (*Model) RenderMarkdown ¶
RenderMarkdown renders markdown content using glamour.
func (*Model) RenderPlanBar ¶
RenderPlanBar renders the plan review card (AskUser-style). Empty when inactive.
func (Model) RenderPromptOutput ¶
RenderPromptOutput renders a user message with optional welcome banner for scrollback.
func (*Model) RenderStatusBar ¶
RenderStatusBar renders the status line above the input (running state + turn).
type PasteErrorMsg ¶
type PasteErrorMsg struct {
Text string
}
PasteErrorMsg carries an error from clipboard paste or file drag-drop. Decrements Pasting counter and displays the error text.
type PasteTextMsg ¶
type PasteTextMsg struct{}
PasteTextMsg signals that Ctrl+V found no image; the textarea should paste text.
type PlanBarInfo ¶
type PlanBarInfo struct {
Tag string // appended to status bar (e.g., "plan mode")
Choices []string // selectable options
Active int // active choice index
// Plan review card fields.
Prompt string // e.g., "Would you like to proceed?"
OtherMode bool // typing custom feedback
OtherBuf string // custom feedback buffer
}
PlanBarInfo provides plan mode status for the status bar.
type PromptMsg ¶
type PromptMsg struct {
Text string
}
PromptMsg injects a message as if the user typed and sent it. The TUI renders it as a user message and forwards it to the agent.
type TaskListUpdateMsg ¶
type TaskListUpdateMsg struct {
Snapshot tools.TaskSnapshot
}
TaskListUpdateMsg notifies the TUI that the task list has changed.