Repository navigation
Description
Summary
The tool-call formatter is visually inconsistent and lacks hierarchy. Tool status lines, collapsed results, expanded trees, and approval summaries each build strings with bare fmt.Sprintf and basic color wrappers (plain text, indentation-based hierarchy, no borders or cards). The Charm stack is already in go.mod (charm.land/lipgloss/v2 v2.0.5, bubbles/v2, x/ansi) and ships the pieces we need natively but are not using: lipgloss/tree, lipgloss/table, lipgloss/list, and the layout helpers Place / PlaceHorizontal. This feature uses them consistently to produce a polished, card-based layout across all tool-call surfaces, and collapses four divergent implementations into one.
Current pain points
- No card framing. Collapsed results are indented text lines with no container. Expanded trees use hand-written
├─/└─runes rather than a real tree renderer. - Connectors are hand-rolled at the source. The
├─/└─lines come fromtool.FormatResult(...):BaseFormatter.FormatExpandedHeader/FormatDataSection/FormatExpandedFooterininternal/domain/formatter.go, plus every tool's ownFormatResultininternal/agent/tools/*.go(20+ tools). The formatter service only re-themes the finished string line by line (themeTreeLinesininternal/services/tool_result_view.go). - Four divergent implementations of the same thing.
statusLine(tool_formatter.go),renderTool(tool_call_renderer.go), the approvalrenderSummary(approval_box_view.go), andformatToolCallsPreview(queue_box_view.go) each formaticon Name(args) statusdifferently. Truncation is width-aware (formatting.TruncateText) in the service but a naive byte cut (args[:47]) in the renderer. - No tool-type differentiation. Bash output, Edit diff, Write preview, A2A indicators, and generic calls all use the same flat text.
- Expand/collapse hints are bare dim text with no visual relationship to the content they govern.
- No argument styling. Arguments render as
key="value"(or collapsed"...") with no distinction between keys and values. - Toggling expand/collapse jumps the scroll position.
ToggleToolResultExpansion/ToggleAllToolResultsExpansionre-render without preserving the viewport offset, so the content the user was reading jumps off screen.
What Charm gives us natively (grounding)
All of this is already in go.mod. No new dependencies.
| Need | Native API | Notes |
|---|---|---|
| Tree connectors | lipgloss/tree (tree.New().Enumerator(tree.RoundedEnumerator), EnumeratorStyle, ItemStyleFunc) |
Replaces hand-written ├─/└─. RoundedEnumerator renders ├── / ╰──. |
| Key/value field lists | lipgloss/table (table.New().Border(lipgloss.HiddenBorder()).BorderColumn(false).Rows(...)) |
Already used in cmd/table.go, help_view.go. |
| Output-preview lists | lipgloss/list |
Optional, for multi-line previews. |
| Bottom-right status inside a card | lipgloss.PlaceHorizontal(w, lipgloss.Right, s) / lipgloss.Place(w, h, lipgloss.Right, lipgloss.Bottom, s) |
No manual padding math. |
| Card border | styles.Provider.RenderBorderedBox (rounded) |
Already exists. |
| Titled border label | reuse spliceBranchIntoTopBorder + truncateBorderLabel (provider.go:251/:292) |
lipgloss v2 has no native border title. The RenderInputField splice is the existing mechanism; generalize it. |
| Spinner in running card | bubbles/v2/spinner via GetSpinnerStyle / RenderSpinner |
Already available. |
| ANSI-aware truncate/width | charm.land/x/ansi (Truncate, StringWidth, Wrap) via formatting.TruncateText |
Already wrapped. |
Architectural constraint: UI components must not import lipgloss directly (see the doc comment in provider.go). New tree / table / card rendering lives behind styles.Provider methods (for UI) or the formatter service, not scattered in component files.
Acceptance criteria
1. One shared tool-card / summary renderer
- Add a single renderer (on
styles.Provider, plus a summary helper feeding it) that producesicon Name(args) statusidentically for all four call sites:statusLine(tool_formatter.go),renderTool(tool_call_renderer.go), approvalrenderSummary(approval_box_view.go),formatToolCallsPreview(queue_box_view.go). - All four use width-aware truncation via
formatting.TruncateText. Remove the naiveargs[:47]cut intool_call_renderer.go:formatArgsPreview. - The card is a rounded-border box (
RenderBorderedBox) with the tool name spliced into the top border via a generalizedRenderTitledCardbuilt on the existingspliceBranchIntoTopBordermechanism.
2. Live tool previews (ToolCallRenderer.RenderPreviews)
- Each running tool renders in a titled card. The
bubbles/v2spinner replaces the status icon inside the card. - Status and elapsed line sit at the bottom-right of the card via
lipgloss.PlaceHorizontal(cardWidth, lipgloss.Right, ...). - Bash tools show their rolling 7-line output inside the card, separated from the header by a dim
─line.
3. Collapsed tool results (FormatToolResultForUI)
- Titled card: header line (status icon + name + arg preview), a dim
─separator, the 5-line dim output preview (reusepreviewLinesfromtool_result_view.go), then a footer "N more lines, ctrl+o to expand" right-aligned viaPlaceHorizontal. - Failure: full body inside the card, no truncation.
- Rejected: Rejected badge in error color inside the card header.
4. Expanded tool results, native lipgloss/tree at the source
- Replace the hand-written
├─/└─box-drawing withlipgloss/tree(RoundedEnumerator) where the tree is built:BaseFormatter/CustomFormatterininternal/domain/formatter.goand each tool'sFormatResultininternal/agent/tools/*.go. - Introduce a shared tree-builder helper in
internal/domain/formatter.goso tools feed structured fields (label/value pairs, sections) instead of drawing glyphs. Each per-tool change is then mechanical: pass fields, delete thefmt.Fprintf("├─ ...")lines. This is a large but mechanical migration; the shared helper keeps each tool's diff tiny. - Field labels styled accent + bold via
EnumeratorStyle/ItemStyleFunc; values in normal weight. Key/value blocks may uselipgloss/tablewithHiddenBorder. - The expanded tree wraps in the same titled card.
- Retire the line-by-line re-theming (
themeTreeLines/wrapTreeLinesintool_result_view.go) once the tree renders natively.
5. Keep LLM / headless output plain (FormatterType gating)
FormatResultis shared by UI, LLM, and headless (FormatterUI/FormatterLLM/FormatterShort,interfaces.go:891). Apply thelipgloss/treestructure for all types, but gate color styling (EnumeratorStyle/ItemStyle, card borders) onFormatterUIonly.FormatterLLM/FormatterShortoutput stays plain, un-colored text (no ANSI). Verify headlessinfer agentoutput is unchanged in substance (a glyph width change from├─to├──is acceptable; if not, keep a custom plain enumerator matching the current 2-dash form).
6. Preserve scroll position on expand/collapse
- Toggling a single result (
ToggleToolResultExpansion) or all results (ToggleAllToolResultsExpansion) inconversation_view.gomust keep the toggled entry anchored at its current screen position rather than jumping. - Capture
Viewport.YOffset()beforeupdateViewportContentFull(), measure the height delta introduced above the anchor, and re-apply the adjusted offset after re-render. Apply the same anchoring to the thinking-block toggle for consistency.
7. Argument rendering
- Keys in accent color, values in default color (string values highlighted green). Long values truncated with
…in accent color. File paths viashortenPathInValue(tool_formatter.go) with a folder-icon prefix. Collapsible args (content=,new_string=) render ascontent="…"in dim italic. Single implementation, shared across call sites (see AC 1).
8. Tool-type differentiation (no emoji)
- Differentiate Bash / Edit / Write / A2A / generic tools by the accent color of the titled border label plus the tool name already shown there. No emoji badges, no new icon glyphs.
9. Queue box previews
- Adopt the shared card style for queued calls instead of bare dim text, and show arguments (currently
formatToolCallsPreviewshows onlyName(...)orN tools).
10. Tests
- Update UI tests (
tool_formatter_test.go,tool_call_renderer_test.go,approval_box_view_test.go) to the new card output. - Tool
FormatResulttests that assert exact├─/└─strings will change with the native tree glyphs; update those expectations. LLM-facing assertions must confirm output stays plain (no ANSI). - No new test dependencies.
- Validate rendered output with the tmux-driven TUI recipe in
AGENTS.md.
Implementation notes
- No new dependencies.
lipgloss/v2/tree,/table,/listare subpackages of thelipgloss/v2already ingo.mod.bubbles/v2/spinnerandcharm.land/x/ansiare present. - Reuse, do not reinvent. Card:
RenderBorderedBox. Titled border:spliceBranchIntoTopBorder/truncateBorderLabel(provider.go:251/:292). Previews:previewLines,capLines,contentWidth,pluralizeLines,formatDurationShort,collapsedFooter,collapseHintLine(all ininternal/services/tool_result_view.go). Truncation:formatting.TruncateText. Args:formatArgsPreview,argsPreviewBudget,shortenPathInValue(tool_formatter.go). - Keep the public interface. The
ToolFormatterinterface ininternal/domain/interfaces.gostays unchanged. Only rendered strings change. - Components go through
styles.Provider, never import lipgloss directly.
Affected files
| File | Role |
|---|---|
internal/ui/styles/provider.go |
Add RenderTitledCard + shared tool-card/summary renderer; generalize the border-title splice |
internal/services/tool_formatter.go |
Route statusLine / FormatToolResultForUI / FormatToolResultExpanded / formatArgsPreview through the shared renderer |
internal/services/tool_result_view.go |
Retire themeTreeLines / wrapTreeLines once the native tree renders |
internal/domain/formatter.go |
Adopt lipgloss/tree in BaseFormatter / CustomFormatter; add shared tree-builder helper; gate styling on FormatterUI |
internal/agent/tools/*.go |
Migrate each tool's FormatResult from ├─/└─ strings to the tree helper (20+ files, mechanical) |
internal/ui/components/tool_call_renderer.go |
Live previews via shared card; remove naive arg truncation |
internal/ui/components/approval_box_view.go |
Approval summary via shared card (keep DiffRenderer for Edit/MultiEdit/Write) |
internal/ui/components/queue_box_view.go |
Queue preview via shared card; show args |
internal/ui/components/conversation_view.go |
Anchor viewport offset across expand/collapse toggles |
Out of scope
- Markdown rendering in the conversation view (separate concern).
- Keybinding / shortcut refactors.
- Changing the
ToolFormatterinterface. - New external dependencies.
- Colors, cards, and spinners are TUI-only. The shared tree structure is adopted at the source formatter, but LLM / headless output stays plain, un-colored text (styles gated on
FormatterUI). - Inline background-task indicators (A2A, subagent trees) remain distinct components.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][FEATURE] Tool calls formatter visual overhaul — card-based layout with lipgloss v2[/-][+][FEATURE] Tool calls formatter visual overhaul - card-based layout with lipgloss v2[/+][-][FEATURE] Tool calls formatter visual overhaul - card-based layout with lipgloss v2[/-][+][FEATURE] Tool call formatter visual overhaul: native lipgloss v2 cards (tree/table/list)[/+]inference-gateway-releaser commentedon Jul 12, 2026
🎉 This issue has been resolved in version 0.143.0 🎉
The release is available on:
Your semantic-release bot 📦🚀