Skip to content

feat(frontend): syntax-highlight all tool results + expand language support#357

Open
dimakis wants to merge 2 commits into
mainfrom
feat/tool-result-highlighting
Open

feat(frontend): syntax-highlight all tool results + expand language support#357
dimakis wants to merge 2 commits into
mainfrom
feat/tool-result-highlighting

Conversation

@dimakis
Copy link
Copy Markdown
Owner

@dimakis dimakis commented May 22, 2026

Summary

  • All tool results now use CodeBlock instead of plain <pre> — Bash output gets bash highlighting, Write/Edit results use the file's language, everything else gets consistent monospace styling with copy button
  • 12 new languages added to both CodeBlock registrations and EXT_MAP: clojure, dart, elixir, erlang, haskell, nginx, nix, objectivec, ocaml, powershell, scala, wasm
  • Total language count: 34 → 46

Test plan

  • Expand a Read tool pill → file content highlighted (unchanged behaviour)
  • Expand a Bash tool pill → output highlighted with bash colouring
  • Expand a Write tool pill → result section uses CodeBlock styling
  • Expand an Edit/Diff tool pill → result section uses CodeBlock styling
  • Expand a Grep/Glob tool pill → plain monospace in CodeBlock (no language)
  • Read/Write/Edit a .nix, .ex, .hs, .dart, .scala file → correct highlighting

🤖 Generated with Claude Code

Use CodeBlock for all tool result rendering, not just Read tool.
Bash output gets bash highlighting, Write/Edit results get the file's
language, and everything else gets consistent monospace + copy button.

Add clojure, dart, elixir, erlang, haskell, nginx, nix, objectivec,
ocaml, powershell, scala, wasm to both CodeBlock registrations and
the EXT_MAP language map.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dimakis
Copy link
Copy Markdown
Owner Author

dimakis commented May 22, 2026

Centaur Review

Found 5 issue(s) (1 critical) (3 warning).

frontend/src/components/__tests__/ToolPill.test.tsx

Broken existing test for non-read tool rendering is the critical issue; the code change itself is sound but needs test updates for the new behavior and new EXT_MAP entries, plus an nginx sync gap between CodeBlock registrations and EXT_MAP.

  • 🔴 regressions (L177): Existing test 'renders plain pre for non-read tools' (lines 177-192) will fail. It asserts .tool-pill-pre exists and .code-block-highlight is null — but the new code renders all tool results through CodeBlock, which uses .code-block-highlight and never creates .tool-pill-pre. The test must be updated to match the new unified rendering. [fixable]

frontend/src/components/CodeBlock.tsx

Broken existing test for non-read tool rendering is the critical issue; the code change itself is sound but needs test updates for the new behavior and new EXT_MAP entries, plus an nginx sync gap between CodeBlock registrations and EXT_MAP.

  • 🔵 style: nginx is imported and registered in CodeBlock but has no extension mapping in packages/protocol/src/language.ts EXT_MAP. The comment at line 8 says 'Keep in sync with EXT_MAP'. Without an EXT_MAP entry (e.g., conf: 'nginx'), no file will ever resolve to this language via languageFromPath. Either add an EXT_MAP entry or remove the nginx registration. [fixable]

packages/protocol/__tests__/language.test.ts

Broken existing test for non-read tool rendering is the critical issue; the code change itself is sound but needs test updates for the new behavior and new EXT_MAP entries, plus an nginx sync gap between CodeBlock registrations and EXT_MAP.

  • 🟡 missing_tests: The 12 new EXT_MAP entries (objectivec, dart, scala, haskell, ocaml, clojure, elixir, erlang, powershell, nix, wasm, and multi-extension variants like .cljs/.edn/.lhs/.mli/.hrl/.psm1/.psd1/.wast) have no test coverage. The existing test file covers 15 extensions but none of the newly added ones. At minimum, add one representative test per new language. [fixable]

frontend/src/components/ToolPill.tsx

Broken existing test for non-read tool rendering is the critical issue; the code change itself is sound but needs test updates for the new behavior and new EXT_MAP entries, plus an nginx sync gap between CodeBlock registrations and EXT_MAP.

  • 🟡 missing_tests: No test covers the new behavior where a non-read tool with a language (e.g., a Bash/command tool with language: 'bash') gets syntax highlighting via CodeBlock. The old test only covered the non-highlighted path. A test should verify that command-type tool results get bash highlighting and that Write-type results get their file-extension-derived highlighting. [fixable]
  • 🟡 regressions (L93): Visual regression: non-read tool results previously rendered as a plain <pre> with a 'Result' <span> label (styled via .tool-pill-label + .tool-pill-pre). They now render inside a CodeBlock with a header bar containing label, copy button, and language badge. This changes the visual appearance — the header chrome (background, padding, copy button) will show even for simple one-line results like Grep output. Intentional UX change, but worth verifying it looks good for short/plain results.

- Update ToolPill test: non-read results now render via CodeBlock
- Add tests for bash/write tool result highlighting
- Add 13 tests for new EXT_MAP languages (objectivec, dart, scala,
  haskell, ocaml, clojure, elixir, erlang, powershell, nix, wasm,
  nginx)
- Add conf → nginx mapping to close CodeBlock/EXT_MAP sync gap

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner Author

@dimakis dimakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Centaur Review

Found 3 issue(s) (2 warning).

packages/protocol/src/language.ts

Clean feature expansion — EXT_MAP and CodeBlock registrations are in sync, the ToolResult refactor handles all edge cases correctly, and tests cover the core behavior. Main concern is .confnginx being overly broad.

  • 🟡 unsafe_assumptions (L97): Mapping .confnginx is too broad. Many non-nginx files use .conf (e.g. httpd.conf for Apache, sysctl.conf, resolv.conf, logrotate.conf, application configs). Applying nginx syntax highlighting to these will produce misleading results. Consider removing this mapping or using basename-level detection (e.g. only match files containing 'nginx' in the name). [fixable]
  • 🟡 unsafe_assumptions (L59): Mapping .mobjectivec conflicts with MATLAB/Octave, which also uses .m files. In codebases that use MATLAB, this will produce incorrect highlighting. No great solution — just worth documenting the ambiguity as a code comment.

packages/protocol/__tests__/language.test.ts

Clean feature expansion — EXT_MAP and CodeBlock registrations are in sync, the ToolResult refactor handles all edge cases correctly, and tests cover the core behavior. Main concern is .confnginx being overly broad.

  • 🔵 missing_tests: New extension variants added to EXT_MAP lack test coverage: .mm (objectivec), .sbt (scala), .lhs (haskell), .mli (ocaml), .cljc/.edn (clojure), .exs (elixir), .hrl (erlang), .psm1/.psd1 (powershell), .wast (wasm). Each language has one extension tested but the secondary extensions are uncovered. [fixable]


// Infrastructure
dockerfile: 'dockerfile',
conf: 'nginx',
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 unsafe_assumptions: Mapping .confnginx is too broad. Many non-nginx files use .conf (e.g. httpd.conf for Apache, sysctl.conf, resolv.conf, logrotate.conf, application configs). Applying nginx syntax highlighting to these will produce misleading results. Consider removing this mapping or using basename-level detection (e.g. only match files containing 'nginx' in the name). [fixable]

kts: 'kotlin',
swift: 'swift',
cs: 'csharp',
m: 'objectivec',
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 unsafe_assumptions: Mapping .mobjectivec conflicts with MATLAB/Octave, which also uses .m files. In codebases that use MATLAB, this will produce incorrect highlighting. No great solution — just worth documenting the ambiguity as a code comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant