Repository navigation
Colour the code blocks in chat output - #196
Merged
Merged
Conversation
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.
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.
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,pyandyml. It also has the grammars fortsxandjsx, which the review does not use but agents often write in a fence.Tests:
highlight.test.tschecks that an alias selects the grammar of its language, and that an unknown language stays plain.ux.test.tschecks 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.