Repository navigation
feat(vscode): syntax-highlight code blocks and show a cursor while streaming - #1796
Conversation
…reaming The chat panel rendered fenced code with no colour at all, while streaming and once finished. marked already turns a still-open fence into <pre><code>, so the missing piece is a highlighter, not waiting for the closing backticks. Vendor a small highlight.js bundle (16 common languages, the same static-file approach as marked.min.js, no new dependency) and register one marked code renderer, so every marked.parse() in the panel (streaming text, finished text, thought bubbles) is highlighted. A language still being typed (py, pyth) falls back to plain escaped text instead of throwing. Token colours follow the light or dark VS Code theme. Add a pure-CSS blinking cursor (U+258C) on the assistant text block that is still receiving chunks. It is cleared when a tool call starts the next block and when the turn completes, is cancelled or fails, and it respects prefers-reduced-motion. The highlighting hook lives in media/markdown-highlight.js so it can be unit tested in Node like the other media helpers. Closes Nano-Collective#751
nc-review: nothing to raise@addyCooks — nothing to raise from the automated review. PR #1796 closes issue #751 by vendoring a small highlight.js bundle (v10.7.3, 16 languages) and registering a marked code hook in 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
CodeQL flags the visibleText helper (js/incomplete-multi-character- sanitization): it removed tags with a regex and then decoded entities, which can reassemble a <script. Skip tags with a scan and decode entities in a single pass instead. Test behaviour is unchanged.
chat-panel.js now calls NanocoderMarkdownHighlight.configureMarkdown at load, but the VM harness only ran the mention, uri and slash command helpers first, so every spec that boots the panel threw a TypeError. Run markdown-highlight.js before the panel, as chat-panel.html does.
Closes #751
Description
The VS Code chat panel rendered fenced code with no colour at all, while streaming and once finished. The issue assumed the renderer waits for the closing backticks, but the vendored
markedv15 already turns a still-open fence into<pre><code class="language-x">, so the missing piece is a highlighter.highlight.jsbundle (media/highlight.min.js, 16 common languages, the same static-file approach asmarked.min.js, no new dependency) and registers onemarkedcode renderer (media/markdown-highlight.js). Everymarked.parse()in the panel, meaning streaming text, finished text and thought bubbles, is highlighted with no per-call-site changes. A language still being typed (py,pyth) falls back to plain escaped text instead of throwing. Token colours follow the light or dark VS Code theme.▌on the assistant text block that is still receiving chunks. It is cleared when a tool call starts the next block and insetProcessing(false)(completed, cancelled or failed), and it respectsprefers-reduced-motion.The highlighting hook lives in its own small file so it can be unit tested in Node like the other media helpers.
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist