fix(web): stop highlighter freezes by using Oniguruma WASM - #219
Merged
Conversation
The JS regex engine can backtrack forever on ordinary source lines and pin the renderer. Chat markdown, search, shell commands, Settings font previews, and remaining Pierre file/diff option sites now share shiki-wasm so the first-caller singleton cannot land on the hangy engine. Adapted from pingdotgg#8360.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis change consistently selects the Shiki WASM highlighter across the web client’s shared syntax-highlighting entry points, including chat, search, shell output, diffs, file previews, and Settings font previews. Focused coverage preserves preferred-engine selection and unsupported-language fallback behavior. Confidence Score: 5/5Safe to merge. There are no outstanding findings. Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/web-highlig..." | Re-trigger Greptile |
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.
What Changed
Chat markdown, search, shell commands, Settings font previews, and remaining Pierre file/diff option sites now create the shared highlighter with
shiki-wasm(Oniguruma) instead ofshiki-js.The shared highlighter is first-caller-wins, so every creation site has to agree. Akeru has no pull-request code tab, and
MessagesTimeline/DiffPanel/FilePreviewPanelare retained but not on the live bot/group routes. Those retained option objects still receive the same engine so they cannot steal the singleton later.Why
Shiki's JavaScript regex engine can backtrack forever on ordinary source lines. One match pins the renderer until the tab is force-quit. WASM Oniguruma tokenizes the same input without hanging.
Adapted from pingdotgg/t3code#8360. Credit to that work and to pingdotgg#3885 for the worker-pool approach.
UI Changes
No intended visual change. Same grammars and themes. Isolated browser check: Scout bot chat still renders at 1440 and 390, Settings Appearance font previews still highlight the code-font sample, and Providers still lists ChatGPT, Claude, Grok, Kimi For Coding, and OpenCode Go.
This fixture home had no group chat, so group-route markdown highlighting was not exercised here. The renderer is the same
ChatMarkdownpath.Checklist
Scope
Verification
vp test run apps/web/src/lib/syntaxHighlighting.test.tspassedvp lintandvp fmton the touched files passedvp run --filter @t3tools/web typecheckpassedvp run dev --home-dirfixture, paired browser: bot chat, Settings Appearance including the highlighted code-font preview, Providers listLimitations
The catastrophic Go-comment hang from upstream pingdotgg#8356 was not reproduced here. The tests prove the engine selection. Desktop Electron and native mobile were not run.
Implemented and verified by Grok 4.6 High in Grok Build via Orca.