perf(markdown): move code highlighting off the main thread into a Shiki worker

Tokenize closed code blocks in a dedicated Shiki Web Worker instead of calling
the shared highlighter synchronously on the UI thread. This removes the
one-shot main-thread highlight stall when a code fence closes on a large block.

Streaming behavior is unchanged: the open (streaming) fence still renders as
plain text and is highlighted once on close. On any worker failure the block
keeps its escaped plain code — highlighting never falls back onto the main
thread.

- Add markdownShikiThemeDefinition (dependency-free CSS-variable theme) so the
  worker can use the theme without pulling in @pierre/diffs / React.
- Add markdown-worker-protocol, markdown-shiki.worker, and the main-thread
  markdown-worker client.
- Route highlightCodeBlocks through the worker; keep the size/VSCode line guard
  and mermaid skip on the main thread.
- Add shiki as a direct dependency (was transitive via @pierre/diffs).
This commit is contained in:
Bohdan Triapitsyn
2026-06-16 01:07:43 +03:00
parent 9ea557d23e
commit 464c4ac0ca
8 changed files with 249 additions and 131 deletions
+5 -4
View File
@@ -99,7 +99,7 @@
},
"packages/electron": {
"name": "@openchamber/electron",
"version": "1.12.4",
"version": "1.13.0",
"dependencies": {
"@openchamber/web": "workspace:*",
"electron-context-menu": "^4.1.2",
@@ -114,7 +114,7 @@
},
"packages/ui": {
"name": "@openchamber/ui",
"version": "1.12.4",
"version": "1.13.0",
"dependencies": {
"@base-ui/react": "^1.4.0",
"@codemirror/autocomplete": "^6.20.0",
@@ -178,6 +178,7 @@
"rehype-katex": "^7.0.1",
"remark-math": "^6.0.0",
"remend": "^1.2.1",
"shiki": "^3.23.0",
"simple-git": "^3.28.0",
"sonner": "^2.0.7",
"strip-json-comments": "^5.0.3",
@@ -216,7 +217,7 @@
},
"packages/vscode": {
"name": "openchamber",
"version": "1.12.4",
"version": "1.13.0",
"dependencies": {
"@openchamber/ui": "workspace:*",
"@opencode-ai/sdk": "^1.17.7",
@@ -239,7 +240,7 @@
},
"packages/web": {
"name": "@openchamber/web",
"version": "1.12.4",
"version": "1.13.0",
"bin": {
"openchamber": "./bin/cli.js",
},