perf(web): resume syntax highlighting from completed lines - #11196
Conversation
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The PR replaces full streaming syntax highlighting with a stateful grammar/HAST-resumption path in the production chat renderer. Tests cover many languages, themes, edits, and fallbacks, but the runtime algorithm is sufficiently nontrivial that its streaming behavior warrants human review. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
6ab8db7 to
ba2471b
Compare
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds incremental syntax highlighting for streaming code blocks. It preserves grammar state across complete lines, falls back to full highlighting when needed, and adds tests for languages, themes, edits, truncation, plaintext, ANSI-like input, and line endings. ChangesIncremental syntax highlighting
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant UncachedShikiCodeBlock
participant createIncrementalHighlighter
participant DiffsHighlighter
UncachedShikiCodeBlock->>createIncrementalHighlighter: Highlight streaming content
createIncrementalHighlighter->>DiffsHighlighter: Highlight uncached complete lines
DiffsHighlighter-->>createIncrementalHighlighter: Return highlighted nodes and grammar state
createIncrementalHighlighter-->>UncachedShikiCodeBlock: Return incremental HTML
Merge Risk: ⚪ Minimal · up to The streaming highlighting change has no confirmed current-head issue requiring resolution before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
## What's Changed * fix(pr): update labels and reviewers without redundant reloads by @maria-rcks in pingdotgg/t3code#11117 * fix(chat): fold question answers into tool activity by @maria-rcks in pingdotgg/t3code#11014 * fix(usage): flag unpriced model activity instead of showing $0.00 by @maria-rcks in pingdotgg/t3code#11021 * fix(server): let Claude launch args override the derived permission mode by @maria-rcks in pingdotgg/t3code#11026 * fix(editors): accept root paths and Windows servers in Zed remote links by @maria-rcks in pingdotgg/t3code#11044 * fix(web): center pull request unavailable states by @maria-rcks in pingdotgg/t3code#11110 * fix(web): remove sidebar pull request link icon by @maria-rcks in pingdotgg/t3code#11179 * fix(ui): color linked pr counts by aggregate status by @maria-rcks in pingdotgg/t3code#11180 * fix(preview): render website favicons for browser tool activity by @maria-rcks in pingdotgg/t3code#11032 * fix(web): simplify pull request summary sections by @maria-rcks in pingdotgg/t3code#10612 * fix(web): preserve drafts when compacting context by @maria-rcks in pingdotgg/t3code#11103 * fix(server): queue messages during context compaction by @maria-rcks in pingdotgg/t3code#11107 * perf(web): format minimap previews only when opened by @juliusmarminge in pingdotgg/t3code#11181 * perf(web): reuse completed Markdown prefixes while streaming by @juliusmarminge in pingdotgg/t3code#11193 * perf(web): resume syntax highlighting from completed lines by @juliusmarminge in pingdotgg/t3code#11196 * perf(web): preserve completed code-line DOM while streaming by @juliusmarminge in pingdotgg/t3code#11198 * perf(web): huge-thread switch no longer blanks the chat pane by @juliusmarminge in pingdotgg/t3code#11169 **Full Changelog**: pingdotgg/t3code@v0.0.41-nightly.20260911.1520...v0.0.41-nightly.20260911.1533 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.41-nightly.20260911.1533
Growing code fences tokenize every earlier line on each streamed chunk. Resume Shiki from the grammar state after the last completed line and tokenize the changing suffix. This adapts the incremental document work in Legend Code using Shiki's grammar-state API.
Completed messages keep the existing cached path. Non-append edits invalidate the prefix; CR/CRLF, plain text, ANSI and missing grammar state fall back to full highlighting. Multiline syntax and embedded languages retain their grammar context.
Five alternating production-browser runs at 1440 × 1000, each with 10 warm-up updates and 40 measured updates. The fixture starts with 200 TypeScript lines and appends one line per update.
The median reduction is 29.6%; every paired run improved. This is a deliberately heavy client-rendering workload, not provider throughput or typical-user latency. Probe and samples. The
codeToHtmlMscounter excludes directcodeToHastwork; the complete synchronous update is the comparison metric.100 focused Markdown/highlighting tests and web typecheck pass. Actual WASM highlighting matches full output through streaming prefixes across 11 languages and two themes, including multiline comments, strings, heredocs, embedded HTML, edits, truncation and fallback languages. Targeted lint reports two warnings in unchanged code.
This improves streaming code in web and Electron's shared renderer. It does not change mobile, file/diff viewers, the wire protocol or provider adapters. Both hosted and locally served web clients use this code; no transport timing claim is made.
Before:
After:
Before streaming:
https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/2fd3e3038ca91da9/highlight-before-realtime.webm
After streaming:
https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/cd992d3d57a131d6/highlight-after-realtime.webm
The videos reconstruct Chrome screenshot frames with their original timestamps, retaining gaps between paints. They are separate from the unrecorded timing runs. The same synthetic fixture and viewport are used; no private transcripts or credentials are included. No observed new blank frames or color flashes during the exercised stream.
Integration follow-up: rebased on current main; the integrated stack passes 94 focused Markdown/highlighting tests and 159 timeline tests, plus web typecheck. The timing table remains pinned to the original measured builds.
Model: GPT-6. Harness: Codex.