Skip to content

fix(web): stop highlighter freezes by using Oniguruma WASM - #219

Merged
leoisadev1 merged 2 commits into
mainfrom
fix/web-highlighter-oniguruma-wasm
Sep 10, 2026
Merged

fix(web): stop highlighter freezes by using Oniguruma WASM#219
leoisadev1 merged 2 commits into
mainfrom
fix/web-highlighter-oniguruma-wasm

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

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 of shiki-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 / FilePreviewPanel are 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 ChatMarkdown path.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I linked the accepted plugin or provider proposal in Why, or this PR does not add one
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Scope

  • Does not resurrect ChatView.
  • Does not change provider adapters.
  • Does not upgrade Pierre or Shiki.

Verification

  • vp test run apps/web/src/lib/syntaxHighlighting.test.ts passed
  • vp lint and vp fmt on the touched files passed
  • vp run --filter @t3tools/web typecheck passed
  • Isolated vp run dev --home-dir fixture, paired browser: bot chat, Settings Appearance including the highlighted code-font preview, Providers list

Limitations

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.

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.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
akeru-bot-landing Skipped Skipped Sep 10, 2026 5:45pm UTC

Request Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This 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/5

Safe to merge.

There are no outstanding findings.

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/web-highlig..." | Re-trigger Greptile

@leoisadev1
leoisadev1 merged commit 8bd8b92 into main Sep 10, 2026
11 of 12 checks passed
@leoisadev1
leoisadev1 deleted the fix/web-highlighter-oniguruma-wasm branch September 10, 2026 21:13
@github-actions github-actions Bot mentioned this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant