Skip to content

Colour the code blocks in chat output - #196

Merged
splitbrain merged 1 commit into
splitbrain:mainfrom
splitbrain-bot:code-highlight
Nov 26, 2026
Merged

splitbrain merged 1 commit into
splitbrain:mainfrom
splitbrain-bot:code-highlight

Conversation

@splitbrain-bot

Copy link
Copy Markdown

A code block in a thread showed plain text. The dashboard already had Shiki for the code pane of the review.

Change: the code blocks in chat output use the same highlighter. A block shows plain text while the message streams and gets its colours when the message is complete, as a mermaid block gets its diagram. A block in a language without a grammar stays plain. The rendered markdown view of the review uses the same component, so its code blocks get colours too.

The highlighter accepts the short language names of code fences, such as ts, js, sh, py and yml. It also has the grammars for tsx and jsx, which the review does not use but agents often write in a fence.

Tests:

  • highlight.test.ts checks that an alias selects the grammar of its language, and that an unknown language stays plain.
  • A new test in ux.test.ts checks that a block is plain while the message streams, has more than one colour after it, and that a block in an unknown language stays plain.

A code block in a thread showed plain text. The dashboard already had Shiki for the code pane of the review, so
the code blocks now use the same highlighter. The highlighter accepts the short language names of code fences,
such as `ts` and `sh`, and has the grammars for `tsx` and `jsx`. A block gets its colours when the message is
complete. A block in a language without a grammar stays plain.
@splitbrain
splitbrain merged commit c07feac into splitbrain:main Nov 26, 2026
6 checks passed
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.

2 participants