Repository navigation
Description
Summary
Follow-up to #865 (card-based tool-call formatter overhaul). The card and diff
surfaces now render file content and diffs cleanly, but the content itself is
still emitted as plain, uncolored text — a Write preview, a Read body, and
the added/removed lines of an Edit/MultiEdit diff show no language-aware
syntax highlighting. Reviewing a proposed change in the approval window would be
noticeably easier to scan with proper highlighting (keywords, strings, comments,
types).
Proposal: add syntax highlighting for programming languages to the diff/content
renderer, keyed off the file extension (and language guess for extensionless
files). chroma is a strong candidate:
it lexes ~250 languages, emits ANSI, and — importantly — is already in the
dependency tree (github.com/alecthomas/chroma/v2 v2.27.0, pulled in
transitively by charm.land/glamour/v2), so this adds no new direct dependency.
It ships a terminal256/terminalTruecolor formatter that maps cleanly onto the
existing per-token styling, and its style registry can be selected from the
active theme.
Scope notes / constraints:
- TUI-only. Highlighting must be gated on
FormatterUI, same as the card
colors.FormatterLLM/FormatterShortoutput must stay plain (ANSI-free) —
the existing tests assert this and headlessinfer agentoutput must not gain
escape codes. - Highlight the content of added/context lines inside a diff; the diff's own
add/remove+/-coloring (from the diff renderer) stays the source of truth
for line-level status. The two color layers must compose without fighting
(foreground token color over the diff line background). - Language detection from
DiffInfo.FilePath/ the tool'sfile_patharg;
fall back to no highlighting (plain, current behavior) on unknown languages
rather than guessing wrong. - Respect width/wrapping already handled by
DiffRenderer— highlighting is a
per-token color pass, it must not change the line-splitting/truncation logic. - Theme integration: pick a chroma style (or map tokens through the theme
provider) so it honors light/dark and the existingstyles.Provider, keeping
lipgloss confined to the provider per the component rules.
Primary surface: internal/ui/components/diff_renderer.go
(renderContentPreview, the per-line diff rendering, RenderWriteToolArguments).
Acceptance Criteria
-
Write/Read/Edit/MultiEditcontent rendered in the TUI shows
language-aware syntax highlighting driven by file extension, with a plain
fallback for unknown/unsupported languages. - Highlighting is gated on
FormatterUI;FormatterLLMandFormatterShort
output remains ANSI-free (existing plain-output tests still pass). - Token highlighting composes with the existing diff add/remove coloring
without visual conflict, and does not alter line wrapping/truncation. - Highlight style honors the active theme (light/dark) via the styles
provider; no lipgloss/chroma imports leak into components beyond the
established provider seam. - No new direct dependency added (reuse the already-vendored
chroma/v2). - Unit tests cover: highlighting applied for a known language, plain fallback
for an unknown extension, and ANSI-free LLM/Short output.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(tui): chroma syntax highlighting for diff and content preview (#868
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 📦🚀