Repository navigation
feat(themes): public tokens for diffs, git status, tabs, dividers, rows, links - #36578
Conversation
Findings
|
25c5fb2 to
56c79a4
Compare
52e557e to
4d713f1
Compare
2295199 to
cc96228
Compare
…ws, links Adds 29 public app theme tokens (diff, git decorations, tab bar, split divider, current workspace row, host badge, chat bubble, text link), each falling back to today's built-in color or CSS chain so existing themes and built-ins render the same. Monaco's diff editor now paints from the diff tokens, with sharper default diff tints (from #34698) and a readable dark ignored-file color. The contrast gate learns one-sided drops, translucent surfaces checked over their base, and main.css chains for half-set pairs. Co-Authored-By: Claude <[email protected]>
…ges as painted The contrast gate now derives an omitted diff tint from the theme's hue (and drops the hue when its tint hides code), checks chat bubbles against chat's mixed foreground on the chat canvas, and models the dark host badge at 80% accent. The main.css fallback table moves to plugin-theme-css-fallbacks.ts. Co-Authored-By: Claude <[email protected]>
…at diff rows A diff tint the theme set itself no longer drops the theme's hue when it fails, and chat diff rows (hue-mixed text on the line tint over the chat canvas) are now checked too. Co-Authored-By: Claude <[email protected]>
…aint exactly as before Every new token now falls back to the exact value its surface used before: - Diff hues default to the git decoration colors at the previous per-side percentages, and chat diff text keeps its 70% mix. - Monaco's diff view, overview ruler and links keep Monaco's stock colors unless the theme painted a diff or link token. The colors go through the derived Monaco theme instead of a global CSS override. - --text-link has no :root default; each link rule keeps its old literal as the fallback, including the markdown-light/-dark preview split and the always-#58a6ff Monaco doc link. - Tab bar, tab text and indicator fall back per element (bg-card, text-foreground, ...) instead of through :root aliases. - Dark --git-decoration-ignored goes back to #6e6e6e (#35910 ships separately). The contrast gate skips checks that have no theme token to drop, so themes that set only older tokens pay no extra probes.
…nd precomputes drop lists
ddda6cd to
2774151
Compare
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
65c539ca-d83a-44a4-b522-11ab6ddc5966
Files selected for processing: 26-
docs/reference/plugin-theme-tokens.mddocs/reference/plugin-themes.mddocs/styleguide/color.mdsrc/renderer/src/app-shell/use-document-appearance.tssrc/renderer/src/assets/main.csssrc/renderer/src/assets/markdown-preview.csssrc/renderer/src/assets/rich-markdown-editor.csssrc/renderer/src/components/floating-terminal/FloatingTerminalPanelSurface.tsxsrc/renderer/src/components/native-chat/NativeChatDiffCard.tsxsrc/renderer/src/components/native-chat/NativeChatDiffView.tsxsrc/renderer/src/components/native-chat/NativeChatToolRun.test.tsxsrc/renderer/src/components/native-chat/native-chat-appearance-palette.test.tssrc/renderer/src/components/native-chat/native-chat-appearance-style.tssrc/renderer/src/components/tab-bar/drop-indicator.tssrc/renderer/src/components/tab-group/TabGroupPanel.tsxsrc/renderer/src/components/tab-group/TabGroupSplitLayout.tsxsrc/renderer/src/components/ui/badge.tsxsrc/renderer/src/lib/document-theme.test.tssrc/renderer/src/lib/document-theme.tssrc/renderer/src/lib/left-sidebar-appearance.tssrc/renderer/src/lib/plugin-monaco-theme.test.tssrc/renderer/src/lib/plugin-monaco-theme.tssrc/renderer/src/lib/plugin-theme-tokens.tssrc/shared/plugins/artifacts/plugin-theme-artifact.tssrc/shared/plugins/artifacts/plugin-theme-css-fallbacks.tssrc/shared/plugins/artifacts/plugin-theme-token-reference-doc.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
| const textColor = effective(text) | ||
| for (const rule of CONTRAST_RULES) { | ||
| const dropped = | ||
| rule.surfaceSource && tokens[rule.surface] === undefined |
There was a problem hiding this comment.
Use the accepted set when adding a diff hue to the drop list.
A diff hue is a surface source for the background and emphasis checks. When one of those checks rejects its own token on an earlier pass, the hue still stays in the accepted set. In the current condition, tokens[rule.surface] is undefined only when the raw theme never set the surface. It stays defined when the surface was set and then rejected. The hue is then not a candidate, so the check skips and the hue stays painted with its unchecked fallback. Cached replay removes the rejected surface from the stored tokens. It then drops the hue, so first paint and cached replay disagree.
Use the same accepted-set test in the condition:
🐛 Proposed fix
-
--- "a/src/renderer/src/lib/plugin-theme-tokens.ts" +++ "b/src/renderer/src/lib/plugin-theme-tokens.ts" @@ -195,7 +195,7 @@ changed = false for (const rule of CONTRAST_RULES) { const dropped = - rule.surfaceSource && tokens[rule.surface] === undefined + rule.surfaceSource && !accepted.has(rule.surface) ? [...rule.dropped, rule.surfaceSource] : rule.dropped // Why skip: a check with nothing of the theme's to drop can't change the result, so a
Test with a dark palette that uses a #aaaaaa foreground and #333333 surfaces. Set --diff-added: #ffffff, --diff-added-background: #ffffff, and --diff-added-emphasis: #000000. Do not omit the emphasis token. Without it, the emphasis check drops the hue first and the test does not isolate this path. Assert that --diff-added-background and --diff-added are absent, that --diff-added-emphasis remains, and that the first paint and the cached replay produce the same token set.
Committable suggestion
-
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.Suggested changerule.surfaceSource && tokens[rule.surface] === undefined rule.surfaceSource && !accepted.has(rule.surface)
Stacked on #36561. Merge that first; this PR's base is
nwparker/theme-contrast-defaults.Stacked on #36561. Merge that first; this PR's base is
nwparker/theme-contrast-defaults.Summary
Plugin app themes could set only about 37 shadcn-style tokens. Diffs, git status, the tab bar, split dividers, the current workspace row, the host badge, chat bubbles and Markdown links used internal variables or hardcoded colors.
This PR adds 29 public, color-only tokens and wires each one into the CSS that already paints those surfaces. It only exposes tokens. If a theme doesn't set a token, the surface paints the same value it painted before this PR, pixel for pixel. That holds for the built-in themes and for every existing plugin theme.
--diff-added,--diff-removed(hues), plus-background,-emphasis,-gutterfor eachdiffEditor.*,diffEditorGutter.*,diffEditorOverview.*--git-decoration-{added,modified,deleted,renamed,untracked,copied,ignored}gitDecoration.*ResourceForeground--tab-bar,--tab-active,--tab-active-foreground,--tab-active-indicator,--tab-inactive,--tab-inactive-foregroundeditorGroupHeader.tabsBackground,tab.*--split-divider,--split-divider-hovereditorGroup.border,sash.hoverBorder--worktree-sidebar-active,--worktree-sidebar-active-border,--host-badge,--host-badge-foregroundlist.activeSelection*--chat-user-message--text-linktextLink.foregroundRoot cause: the public token set stopped at shadcn's core, and each surface above read a private variable or a literal. Fixing it at the token layer covers every surface for every theme in one place, so no per-surface settings are needed.
How an omitted token resolves to exactly what the surface painted before:
var(--git-decoration-added)andvar(--git-decoration-deleted). The line and gutter tints keep their previous per-side percentages: light 13/26 and 11/22, dark 16/30 and 18/32. Chat diff text keeps its 70% mix.bg-tab-bar,text-tab-active-foreground,text-tab-inactive-foregroundandbg-tab-active-indicatorare@theme inlinecolors, for examplevar(--tab-bar, var(--card)). Each one resolves on the element, just like thebg-card/text-foreground/text-muted-foreground/bg-foregroundclasses it replaces.var(--bg-titlebar, var(--tab-bar, var(--card))).--tab-activeand--tab-inactivewere already derived at:root. They now readvar(--tab-bar, var(--card)).--text-linkhas no default. Each link rule keeps its previous selector and literal as the fallback:.markdown-light/.markdown-darkpreview links, rich-editor.darklinks, and the Monaco doc link, which is always#58a6ff.var(--token, <previous expression>)at the consumer. The left sidebar's Match terminal / Tinted modes and the chat's Match terminal mode reset them toinitial, so the user's appearance choice still wins.derivePluginMonacoThemesetsdiffEditor.*,diffEditorGutter.*,diffEditorOverview.*andtextLink.*only when the theme painted that token or its hue. Every other theme keeps Monaco's stock colors.Contrast gate (
plugin-theme-tokens.ts):--sidebaror--editor-surface.PLUGIN_APP_THEME_CSS_FALLBACKSmirrors main.css for this.Docs:
docs/reference/plugin-theme-tokens.mdis regenerated, with a "When omitted" column.docs/reference/plugin-themes.mdexplains the gate and the appearance-mode behavior.docs/styleguide/color.mdcovers the diff tokens.Refs #34696 (the sharper default palette needs its own opt-in PR; this one doesn't change defaults)
Refs #35910 (themes can now set
--git-decoration-ignored; the brighter dark default ships separately)Refs #10642 (diff colors are now themeable; editor-only themes are a separate workstream)
Refs #14887 (themes can recolor the split divider; there is no per-user setting)
Refs #16164 (themes can invert tab colors; the built-in defaults are unchanged)
Refs #35908 (row background, row border and host badge colors; corner radius is not a color and is left out)
Refs #25907
Builds on #34698 by @purian23 (diff tokens and the Monaco diff color keys), #14893 by @mmarabel (split divider), #25921 by @pawel-kotowski (chat bubble color) and #6477 by @andrewroxby (link color variable). Each of those is reimplemented here as a theme token instead of a setting.
Visual proof: zero pixel change without opt-in
Each image puts the stack parent (#36561) on the left and this branch on the right. Both were captured from real background Electron instances (
ORCA_BACKGROUND_LAUNCH=1) on throwaway profiles, through CDP. The scenario has a repo with modified, untracked, staged-rename, staged-delete and ignored (out/) files. The window is split into a rich Markdown editor with links and a Monaco diff, with the source-control or explorer panel open.Built-in dark (source control):

Built-in light (explorer, ignored

out/):Catppuccin Mocha, the official plugin from stablyai/orca-plugins main (source control):

Catppuccin Latte (explorer):

Surfaces the main layout doesn't show, rendered with each build's real components through the fixture harness. They are the chat diff view and diff card (rows and gutters), the chat user bubble (

ChatSurfacePreview), the active worktree row with a host badge, the active and inactive tabs with the indicator,.markdown-lightand.markdown-darkpreview links (including a light preview inside a dark app), and rich-editor and Monaco doc links. Columns: dark parent, dark branch, light parent, light branch.Every exact-diff pixel is a ±1 channel antialiasing wobble, mostly on the rounded split-divider edge. The same wobble appears when the parent build is captured twice: 478 to 1019 such pixels. The computed-style dump covers color, background, all borders, outline, fill, stroke, text-decoration and box-shadow for every visible element. It also covers the Monaco diff editor's resolved
--vscode-diffEditor*,--vscode-diffEditorGutter*,--vscode-diffEditorOverview*and--vscode-textLink*variables. All of them are byte-identical.The harness catches the regressions this commit fixes. Run against the previous head (c879ccb), the same fixture probe differed by 7.7% to 8.1% of pixels. Monaco's variables also changed for built-in and Catppuccin themes, from stock
rgba(155,185,85,.2)tocolor-mix(#5ecc71 20%). Under Catppuccin,textLinkchanged from#3794ffto#58a6ffand the overview ruler was recolored.Opt-in still works. A Mocha copy that sets

--diff-added,--diff-removed,--text-link,--tab-bar,--tab-active-indicator,--split-divider,--worktree-sidebar-active,--host-badgeand--git-decoration-ignoredrecolors the Monaco diff rows, gutters, ruler and links, the tab strip and indicator, the divider and the row.Merge-risk assessment
Low. The PR is additive, and without opt-in the output is pixel- and computed-style-identical.
validate:pluginon an older Orca rejects the new keys, which is expected for authoring.:rootgains only the--diff-*alias and emphasis custom properties, and thediv.monaco-diff-editoroverride that ran on every editor is gone.--diff-*-groundand--tab-group-split-divider*were internal, and every consumer is updated. No source references the old names.Perf
What was scanned: the
perf-scanchecklist (six questions) run against this PR's diff versus #36561 (4d713f16a24). I traced every hot path the diff touches:applyPluginAppTheme→safePluginThemeTokens→derivePluginMonacoTheme, which run once per theme or light/dark change.:rootand in the chat-scheme blocks.@theme inlinetab utilities.div.monaco-diff-editoroverride, which used to match every Monaco diff editor.The PR adds no timers, effects, subscriptions, IPC calls or native resources.
Findings:
ddda6cd7646): ring checks resolved their surface even when the theme set no ring. They now skip first. The per-rule drop lists are also computed once at module load instead of on every pass.Measurements. Built-in themes never call the gate. App timings come from dev builds on macOS, both builds on the same scenario: split Markdown and Monaco diff, source-control panel, about 1,370 elements. Each figure is per operation over 20 or 200 iterations, two runs per build.
The recalc differences are within run-to-run noise: the ranges overlap and switch order between runs. The gate's JS overhead stays in microseconds per theme apply. The browser probe cost is unchanged because the probe count is identical. The Monaco CSS override is gone, so Monaco diff editors pay nothing for these tokens unless a theme sets diff colors. Then Monaco applies them through its own theme.
Six-question disposition:
useDocumentAppearanceeffect, as before.Limits: these are dev-build timings, not a packaged build. There is no Windows or Linux timing in this pass.
Negative user-facing tradeoffs
None known for users who don't opt in. The evidence is above.
Notes for theme authors, which are behavior rather than regressions:
--tab-baralso recolors the title bar and the floating terminal header, because tabs sit in them.Validation
pnpm tc:web,pnpm tc:node,oxlintandoxfmt --checkon the changed files all pass.pnpm testpasses 502 files / 5363 tests acrosssrc/shared/plugins, native-chat, tab-bar, document-theme and plugin-monaco-theme. A new test pins that Monaco keeps its stock diff and link colors unless the theme painted those tokens.pnpm generate:plugin-schemaswas run and the generated docs are committed.gpt-6.1-sol, xhigh) reviewed the previous head. Every valid finding is fixed in 2295199:textLinkwere recolored for existing plugin themes, because computed defaults were read as opt-in..markdown-light/.markdown-dark.:rootinstead of the element.dark:bg-accent/80compiles to the samecolor-mix(in oklab, …)as the fallback.🤖 Generated with Claude Code