Documentation
¶
Overview ¶
Package render provides output and rendering components for the TUI.
It includes a streaming renderer, markdown formatting, spinner animation, tool-call panels, and the welcome banner.
Index ¶
- func PrintAssistantContent(content string)
- func PrintAssistantLabel(_ int)
- func PrintAwaitingMessage()
- func PrintContextInfo(info string)
- func PrintError(msg string)
- func PrintGoodbye()
- func PrintInfo(msg string)
- func PrintSeparator(_ int)
- func PrintSuccess(msg string)
- func PrintTeamPanel(name, strategy string, members []TeamMemberInfo, width int)
- func PrintTeamStatusBar(name string, strategy string, members []TeamMemberInfo, width int)
- func PrintUserMessage(msg string, _ int)
- func PrintWelcomeBanner(info BannerInfo, width int)
- func RenderInputBox(placeholder string, width int) string
- func RenderStatusBar(info StatusBarInfo, width int) string
- func RenderToolCallCompact(name string, status ToolStatus, duration time.Duration) string
- func RenderToolResult(toolName, description, content string, width int, success bool) string
- type BannerInfo
- type MarkdownRenderer
- type Spinner
- type SpinnerOption
- type StatusBarInfo
- type StreamRenderer
- func (r *StreamRenderer) Abort() string
- func (r *StreamRenderer) Finish() string
- func (r *StreamRenderer) FinishWithToolResult(toolName, desc, code string, success bool) string
- func (r *StreamRenderer) OnDelta(delta string)
- func (r *StreamRenderer) OnError(err error) string
- func (r *StreamRenderer) OnToolCall(name string)
- func (r *StreamRenderer) OnToolResult(name string, success bool)
- func (r *StreamRenderer) Reset()
- func (r *StreamRenderer) SetWidth(width int)
- func (r *StreamRenderer) StartThinking()
- type TeamMemberInfo
- type ToolCallPanel
- type ToolStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintAssistantContent ¶
func PrintAssistantContent(content string)
PrintAssistantContent prints a rendered assistant response line.
func PrintAssistantLabel ¶
func PrintAssistantLabel(_ int)
PrintAssistantLabel outputs the assistant marker before streaming.
func PrintAwaitingMessage ¶
func PrintAwaitingMessage()
PrintAwaitingMessage prints the "Awaiting your next command or request." line.
func PrintContextInfo ¶
func PrintContextInfo(info string)
PrintContextInfo prints a context info line
func PrintTeamPanel ¶
func PrintTeamPanel(name, strategy string, members []TeamMemberInfo, width int)
PrintTeamPanel prints a detailed team member panel. This is used by /team status and /agents commands.
func PrintTeamStatusBar ¶
func PrintTeamStatusBar(name string, strategy string, members []TeamMemberInfo, width int)
PrintTeamStatusBar prints a compact one-line team status bar. Format: 📋 Team: MyTeam (3 members) [●2 ✓1 ✗0]
func PrintUserMessage ¶
PrintUserMessage displays the user's message with a styled prompt.
func PrintWelcomeBanner ¶
func PrintWelcomeBanner(info BannerInfo, width int)
PrintWelcomeBanner outputs the startup banner with logo, connection info, tips.
func RenderInputBox ¶
RenderInputBox renders a Gemini-CLI style bordered input box.
func RenderStatusBar ¶
func RenderStatusBar(info StatusBarInfo, width int) string
RenderStatusBar renders a Gemini-CLI style bottom status bar.
func RenderToolCallCompact ¶
func RenderToolCallCompact(name string, status ToolStatus, duration time.Duration) string
RenderToolCallCompact renders a compact tool call line with custom icons.
Types ¶
type BannerInfo ¶
BannerInfo holds the data displayed in the welcome banner.
type MarkdownRenderer ¶
type MarkdownRenderer struct {
// contains filtered or unexported fields
}
MarkdownRenderer converts markdown text to ANSI-styled terminal output.
It wraps charmbracelet/glamour with sensible defaults and caches the renderer instance for reuse across multiple calls.
func NewMarkdownRenderer ¶
func NewMarkdownRenderer(width int, profile termenv.Profile) *MarkdownRenderer
NewMarkdownRenderer creates a renderer that word-wraps at the given width. The profile controls color depth (TrueColor, ANSI256, ANSI, Ascii). Pass 0 for width to use a default of 80.
func (*MarkdownRenderer) Render ¶
func (m *MarkdownRenderer) Render(content string) string
Render converts a markdown string to ANSI-formatted terminal output. On error it returns the original content unchanged.
func (*MarkdownRenderer) SetWidth ¶
func (m *MarkdownRenderer) SetWidth(width int)
SetWidth updates the wrap width for subsequent Render calls.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner displays an animated indicator while waiting for a response.
It renders a single line like:
⠹ Thinking... (first 2 seconds) ⠼ Thinking... (3.2s) (after 2 seconds, shows elapsed time)
func NewSpinner ¶
func NewSpinner(label string, opts ...SpinnerOption) *Spinner
NewSpinner creates a Spinner with the given label.
type SpinnerOption ¶
type SpinnerOption func(*Spinner)
SpinnerOption configures a Spinner.
func WithFrames ¶
func WithFrames(frames []string) SpinnerOption
WithFrames sets custom animation frames.
func WithInterval ¶
func WithInterval(d time.Duration) SpinnerOption
WithInterval sets the animation frame interval.
func WithOutput ¶
func WithOutput(o *termenv.Output) SpinnerOption
WithOutput sets a custom termenv output (useful for testing).
type StatusBarInfo ¶
type StatusBarInfo struct {
WorkDir string
SandboxMsg string
Mode string // e.g., "auto", "manual"
}
StatusBarInfo holds data for the bottom status bar.
type StreamRenderer ¶
type StreamRenderer struct {
// contains filtered or unexported fields
}
StreamRenderer manages the rendering lifecycle of a single assistant response. It coordinates the spinner, raw text streaming, tool-call panel, and final markdown re-render.
The output flow mirrors Gemini CLI.
1. Show "Thinking..." spinner. 2. On first delta: stop spinner 3. On tool call: render compact tool indicator 4. On finish: overwrite raw text with glamour-rendered markdown.
func NewStreamRenderer ¶
func NewStreamRenderer(width int) *StreamRenderer
NewStreamRenderer creates a renderer for the given terminal width.
func (*StreamRenderer) Abort ¶
func (r *StreamRenderer) Abort() string
Abort stops the renderer without re-rendering markdown.
func (*StreamRenderer) Finish ¶
func (r *StreamRenderer) Finish() string
Finish ends the streaming phase and re-renders the complete content as formatted markdown, overwriting the raw output. It returns the full raw content string for history purposes.
func (*StreamRenderer) FinishWithToolResult ¶
func (r *StreamRenderer) FinishWithToolResult(toolName, desc, code string, success bool) string
FinishWithToolResult ends the stream and also renders ta tool result box.
func (*StreamRenderer) OnDelta ¶
func (r *StreamRenderer) OnDelta(delta string)
OnDelta processes an incremental text chunk from the SSE stream. It stops the spinner on the first delta and prints the raw text.
func (*StreamRenderer) OnError ¶
func (r *StreamRenderer) OnError(err error) string
OnError displays an error message and aborts the rendering.
func (*StreamRenderer) OnToolCall ¶
func (r *StreamRenderer) OnToolCall(name string)
OnToolCall records and displays a tool invocation during streaming.
func (*StreamRenderer) OnToolResult ¶
func (r *StreamRenderer) OnToolResult(name string, success bool)
OnToolResult marks a tool call as finished.
func (*StreamRenderer) Reset ¶
func (r *StreamRenderer) Reset()
Reset prepares the renderer for a new streaming response.
func (*StreamRenderer) SetWidth ¶
func (r *StreamRenderer) SetWidth(width int)
SetWidth updates the terminal width for subsequent renders.
func (*StreamRenderer) StartThinking ¶
func (r *StreamRenderer) StartThinking()
StartThinking begins the spinner animation.
type TeamMemberInfo ¶
type TeamMemberInfo struct {
Label string
Role string
Status string // idle, running, completed, failed
IsLeader bool
Focused bool
NodeID string
Progress string
}
TeamMemberInfo holds info needed for rendering a team member.
type ToolCallPanel ¶
type ToolCallPanel struct {
// contains filtered or unexported fields
}
ToolCallPanel manages the display of tool invocations during a streaming response. It renders Gemini-CLI style bordered panels:
┌──────────────────────────────────────────────────────┐
│ ✓ WriteFile Writing to hello.py │
│ │
│ 1 print("Hello, world!") │
└──────────────────────────────────────────────────────┘
func NewToolCallPanel ¶
func NewToolCallPanel() *ToolCallPanel
NewToolCallPanel creates a new panel with default output.
func (*ToolCallPanel) Finish ¶
func (p *ToolCallPanel) Finish(name string, success bool)
Finish marks a tool call as completed (success or failure) and re-renders the line.
func (*ToolCallPanel) LineCount ¶
func (p *ToolCallPanel) LineCount() int
LineCount returns the number of terminal lines this panel has output.
func (*ToolCallPanel) SetWidth ¶
func (p *ToolCallPanel) SetWidth(w int)
SetWidth updates the panel width.
func (*ToolCallPanel) Start ¶
func (p *ToolCallPanel) Start(name string)
Start records the beginning of a tool call and renders it.
func (*ToolCallPanel) StartWithArgs ¶
func (p *ToolCallPanel) StartWithArgs(name, args string)
StartWithArgs records a tool call with argument summary.
type ToolStatus ¶
type ToolStatus int
ToolStatus represents the current state of a tool invocation.
const ( ToolRunning ToolStatus = iota ToolSuccess ToolFailed )