Documentation
¶
Index ¶
- Constants
- func EffortFillStyle(level effort.Level) lipgloss.Style
- func EffortGauge(level effort.Level) string
- func EffortGaugeEmpty() string
- func ExtractField[T any](field func(T) string) func(string) string
- func FormatTokenCount(count int64) string
- func FormatToolResult(content string, width int) string
- func Icon(msg *types.Message, inProgress spinner.Spinner) string
- func LongRunningWarning(msg *types.Message) string
- func NoArgsRenderer(msg *types.Message, s spinner.Spinner, sessionState service.SessionStateReader, ...) string
- func ParseArgs[T any](args string) (T, error)
- func Pluralize(count int, singular, plural string) string
- func RenderFriendlyHeader(msg *types.Message, s spinner.Spinner) (string, bool)
- func RenderTool(msg *types.Message, inProgress spinner.Spinner, args, result string, width int, ...) string
- func ThinkingDescription(label string) string
- func ThinkingGaugeValue(label string) string
- func ThinkingMarker(label string) string
- func TruncateText(text string, maxWidth int) string
- func TruncateTextLeft(text string, maxWidth int) string
- func WrapLines(text string, width int) []string
- func WrapLinesWords(text string, width int) []string
- type Base
- type CollapsedRenderer
- type Renderer
Constants ¶
const EffortGaugeCells = 6
EffortGaugeCells is the fixed cell width of the effort gauge. The six cells map one-to-one onto the six selectable effort levels, so the gauge is lossless: the filled-cell count alone identifies the level, and the color ramp is a secondary cue.
const LongRunningThreshold = 60 * time.Second
LongRunningThreshold is the duration after which a running tool call displays a warning hint that it may be blocked on external input.
Variables ¶
This section is empty.
Functions ¶
func EffortFillStyle ¶ added in v1.88.0
EffortFillStyle returns the foreground style for a level's filled cells: a low-to-high ramp (muted → accent → highlight → success → warning) kept as a secondary cue on top of the now-lossless cell count. Colors come from the active theme so the gauge stays theme-aware.
func EffortGauge ¶ added in v1.88.0
EffortGauge renders the fixed-width six-cell gauge for an effort level: the filled cells take the level's ramp color, the rest are faint. The width is constant across levels so the badge column stays aligned wherever the gauge is shown (roster rows, focus card, agent-details dialog).
func EffortGaugeEmpty ¶ added in v1.88.0
func EffortGaugeEmpty() string
EffortGaugeEmpty renders a fully empty, faint six-cell gauge. It marks a model that is capable of thinking but has it switched off ("off"), reading as "capable but disabled" — distinct from a non-capable model, which shows no gauge at all.
func ExtractField ¶
ExtractField creates an argument extractor function that parses JSON and extracts a field. The field function receives the parsed args and returns the display string. It supports partial JSON parsing for streaming tool calls.
func FormatTokenCount ¶ added in v1.88.0
FormatTokenCount formats a token count with K/M suffixes for readability (e.g. 8200 → "8.2K", 1500000 → "1.5M"). Values below 1000 are rendered verbatim. This is the canonical implementation shared by the sidebar and the cost/model dialogs.
func FormatToolResult ¶
func LongRunningWarning ¶ added in v1.41.0
LongRunningWarning returns a warning string if the tool call has been running longer than LongRunningThreshold, or empty string otherwise.
func NoArgsRenderer ¶ added in v1.53.0
func NoArgsRenderer(msg *types.Message, s spinner.Spinner, sessionState service.SessionStateReader, width, _ int) string
NoArgsRenderer is a Renderer that displays only the tool name and status, without arguments or a result. Useful for tools whose arguments aren't worth surfacing in the UI (e.g. user_prompt, todo helpers).
func ParseArgs ¶
ParseArgs unmarshals JSON arguments into a typed struct. Returns an error if parsing fails.
func Pluralize ¶ added in v1.53.0
Pluralize formats a count with its singular or plural form, e.g. Pluralize(1, "file", "files") returns "1 file" while Pluralize(3, "file", "files") returns "3 files".
func RenderFriendlyHeader ¶
RenderFriendlyHeader renders a friendly description header if present in the tool call arguments. Returns the rendered header string and true if a friendly description was found, empty string and false otherwise. Custom renderers can use this to show the friendly description before their custom content.
func RenderTool ¶
func ThinkingDescription ¶ added in v1.88.0
ThinkingDescription returns a human-readable description of a model's thinking-effort wire label, shared by the sidebar focus card and the agent-details dialog so both speak the same vocabulary:
- an effort level passes through verbatim (e.g. "high", "minimal")
- "adaptive" stays "adaptive"
- a decimal token budget becomes "<count> tokens" (e.g. "8.2K tokens")
- "off" stays "off"
- an empty label yields "" (the model has no thinking configuration)
func ThinkingGaugeValue ¶ added in v1.88.0
ThinkingGaugeValue renders the shared "<marker> <description>" thinking summary used by the sidebar focus card and the agent-details dialog: the effort gauge (or compact marker) followed by the human-readable description from ThinkingDescription. Returns "" when the label carries no thinking configuration. The "off" description is rendered faint to read as disabled.
func ThinkingMarker ¶ added in v1.88.0
ThinkingMarker returns the compact visual marker for a thinking wire label, used in the gauge column of the focus card and the agent-details dialog:
- an effort level → the six-cell effort gauge (colored)
- "off" → a dim empty gauge
- "adaptive" → the muted word "auto"
- a token budget → the token glyph "◉"
- an empty label → "" (no marker)
Unknown/future level words yield "" so the descriptive value still carries the meaning.
func TruncateText ¶
TruncateText truncates text to fit within maxWidth, adding an ellipsis if needed. Uses a forward-scanning approach for O(n) complexity instead of O(n²). Note: lipgloss.Width returns the maximum line width for multi-line strings.
func TruncateTextLeft ¶ added in v1.88.0
TruncateTextLeft truncates text from the left to fit within maxWidth, keeping the tail and prepending an ellipsis when truncation occurs. It mirrors TruncateText's edge cases but is the keep-the-tail counterpart: useful for model identifiers where the informative suffix (e.g. "…sonnet-4-6") should survive. Wraps ansi.TruncateLeft so ANSI escape sequences and wide characters are handled correctly.
func WrapLines ¶
WrapLines wraps text to fit within the given width. Each line that exceeds the width is split at rune boundaries.
func WrapLinesWords ¶
WrapLinesWords wraps text to fit within the given width, preferring to break at word boundaries (spaces). If a single word exceeds the width, it falls back to splitting at rune boundaries.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base provides common boilerplate for tool components. It handles spinner management, sizing, and delegates rendering to a custom function.
func NewBase ¶
NewBase creates a new base tool component with the given renderer. Accepts SessionStateReader for read-only access (also accepts *SessionState which implements it).
func NewBaseWithCollapsed ¶
func NewBaseWithCollapsed(msg *types.Message, sessionState service.SessionStateReader, render Renderer, collapsedRender CollapsedRenderer) *Base
NewBaseWithCollapsed creates a new base tool component with both regular and collapsed renderers. Accepts SessionStateReader for read-only access (also accepts *SessionState which implements it).
func (*Base) CollapsedView ¶
CollapsedView returns a simplified view for use in collapsed reasoning blocks. Falls back to the regular View() if no collapsed renderer is provided.
func (*Base) ExpandedView ¶ added in v1.60.0
ExpandedView returns the regular, full tool renderer.
func (*Base) StopAnimation ¶
func (b *Base) StopAnimation()
StopAnimation stops the spinner animation and unregisters from the animation coordinator. This must be called when the view is removed from the UI to avoid leaked animation subscriptions.
type CollapsedRenderer ¶
type CollapsedRenderer func(msg *types.Message, s spinner.Spinner, sessionState service.SessionStateReader, width, height int) string
CollapsedRenderer is a function that renders a simplified view for collapsed reasoning blocks.
type Renderer ¶
type Renderer func(msg *types.Message, s spinner.Spinner, sessionState service.SessionStateReader, width, height int) string
Renderer is a function that renders a tool call view. It receives the message, spinner, session state reader, and available width/height. Note: Uses SessionStateReader interface for read-only access to session state.
func SimpleRenderer ¶
SimpleRenderer creates a renderer that extracts a single string argument and renders it with RenderTool. This covers the most common case where tools just display one argument (like path, command, etc.).