Repository navigation
feat(tui): card-based tool-call formatter overhaul + scrollable approval review (#864) - #865
Merged
Merged
Conversation
…primitive Add BaseFormatter/CustomFormatter.FormatExpanded building the expanded result as one native lipgloss/tree (RoundedEnumerator), replacing the hand-drawn tree that spanned FormatExpandedHeader/DataSection/Footer. Add Provider.RenderTitledCard + ToolTitleColor for the tool-card overhaul. Old trio methods retained until call sites migrate. Part of #864.
Route every structured tool's FormatForLLM plus the service LLM fallback through domain.FormatExpanded (one native lipgloss/tree), and delete the hand-drawn FormatExpandedHeader/FormatDataSection/FormatExpandedFooter trio (+ CustomFormatter override) and todowrite's emoji header. Teach the UI wrap/theme helpers the rounded '╰' glyph so the expanded view themes and wraps the native tree. Edit/MultiEdit diffs and memory/write bodies now feed the shared Result section. Part of #864.
…mmary Add ToolFormatter.RenderToolSummary (one width-aware '<icon> Name(args) <trailing>' builder) and route statusLine through it. Frame the collapsed view (status, dim separator, preview, right-aligned footer) and the expanded tree in a rounded titled card via Provider.RenderTitledCard, with the tool name on the border coloured by type (AC8, no emoji). Regenerate mocks and update the affected formatter tests. Part of #864.
Route the tool-result and thinking-block toggles through rebuildPreservingScroll, which measures the pre-toggle line spans, applies the state change, re-renders, and offsets the viewport by the height delta of changed entries above the scroll position - so expanding an off-screen entry no longer makes the view jump. Stays pinned to the bottom when the user is following the tail. Part of #864.
Inject the shared ToolFormatter into ToolCallRenderer and QueueBoxView. Live previews now render the width-aware '<icon> Name(args) <status>' summary inside a titled card (spinner as the status icon, bash output inside), replacing the byte-slice args[:47] preview that broke on multibyte runes and dumped raw JSON. Queued tool calls show their argument preview instead of a bare Name(...). Part of #864.
Add tests for FormatExpanded's native rounded-tree structure, the LLM path staying card-free and plain, RenderTitledCard framing/width, the shared RenderToolSummary (width-aware, rune-safe), and viewport scroll anchoring across expand/collapse. Part of #864.
The approval box capped the diff preview to ~half the terminal with no way to review the rest before approving. ctrl+o now toggles a scrollable full-diff window (up/down scroll) that fills the screen while the action buttons stay pinned, so a file larger than the terminal is fully reviewable — consistent with expanding tool results in the conversation view.
The Write new-file preview hard-capped at 50 lines with its own "… N more lines" footer, which shadowed the scrollable approval window (the tail was already dropped before scrolling could reach it) and, on an exactly-50-line file, showed a phantom "… 1 more lines" from the trailing newline. The renderer now drops the empty trailing element and takes a configurable cap via SetMaxLines; the expanded approval box renders every line (SetMaxLines(-1)) and lets its own window be the single height bound.
ToggleAllToolResultsExpansion collapsed-first whenever *any* result was expanded, so a lone collapsed card — e.g. a rejected Write — ignored the first ctrl+o when a default-expanded Edit diff sat above it (the press just collapsed the Edit). It now expands-first unless every result is already expanded, so the collapsed card always opens on the first press; collapsing only kicks in once everything is open.
Rejecting an approval with esc clears the StateManager's approval state without completing the huh form, so ApprovalBoxView.active/form were never reset. IsActive() trusted those stale fields and kept returning true, so ctrl+o was routed to the (defunct) approval box and swallowed instead of expanding the rejected result in the conversation. IsActive() now consults the live StateManager — matching Render — so it reports false the moment the approval is cleared by any path, and ctrl+o falls through to the conversation.
6 tasks
…domain renderExpandedTree used FormatStatus, which emits a raw color escape, so the Status node leaked ANSI into the FormatterLLM tree message sent to the model. Use a plain glyph status instead (the UI re-themes the tree via themeTreeLines). Also move the lipgloss/v2/tree dependency behind a leaf wrapper (internal/ui/styles/tree), matching the colors/icons convention so the domain layer no longer imports lipgloss directly. Guard the LLM path with an ANSI-free assertion in TestFormatExpandedNativeTree (real renderExpandedTree path).
edenreich
added a commit
that referenced
this pull request
Jul 11, 2026
) ## Summary Add language-aware syntax highlighting using chroma (already a transitive dependency via glamour) for diff content and file content previews in the card-based tool-call formatter, keyed off file extension with a plain fallback. ## Changes - **`diffview/diffview.go`** — Add `WithChromaStyle` fluent setter on `DiffView`. Nil/no-call preserves exact current behavior. Clears the syntax cache on set. - **`diff_renderer.go`** — Add private `chromaStyle()` method deriving `github` (light) or `github-dark` from the active theme's brightness. Wire it into `buildDiffView()` and `renderContentPreview()` (which now takes a `filePath` parameter for lexer selection). - **`diff_renderer_test.go`** — Three new tests: known language (.go), unknown extension (.xyzabc), and nil style provider (no crash). ## Key Design Decisions | Decision | Rationale | |----------|-----------| | Chroma style gated on `chromaStyle == nil` inside `highlightCode()` | Existing guard — nil = no highlighting, no perf cost | | `Highlight()` with `lineNumbers=false` for content previews | Custom gutter is already rendered; `Highlight` handles tab expansion, normalization, tokenisation | | `contentPreviewLimit` cap applied after highlighting | Lexing only processes the shown lines (default 50), no unbounded work | | LLM format also gets chroma | Diff output already has ANSI backgrounds from #865; chroma tokens are additive readability improvement | ## Testing - `task precommit:run` — all hooks pass - Existing `TestDiffRenderer_*` tests pass - New `TestDiffRenderer_SyntaxHighlight_*` tests pass Closes #866
Contributor
|
🎉 This PR is included in version 0.143.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #864 — a card-based visual overhaul of the tool-call formatter, plus a set of approval-box review fixes surfaced during testing.
The four surfaces that render a tool call (
statusLine, liverenderTool, approval summary, queue preview) each builticon Name(args) statusdifferently — one width-aware, another a naiveargs[:47]byte-cut that dumped raw JSON and broke multibyte runes. Collapsed/expanded results had no card framing, the expanded tree was hand-drawn├─/└─runes re-themed line-by-line, and toggling expand/collapse jumped the scroll position. This unifies all of it.What changed (#864 acceptance criteria)
<icon> Name(args) <status>builder (ToolFormatter.RenderToolSummary); the status line, live preview, approval summary and queue preview all route through it. Killed theargs[:47]byte-slice.lipgloss/tree— expanded results build one realtree(RoundedEnumerator); all ~18 tools + the service fallback migrated; the hand-drawn connectors deleted.├──/╰──glyphs.rebuildPreservingScrollanchors the view across expand/collapse.Name(...).Approval-box review fixes (found while testing)
… 1 more lineson an exactly-50-line file (trailing-newline off-by-one). The renderer now drops the empty trailing element and takes a configurable cap; the expanded box renders every line and is its own single height bound.IsActive()kept returning true and swallowed ctrl+o. It now consults the live StateManager, so a rejected result expands again.Testing
task test(unit + integration),task test:e2e, andtask lintall pass.├──/╰──).Notes
feat:) → a matching[DOCS]ticket forinference-gateway/docswill follow.content: ...(the formatter elides the arg, same as a successful write, which has no result body when rejected). Can add a rejected-diff view as a follow-up if wanted.