feat: Shiki-backed syntax highlighting with VS Code theme bridge (#1026) - #1028
Merged
Conversation
Add syntax_theme_bridge.ts: resolves the active VS Code color theme to either a Shiki built-in name (fast path, ~30 popular themes) or a full TextMate theme object extracted from the contributing extension's filesystem. Handles include chains (max depth 5, cycle detection) and merges editor.tokenColorCustomizations user overrides. Wire into ChatPanel: postSyntaxTheme() fires on theme change, on workbench.colorTheme change, and on tokenColorCustomizations change. Add 'syntax-theme' to both Lane 2 relay allowlists so the message reaches the framed app. 8 tests covering: built-in matching, custom extraction, include chains, cycle detection, user override merging, and fallback behavior.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…#1026) Overlay promotion from opencode fork branch with Slices 2-5: - shiki-theme-state.ts: reactive theme state for the webview - shiki-highlight-worker.ts: dedicated Shiki tokenization Web Worker - shiki-highlight-plugin.ts: CM6 ViewPlugin with Shiki decorations - editor-core.ts: wired Shiki extension + language-data fallback - preview-editor.tsx + editable-diff-view: pass lang to baseExtensions - markdown-shiki.worker.ts: theme-update support - pierre/worker.ts: active theme for @pierre/diffs pools - app.tsx: syntax-theme message handler Plus opencode fork upstream changes included in the full promotion.
Three bugs fixed in the fork: 1. Empty fallback theme: worker init now uses the actual OpenCodeTheme (30+ TextMate scope rules) instead of an empty stub 2. Worker URL: uses Vite ?worker&url import pattern matching existing markdown-shiki and @pierre/diffs workers 3. Test compat: extracted pure decoration logic to shiki-highlight- decorations.ts; editor-core.ts lazy-imports the plugin module New integration test verifies Shiki produces colored tokens + valid CM6 decorations for Julia, TypeScript, Python, Rust, Go, YAML, and Shell (16 tests, all green).
…fa55b660a) Previous incremental syncs used intermediate fork commits as the base, causing new Shiki files to be missing from the overlay. Redo as a full fork-vs-upstream-base delta to get all 18 files correctly. Fixes: shiki-highlight-plugin.ts, shiki-highlight-worker.ts, shiki-highlight-decorations.ts, shiki-theme-state.ts and tests now present in the overlay. The binary was already built from the correct fork commit (afc0f1c26a) — this fixes only the overlay tracking copy.
The extension previously posted syntax-theme only after a later VS Code theme/configuration change. A newly opened Preview tab therefore stayed on the OpenCode fallback palette forever. Post the resolved syntax theme on the existing app-ready handshake, when the iframe listener is guaranteed to exist. Restore live refreshes for colorTheme and tokenColorCustomizations changes, and admit the message through both Lane 2 relay render paths. Add regression coverage proving a fresh panel receives dark-plus after app-ready and both relays contain syntax-theme.
The sync:apply rewrote the manifest to point at the Shiki feature branch (afc0f1c26a) instead of local/amicode. Restore main's manifest so the drift gate passes against local/amicode as-is.
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.
Closes #1026
Slice 1: VS Code theme extraction + bridge
Adds
syntax_theme_bridge.ts— resolves the active VS Code color theme to either a Shiki built-in name (fast path, ~30 popular themes) or a full TextMate theme object extracted from the contributing extension's filesystem.What it does
vscode.extensions.all, reads the theme JSON, resolvesincludechains (max depth 5, cycle detection), and returns the full TextMate theme objecteditor.tokenColorCustomizations.textMateRuleson toponDidChangeActiveColorTheme,workbench.colorTheme, andeditor.tokenColorCustomizationschangessyntax-themeto both relay allowlists so the message reaches the framed appTesting
syntax_theme_bridge.test.tscovering all behaviorsRemaining slices (fork changes)
@codemirror/language-data)