Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Adopt base16 for color themes and widen theme coverage (#3075)
serafin-garcia510cc4ee5ff4
diff --git a/.changeset/base16-color-themes.md b/.changeset/base16-color-themes.mdnew file mode 100644index 000000000..9567f94c0--- /dev/null+++ b/.changeset/base16-color-themes.md@@ -0,0 +1,19 @@+---+"@inkeep/open-knowledge": patch+---++Color themes are now authored in base16, the format the wider theming ecosystem already uses, and they reach considerably more of the app.++The built-in palettes (Dracula, Catppuccin Frappé and Latte, Monokai, Gruvbox, Solarized) are reproduced from their canonical upstream schemes, and Settings → Plugins → Themes gains a "Paste a base16 scheme" field: drop in any of the several hundred published schemes as YAML or JSON — in either the current Tinted Theming layout or the original one — and it applies as-is. The sixteen slots are also editable by hand. An existing custom theme built from the older six-color picker is upgraded automatically rather than reset.++The reason for the format change is coverage. The previous palette used ad-hoc names like "surface" and "accent" that several surfaces had no way to consume, so picking a theme left them on hardcoded colors. base16's slots carry fixed roles that map onto those surfaces directly, and the following now follow the selected theme:++- **Source-mode syntax highlighting.** The CodeMirror editor was pinned to one of two bundled palettes regardless of theme. This also covers the diff view, the text viewer, the text-file editor, and the Mermaid editor.+- **Terminal colors.** All sixteen ANSI slots, so program output is themed, not just the terminal's background.+- **Callouts.** All fifteen accent colors.+- **Fenced code blocks** in the WYSIWYG editor, plus inline code, blockquotes, tables, links, highlight marks, and horizontal rules.+- **Lint squigglies, broken-link underlines, and the file tree's problem indicators.**+- **`html preview` embeds**, which now receive the host's live token values instead of a build-time snapshot of the default theme, so an embed matches the surrounding editor.+- **The desktop window chrome** on Windows and Linux — the titlebar overlay and window background take the active theme's colors rather than staying neutral.++Also fixes three keyframe animations (the sidebar push pulse and two settings flashes) that painted nothing in any theme, including the default one, because they wrapped a color token in `hsl()`.diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex 9c5dd9cde..7607c33ff 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -2505,16 +2505,6 @@ Homepage: https://github.com/u-wave/react-vimeo#readmeCopyright (c) 2016 Renée Kooi-### `@uiw/[email protected]`-Homepage: https://uiwjs.github.io/react-codemirror/#/theme/data/basic/light--_(No LICENSE file in package; SPDX identifier in `package.json` is the sole declared grant.)_--### `@uiw/[email protected]`-Homepage: https://uiwjs.github.io/react-codemirror/#/theme/doc--_(No LICENSE file in package; SPDX identifier in `package.json` is the sole declared grant.)_-### `@upsetjs/[email protected]`Homepage: https://github.com/upsetjs/venn.jsdiff --git a/docs/content/reference/configuration.mdx b/docs/content/reference/configuration.mdxindex 6f64aeee6..5ef53da39 100644--- a/docs/content/reference/configuration.mdx+++ b/docs/content/reference/configuration.mdx@@ -36,7 +36,10 @@ A key set in a file more specific than its scope (a user-scope key in `.ok/confi| `contentRules.markdownlint.enabled` | boolean | `false` | project | Enable the [markdownlint](/docs/advanced/content-rules/markdownlint) content-rules plugin for this project (shared via git). Off by default — turn it on in **Settings → This project → Plugins**. The rules themselves live in your native `.markdownlint.*` file, not here. || `contentRules.frontmatter.enabled` | boolean | `false` | project | Enable the [Frontmatter schemas](/docs/advanced/content-rules/frontmatter) content-rules plugin for this project (shared via git). Off by default — turn it on in **Settings → This project → Plugins**. || `contentRules.frontmatter.schemas` | array | `[]` | project | Frontmatter schema mappings: each entry scopes one JSON Schema file to a set of docs — `file` (project-root-relative path), optional `appliesTo` (glob or list; leading `!` excludes; absent means every doc), optional `enabled: false` to park a mapping. Schema content lives in the mapped files, not here. See [Frontmatter schemas](/docs/advanced/content-rules/frontmatter). |-| `appearance.theme` | `"light" \| "dark" \| "system"` | (unset) | user | Editor theme. |+| `appearance.theme` | `"light" \| "dark" \| "system"` | (unset) | user | Editor light/dark theme. |+| `appearance.colorTheme` | `"default" \| "dracula" \| "catppuccin-frappe" \| "catppuccin-latte" \| "monokai" \| "gruvbox" \| "solarized" \| "custom"` | (unset) | user | IDE color palette layered on top of the light/dark `theme`. `default` (the effective value when unset) follows `theme`; the named palettes are self-contained schemes that force their own light/dark mode; `custom` applies `appearance.customTheme`. Pick it in **Settings → Plugins → Themes**. |+| `appearance.colorThemeEnabled` | boolean | `true` | user | Whether the Themes plugin appears in **Settings → Plugins**. On by default (absent = enabled). |+| `appearance.customTheme` | object | (unset) | user | The `custom` palette's [base16](https://github.com/tinted-theming/schemes) scheme: sixteen `base00`–`base0F` `#rrggbb` slots, plus optional `name`, `author` (a credit line carried through from an imported scheme), and `variant` (`"dark" \| "light"`, auto-detected from the tonal ramp when absent). A config written before base16 carried six semantic seed colors (`background`/`surface`/`foreground`/`primary`/`accent`/`border`) instead; that shape still parses and is upgraded to the sixteen slots automatically on read. Edit in **Settings → Plugins → Themes**. || `appearance.sidebar.showHiddenFiles` | boolean | `false` | project-local | Show files whose path segments start with `.`. The sidebar otherwise lists every file on disk under the content directory; tooling internals (`.git/`, `.ok/`, `node_modules/`) stay hidden regardless. Toggled from the sidebar's right-click menu or the macOS **View → Show Hidden Files** item. || `autoSync.mode` | `"off" \| "follow" \| "full" \| null` | `null` | project-local | Per-machine sync mode for this project: `off` (no sync), `follow` (one-directional — pull remote changes, never push your own; the earlier value `pull` is accepted as an alias), `full` (bidirectional pull and push). `null` means "unanswered"; the editor's onboarding modal triggers on first remote-detected open. Supersedes `autoSync.enabled`. || `autoSync.enabled` | `boolean \| null` | `null` | project-local | Legacy per-machine auto-sync toggle, superseded by `autoSync.mode`. Read only when `mode` is absent (`true` = full, `false` = off). `null` means "unanswered". |diff --git a/packages/app/package.json b/packages/app/package.jsonindex e51aa3c97..072a45057 100644--- a/packages/app/package.json+++ b/packages/app/package.json@@ -52,7 +52,7 @@{"name": "all JS chunks combined (gzipped)","path": "dist/assets/*.js",- "limit": "3.72 MB",+ "limit": "3.78 MB","gzip": true,"running": false},@@ -121,7 +121,6 @@"@tiptap/suggestion": "^3.22.3","@tiptap/y-tiptap": "3.0.3","@u-wave/react-vimeo": "^0.9.12",- "@uiw/codemirror-theme-basic": "^4.25.9","@visimer/core": "^0.1.0","@visimer/dom": "^0.1.0","@xterm/addon-fit": "0.11.0",diff --git a/packages/app/scripts/gen-color-themes.ts b/packages/app/scripts/gen-color-themes.tsindex 45a53f4c6..9a0c2f274 100644--- a/packages/app/scripts/gen-color-themes.ts+++ b/packages/app/scripts/gen-color-themes.ts@@ -1,13 +1,15 @@/*** Regenerate `src/color-themes.generated.css` from the `COLOR_THEMES` registry- * in `src/lib/color-themes.ts`. Run via `bun run gen:color-themes`. The- * companion `src/lib/color-themes.generated.test.ts` fails on drift, so commit- * the regenerated file whenever a palette changes.+ * in `src/lib/color-themes.ts`. Run via `pnpm run gen:color-themes`. The+ * companion `src/lib/color-themes.test.ts` fails on drift, so commit the+ * regenerated file whenever a palette changes.*/import { writeFileSync } from 'node:fs';-import { resolve } from 'node:path';+import { dirname, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';import { generateColorThemesCss } from '../src/lib/color-themes';-const out = resolve(import.meta.dir, '../src/color-themes.generated.css');+const here = dirname(fileURLToPath(import.meta.url));+const out = resolve(here, '../src/color-themes.generated.css');writeFileSync(out, generateColorThemesCss());console.log(`Wrote ${out}`);diff --git a/packages/app/src/color-themes.generated.css b/packages/app/src/color-themes.generated.cssindex f6ebf3812..0003f9f6b 100644--- a/packages/app/src/color-themes.generated.css+++ b/packages/app/src/color-themes.generated.css@@ -1,26 +1,26 @@-/* GENERATED by `bun run gen:color-themes` from src/lib/color-themes.ts — do not edit by hand. */+/* GENERATED by `pnpm run gen:color-themes` from packages/core/src/theme/theme-plugins.ts — do not edit by hand. */html[data-color-theme="dracula"] {color-scheme: dark;--background: #282a36;--foreground: #f8f8f2;- --card: #343746;+ --card: #21222c;--card-foreground: #f8f8f2;- --popover: #343746;+ --popover: #21222c;--popover-foreground: #f8f8f2;--primary: #bd93f9;--primary-foreground: #282a36;- --secondary: #343746;+ --secondary: #21222c;--secondary-foreground: #f8f8f2;- --muted: #343746;- --muted-foreground: #9aa0c5;- --accent: #343746;+ --muted: #21222c;+ --muted-foreground: #9ea8c7;+ --accent: #44475a;--accent-foreground: #f8f8f2;--destructive: #ff5555;--border: #44475a;--input: #44475a;--ring: #bd93f9;- --selection-soft: oklch(from var(--primary) l c h / 0.3);+ --selection-soft: #44475a;--chart-1: #bd93f9;--chart-2: #50fa7b;--chart-3: #f1fa8c;@@ -30,138 +30,270 @@ html[data-color-theme="dracula"] {--sidebar-foreground: #f8f8f2;--sidebar-primary: #bd93f9;--sidebar-primary-foreground: #282a36;- --sidebar-accent: oklch(from var(--primary) l c h / 0.14);+ --sidebar-accent: #44475a;--sidebar-accent-foreground: #bd93f9;- --sidebar-hover: #343746;+ --sidebar-hover: #44475a;--sidebar-border: #44475a;--sidebar-ring: #bd93f9;--syntax-keyword: #ff79c6;--syntax-tag: #ff5555;- --syntax-attr: #8be9fd;+ --syntax-attr: #bd93f9;--syntax-string: #50fa7b;--syntax-number: #ffb86c;--syntax-atom: #8be9fd;+ --syntax-comment: #6272a4;+ --syntax-func: #bd93f9;+ --syntax-var: #ff5555;+ --syntax-type: #f1fa8c;+ --syntax-operator: #f8f8f2;+ --syntax-meta: #993333;+ --syntax-bg: #21222c;+ --link-color: #bd93f9;+ --broken-link-color: #ff5555;+ --lint-warning-color: #f1fa8c;+ --lint-error-color: #ff5555;+ --diff-added: #50fa7b;+ --diff-removed: #ff5555;+ --callout-note-color: #bd93f9;+ --callout-info-color: #bd93f9;+ --callout-todo-color: #bd93f9;+ --callout-abstract-color: #8be9fd;+ --callout-tip-color: #50fa7b;+ --callout-success-color: #50fa7b;+ --callout-important-color: #ff79c6;+ --callout-example-color: #ff79c6;+ --callout-question-color: #ff79c6;+ --callout-warning-color: #f1fa8c;+ --callout-caution-color: #ffb86c;+ --callout-danger-color: #ffb86c;+ --callout-failure-color: #ff5555;+ --callout-bug-color: #ff5555;+ --callout-quote-color: #6272a4;+ --ansi-black: #282a36;+ --ansi-red: #ff5555;+ --ansi-green: #50fa7b;+ --ansi-yellow: #f1fa8c;+ --ansi-blue: #bd93f9;+ --ansi-magenta: #ff79c6;+ --ansi-cyan: #8be9fd;+ --ansi-white: #f8f8f2;+ --ansi-bright-black: #6272a4;+ --ansi-bright-red: #ff5555;+ --ansi-bright-green: #50fa7b;+ --ansi-bright-yellow: #f1fa8c;+ --ansi-bright-blue: #bd93f9;+ --ansi-bright-magenta: #ff79c6;+ --ansi-bright-cyan: #8be9fd;+ --ansi-bright-white: #ffffff;}html[data-color-theme="catppuccin-frappe"] {color-scheme: dark;--background: #303446;--foreground: #c6d0f5;- --card: #414559;+ --card: #292c3c;--card-foreground: #c6d0f5;- --popover: #414559;+ --popover: #292c3c;--popover-foreground: #c6d0f5;- --primary: #ca9ee6;+ --primary: #8caaee;--primary-foreground: #303446;- --secondary: #414559;+ --secondary: #292c3c;--secondary-foreground: #c6d0f5;- --muted: #414559;- --muted-foreground: #a5adce;+ --muted: #292c3c;+ --muted-foreground: #626880;--accent: #414559;--accent-foreground: #c6d0f5;--destructive: #e78284;- --border: #51576d;- --input: #51576d;- --ring: #ca9ee6;- --selection-soft: oklch(from var(--primary) l c h / 0.3);- --chart-1: #ca9ee6;+ --border: #414559;+ --input: #414559;+ --ring: #8caaee;+ --selection-soft: #414559;+ --chart-1: #8caaee;--chart-2: #a6d189;--chart-3: #e5c890;--chart-4: #ca9ee6;--chart-5: #e78284;--sidebar: #292c3c;--sidebar-foreground: #c6d0f5;- --sidebar-primary: #ca9ee6;+ --sidebar-primary: #8caaee;--sidebar-primary-foreground: #303446;- --sidebar-accent: oklch(from var(--primary) l c h / 0.14);- --sidebar-accent-foreground: #ca9ee6;+ --sidebar-accent: #414559;+ --sidebar-accent-foreground: #8caaee;--sidebar-hover: #414559;- --sidebar-border: #51576d;- --sidebar-ring: #ca9ee6;+ --sidebar-border: #414559;+ --sidebar-ring: #8caaee;--syntax-keyword: #ca9ee6;--syntax-tag: #e78284;--syntax-attr: #8caaee;--syntax-string: #a6d189;--syntax-number: #ef9f76;--syntax-atom: #81c8be;+ --syntax-comment: #51576d;+ --syntax-func: #8caaee;+ --syntax-var: #e78284;+ --syntax-type: #e5c890;+ --syntax-operator: #c6d0f5;+ --syntax-meta: #eebebe;+ --syntax-bg: #292c3c;+ --link-color: #8caaee;+ --broken-link-color: #e78284;+ --lint-warning-color: #e5c890;+ --lint-error-color: #e78284;+ --diff-added: #a6d189;+ --diff-removed: #e78284;+ --callout-note-color: #8caaee;+ --callout-info-color: #8caaee;+ --callout-todo-color: #8caaee;+ --callout-abstract-color: #81c8be;+ --callout-tip-color: #a6d189;+ --callout-success-color: #a6d189;+ --callout-important-color: #ca9ee6;+ --callout-example-color: #ca9ee6;+ --callout-question-color: #ca9ee6;+ --callout-warning-color: #e5c890;+ --callout-caution-color: #ef9f76;+ --callout-danger-color: #ef9f76;+ --callout-failure-color: #e78284;+ --callout-bug-color: #e78284;+ --callout-quote-color: #51576d;+ --ansi-black: #303446;+ --ansi-red: #e78284;+ --ansi-green: #a6d189;+ --ansi-yellow: #e5c890;+ --ansi-blue: #8caaee;+ --ansi-magenta: #ca9ee6;+ --ansi-cyan: #81c8be;+ --ansi-white: #c6d0f5;+ --ansi-bright-black: #51576d;+ --ansi-bright-red: #e78284;+ --ansi-bright-green: #a6d189;+ --ansi-bright-yellow: #e5c890;+ --ansi-bright-blue: #8caaee;+ --ansi-bright-magenta: #ca9ee6;+ --ansi-bright-cyan: #81c8be;+ --ansi-bright-white: #babbf1;}html[data-color-theme="catppuccin-latte"] {color-scheme: light;--background: #eff1f5;--foreground: #4c4f69;- --card: #ffffff;+ --card: #e6e9ef;--card-foreground: #4c4f69;- --popover: #ffffff;+ --popover: #e6e9ef;--popover-foreground: #4c4f69;- --primary: #8839ef;- --primary-foreground: #ffffff;- --secondary: #ffffff;+ --primary: #1e66f5;+ --primary-foreground: #eff1f5;+ --secondary: #e6e9ef;--secondary-foreground: #4c4f69;- --muted: #ffffff;- --muted-foreground: #6c6f85;- --accent: #ffffff;+ --muted: #e6e9ef;+ --muted-foreground: #acb0be;+ --accent: #ccd0da;--accent-foreground: #4c4f69;--destructive: #d20f39;--border: #ccd0da;--input: #ccd0da;- --ring: #8839ef;- --selection-soft: oklch(from var(--primary) l c h / 0.3);- --chart-1: #8839ef;+ --ring: #1e66f5;+ --selection-soft: #ccd0da;+ --chart-1: #1e66f5;--chart-2: #40a02b;--chart-3: #df8e1d;--chart-4: #8839ef;--chart-5: #d20f39;--sidebar: #e6e9ef;--sidebar-foreground: #4c4f69;- --sidebar-primary: #8839ef;- --sidebar-primary-foreground: #ffffff;- --sidebar-accent: oklch(from var(--primary) l c h / 0.14);- --sidebar-accent-foreground: #8839ef;- --sidebar-hover: #ffffff;+ --sidebar-primary: #1e66f5;+ --sidebar-primary-foreground: #eff1f5;+ --sidebar-accent: #ccd0da;+ --sidebar-accent-foreground: #1e66f5;+ --sidebar-hover: #ccd0da;--sidebar-border: #ccd0da;- --sidebar-ring: #8839ef;+ --sidebar-ring: #1e66f5;--syntax-keyword: #8839ef;--syntax-tag: #d20f39;--syntax-attr: #1e66f5;--syntax-string: #40a02b;--syntax-number: #fe640b;--syntax-atom: #179299;+ --syntax-comment: #bcc0cc;+ --syntax-func: #1e66f5;+ --syntax-var: #d20f39;+ --syntax-type: #df8e1d;+ --syntax-operator: #4c4f69;+ --syntax-meta: #dd7878;+ --syntax-bg: #e6e9ef;+ --link-color: #1e66f5;+ --broken-link-color: #d20f39;+ --lint-warning-color: #df8e1d;+ --lint-error-color: #d20f39;+ --diff-added: #40a02b;+ --diff-removed: #d20f39;+ --callout-note-color: #1e66f5;+ --callout-info-color: #1e66f5;+ --callout-todo-color: #1e66f5;+ --callout-abstract-color: #179299;+ --callout-tip-color: #40a02b;+ --callout-success-color: #40a02b;+ --callout-important-color: #8839ef;+ --callout-example-color: #8839ef;+ --callout-question-color: #8839ef;+ --callout-warning-color: #df8e1d;+ --callout-caution-color: #fe640b;+ --callout-danger-color: #fe640b;+ --callout-failure-color: #d20f39;+ --callout-bug-color: #d20f39;+ --callout-quote-color: #bcc0cc;+ --ansi-black: #eff1f5;+ --ansi-red: #d20f39;+ --ansi-green: #40a02b;+ --ansi-yellow: #df8e1d;+ --ansi-blue: #1e66f5;+ --ansi-magenta: #8839ef;+ --ansi-cyan: #179299;+ --ansi-white: #4c4f69;+ --ansi-bright-black: #bcc0cc;+ --ansi-bright-red: #d20f39;+ --ansi-bright-green: #40a02b;+ --ansi-bright-yellow: #df8e1d;+ --ansi-bright-blue: #1e66f5;+ --ansi-bright-magenta: #8839ef;+ --ansi-bright-cyan: #179299;+ --ansi-bright-white: #7287fd;}html[data-color-theme="monokai"] {color-scheme: dark;--background: #272822;--foreground: #f8f8f2;- --card: #31322b;+ --card: #383830;--card-foreground: #f8f8f2;- --popover: #31322b;+ --popover: #383830;--popover-foreground: #f8f8f2;--primary: #66d9ef;--primary-foreground: #272822;- --secondary: #31322b;+ --secondary: #383830;--secondary-foreground: #f8f8f2;- --muted: #31322b;- --muted-foreground: #a6a28c;- --accent: #31322b;+ --muted: #383830;+ --muted-foreground: #a59f85;+ --accent: #49483e;--accent-foreground: #f8f8f2;--destructive: #f92672;--border: #49483e;--input: #49483e;--ring: #66d9ef;- --selection-soft: oklch(from var(--primary) l c h / 0.3);+ --selection-soft: #49483e;--chart-1: #66d9ef;--chart-2: #a6e22e;- --chart-3: #e6db74;+ --chart-3: #f4bf75;--chart-4: #ae81ff;--chart-5: #f92672;- --sidebar: #1e1f1a;+ --sidebar: #383830;--sidebar-foreground: #f8f8f2;--sidebar-primary: #66d9ef;--sidebar-primary-foreground: #272822;- --sidebar-accent: oklch(from var(--primary) l c h / 0.14);+ --sidebar-accent: #49483e;--sidebar-accent-foreground: #66d9ef;- --sidebar-hover: #31322b;+ --sidebar-hover: #49483e;--sidebar-border: #49483e;--sidebar-ring: #66d9ef;--syntax-keyword: #ae81ff;@@ -169,43 +301,87 @@ html[data-color-theme="monokai"] {--syntax-attr: #66d9ef;--syntax-string: #a6e22e;--syntax-number: #fd971f;- --syntax-atom: #66d9ef;+ --syntax-atom: #a1efe4;+ --syntax-comment: #75715e;+ --syntax-func: #66d9ef;+ --syntax-var: #f92672;+ --syntax-type: #f4bf75;+ --syntax-operator: #f8f8f2;+ --syntax-meta: #cc6633;+ --syntax-bg: #383830;+ --link-color: #66d9ef;+ --broken-link-color: #f92672;+ --lint-warning-color: #f4bf75;+ --lint-error-color: #f92672;+ --diff-added: #a6e22e;+ --diff-removed: #f92672;+ --callout-note-color: #66d9ef;+ --callout-info-color: #66d9ef;+ --callout-todo-color: #66d9ef;+ --callout-abstract-color: #a1efe4;+ --callout-tip-color: #a6e22e;+ --callout-success-color: #a6e22e;+ --callout-important-color: #ae81ff;+ --callout-example-color: #ae81ff;+ --callout-question-color: #ae81ff;+ --callout-warning-color: #f4bf75;+ --callout-caution-color: #fd971f;+ --callout-danger-color: #fd971f;+ --callout-failure-color: #f92672;+ --callout-bug-color: #f92672;+ --callout-quote-color: #75715e;+ --ansi-black: #272822;+ --ansi-red: #f92672;+ --ansi-green: #a6e22e;+ --ansi-yellow: #f4bf75;+ --ansi-blue: #66d9ef;+ --ansi-magenta: #ae81ff;+ --ansi-cyan: #a1efe4;+ --ansi-white: #f8f8f2;+ --ansi-bright-black: #75715e;+ --ansi-bright-red: #f92672;+ --ansi-bright-green: #a6e22e;+ --ansi-bright-yellow: #f4bf75;+ --ansi-bright-blue: #66d9ef;+ --ansi-bright-magenta: #ae81ff;+ --ansi-bright-cyan: #a1efe4;+ --ansi-bright-white: #f9f8f5;}html[data-color-theme="gruvbox"] {color-scheme: dark;--background: #282828;- --foreground: #ebdbb2;- --card: #32302f;- --card-foreground: #ebdbb2;- --popover: #32302f;- --popover-foreground: #ebdbb2;+ --foreground: #d5c4a1;+ --card: #3c3836;+ --card-foreground: #d5c4a1;+ --popover: #3c3836;+ --popover-foreground: #d5c4a1;--primary: #83a598;- --primary-foreground: #1d2021;- --secondary: #32302f;- --secondary-foreground: #ebdbb2;- --muted: #32302f;- --muted-foreground: #a89984;- --accent: #32302f;- --accent-foreground: #ebdbb2;+ --primary-foreground: #282828;+ --secondary: #3c3836;+ --secondary-foreground: #d5c4a1;+ --muted: #3c3836;+ --muted-foreground: #bdae93;+ --accent: #504945;+ --accent-foreground: #d5c4a1;--destructive: #fb4934;- --border: #3c3836;- --input: #3c3836;+ --border: #504945;+ --input: #504945;--ring: #83a598;- --selection-soft: oklch(from var(--primary) l c h / 0.3);+ --selection-soft: #504945;--chart-1: #83a598;--chart-2: #b8bb26;--chart-3: #fabd2f;--chart-4: #d3869b;--chart-5: #fb4934;- --sidebar: #1d2021;- --sidebar-foreground: #ebdbb2;+ --sidebar: #3c3836;+ --sidebar-foreground: #d5c4a1;--sidebar-primary: #83a598;- --sidebar-primary-foreground: #1d2021;- --sidebar-accent: oklch(from var(--primary) l c h / 0.14);+ --sidebar-primary-foreground: #282828;+ --sidebar-accent: #504945;--sidebar-accent-foreground: #83a598;- --sidebar-hover: #32302f;- --sidebar-border: #3c3836;+ --sidebar-hover: #504945;+ --sidebar-border: #504945;--sidebar-ring: #83a598;--syntax-keyword: #d3869b;--syntax-tag: #fb4934;@@ -213,6 +389,50 @@ html[data-color-theme="gruvbox"] {--syntax-string: #b8bb26;--syntax-number: #fe8019;--syntax-atom: #8ec07c;+ --syntax-comment: #665c54;+ --syntax-func: #83a598;+ --syntax-var: #fb4934;+ --syntax-type: #fabd2f;+ --syntax-operator: #d5c4a1;+ --syntax-meta: #d65d0e;+ --syntax-bg: #3c3836;+ --link-color: #83a598;+ --broken-link-color: #fb4934;+ --lint-warning-color: #fabd2f;+ --lint-error-color: #fb4934;+ --diff-added: #b8bb26;+ --diff-removed: #fb4934;+ --callout-note-color: #83a598;+ --callout-info-color: #83a598;+ --callout-todo-color: #83a598;+ --callout-abstract-color: #8ec07c;+ --callout-tip-color: #b8bb26;+ --callout-success-color: #b8bb26;+ --callout-important-color: #d3869b;+ --callout-example-color: #d3869b;+ --callout-question-color: #d3869b;+ --callout-warning-color: #fabd2f;+ --callout-caution-color: #fe8019;+ --callout-danger-color: #fe8019;+ --callout-failure-color: #fb4934;+ --callout-bug-color: #fb4934;+ --callout-quote-color: #665c54;+ --ansi-black: #282828;+ --ansi-red: #fb4934;+ --ansi-green: #b8bb26;+ --ansi-yellow: #fabd2f;+ --ansi-blue: #83a598;+ --ansi-magenta: #d3869b;+ --ansi-cyan: #8ec07c;+ --ansi-white: #d5c4a1;+ --ansi-bright-black: #665c54;+ --ansi-bright-red: #fb4934;+ --ansi-bright-green: #b8bb26;+ --ansi-bright-yellow: #fabd2f;+ --ansi-bright-blue: #83a598;+ --ansi-bright-magenta: #d3869b;+ --ansi-bright-cyan: #8ec07c;+ --ansi-bright-white: #fbf1c7;}html[data-color-theme="solarized"] {@@ -224,31 +444,31 @@ html[data-color-theme="solarized"] {--popover: #073642;--popover-foreground: #93a1a1;--primary: #268bd2;- --primary-foreground: #fdf6e3;+ --primary-foreground: #002b36;--secondary: #073642;--secondary-foreground: #93a1a1;--muted: #073642;- --muted-foreground: #6a7f86;- --accent: #073642;+ --muted-foreground: #839496;+ --accent: #586e75;--accent-foreground: #93a1a1;--destructive: #dc322f;- --border: #0e4a56;- --input: #0e4a56;+ --border: #586e75;+ --input: #586e75;--ring: #268bd2;- --selection-soft: oklch(from var(--primary) l c h / 0.3);+ --selection-soft: #586e75;--chart-1: #268bd2;--chart-2: #859900;--chart-3: #b58900;--chart-4: #6c71c4;--chart-5: #dc322f;- --sidebar: #00252e;+ --sidebar: #073642;--sidebar-foreground: #93a1a1;--sidebar-primary: #268bd2;- --sidebar-primary-foreground: #fdf6e3;- --sidebar-accent: oklch(from var(--primary) l c h / 0.14);+ --sidebar-primary-foreground: #002b36;+ --sidebar-accent: #586e75;--sidebar-accent-foreground: #268bd2;- --sidebar-hover: #073642;- --sidebar-border: #0e4a56;+ --sidebar-hover: #586e75;+ --sidebar-border: #586e75;--sidebar-ring: #268bd2;--syntax-keyword: #6c71c4;--syntax-tag: #dc322f;@@ -256,4 +476,48 @@ html[data-color-theme="solarized"] {--syntax-string: #859900;--syntax-number: #cb4b16;--syntax-atom: #2aa198;+ --syntax-comment: #657b83;+ --syntax-func: #268bd2;+ --syntax-var: #dc322f;+ --syntax-type: #b58900;+ --syntax-operator: #93a1a1;+ --syntax-meta: #d33682;+ --syntax-bg: #073642;+ --link-color: #268bd2;+ --broken-link-color: #dc322f;+ --lint-warning-color: #b58900;+ --lint-error-color: #dc322f;+ --diff-added: #859900;+ --diff-removed: #dc322f;+ --callout-note-color: #268bd2;+ --callout-info-color: #268bd2;+ --callout-todo-color: #268bd2;+ --callout-abstract-color: #2aa198;+ --callout-tip-color: #859900;+ --callout-success-color: #859900;+ --callout-important-color: #6c71c4;+ --callout-example-color: #6c71c4;+ --callout-question-color: #6c71c4;+ --callout-warning-color: #b58900;+ --callout-caution-color: #cb4b16;+ --callout-danger-color: #cb4b16;+ --callout-failure-color: #dc322f;+ --callout-bug-color: #dc322f;+ --callout-quote-color: #657b83;+ --ansi-black: #002b36;+ --ansi-red: #dc322f;+ --ansi-green: #859900;+ --ansi-yellow: #b58900;+ --ansi-blue: #268bd2;+ --ansi-magenta: #6c71c4;+ --ansi-cyan: #2aa198;+ --ansi-white: #93a1a1;+ --ansi-bright-black: #657b83;+ --ansi-bright-red: #dc322f;+ --ansi-bright-green: #859900;+ --ansi-bright-yellow: #b58900;+ --ansi-bright-blue: #268bd2;+ --ansi-bright-magenta: #6c71c4;+ --ansi-bright-cyan: #2aa198;+ --ansi-bright-white: #fdf6e3;}diff --git a/packages/app/src/components/DiffView.tsx b/packages/app/src/components/DiffView.tsxindex f3761cdd3..3e0cbec43 100644--- a/packages/app/src/components/DiffView.tsx+++ b/packages/app/src/components/DiffView.tsx@@ -5,26 +5,23 @@ import { EditorState } from '@codemirror/state';import { EditorView } from '@codemirror/view';import { plural } from '@lingui/core/macro';import { Trans, useLingui } from '@lingui/react/macro';-import { basicDarkInit, basicLightInit } from '@uiw/codemirror-theme-basic';import { basicSetup } from 'codemirror';import { useTheme } from 'next-themes';import { useEffect, useRef, useState } from 'react';import { createPortal } from 'react-dom';+import { okCmTheme } from '@/editor/extensions/cm-theme';import { useConflictFooterHeightVar } from '@/hooks/use-conflict-footer-height';import { Button } from './ui/button';-const darkTheme = basicDarkInit({- settings: {- background: 'var(--background)',- gutterBackground: 'var(--muted)',- },+const darkTheme = okCmTheme({+ dark: true,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});--const lightTheme = basicLightInit({- settings: {- background: 'var(--background)',- gutterBackground: 'var(--muted)',- },+const lightTheme = okCmTheme({+ dark: false,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});const conflictMergeControlTheme = EditorView.theme({diff --git a/packages/app/src/components/MermaidDocEditor.tsx b/packages/app/src/components/MermaidDocEditor.tsxindex 3c4e3f77e..dccaab7ac 100644--- a/packages/app/src/components/MermaidDocEditor.tsx+++ b/packages/app/src/components/MermaidDocEditor.tsx@@ -25,7 +25,6 @@ import { EditorState } from '@codemirror/state';import { EditorView } from '@codemirror/view';import type { HocuspocusProvider } from '@hocuspocus/provider';import { useLingui } from '@lingui/react/macro';-import { basicDarkInit, basicLightInit } from '@uiw/codemirror-theme-basic';import { basicSetup } from 'codemirror';import { mermaid } from 'codemirror-lang-mermaid';import { useTheme } from 'next-themes';@@ -34,13 +33,18 @@ import { yCollab } from 'y-codemirror.next';import * as Y from 'yjs';import { propEditorHighlight } from '@/editor/components/CodeMirrorPropInput';import { type MermaidSourceBinding, MermaidView } from '@/editor/components/Mermaid';+import { okCmTheme } from '@/editor/extensions/cm-theme';import { isOverlayLayerOpen } from '@/lib/overlay-layers';-const darkTheme = basicDarkInit({- settings: { background: 'var(--background)', gutterBackground: 'var(--muted)' },+const darkTheme = okCmTheme({+ dark: true,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});-const lightTheme = basicLightInit({- settings: { background: 'var(--background)', gutterBackground: 'var(--muted)' },+const lightTheme = okCmTheme({+ dark: false,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});/**diff --git a/packages/app/src/components/TextDocEditor.tsx b/packages/app/src/components/TextDocEditor.tsxindex ba799adbb..4cb482826 100644--- a/packages/app/src/components/TextDocEditor.tsx+++ b/packages/app/src/components/TextDocEditor.tsx@@ -31,20 +31,24 @@ import {extensionOf,} from '@inkeep/open-knowledge-core';import { useLingui } from '@lingui/react/macro';-import { basicDarkInit, basicLightInit } from '@uiw/codemirror-theme-basic';import { basicSetup } from 'codemirror';import { useTheme } from 'next-themes';import { useEffect, useRef, useState } from 'react';import { yCollab } from 'y-codemirror.next';import * as Y from 'yjs';import { propEditorHighlight } from '@/editor/components/CodeMirrorPropInput';+import { okCmTheme } from '@/editor/extensions/cm-theme';import { loadCodeMirrorLanguageForExtension } from './text-viewer-languages';-const darkTheme = basicDarkInit({- settings: { background: 'var(--background)', gutterBackground: 'var(--muted)' },+const darkTheme = okCmTheme({+ dark: true,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});-const lightTheme = basicLightInit({- settings: { background: 'var(--background)', gutterBackground: 'var(--muted)' },+const lightTheme = okCmTheme({+ dark: false,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});export function TextDocEditor({diff --git a/packages/app/src/components/TextViewer.tsx b/packages/app/src/components/TextViewer.tsxindex 138ab0673..6ae6e034f 100644--- a/packages/app/src/components/TextViewer.tsx+++ b/packages/app/src/components/TextViewer.tsx@@ -24,26 +24,23 @@import { EditorState } from '@codemirror/state';import { EditorView } from '@codemirror/view';import { codeLanguageForExtension } from '@inkeep/open-knowledge-core';-import { basicDarkInit, basicLightInit } from '@uiw/codemirror-theme-basic';import { basicSetup } from 'codemirror';import { useTheme } from 'next-themes';import { useEffect, useRef } from 'react';+import { okCmTheme } from '@/editor/extensions/cm-theme';import { loadCodeMirrorLanguageForExtension } from './text-viewer-languages';import { useViewerText, type ViewerTextSource } from './use-viewer-text';import { ViewerErrorPane, ViewerLoadingPane } from './ViewerStatusPane';-const darkTheme = basicDarkInit({- settings: {- background: 'var(--background)',- gutterBackground: 'var(--muted)',- },+const darkTheme = okCmTheme({+ dark: true,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});--const lightTheme = basicLightInit({- settings: {- background: 'var(--background)',- gutterBackground: 'var(--muted)',- },+const lightTheme = okCmTheme({+ dark: false,+ background: 'var(--background)',+ gutterBackground: 'var(--muted)',});/**diff --git a/packages/app/src/components/file-tree-problem-indicators.ts b/packages/app/src/components/file-tree-problem-indicators.tsindex fa387fcbe..cb67c7880 100644--- a/packages/app/src/components/file-tree-problem-indicators.ts+++ b/packages/app/src/components/file-tree-problem-indicators.ts@@ -9,13 +9,12 @@* `.mdx` row) because the tree's single decoration lane is already taken by* the symlink / agent icons.*- * Color plumbing: the editor's `--lint-error-color` / `--lint-warning-color`- * tokens are NOT `:root`-defined (they live under `.dark .cm-editor` etc.), so- * they never reach this shadow root. The tree uses its own inheritable- * `--ok-tree-problem-*` tokens: light mode rides the `var()` fallback- * literals below (the editor's own light-mode fallbacks), dark mode overrides- * at `.dark` scope in `globals.css` — custom properties inherit through- * shadow boundaries, so the override reaches these rules.+ * Color plumbing: these rules name the tree-owned `--ok-tree-problem-*` pair,+ * which `globals.css` aliases at `:root` to the editor's theme-derived+ * `--lint-error-color` / `--lint-warning-color`. Custom properties inherit+ * through shadow boundaries, so that alias is what reaches this shadow root,+ * and both light and dark follow whichever theme resolved the lint tokens.+ * The `var()` fallback literals below only apply if the alias is missing.*/import { filePathToDocName } from '@/lib/doc-hash';diff --git a/packages/app/src/components/settings/ColorThemePicker.tsx b/packages/app/src/components/settings/ColorThemePicker.tsxindex b437e5c05..7f89f2d03 100644--- a/packages/app/src/components/settings/ColorThemePicker.tsx+++ b/packages/app/src/components/settings/ColorThemePicker.tsx@@ -1,18 +1,16 @@import { useLingui } from '@lingui/react/macro';import { RadioGroup as RadioGroupPrimitive } from 'radix-ui';import {+ base16ToTokens,COLOR_THEMES,type ColorTheme,- type CustomThemeSeed,customThemeKind,defaultThemeTokens,- expandCustomSeed,- expandPalette,- resolveCustomSeed,+ resolveCustomScheme,} from '@/lib/color-themes';import { cn } from '@/lib/utils';-type SeedInput = Partial<Record<keyof CustomThemeSeed, unknown>> | undefined;+type SeedInput = Record<string, unknown> | undefined;interface ColorThemePickerProps {/** Currently-selected theme id (the `appearance.colorTheme` value; `''`/unknown → default). */@@ -59,15 +57,15 @@ function swatchColors(defaultMode: 'light' | 'dark',): SwatchColors {if (theme.id === 'custom') {- return swatchFromTokens(expandPalette(expandCustomSeed(resolveCustomSeed(customSeed))));+ return swatchFromTokens(base16ToTokens(resolveCustomScheme(customSeed)));}- if (!theme.base) {+ if (!theme.scheme) {// `default` has no authored palette — it IS the base stylesheet. Reading the// cascaded `var(--…)` here would inherit whichever palette is currently// applied to `<html>`, so paint the base tokens as literals instead.return swatchFromTokens(defaultThemeTokens(defaultMode));}- return swatchFromTokens(expandPalette(theme.base));+ return swatchFromTokens(base16ToTokens(theme.scheme));}/** A miniature editor-window preview, à la the Vivaldi theme tiles. */@@ -168,7 +166,7 @@ export function ColorThemePicker({<span className="text-1sm font-medium text-foreground">{theme.label}</span><span className="text-[10px] font-medium uppercase tracking-wide text-muted-foreground">{theme.id === 'custom'- ? customThemeKind(resolveCustomSeed(customSeed)) === 'dark'+ ? customThemeKind(resolveCustomScheme(customSeed)) === 'dark'? t`Dark`: t`Light`: theme.kind === 'system'diff --git a/packages/app/src/components/settings/CustomThemeEditor.dom.test.tsx b/packages/app/src/components/settings/CustomThemeEditor.dom.test.tsxindex b58121418..aed90c900 100644--- a/packages/app/src/components/settings/CustomThemeEditor.dom.test.tsx+++ b/packages/app/src/components/settings/CustomThemeEditor.dom.test.tsx@@ -1,7 +1,8 @@+import { BASE16_SLOT_ROLES, BASE16_SLOTS, parseBase16Scheme } from '@inkeep/open-knowledge-core';import { cleanup, fireEvent, render } from '@testing-library/react';import type { ReactNode } from 'react';import { afterEach, describe, expect, test, vi } from 'vitest';-import { DEFAULT_CUSTOM_SEED } from '@/lib/color-themes';+import { DEFAULT_CUSTOM_SCHEME } from '@/lib/color-themes';import { renderLinguiTemplate } from '@/test-utils/lingui-mock';let mergedConfig: { appearance?: { colorTheme?: string; customTheme?: Record<string, string> } } =@@ -22,11 +23,60 @@ vi.doMock('@/lib/use-apply-config-color-theme', () => ({const userBinding = { patch: (p: unknown) => patchCalls.push(p) } as never;+/** The six pre-base16 seed keys, nulled by every full-scheme write to delete them. */+const RETIRED_LEGACY_KEYS = {+ background: null,+ surface: null,+ foreground: null,+ primary: null,+ accent: null,+ border: null,+};++/** The full scheme flattened into the config shape `reset` / `import` write. */+const DEFAULT_SCHEME_PATCH = {+ name: DEFAULT_CUSTOM_SCHEME.name,+ // The default scheme carries no credit, and the write nulls it so importing a+ // credited scheme and then resetting doesn't strand the old author.+ author: null,+ variant: DEFAULT_CUSTOM_SCHEME.variant,+ ...DEFAULT_CUSTOM_SCHEME.palette,+ ...RETIRED_LEGACY_KEYS,+};++/** A complete scheme in the current upstream layout, for the import path. */+const PASTED_SCHEME = `system: "base16"+name: "Ayu Dark"+author: "A. Scheme Author"+variant: "dark"+palette:+ base00: "#0f1419"+ base01: "#131721"+ base02: "#272d38"+ base03: "#3e4b59"+ base04: "#bfbdb6"+ base05: "#e6e1cf"+ base06: "#e6e1cf"+ base07: "#f3f4f5"+ base08: "#f07178"+ base09: "#ff8f40"+ base0A: "#ffb454"+ base0B: "#b8cc52"+ base0C: "#95e6cb"+ base0D: "#59c2ff"+ base0E: "#d2a6ff"+ base0F: "#e6b673"+`;+async function renderEditor() {const { CustomThemeEditor } = await import('./CustomThemeEditor');return render(<CustomThemeEditor userBinding={userBinding} />);}+function hexInputs(container: HTMLElement): HTMLInputElement[] {+ return [...container.querySelectorAll<HTMLInputElement>('input:not([type="color"])')];+}+describe('CustomThemeEditor', () => {afterEach(() => {cleanup();@@ -34,11 +84,11 @@ describe('CustomThemeEditor', () => {mergedConfig = {};});- test('renders a color + hex input for each of the six seed fields', async () => {+ test('renders a color + hex input for each of the sixteen base16 slots', async () => {const { container } = await renderEditor();- expect(container.querySelectorAll('input[type="color"]').length).toBe(6);- // 6 color + 6 hex text inputs.- expect(container.querySelectorAll('input').length).toBe(12);+ expect(container.querySelectorAll('input[type="color"]').length).toBe(16);+ // 16 color + 16 hex text inputs.+ expect(hexInputs(container).length).toBe(16);});test('the section is a landmark labelled by its heading, like sibling subsections', async () => {@@ -49,18 +99,18 @@ describe('CustomThemeEditor', () => {expect(heading?.textContent).toBe('Custom theme');});- test('committing a valid hex patches that field on the user binding', async () => {+ test('committing a valid hex patches that slot on the user binding', async () => {mergedConfig = { appearance: { colorTheme: 'custom' } };const { container } = await renderEditor();- const hex = container.querySelectorAll('input:not([type="color"])')[0] as HTMLInputElement;+ const hex = hexInputs(container)[0] as HTMLInputElement;fireEvent.change(hex, { target: { value: '#123456' } });fireEvent.blur(hex, { target: { value: '#123456' } });- expect(patchCalls).toContainEqual({ appearance: { customTheme: { background: '#123456' } } });+ expect(patchCalls).toContainEqual({ appearance: { customTheme: { base00: '#123456' } } });});test('an invalid hex does not patch', async () => {const { container } = await renderEditor();- const hex = container.querySelectorAll('input:not([type="color"])')[0] as HTMLInputElement;+ const hex = hexInputs(container)[0] as HTMLInputElement;fireEvent.change(hex, { target: { value: 'nope' } });fireEvent.blur(hex, { target: { value: 'nope' } });expect(patchCalls.length).toBe(0);@@ -68,23 +118,223 @@ describe('CustomThemeEditor', () => {test('an invalid hex shows an inline error, marks the field invalid, and keeps the value', async () => {const { container, queryByTestId } = await renderEditor();- const hex = container.querySelectorAll('input:not([type="color"])')[0] as HTMLInputElement;+ const hex = hexInputs(container)[0] as HTMLInputElement;// Pristine value is a valid hex — no error, not marked invalid.- expect(queryByTestId('custom-theme-hex-error-background')).toBeNull();+ expect(queryByTestId('custom-theme-hex-error-base00')).toBeNull();expect(hex.getAttribute('aria-invalid')).toBe('false');fireEvent.change(hex, { target: { value: '#12' } });- expect(queryByTestId('custom-theme-hex-error-background')).not.toBeNull();+ expect(queryByTestId('custom-theme-hex-error-base00')).not.toBeNull();expect(hex.getAttribute('aria-invalid')).toBe('true');// The invalid value stays visible (no silent revert) so the user can fix it.expect(hex.value).toBe('#12');});- test('reset writes the full default seed', async () => {+ test('an invalid slot associates its error with the input via aria-describedby', async () => {+ // A screen-reader user returning to an invalid hex field must hear the error+ // as the field's description, not just once when it first appears. The+ // describedby target must exist and carry the message (mirrors the+ // paste-import field's own wiring).+ const { container, getByTestId } = await renderEditor();+ const hex = hexInputs(container)[0] as HTMLInputElement;+ // Valid pristine value: no association.+ expect(hex.getAttribute('aria-describedby')).toBeNull();++ fireEvent.change(hex, { target: { value: '#12' } });+ const errorId = hex.getAttribute('aria-describedby');+ expect(errorId).toBe('custom-theme-hex-error-base00');+ // The referenced node exists and carries the error text.+ expect(getByTestId('custom-theme-hex-error-base00').id).toBe(errorId);+ });++ test('reset writes the full default scheme', async () => {const { getByText } = await renderEditor();fireEvent.click(getByText('Reset'));expect(patchCalls).toContainEqual({- appearance: { customTheme: { ...DEFAULT_CUSTOM_SEED } },+ appearance: { customTheme: DEFAULT_SCHEME_PATCH },+ });+ });++ test('importing a pasted scheme writes all sixteen slots and the metadata', async () => {+ // `author` included: a scheme's credit line has to survive the write, or it+ // is gone by the next reload and "Copy as YAML" hands back an uncredited+ // copy of someone else's scheme.+ const { getByTestId, getByText } = await renderEditor();+ fireEvent.change(getByTestId('custom-theme-import'), { target: { value: PASTED_SCHEME } });+ fireEvent.click(getByText('Import scheme'));+ expect(patchCalls).toContainEqual({+ appearance: {+ customTheme: {+ name: 'Ayu Dark',+ author: 'A. Scheme Author',+ variant: 'dark',+ base00: '#0f1419',+ base01: '#131721',+ base02: '#272d38',+ base03: '#3e4b59',+ base04: '#bfbdb6',+ base05: '#e6e1cf',+ base06: '#e6e1cf',+ base07: '#f3f4f5',+ base08: '#f07178',+ base09: '#ff8f40',+ base0A: '#ffb454',+ base0B: '#b8cc52',+ base0C: '#95e6cb',+ base0D: '#59c2ff',+ base0E: '#d2a6ff',+ base0F: '#e6b673',+ ...RETIRED_LEGACY_KEYS,+ },+ },+ });+ });++ test('an imported scheme repopulates the slot inputs', async () => {+ const { container, getByTestId, getByText } = await renderEditor();+ fireEvent.change(getByTestId('custom-theme-import'), { target: { value: PASTED_SCHEME } });+ fireEvent.click(getByText('Import scheme'));+ const values = hexInputs(container).map((input) => input.value);+ expect(values[0]).toBe('#0f1419');+ expect(values[BASE16_SLOTS.indexOf('base0D')]).toBe('#59c2ff');+ });++ test('an unparseable paste surfaces an inline error and writes nothing', async () => {+ const { getByTestId, getByText, queryByTestId } = await renderEditor();+ fireEvent.change(getByTestId('custom-theme-import'), { target: { value: 'not a scheme' } });+ fireEvent.click(getByText('Import scheme'));+ expect(queryByTestId('custom-theme-import-error')).not.toBeNull();+ expect(patchCalls.length).toBe(0);+ });++ test('editing a slot on a pre-base16 config migrates it and retires the old keys', async () => {+ // The upgrade path: a user with an existing custom theme changes one color.+ // The write must carry their whole (upgraded) palette and delete the six+ // legacy keys, not leave a half-format config behind.+ mergedConfig = {+ appearance: {+ colorTheme: 'custom',+ customTheme: {+ background: '#101010',+ surface: '#202020',+ foreground: '#fafafa',+ primary: '#3366ff',+ accent: '#33ddcc',+ border: '#303030',+ },+ },+ };+ const { container } = await renderEditor();+ const hex = hexInputs(container)[0] as HTMLInputElement;+ fireEvent.change(hex, { target: { value: '#123456' } });+ fireEvent.blur(hex, { target: { value: '#123456' } });++ expect(patchCalls.length).toBe(1);+ const written = (patchCalls[0] as { appearance: { customTheme: Record<string, unknown> } })+ .appearance.customTheme;+ // The edited slot, and the rest of their palette carried through.+ expect(written.base00).toBe('#123456');+ expect(written.base01).toBe('#202020');+ expect(written.base05).toBe('#fafafa');+ expect(written.base0D).toBe('#3366ff');+ // Legacy keys nulled — a null in a config patch deletes the key.+ for (const key of ['background', 'surface', 'foreground', 'primary', 'accent', 'border']) {+ expect(written[key], key).toBeNull();+ }+ });++ test('editing a slot on an already-base16 config patches only that slot', async () => {+ // No migration to do, so the write stays minimal rather than rewriting all+ // sixteen slots on every keystroke-commit.+ mergedConfig = {+ appearance: { colorTheme: 'custom', customTheme: { base00: '#101010' } },+ };+ const { container } = await renderEditor();+ const hex = hexInputs(container)[0] as HTMLInputElement;+ fireEvent.change(hex, { target: { value: '#123456' } });+ fireEvent.blur(hex, { target: { value: '#123456' } });+ expect(patchCalls).toContainEqual({ appearance: { customTheme: { base00: '#123456' } } });+ });++ test('every slot shows its role, not just the opaque slot id', async () => {+ // `base09` teaches nothing on its own; the role is what makes the control+ // legible without cross-referencing the spec.+ const { container } = await renderEditor();+ const text = container.textContent ?? '';+ expect(text).toContain('base09');+ expect(text).toContain(BASE16_SLOT_ROLES.base09);+ expect(text).toContain(BASE16_SLOT_ROLES.base0D);+ });++ test('the preview renders and marks the surfaces a hovered slot drives', async () => {+ const { container, getByLabelText } = await renderEditor();+ const preview = getByLabelText('Theme preview');+ expect(preview).toBeTruthy();+ // Nothing is lit until a slot is pointed at.+ expect(container.querySelectorAll('[data-lit="true"]').length).toBe(0);++ const stringSwatch = container.querySelector<HTMLInputElement>('input[aria-label^="base0B "]');+ expect(stringSwatch).not.toBeNull();+ fireEvent.mouseEnter(stringSwatch as HTMLInputElement);+ // base0B is the strings slot — the code sample's string literal lights up.+ expect(+ container.querySelectorAll('[data-lit="true"][data-slot="base0B"]').length,+ ).toBeGreaterThan(0);++ fireEvent.mouseLeave(stringSwatch as HTMLInputElement);+ expect(container.querySelectorAll('[data-lit="true"]').length).toBe(0);+ });++ test('keyboard focus lights the same surfaces as hover', async () => {+ // The spotlight must not be pointer-only — the slot list is a tab sequence.+ const { container } = await renderEditor();+ const hex = container.querySelector<HTMLInputElement>('input[aria-label="base0E hex value"]');+ expect(hex).not.toBeNull();+ fireEvent.focus(hex as HTMLInputElement);+ expect(+ container.querySelectorAll('[data-lit="true"][data-slot="base0E"]').length,+ ).toBeGreaterThan(0);+ fireEvent.blur(hex as HTMLInputElement);+ expect(container.querySelectorAll('[data-lit="true"]').length).toBe(0);+ });++ test('copy-as-YAML writes a scheme that parses back', async () => {+ const written: string[] = [];+ Object.defineProperty(navigator, 'clipboard', {+ configurable: true,+ value: {+ writeText: (text: string) => {+ written.push(text);+ return Promise.resolve();+ },+ },});+ const { getByText } = await renderEditor();+ fireEvent.click(getByText('Copy as YAML'));+ await Promise.resolve();+ expect(written.length).toBe(1);+ const parsed = parseBase16Scheme(written[0] as string);+ expect(parsed.ok).toBe(true);+ if (!parsed.ok) return;+ expect(parsed.scheme.palette).toEqual(DEFAULT_CUSTOM_SCHEME.palette);+ });++ test('links out to the upstream scheme collection', async () => {+ const { container } = await renderEditor();+ const link = container.querySelector<HTMLAnchorElement>(+ 'a[href="https://github.com/tinted-theming/schemes"]',+ );+ expect(link).not.toBeNull();+ expect(link?.rel).toContain('noopener');+ });++ test('the import error clears once the user edits the paste again', async () => {+ const { getByTestId, getByText, queryByTestId } = await renderEditor();+ const textarea = getByTestId('custom-theme-import');+ fireEvent.change(textarea, { target: { value: 'not a scheme' } });+ fireEvent.click(getByText('Import scheme'));+ expect(queryByTestId('custom-theme-import-error')).not.toBeNull();+ fireEvent.change(textarea, { target: { value: 'base00: "#111111"' } });+ expect(queryByTestId('custom-theme-import-error')).toBeNull();});});diff --git a/packages/app/src/components/settings/CustomThemeEditor.tsx b/packages/app/src/components/settings/CustomThemeEditor.tsxindex 3fd70c332..bdac86daa 100644--- a/packages/app/src/components/settings/CustomThemeEditor.tsx+++ b/packages/app/src/components/settings/CustomThemeEditor.tsx@@ -1,123 +1,148 @@-import type { ConfigBinding } from '@inkeep/open-knowledge-core';+import {+ BASE16_SLOT_ROLES,+ BASE16_SLOTS,+ type Base16ParseError,+ type Base16Scheme,+ type Base16Slot,+ base16ToYaml,+ type ConfigBinding,+ parseBase16Scheme,+} from '@inkeep/open-knowledge-core';import { useLingui } from '@lingui/react/macro';+import { ArrowUpRight } from 'lucide-react';import { useTheme } from 'next-themes';import { useEffect, useState } from 'react';+import { toast } from 'sonner';import { Button } from '@/components/ui/button';import { FieldError } from '@/components/ui/field';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';+import { Textarea } from '@/components/ui/textarea';import {- type CustomThemeSeed,customThemeKind,- DEFAULT_CUSTOM_SEED,- expandCustomSeed,- expandPalette,+ customThemeWritePatch,+ DEFAULT_CUSTOM_SCHEME,+ hasLegacyCustomSeed,isHexColor,- resolveCustomSeed,+ resolveCustomScheme,} from '@/lib/color-themes';import { useConfigContextOptional } from '@/lib/config-context';+import { dispatchExternalLinkClick } from '@/lib/external-link';import { applyColorThemeToDom } from '@/lib/use-apply-config-color-theme';+import { ThemePreviewCanvas } from './ThemePreviewCanvas';-const FIELD_ORDER: (keyof CustomThemeSeed)[] = [- 'background',- 'surface',- 'foreground',- 'primary',- 'accent',- 'border',-];--/** A compact mini-window preview painted from the live seed. */-function SeedPreview({ seed }: { seed: CustomThemeSeed }) {- const t = expandPalette(expandCustomSeed(seed));- return (- <div- aria-hidden- className="h-20 w-32 shrink-0 overflow-hidden rounded-md border"- style={{ backgroundColor: t.background, borderColor: t.border }}- >- <div- className="flex h-1/3 items-center gap-1 px-1.5"- style={{ backgroundColor: t.sidebar, borderBottom: `1px solid ${t.border}` }}- >- <span className="h-1.5 w-6 rounded-full" style={{ backgroundColor: t.primary }} />- </div>- <div className="flex flex-col gap-1 p-1.5">- <span- className="h-1.5 w-4/5 rounded-full"- style={{ backgroundColor: t['syntax-keyword'] }}- />- <span- className="h-1.5 w-3/5 rounded-full opacity-70"- style={{ backgroundColor: t.foreground }}- />- <span- className="h-1.5 w-2/3 rounded-full"- style={{ backgroundColor: t['syntax-string'] }}- />- </div>- </div>- );-}+/** The tonal ramp and the accents are edited as separate groups — they're read differently. */+const RAMP_SLOTS = BASE16_SLOTS.slice(0, 8) as readonly Base16Slot[];+const ACCENT_SLOTS = BASE16_SLOTS.slice(8) as readonly Base16Slot[];++const SCHEMES_URL = 'https://github.com/tinted-theming/schemes';/**- * Editor for the six `appearance.customTheme` seed colors (the `custom` color- * theme). Reads the live seed from merged config, writes per-field through the- * user `ConfigBinding`, and — when `custom` is the active theme — applies edits- * to the DOM optimistically so the whole app previews as you type. Light/dark- * mode is auto-detected from the background's luminance.+ * Editor for the `custom` color theme's base16 scheme.+ *+ * Two ways in: paste a scheme from the base16 ecosystem (the fast path — any of+ * the several hundred published schemes works unmodified), or adjust the+ * sixteen slots by hand. Reads the live scheme from merged config, writes+ * through the user `ConfigBinding`, and — when `custom` is the active theme —+ * applies edits to the DOM optimistically so the whole app previews as you+ * type. Light/dark mode comes from the scheme's own variant.+ *+ * Slot names are opaque on their own, so every slot carries its role in the+ * label and lights up the surfaces it drives in the preview on hover/focus.*/export function CustomThemeEditor({ userBinding }: { userBinding: ConfigBinding }) {const { t } = useLingui();const { setTheme } = useTheme();const merged = useConfigContextOptional()?.merged ?? null;- const committed = resolveCustomSeed(merged?.appearance?.customTheme);+ const committed = resolveCustomScheme(merged?.appearance?.customTheme);const isActive = merged?.appearance?.colorTheme === 'custom';// Local working copy for smooth live editing; re-sync when committed config// changes underneath us (another window, a reset, a hand-edit).- const [seed, setSeed] = useState<CustomThemeSeed>(committed);+ const [scheme, setScheme] = useState<Base16Scheme>(committed);const committedKey = JSON.stringify(committed);// biome-ignore lint/correctness/useExhaustiveDependencies: committedKey is the value-stable proxy for `committed`.useEffect(() => {- setSeed(committed);+ setScheme(committed);}, [committedKey]);- const labels: Record<keyof CustomThemeSeed, string> = {- background: t`Background`,- surface: t`Surface`,- foreground: t`Text`,- primary: t`Primary`,- accent: t`Accent`,- border: t`Border`,- };+ const [paste, setPaste] = useState('');+ const [pasteError, setPasteError] = useState<string | null>(null);+ // Which slot the pointer/keyboard is on, so the preview can ring its surfaces.+ const [hoveredSlot, setHoveredSlot] = useState<Base16Slot | null>(null);+ // A config written before base16 still carries the six seed colors. It reads+ // correctly (they upgrade into slots), but the next write should normalize it.+ const needsLegacyMigration = hasLegacyCustomSeed(merged?.appearance?.customTheme);- function preview(next: CustomThemeSeed) {+ function preview(next: Base16Scheme) {if (!isActive) return;- applyColorThemeToDom('custom', next);+ applyColorThemeToDom('custom', customThemeWritePatch(next));setTheme(customThemeKind(next) === 'dark' ? 'dark' : 'light');}- function onPick(key: keyof CustomThemeSeed, value: string) {- const next = { ...seed, [key]: value };- setSeed(next);+ function onPick(slot: Base16Slot, value: string) {+ const next = { ...scheme, palette: { ...scheme.palette, [slot]: value } };+ setScheme(next);// Only push valid hex to the live DOM preview — an invalid partial the user// is mid-typing shouldn't repaint the app with a broken color.if (isHexColor(value)) preview(next);}- function commit(key: keyof CustomThemeSeed, value: string) {+ function commit(slot: Base16Slot, value: string) {// Invalid input stays visible (with its inline error) so the user can// correct it — no silent revert, and nothing is written to config until the// value is a valid 6-digit hex.if (!isHexColor(value)) return;- userBinding.patch({ appearance: { customTheme: { [key]: value } } });+ if (needsLegacyMigration) {+ // First edit against a pre-base16 config: write the resolved scheme in+ // full and retire the old keys, rather than leaving a half-format behind.+ const next = { ...scheme, palette: { ...scheme.palette, [slot]: value } };+ userBinding.patch({ appearance: { customTheme: customThemeWritePatch(next) } });+ return;+ }+ userBinding.patch({ appearance: { customTheme: { [slot]: value } } });+ }++ function importPasted() {+ const result = parseBase16Scheme(paste);+ if (!result.ok) {+ setPasteError(describeParseError(result.error, t));+ return;+ }+ setPasteError(null);+ setPaste('');+ setScheme(result.scheme);+ preview(result.scheme);+ userBinding.patch({ appearance: { customTheme: customThemeWritePatch(result.scheme) } });+ }++ async function exportYaml() {+ const yaml = base16ToYaml(scheme);+ const write = navigator.clipboard?.writeText?.bind(navigator.clipboard);+ if (write) {+ try {+ await write(yaml);+ toast.success(t`Scheme copied as base16 YAML`);+ return;+ } catch {+ // Denied or unavailable — fall through to the in-page path below.+ }+ }+ // Clipboard can be denied (permission, insecure context). Drop the YAML+ // into the paste box rather than failing silently — it stays selectable and+ // copyable by hand, and re-importing it is a no-op.+ setPaste(yaml);+ setPasteError(null);+ toast.error(t`Couldn’t reach the clipboard — the scheme is in the box below.`);}function reset() {- setSeed(DEFAULT_CUSTOM_SEED);- preview(DEFAULT_CUSTOM_SEED);- userBinding.patch({ appearance: { customTheme: { ...DEFAULT_CUSTOM_SEED } } });+ setScheme(DEFAULT_CUSTOM_SCHEME);+ setPasteError(null);+ preview(DEFAULT_CUSTOM_SCHEME);+ userBinding.patch({+ appearance: { customTheme: customThemeWritePatch(DEFAULT_CUSTOM_SCHEME) },+ });}return (@@ -126,64 +151,210 @@ export function CustomThemeEditor({ userBinding }: { userBinding: ConfigBindingclassName="space-y-3"data-section="custom-theme">- <div className="flex items-center justify-between gap-2">+ <div className="flex items-start justify-between gap-2"><div><h3 id="settings-custom-theme-title" className="font-medium text-sm">{t`Custom theme`}</h3><p className="text-1sm text-muted-foreground">{isActive- ? t`Edits apply live. Light or dark is chosen from the background.`- : t`Pick “Custom” above to use this palette.`}+ ? t`Edits apply live. Light or dark comes from the scheme.`+ : t`Pick “Custom” above to use this scheme.`}</p></div>- <Button variant="ghost" size="sm" onClick={reset} className="text-muted-foreground">- {t`Reset`}- </Button>+ <div className="flex shrink-0 items-center gap-1">+ <Button variant="outline" size="sm" onClick={exportYaml}>+ {t`Copy as YAML`}+ </Button>+ <Button variant="ghost" size="sm" onClick={reset} className="text-muted-foreground">+ {t`Reset`}+ </Button>+ </div>+ </div>++ {/* Preview first: it is the thing that makes the slots below legible. */}+ <ThemePreviewCanvas scheme={scheme} highlightSlot={hoveredSlot} className="w-full" />++ <div className="space-y-3">+ <SlotGroup+ label={t`Background to foreground`}+ slots={RAMP_SLOTS}+ scheme={scheme}+ onPick={onPick}+ commit={commit}+ onSlotFocus={setHoveredSlot}+ hexLabel={(slot) => t`${slot} hex value`}+ invalidHint={t`Enter a 6-digit hex like #1A2B3C`}+ />+ <SlotGroup+ label={t`Accents`}+ slots={ACCENT_SLOTS}+ scheme={scheme}+ onPick={onPick}+ commit={commit}+ onSlotFocus={setHoveredSlot}+ hexLabel={(slot) => t`${slot} hex value`}+ invalidHint={t`Enter a 6-digit hex like #1A2B3C`}+ />+ </div>++ <div className="space-y-1.5 border-t pt-3">+ <Label htmlFor="custom-theme-import" className="text-1sm text-muted-foreground">+ {t`Paste a base16 scheme`}+ </Label>+ <Textarea+ id="custom-theme-import"+ value={paste}+ spellCheck={false}+ rows={3}+ placeholder={+ 'system: "base16"\nname: "Ayu Dark"\nvariant: "dark"\npalette:\n base00: "#0f1419"\n base01: "#131721"'+ }+ aria-invalid={pasteError !== null}+ aria-describedby={pasteError ? 'custom-theme-import-error' : undefined}+ onChange={(e) => {+ setPaste(e.target.value);+ if (pasteError) setPasteError(null);+ }}+ className="font-mono text-1sm"+ data-testid="custom-theme-import"+ />+ {pasteError ? (+ <FieldError id="custom-theme-import-error" data-testid="custom-theme-import-error">+ {pasteError}+ </FieldError>+ ) : null}+ <div className="flex flex-wrap items-center gap-x-2 gap-y-1">+ <Button variant="outline" size="sm" disabled={!paste.trim()} onClick={importPasted}>+ {t`Import scheme`}+ </Button>+ <span className="text-xs text-muted-foreground">+ {t`YAML or JSON, in either base16 layout.`}{' '}+ <a+ href={SCHEMES_URL}+ target="_blank"+ rel="noopener noreferrer"+ onClick={(e) => dispatchExternalLinkClick(e, SCHEMES_URL)}+ onAuxClick={(e) => dispatchExternalLinkClick(e, SCHEMES_URL)}+ className="inline-flex items-center gap-0.5 underline-offset-2 hover:text-foreground hover:underline"+ >+ {t`Browse hundreds of schemes`}+ <ArrowUpRight aria-hidden className="size-3" />+ </a>+ </span>+ </div></div>+ </section>+ );+}- <div className="flex items-start gap-4">- <SeedPreview seed={seed} />- <div className="grid flex-1 grid-cols-1 gap-2 sm:grid-cols-2">- {FIELD_ORDER.map((key) => (- <div key={key} className="flex items-center gap-2">+function SlotGroup({+ label,+ slots,+ scheme,+ onPick,+ commit,+ hexLabel,+ invalidHint,+ onSlotFocus,+}: {+ label: string;+ slots: readonly Base16Slot[];+ scheme: Base16Scheme;+ onPick: (slot: Base16Slot, value: string) => void;+ commit: (slot: Base16Slot, value: string) => void;+ hexLabel: (slot: Base16Slot) => string;+ invalidHint: string;+ onSlotFocus: (slot: Base16Slot | null) => void;+}) {+ return (+ <div className="space-y-1.5">+ <span className="text-xs font-medium uppercase tracking-wide text-muted-foreground">+ {label}+ </span>+ <div className="grid grid-cols-1 gap-x-3 gap-y-2 sm:grid-cols-2">+ {slots.map((slot) => {+ const value = scheme.palette[slot];+ const valid = isHexColor(value);+ // Hover and focus both drive the preview highlight: pointer users+ // sweep the list, keyboard users tab through it. The handlers live on+ // the inputs rather than the row wrapper — a static container with+ // pointer handlers is unreachable by keyboard and fails a11y lint.+ const spotlight = {+ onMouseEnter: () => onSlotFocus(slot),+ onMouseLeave: () => onSlotFocus(null),+ onFocus: () => onSlotFocus(slot),+ };+ return (+ <div key={slot} className="flex items-center gap-1.5 rounded px-1 py-0.5"><Inputtype="color"- aria-label={labels[key]}- value={seed[key]}- onChange={(e) => onPick(key, e.target.value)}- onBlur={(e) => commit(key, e.target.value)}- className="h-8 w-9 shrink-0 cursor-pointer rounded-md p-1"+ aria-label={`${slot} — ${BASE16_SLOT_ROLES[slot]}`}+ value={valid ? value : '#000000'}+ onChange={(e) => onPick(slot, e.target.value)}+ onBlur={(e) => {+ onSlotFocus(null);+ commit(slot, e.target.value);+ }}+ {...spotlight}+ className="h-7 w-8 shrink-0 cursor-pointer rounded-md p-1"/><div className="relative min-w-0 flex-1">- <Label className="text-1sm text-muted-foreground">{labels[key]}</Label>+ {/* The role, not just the slot id — "base09" alone teaches nothing. */}+ <Label className="block truncate text-[10px] leading-tight text-muted-foreground">+ <span className="font-mono">{slot}</span>{' '}+ <span className="opacity-80">{BASE16_SLOT_ROLES[slot]}</span>+ </Label><Input- value={seed[key]}+ value={value}spellCheck={false}- aria-label={t`${labels[key]} hex value`}- aria-invalid={!isHexColor(seed[key])}- onChange={(e) => onPick(key, e.target.value)}- onBlur={(e) => commit(key, e.target.value)}+ aria-label={hexLabel(slot)}+ aria-invalid={!valid}+ aria-describedby={!valid ? `custom-theme-hex-error-${slot}` : undefined}+ onChange={(e) => onPick(slot, e.target.value)}+ onBlur={(e) => {+ onSlotFocus(null);+ commit(slot, e.target.value);+ }}onKeyDown={(e) => {- if (e.key === 'Enter') commit(key, (e.target as HTMLInputElement).value);+ if (e.key === 'Enter') commit(slot, (e.target as HTMLInputElement).value);}}- className="h-7 font-mono text-1sm uppercase"+ {...spotlight}+ className="h-6 font-mono text-[11px] uppercase"/>- {!isHexColor(seed[key]) ? (+ {!valid ? (// Absolutely positioned so an invalid value doesn't reflow the- // other color fields in the grid — every swatch stays put.+ // other swatches in the grid — every tile stays put.<FieldError+ id={`custom-theme-hex-error-${slot}`}className="absolute top-full left-0 mt-0.5 text-xs leading-tight"- data-testid={`custom-theme-hex-error-${key}`}+ data-testid={`custom-theme-hex-error-${slot}`}>- {t`Enter a 6-digit hex like #1A2B3C`}+ {invalidHint}</FieldError>) : null}</div></div>- ))}- </div>+ );+ })}</div>- </section>+ </div>);}++type Translate = ReturnType<typeof useLingui>['t'];++function describeParseError(error: Base16ParseError, t: Translate): string {+ switch (error.kind) {+ case 'unparseable':+ return error.line === undefined+ ? t`That doesn’t parse as YAML or JSON.`+ : t`That doesn’t parse as YAML or JSON — check line ${error.line}.`;+ case 'not-a-scheme':+ return t`That parsed, but it isn’t a base16 scheme.`;+ case 'missing-slots':+ return t`Missing ${error.slots.length} slot(s): ${error.slots.join(', ')}`;+ case 'bad-hex':+ return t`Not a hex color: ${error.slots.join(', ')}`;+ }+}diff --git a/packages/app/src/components/settings/ThemePreviewCanvas.dom.test.tsx b/packages/app/src/components/settings/ThemePreviewCanvas.dom.test.tsxnew file mode 100644index 000000000..f90acce61--- /dev/null+++ b/packages/app/src/components/settings/ThemePreviewCanvas.dom.test.tsx@@ -0,0 +1,54 @@+import { BASE16_SLOTS, type Base16Scheme, type Base16Slot } from '@inkeep/open-knowledge-core';+import { cleanup, render } from '@testing-library/react';+import type { ReactNode } from 'react';+import { afterEach, describe, expect, test, vi } from 'vitest';+import { renderLinguiTemplate } from '@/test-utils/lingui-mock';++vi.doMock('@lingui/react/macro', () => ({+ Trans: ({ children }: { children: ReactNode }) => <>{children}</>,+ useLingui: () => ({ t: renderLinguiTemplate }),+}));++/** A scheme with a distinct hex per slot so a swatch can be traced to its slot. */+function schemeOf(): Base16Scheme {+ const palette = {} as Base16Scheme['palette'];+ for (const [i, slot] of BASE16_SLOTS.entries()) {+ palette[slot] = `#${i.toString(16).repeat(6)}`;+ }+ return { name: 'T', variant: 'dark', palette };+}++async function renderCanvas(highlightSlot?: Base16Slot) {+ const { ThemePreviewCanvas } = await import('./ThemePreviewCanvas');+ return render(<ThemePreviewCanvas scheme={schemeOf()} highlightSlot={highlightSlot} />);+}++/** The terminal strip is the row anchored by the `$` shell prompt. */+function terminalStrip(getByText: (text: string) => HTMLElement): HTMLElement {+ return getByText('$').parentElement as HTMLElement;+}++describe('ThemePreviewCanvas terminal strip', () => {+ afterEach(cleanup);++ test('labels the yellow swatch base0A — the slot that drives ansi-yellow — not base09', async () => {+ // The strip pairs each ANSI accent with the slot ANSI_BY_SLOT maps it from:+ // red→base08, yellow→base0A, green→base0B, cyan→base0C, blue→base0D,+ // magenta→base0E. base09 is orange and has no ANSI slot, so it must not+ // appear in the strip — mislabelling the yellow swatch base09 teaches the+ // wrong slot→color association, which is the whole point of the preview.+ const { getByText } = await renderCanvas();+ const slots = [...terminalStrip(getByText).querySelectorAll('[data-slot]')].map((el) =>+ el.getAttribute('data-slot'),+ );+ expect(slots).toContain('base0A');+ expect(slots).not.toContain('base09');+ });++ test('highlighting base0A lights the terminal yellow swatch', async () => {+ const { getByText } = await renderCanvas('base0A');+ expect(+ terminalStrip(getByText).querySelectorAll('[data-slot="base0A"][data-lit="true"]').length,+ ).toBeGreaterThan(0);+ });+});diff --git a/packages/app/src/components/settings/ThemePreviewCanvas.tsx b/packages/app/src/components/settings/ThemePreviewCanvas.tsxnew file mode 100644index 000000000..45a1a952f--- /dev/null+++ b/packages/app/src/components/settings/ThemePreviewCanvas.tsx@@ -0,0 +1,204 @@+import type { Base16Scheme, Base16Slot } from '@inkeep/open-knowledge-core';+import { base16ToTokens } from '@inkeep/open-knowledge-core';+import { useLingui } from '@lingui/react/macro';+import { cn } from '@/lib/utils';++/**+ * A miniature of the app painted from a scheme, so editing a slot shows the+ * surfaces it drives rather than an abstract swatch.+ *+ * Every element declares the slot it comes from; passing `highlightSlot` rings+ * the matching ones. That pairing is the whole point — "base09" means nothing+ * on its own, but seeing the numbers in a code block light up explains it in+ * one glance.+ *+ * Colors are applied as inline literals resolved through `base16ToTokens`, not+ * as `var(--…)`. The preview has to be able to show a scheme that ISN'T the+ * active one (you edit Custom while Dracula is applied), and a cascaded `var()`+ * would inherit whatever is live on `<html>` instead.+ */++interface ThemePreviewCanvasProps {+ scheme: Base16Scheme;+ /** Slot to emphasise — set while a slot input is hovered or focused. */+ highlightSlot?: Base16Slot | null;+ className?: string;+}++/** Wraps a preview element so it can be rung when its slot is highlighted. */+function Lit({+ slot,+ active,+ className,+ style,+ children,+}: {+ slot: Base16Slot;+ active: Base16Slot | null | undefined;+ className?: string;+ style?: React.CSSProperties;+ children?: React.ReactNode;+}) {+ const on = active === slot;+ return (+ <span+ data-slot={slot}+ data-lit={on ? 'true' : undefined}+ className={cn('rounded-[2px] transition-shadow', on && 'ring-2 ring-offset-1', className)}+ style={{+ ...style,+ // Ring color tracks the previewed scheme's foreground so it reads on+ // both light and dark schemes without a second palette.+ ...(on ? { boxShadow: '0 0 0 2px currentColor' } : null),+ }}+ >+ {children}+ </span>+ );+}++export function ThemePreviewCanvas({ scheme, highlightSlot, className }: ThemePreviewCanvasProps) {+ const { t } = useLingui();+ const p = scheme.palette;+ const tok = base16ToTokens(scheme);+ const hl = highlightSlot ?? null;++ return (+ <div+ aria-label={t`Theme preview`}+ role="img"+ className={cn(+ 'overflow-hidden rounded-lg border text-[9px] leading-[1.5] select-none',+ className,+ )}+ style={{ backgroundColor: p.base00, color: p.base05, borderColor: p.base02 }}+ >+ {/* Chrome row — sidebar surface + the accent the primary button uses. */}+ <div+ className="flex items-center gap-1.5 px-2 py-1.5"+ style={{ backgroundColor: p.base01, borderBottom: `1px solid ${p.base02}` }}+ >+ <Lit slot="base0D" active={hl}>+ <span+ className="inline-block rounded-full px-1.5 py-[1px] font-medium"+ style={{ backgroundColor: p.base0D, color: p.base00 }}+ >+ {t`Save`}+ </span>+ </Lit>+ <Lit slot="base04" active={hl} className="flex-1 truncate">+ <span style={{ color: p.base04 }}>notes / release-plan.md</span>+ </Lit>+ </div>++ <div className="flex">+ {/* Sidebar — base01 surface, base02 selection, base04 secondary text. */}+ <div+ className="w-[26%] shrink-0 space-y-[3px] p-1.5"+ style={{ backgroundColor: p.base01, borderRight: `1px solid ${p.base02}` }}+ >+ <Lit+ slot="base02"+ active={hl}+ className="block rounded px-1 py-[1px]"+ style={{ backgroundColor: p.base02 }}+ >+ <span style={{ color: p.base05 }}>release-plan</span>+ </Lit>+ <Lit slot="base04" active={hl} className="block px-1">+ <span style={{ color: p.base04 }}>backlog</span>+ </Lit>+ <Lit slot="base04" active={hl} className="block px-1">+ <span style={{ color: p.base04 }}>archive</span>+ </Lit>+ </div>++ {/* Editor body. */}+ <div className="min-w-0 flex-1 space-y-1.5 p-2">+ <Lit slot="base0D" active={hl} className="block font-semibold">+ <span style={{ color: tok['syntax-func'] }}>{t`Release plan`}</span>+ </Lit>++ <div className="space-y-[2px]">+ <span style={{ color: p.base05 }}>{t`Ship the editor with a`} </span>+ <Lit slot="base0D" active={hl}>+ <span style={{ color: tok['link-color'], textDecoration: 'underline' }}>+ {t`themed preview`}+ </span>+ </Lit>+ <span style={{ color: p.base05 }}>.</span>+ </div>++ {/* Callout — one of fifteen accents a theme now drives. */}+ <Lit+ slot="base0A"+ active={hl}+ className="block rounded px-1.5 py-1"+ style={{+ backgroundColor: p.base01,+ borderLeft: `2px solid ${tok['callout-warning-color']}`,+ }}+ >+ <span style={{ color: tok['callout-warning-color'] }} className="font-medium">+ {t`Warning`}+ </span>+ </Lit>++ {/* Fenced code — the syntax slots, the ones hardest to read abstractly. */}+ <div+ className="rounded px-1.5 py-1 font-mono"+ style={{ backgroundColor: tok['syntax-bg'] }}+ >+ <div>+ <Lit slot="base0E" active={hl}>+ <span style={{ color: tok['syntax-keyword'] }}>const</span>+ </Lit>{' '}+ <Lit slot="base08" active={hl}>+ <span style={{ color: tok['syntax-var'] }}>retries</span>+ </Lit>+ <span style={{ color: tok['syntax-operator'] }}> = </span>+ <Lit slot="base09" active={hl}>+ <span style={{ color: tok['syntax-number'] }}>3</span>+ </Lit>+ </div>+ <div>+ <Lit slot="base0B" active={hl}>+ <span style={{ color: tok['syntax-string'] }}>"ready"</span>+ </Lit>{' '}+ <Lit slot="base03" active={hl}>+ <span style={{ color: tok['syntax-comment'], fontStyle: 'italic' }}>+ {t`// note`}+ </span>+ </Lit>+ </div>+ </div>++ {/* Terminal strip — base16's accent slots ARE the ANSI palette. */}+ <div+ className="flex items-center gap-1 rounded px-1.5 py-1 font-mono"+ style={{ backgroundColor: p.base00, border: `1px solid ${p.base02}` }}+ >+ <span style={{ color: p.base04 }}>$</span>+ {(+ [+ ['base08', tok['ansi-red']],+ ['base0A', tok['ansi-yellow']],+ ['base0B', tok['ansi-green']],+ ['base0C', tok['ansi-cyan']],+ ['base0D', tok['ansi-blue']],+ ['base0E', tok['ansi-magenta']],+ ] as const+ ).map(([slot, color]) => (+ <Lit key={slot} slot={slot as Base16Slot} active={hl}>+ <span+ className="inline-block size-1.5 rounded-[1px]"+ style={{ backgroundColor: color }}+ />+ </Lit>+ ))}+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/packages/app/src/components/settings/field-controls.tsx b/packages/app/src/components/settings/field-controls.tsxindex 88a01d3a3..20e3eeda3 100644--- a/packages/app/src/components/settings/field-controls.tsx+++ b/packages/app/src/components/settings/field-controls.tsx@@ -38,7 +38,7 @@ import { Switch } from '@/components/ui/switch';import { Textarea } from '@/components/ui/textarea';import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';-import { colorThemeMode, customThemeKind, resolveCustomSeed } from '@/lib/color-themes';+import { colorThemeMode, customThemeKind, resolveCustomScheme } from '@/lib/color-themes';import { useConfigContextOptional } from '@/lib/config-context';import { applyColorThemeToDom } from '@/lib/use-apply-config-color-theme';import { cn } from '@/lib/utils';@@ -316,7 +316,9 @@ function FieldControlBody({// effect restores the user's saved light/dark mode on the round-trip.applyColorThemeToDom(next, customSeed);if (next === 'custom') {- setTheme(customThemeKind(resolveCustomSeed(customSeed)) === 'dark' ? 'dark' : 'light');+ setTheme(+ customThemeKind(resolveCustomScheme(customSeed)) === 'dark' ? 'dark' : 'light',+ );} else {const mode = colorThemeMode(next);if (mode) setTheme(mode);diff --git a/packages/app/src/components/terminal-theme.test.ts b/packages/app/src/components/terminal-theme.test.tsindex 021811457..e77a1f43a 100644--- a/packages/app/src/components/terminal-theme.test.ts+++ b/packages/app/src/components/terminal-theme.test.ts@@ -124,6 +124,27 @@ describe('computeLiveXtermTheme', () => {for (const slot of ANSI_16) expect(theme[slot]).toBe(XTERM_DARK_THEME[slot]);});+ test('overrides ANSI slots from resolved --ansi-* tokens, per slot', () => {+ // This is the mechanism that makes program output track the active theme:+ // each resolved --ansi-* token replaces its curated slot. A typo in an+ // --ansi-* token name would silently fall back to the curated palette under+ // every theme, which the fallback tests above cannot catch.+ const theme = computeLiveXtermTheme(+ 'dark',+ reader({+ '--ansi-red': 'rgb(200, 0, 0)',+ '--ansi-yellow': 'rgb(220, 200, 0)',+ '--ansi-bright-green': 'rgb(0, 220, 100)',+ }),+ );+ expect(theme.red).toBe('rgb(200, 0, 0)');+ expect(theme.yellow).toBe('rgb(220, 200, 0)');+ expect(theme.brightGreen).toBe('rgb(0, 220, 100)');+ // A slot whose token did not resolve keeps its curated fallback.+ expect(theme.blue).toBe(XTERM_DARK_THEME.blue);+ expect(theme.brightRed).toBe(XTERM_DARK_THEME.brightRed);+ });+test('falls back to the curated palette when tokens do not resolve', () => {expect(computeLiveXtermTheme('dark', () => null)).toEqual(XTERM_DARK_THEME);expect(computeLiveXtermTheme('light', () => null)).toEqual(XTERM_LIGHT_THEME);diff --git a/packages/app/src/components/terminal-theme.ts b/packages/app/src/components/terminal-theme.tsindex 719ba3200..6bb7531e3 100644--- a/packages/app/src/components/terminal-theme.ts+++ b/packages/app/src/components/terminal-theme.ts@@ -1,15 +1,14 @@+import type { AnsiSlotName } from '@inkeep/open-knowledge-core';import type { ITheme } from '@xterm/xterm';/**- * Curated xterm palettes for the docked terminal, one per resolved app mode.+ * Fallback xterm palettes for the docked terminal, one per resolved app mode.*- * Hand-tuned rather than derived from the app's CSS tokens: xterm's 16 ANSI- * slots have no clean mapping onto the app's semantic tokens, and a curated- * pair gives correct contrast in both modes. The surface colors track the- * neutral `--background`/`--foreground` tokens closely enough to blend with the- * `bg-background` wrapper; the ANSI slots follow the VS Code terminal palettes,- * which are tuned for legibility. `minimumContrastRatio` on the Terminal lifts- * any remaining low-contrast program output toward AA at render time.+ * `computeLiveXtermTheme` normally derives every slot from the live theme+ * tokens; these are what it falls back to per-slot when a token can't be+ * resolved (off-DOM, tests) and what the `default` theme's own `--ansi-*`+ * values were seeded from. The ANSI slots follow the VS Code terminal+ * palettes, which are tuned for legibility.*/export const XTERM_DARK_THEME = {background: '#171717',@@ -103,14 +102,39 @@ function readTokenColor(token: string): string | null {}}+/** xterm ANSI slot → the `--ansi-*` custom property carrying its color. */+const ANSI_TOKEN_BY_SLOT: Record<AnsiSlotName, string> = {+ black: '--ansi-black',+ red: '--ansi-red',+ green: '--ansi-green',+ yellow: '--ansi-yellow',+ blue: '--ansi-blue',+ magenta: '--ansi-magenta',+ cyan: '--ansi-cyan',+ white: '--ansi-white',+ brightBlack: '--ansi-bright-black',+ brightRed: '--ansi-bright-red',+ brightGreen: '--ansi-bright-green',+ brightYellow: '--ansi-bright-yellow',+ brightBlue: '--ansi-bright-blue',+ brightMagenta: '--ansi-bright-magenta',+ brightCyan: '--ansi-bright-cyan',+ brightWhite: '--ansi-bright-white',+};+/**- * The curated mode palette with its surface slots re-derived from the live- * theme tokens, so the terminal follows plugin/custom color themes instead of- * only light/dark. ANSI slots stay curated by mode: the 16 ANSI colors have no- * mapping onto the semantic token set that preserves terminal legibility, and- * `minimumContrastRatio` lifts residual clashes. Any token that fails to- * resolve falls back to the curated value, so this degrades to- * `xtermThemeForMode` when no color theme is active or off-DOM.+ * The live theme as an xterm palette — surfaces and all sixteen ANSI slots read+ * from the app's tokens, so a color theme repaints program output and not just+ * the terminal's chrome.+ *+ * The ANSI slots are readable because every theme is authored in base16, whose+ * accent slots are defined against ANSI in the first place; a palette keyed by+ * app-semantic names carries no such mapping and leaves these unreachable.+ * `minimumContrastRatio` on the Terminal still lifts low-contrast program+ * output at render time.+ *+ * Any token that fails to resolve falls back to the curated value, so this+ * degrades to `xtermThemeForMode` off-DOM (tests, SSR).*/export function computeLiveXtermTheme(resolvedTheme: string | undefined,@@ -119,8 +143,16 @@ export function computeLiveXtermTheme(const base = xtermThemeForMode(resolvedTheme);const background = readToken('--background') ?? base.background;const foreground = readToken('--foreground') ?? base.foreground;++ const ansi: Partial<Record<AnsiSlotName, string>> = {};+ for (const slot of Object.keys(ANSI_TOKEN_BY_SLOT) as AnsiSlotName[]) {+ const resolved = readToken(ANSI_TOKEN_BY_SLOT[slot]);+ if (resolved) ansi[slot] = resolved;+ }+return {...base,+ ...ansi,background,foreground,cursor: foreground,diff --git a/packages/app/src/editor/extensions/CodeBlockView.tsx b/packages/app/src/editor/extensions/CodeBlockView.tsxindex 4246bf28e..eb70eb805 100644--- a/packages/app/src/editor/extensions/CodeBlockView.tsx+++ b/packages/app/src/editor/extensions/CodeBlockView.tsx@@ -38,6 +38,7 @@ import {import { Input } from '@/components/ui/input';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { useIsEmbedded } from '@/hooks/use-is-embedded';+import { useColorThemeEpoch } from '@/lib/color-theme-epoch';import { cn } from '@/lib/utils';import { docNameToRelativePath } from '@/lib/workspace-paths';import { OPT_OUT_ATTR } from '../clipboard/index.ts';@@ -148,6 +149,8 @@ export function CodeBlockView({ node, updateAttributes, editor, getPos, selectedconst { resolvedTheme } = useTheme();const appTheme: PreviewTheme =resolvedTheme === 'dark' || resolvedTheme === 'light' ? resolvedTheme : readAppTheme();+ // The color-theme axis has no React signal of its own — see `useColorThemeEpoch`.+ const colorThemeEpoch = useColorThemeEpoch();// Theme baked into the preview `srcDoc` for a flash-free first paint.// Frozen at mount: a theme toggle must NOT rebuild `srcDoc` (rebuilding// reloads the iframe — state loss, chart re-animation), so toggles re-skin@@ -233,10 +236,13 @@ export function CodeBlockView({ node, updateAttributes, editor, getPos, selected// Re-skin the live preview when the reader toggles the app theme —// `postMessage` only, no `srcDoc` rebuild, so the iframe never reloads.// The iframe `onLoad` handler covers the reverse: re-pushing the current- // theme after a reload.+ // theme after a reload. `colorThemeEpoch` is in the deps because switching+ // between two palettes of the same kind (Dracula -> Monokai) never changes+ // `appTheme`, and the forwarded tokens must still follow.+ // biome-ignore lint/correctness/useExhaustiveDependencies: colorThemeEpoch is a signal-only dependency — its bump re-runs this effect so the live iframe re-reads the palette's tokens; it is intentionally not referenced in the body.useEffect(() => {previewFrameRef.current?.contentWindow?.postMessage(buildPreviewThemeMessage(appTheme), '*');- }, [appTheme]);+ }, [appTheme, colorThemeEpoch]);// Auto-height: the preview iframe reports its rendered content height; fit// the wrapper to it. An explicit `h=` always wins downstream indiff --git a/packages/app/src/editor/extensions/cm-theme.ts b/packages/app/src/editor/extensions/cm-theme.tsnew file mode 100644index 000000000..dcee1111a--- /dev/null+++ b/packages/app/src/editor/extensions/cm-theme.ts@@ -0,0 +1,173 @@+/**+ * The CodeMirror theme every CM surface in the app shares.+ *+ * Colors come from the app's CSS custom properties rather than a bundled+ * palette, so a selected IDE color theme repaints source mode, the diff view,+ * the text viewer, the text-doc editor and the Mermaid editor the same way it+ * repaints the rest of the chrome. Every CM surface shares this one theme; a+ * per-surface+ * `basicDark`/`basicLight` pair would pin its syntax colors to a bundled+ * palette that no theme can reach.+ *+ * Tag → token mapping follows base16's slot roles, which is what makes it+ * meaningful across arbitrary imported schemes: `--syntax-var` is base16's+ * "variables / tags" slot, `--syntax-string` its "strings" slot, and so on.+ */++import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';+import type { Extension } from '@codemirror/state';+import { EditorView } from '@codemirror/view';+import { tags } from '@lezer/highlight';++/**+ * Token colors, keyed on Lezer tags. Markdown constructs come first because+ * source mode is the dominant surface; the general programming tags below it+ * cover fenced code blocks, which CM parses with a nested language.+ */+const okSyntaxHighlight = HighlightStyle.define([+ // --- markdown ---+ {+ tag: [tags.heading, tags.heading1, tags.heading2, tags.heading3],+ color: 'var(--syntax-func)',+ fontWeight: 'bold',+ },+ { tag: [tags.heading4, tags.heading5, tags.heading6], color: 'var(--syntax-func)' },+ { tag: tags.strong, fontWeight: 'bold', color: 'var(--foreground)' },+ { tag: tags.emphasis, fontStyle: 'italic', color: 'var(--foreground)' },+ { tag: tags.strikethrough, textDecoration: 'line-through' },+ {+ tag: tags.link,+ color: 'var(--link-color)',+ textDecoration: 'underline',+ textUnderlinePosition: 'under',+ },+ { tag: tags.url, color: 'var(--syntax-attr)' },+ { tag: tags.monospace, color: 'var(--syntax-string)' },+ { tag: tags.quote, color: 'var(--syntax-comment)', fontStyle: 'italic' },+ { tag: tags.list, color: 'var(--syntax-keyword)' },+ { tag: tags.contentSeparator, color: 'var(--syntax-comment)' },+ // The `#`, `*`, backtick markers themselves — deliberately recessive so the+ // content reads first.+ { tag: tags.processingInstruction, color: 'var(--muted-foreground)' },++ // --- comments + meta ---+ {+ tag: [tags.comment, tags.lineComment, tags.blockComment],+ color: 'var(--syntax-comment)',+ fontStyle: 'italic',+ },+ { tag: [tags.meta, tags.annotation, tags.namespace], color: 'var(--syntax-meta)' },+ { tag: tags.docComment, color: 'var(--syntax-comment)', fontStyle: 'italic' },++ // --- keywords ---+ {+ tag: [tags.keyword, tags.controlKeyword, tags.moduleKeyword, tags.operatorKeyword],+ color: 'var(--syntax-keyword)',+ fontWeight: '600',+ },+ { tag: [tags.modifier, tags.self], color: 'var(--syntax-keyword)' },++ // --- names ---+ { tag: tags.tagName, color: 'var(--syntax-tag)' },+ { tag: [tags.typeName, tags.className], color: 'var(--syntax-type)' },+ { tag: [tags.attributeName, tags.propertyName], color: 'var(--syntax-attr)' },+ { tag: [tags.variableName, tags.macroName], color: 'var(--syntax-var)' },+ {+ tag: [tags.function(tags.variableName), tags.definition(tags.name), tags.labelName],+ color: 'var(--syntax-func)',+ },++ // --- literals ---+ { tag: [tags.string, tags.character, tags.special(tags.string)], color: 'var(--syntax-string)' },+ { tag: [tags.number, tags.integer, tags.float, tags.literal], color: 'var(--syntax-number)' },+ {+ tag: [tags.bool, tags.null, tags.atom, tags.constant(tags.name), tags.standard(tags.name)],+ color: 'var(--syntax-atom)',+ },+ { tag: [tags.regexp, tags.escape], color: 'var(--syntax-atom)' },+ { tag: tags.color, color: 'var(--syntax-atom)' },++ // --- punctuation ---+ {+ tag: [+ tags.operator,+ tags.punctuation,+ tags.separator,+ tags.bracket,+ tags.brace,+ tags.paren,+ tags.squareBracket,+ tags.angleBracket,+ ],+ color: 'var(--syntax-operator)',+ },++ // --- diff + invalid ---+ { tag: tags.inserted, color: 'var(--diff-added)' },+ { tag: tags.deleted, color: 'var(--diff-removed)' },+ { tag: tags.changed, color: 'var(--syntax-number)' },+ { tag: tags.invalid, color: 'var(--destructive)' },+]);++/** Per-surface chrome, for the few CM hosts that don't sit on `--background`. */+export interface OkCmThemeOptions {+ /** Whether the resolved app mode is dark — CodeMirror's own `&dark` selector hook. */+ dark: boolean;+ /** Editor canvas. Defaults to transparent so the CM inherits its host's surface. */+ background?: string;+ /** Gutter canvas. Defaults to transparent for the same reason. */+ gutterBackground?: string;+}++/**+ * The editor chrome — caret, selection, gutters, active line. Shared visuals+ * that `globals.css` already owns (font, padding, focus outline, scrollbar) are+ * deliberately absent so the two don't compete.+ */+function createOkCmTheme(options: OkCmThemeOptions): Extension {+ const background = options.background ?? 'transparent';+ const gutterBackground = options.gutterBackground ?? 'transparent';+ return EditorView.theme(+ {+ '&': { color: 'var(--foreground)', backgroundColor: background },+ '.cm-content': { caretColor: 'var(--foreground)' },+ '.cm-cursor, .cm-dropCursor': { borderLeftColor: 'var(--foreground)' },+ '&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': {+ backgroundColor: 'var(--selection-soft)',+ },+ '.cm-selectionMatch': {+ backgroundColor: 'color-mix(in oklab, var(--syntax-type) 30%, transparent)',+ },+ '.cm-gutters': {+ backgroundColor: gutterBackground,+ color: 'var(--muted-foreground)',+ border: 'none',+ },+ '.cm-activeLine': {+ backgroundColor: 'color-mix(in oklab, var(--foreground) 4%, transparent)',+ },+ '.cm-activeLineGutter': { backgroundColor: 'transparent', color: 'var(--foreground)' },+ '.cm-foldPlaceholder': {+ backgroundColor: 'var(--muted)',+ color: 'var(--muted-foreground)',+ border: 'none',+ },+ '.cm-panels': { backgroundColor: 'var(--popover)', color: 'var(--popover-foreground)' },+ '.cm-searchMatch': {+ backgroundColor: 'color-mix(in oklab, var(--syntax-type) 30%, transparent)',+ },+ '.cm-searchMatch.cm-searchMatch-selected': {+ backgroundColor: 'color-mix(in oklab, var(--primary) 40%, transparent)',+ },+ },+ { dark: options.dark },+ );+}++/**+ * The full theme bundle: chrome plus token colors. `fallback: true` keeps+ * unstyled tags on CodeMirror's base styling rather than leaving them unpainted.+ */+export function okCmTheme(options: OkCmThemeOptions): Extension[] {+ return [createOkCmTheme(options), syntaxHighlighting(okSyntaxHighlight, { fallback: true })];+}diff --git a/packages/app/src/editor/extensions/nested-cm-extensions.ts b/packages/app/src/editor/extensions/nested-cm-extensions.tsindex 875e42fee..247a6421d 100644--- a/packages/app/src/editor/extensions/nested-cm-extensions.ts+++ b/packages/app/src/editor/extensions/nested-cm-extensions.ts@@ -18,14 +18,13 @@import { markdown, markdownLanguage } from '@codemirror/lang-markdown';import type { Compartment, Extension } from '@codemirror/state';import { EditorView, keymap } from '@codemirror/view';-import { tags as t } from '@lezer/highlight';import { GFM } from '@lezer/markdown';-import { basicDarkInit, basicLightInit } from '@uiw/codemirror-theme-basic';import type * as Y from 'yjs';import { codeLanguages } from '../markdown-code-languages';import { createAgentFlashSourceExtension } from '../plugins/agent-flash-source';import { createMdLinkSourceExtension } from '../plugins/md-link-source';import { createWikiLinkSourceExtension } from '../plugins/wiki-link-source';+import { okCmTheme } from './cm-theme';// Theme factories — each caller gets a fresh theme object.// Background is transparent so the CM inherits its host's surface:@@ -36,85 +35,12 @@ import { createWikiLinkSourceExtension } from '../plugins/wiki-link-source';// paints a pure-white panel inside the tinted wrapper, creating a// raised-panel / inner-shadow illusion. Transparent keeps the CM flush// with its host.-export const darkTheme = basicDarkInit({- settings: {- background: 'transparent',- gutterBackground: 'transparent',- },-});--// Overrides for basicLightStyle tokens that fail WCAG AA contrast on white.-// Same Nord hue, darker lightness. NOTE: tagHighlighter overwrites per-tag-id —-// later specs fully replace earlier ones, no CSS cascade — so any override on a-// tag with formatting (bold/italic/underline) must repeat those attrs.-export const lightTheme = basicLightInit({- settings: {- background: 'transparent',- gutterBackground: 'transparent',- },- styles: [- { tag: [t.brace, t.processingInstruction, t.inserted], color: '#3d6968' },- {- tag: t.link,- color: '#3d6968',- textDecoration: 'underline',- textUnderlinePosition: 'under',- },- {- tag: [- t.keyword,- t.function(t.variableName),- t.regexp,- t.color,- t.constant(t.name),- t.standard(t.name),- ],- color: '#345575',- },- {- tag: [t.heading, t.special(t.heading1), t.heading1, t.heading2, t.heading3, t.heading4],- color: '#345575',- fontWeight: 'bold',- },- { tag: [t.heading5, t.heading6], color: '#345575' },- { tag: t.strong, color: '#345575', fontWeight: 'bold' },- { tag: t.emphasis, color: '#345575', fontStyle: 'italic' },- {- tag: [- t.name,- t.deleted,- t.character,- t.propertyName,- t.macroName,- t.variableName,- t.angleBracket,- t.string,- t.url,- t.escape,- t.special(t.string),- t.atom,- t.bool,- t.special(t.variableName),- ],- color: '#9a5739',- },- {- tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace, t.meta],- color: '#3d6968',- },- {- tag: [t.definition(t.name), t.separator, t.operator, t.operatorKeyword],- color: '#4a6938',- },- {- tag: [t.typeName, t.className, t.attributeName, t.contentSeparator],- color: '#8b6500',- },- { tag: t.tagName, color: '#774d70' },- { tag: t.squareBracket, color: '#964148' },- { tag: t.labelName, color: '#3a5e85' },- ],-});+//+// Both resolve their colors from the app's CSS tokens, so the active IDE color+// theme drives syntax highlighting here the same way it drives the chrome. The+// dark/light split remains only for CodeMirror's own `&dark` selector hook.+export const darkTheme: Extension = okCmTheme({ dark: true });+export const lightTheme: Extension = okCmTheme({ dark: false });interface NestedCMOptions {/** Per-instance theme compartment — caller MUST create their own */diff --git a/packages/app/src/editor/extensions/preview-iframe-header.ts b/packages/app/src/editor/extensions/preview-iframe-header.tsindex 36ddf8e82..d41285411 100644--- a/packages/app/src/editor/extensions/preview-iframe-header.ts+++ b/packages/app/src/editor/extensions/preview-iframe-header.ts@@ -1,4 +1,10 @@import { PREVIEW_THEME_TOKENS } from '@inkeep/open-knowledge-core';+import {+ domPreviewTokenEnv,+ type PreviewTokenEnv,+ readLivePreviewTokens,+ renderTokenDecls,+} from './preview-live-tokens';/** The reader's resolved app theme, baked into a preview iframe's `srcDoc`. */export type PreviewTheme = 'light' | 'dark';@@ -10,18 +16,29 @@ export type PreviewTheme = 'light' | 'dark';*/const PREVIEW_THEME_MESSAGE_KEY = 'okPreviewTheme';+/** `postMessage` payload key carrying the host's resolved design tokens. */+const PREVIEW_TOKENS_MESSAGE_KEY = 'okPreviewTokens';+/** The `postMessage` payload shape sent parent → preview iframe on toggle. */export interface PreviewThemeMessage {[PREVIEW_THEME_MESSAGE_KEY]: PreviewTheme;+ [PREVIEW_TOKENS_MESSAGE_KEY]?: Record<string, string>;}/*** Build the message the NodeView posts into a preview iframe when the reader- * toggles the app theme. The iframe's bootstrap script flips its root class- * in response — no `srcDoc` rebuild, no reload.+ * toggles the app theme or switches color theme. The iframe's bootstrap script+ * flips its root class and applies the forwarded tokens in response — no+ * `srcDoc` rebuild, no reload.*/-export function buildPreviewThemeMessage(theme: PreviewTheme): PreviewThemeMessage {- return { [PREVIEW_THEME_MESSAGE_KEY]: theme };+export function buildPreviewThemeMessage(+ theme: PreviewTheme,+ env: PreviewTokenEnv | null = domPreviewTokenEnv(),+): PreviewThemeMessage {+ const tokens = readLivePreviewTokens(env);+ return tokens+ ? { [PREVIEW_THEME_MESSAGE_KEY]: theme, [PREVIEW_TOKENS_MESSAGE_KEY]: tokens }+ : { [PREVIEW_THEME_MESSAGE_KEY]: theme };}/**@@ -137,10 +154,18 @@ function themeDecls(theme: PreviewTheme): string {* hand-styling. An embed that sets its own `body` background still wins —* the user `<style>` comes later in source order.*/-function themeTokenStyle(): string {+function themeTokenStyle(env: PreviewTokenEnv | null): string {+ const live = readLivePreviewTokens(env);+ // Matches both roots so it out-orders `:root.dark` (equal specificity, later+ // in source) as well as `:root`. Without the `.dark` half a live override+ // would silently lose to the baked dark block. Empty when no palette is+ // selected, leaving the baked blocks — and the iframe's own light/dark flip —+ // in charge.+ const liveBlock =+ live && Object.keys(live).length > 0 ? `\n:root,:root.dark{${renderTokenDecls(live)}}` : '';return `<style>:root{${themeDecls('light')};color-scheme:light}-:root.dark{${themeDecls('dark')};color-scheme:dark}+:root.dark{${themeDecls('dark')};color-scheme:dark}${liveBlock}body{background:var(--background);color:var(--foreground)}</style>`;}@@ -169,11 +194,18 @@ function previewBootstrapScript(theme: PreviewTheme): string {return (`<script>(function(){` +`var d=document.documentElement;${initialClass}` ++ `var applied=[];` +`addEventListener('message',function(e){` +`if(e.source!==parent)return;` +`var t=e&&e.data&&e.data.${PREVIEW_THEME_MESSAGE_KEY};` +`if(t==='dark'){d.classList.add('dark');}` +`else if(t==='light'){d.classList.remove('dark');}` ++ `var k=e&&e.data&&e.data.${PREVIEW_TOKENS_MESSAGE_KEY};` ++ `if(k){` ++ `for(var i=0;i<applied.length;i++){if(!(applied[i] in k)){try{d.style.removeProperty(applied[i]);}catch(_e){}}}` ++ `applied=[];` ++ `for(var n in k){applied.push(n);try{d.style.setProperty(n,k[n]);}catch(_e){}}` ++ `}` +`});` +`var raf;` +`function report(){` +@@ -258,9 +290,12 @@ const PREVIEW_CSP =* CSP and both `<style>` blocks are theme-independent, so the header differs* between themes by exactly that one class statement.*/-export function buildPreviewIframeHeader(theme: PreviewTheme): string {+export function buildPreviewIframeHeader(+ theme: PreviewTheme,+ env: PreviewTokenEnv | null = domPreviewTokenEnv(),+): string {return `<meta http-equiv="Content-Security-Policy" content="${PREVIEW_CSP}">-${themeTokenStyle()}+${themeTokenStyle(env)}${PREVIEW_SCROLLBAR_STYLE}${previewBootstrapScript(theme)}`;}diff --git a/packages/app/src/editor/extensions/preview-live-tokens.test.ts b/packages/app/src/editor/extensions/preview-live-tokens.test.tsnew file mode 100644index 000000000..9a37dc21b--- /dev/null+++ b/packages/app/src/editor/extensions/preview-live-tokens.test.ts@@ -0,0 +1,91 @@+/**+ * Live-token forwarding for the preview iframe.+ *+ * A preview runs at a null origin and inherits nothing from the host, so its+ * tokens are baked into the `srcDoc` and pushed over `postMessage`. The baked+ * set describes the DEFAULT theme only; these tests pin when the host's live+ * values override it and — load-bearing — when they must NOT, because a live+ * override is mode-agnostic and would pin an embed to whichever mode was+ * active at mount.+ *+ * The host is injected rather than stood up as a DOM, matching the+ * `computeLiveXtermTheme` reader seam.+ */++import { describe, expect, test } from 'vitest';+import { buildPreviewIframeHeader, buildPreviewThemeMessage } from './preview-iframe-header';+import { type PreviewTokenEnv, readLivePreviewTokens } from './preview-live-tokens';++/** A host with a palette selected, resolving the given tokens and nothing else. */+function withPalette(tokens: Record<string, string>): PreviewTokenEnv {+ return { paletteActive: true, readToken: (name) => tokens[name] ?? null };+}++/** A host on the default theme — no palette, so nothing should be forwarded. */+const NO_PALETTE: PreviewTokenEnv = { paletteActive: false, readToken: () => null };++describe('readLivePreviewTokens', () => {+ test('returns an empty map when no color theme is selected', () => {+ expect(readLivePreviewTokens(NO_PALETTE)).toEqual({});+ });++ test('returns null when there is no host to read', () => {+ expect(readLivePreviewTokens(null)).toBeNull();+ });++ test('forwards the host values once a palette is selected', () => {+ const tokens = readLivePreviewTokens(+ withPalette({ '--primary': '#bd93f9', '--background': '#282a36' }),+ );+ expect(tokens?.['--primary']).toBe('#bd93f9');+ expect(tokens?.['--background']).toBe('#282a36');+ });++ test('forwards tokens beyond the baked snapshot set', () => {+ // The snapshot covers charts and the core surface pair; an embed reaching+ // for a syntax color has nothing to bind to without these.+ const tokens = readLivePreviewTokens(withPalette({ '--syntax-string': '#50fa7b' }));+ expect(tokens?.['--syntax-string']).toBe('#50fa7b');+ });++ test('drops a value that still carries var() indirection', () => {+ // Unresolved inside the null-origin frame, where the chain does not exist.+ const tokens = readLivePreviewTokens(withPalette({ '--primary': 'var(--color-sky-blue)' }));+ expect(tokens?.['--primary']).toBeUndefined();+ });+});++describe('srcDoc live-override block', () => {+ test('is absent under the default theme, leaving the baked light/dark blocks in charge', () => {+ const header = buildPreviewIframeHeader('light', NO_PALETTE);+ expect(header).toContain(':root{');+ expect(header).toContain(':root.dark{');+ expect(header).not.toContain(':root,:root.dark{');+ });++ test('matches both roots when a palette is selected, so it beats the baked dark block', () => {+ const header = buildPreviewIframeHeader('dark', withPalette({ '--background': '#282a36' }));+ // Equal specificity to `:root.dark` and later in source order — the only+ // shape that wins in both modes.+ expect(header).toContain(':root,:root.dark{');+ expect(header).toContain('--background:#282a36');+ });+});++describe('buildPreviewThemeMessage', () => {+ test('carries the palette tokens so a live iframe re-skins without a reload', () => {+ const message = buildPreviewThemeMessage('dark', withPalette({ '--primary': '#bd93f9' })) as+ | Record<string, unknown>+ | undefined;+ expect(message?.okPreviewTheme).toBe('dark');+ expect((message?.okPreviewTokens as Record<string, string>)['--primary']).toBe('#bd93f9');+ });++ test('carries an empty token map under the default theme', () => {+ // Empty rather than absent: the iframe bootstrap uses the payload to REMOVE+ // properties a previously-selected palette set, so switching back to+ // `default` can't strand them as inline overrides.+ const message = buildPreviewThemeMessage('light', NO_PALETTE) as Record<string, unknown>;+ expect(message.okPreviewTokens).toEqual({});+ });+});diff --git a/packages/app/src/editor/extensions/preview-live-tokens.ts b/packages/app/src/editor/extensions/preview-live-tokens.tsnew file mode 100644index 000000000..babde8cbd--- /dev/null+++ b/packages/app/src/editor/extensions/preview-live-tokens.ts@@ -0,0 +1,112 @@+/**+ * Live design-token reads for the preview iframe.+ *+ * A preview runs at a null origin (`sandbox="allow-scripts"` without+ * `allow-same-origin`), so it inherits nothing from the host page — its tokens+ * have to be baked into the `srcDoc` or pushed over `postMessage`. The baked+ * set comes from `PREVIEW_THEME_TOKENS`, a build-time snapshot of the DEFAULT+ * theme, which is why an embed used to render on neutral-black next to a+ * Dracula editor.+ *+ * Reading the host's computed values instead means an embed tracks whichever+ * color theme is active, including a user-imported one that didn't exist at+ * build time. The snapshot stays as the fallback for environments where+ * `getComputedStyle` can't resolve custom properties (tests, SSR).+ */++import { PREVIEW_THEME_TOKENS } from '@inkeep/open-knowledge-core';+import { COLOR_THEME_ATTRIBUTE } from '@/lib/use-apply-config-color-theme';++/**+ * Tokens forwarded on top of the snapshot set. The snapshot covers charts and+ * the core surface pair; these are the ones an embed reaches for next —+ * elevated surfaces, interactive accents, and the syntax colors a code-shaped+ * embed needs.+ */+const EXTRA_PREVIEW_TOKENS = [+ '--popover',+ '--popover-foreground',+ '--secondary',+ '--secondary-foreground',+ '--muted',+ '--accent',+ '--accent-foreground',+ '--input',+ '--ring',+ '--selection-soft',+ '--syntax-keyword',+ '--syntax-string',+ '--syntax-number',+ '--syntax-comment',+ '--syntax-func',+ '--syntax-bg',+] as const;++/** Every custom property a preview iframe receives, snapshot set first. */+const PREVIEW_FORWARDED_TOKENS: readonly string[] = [+ ...PREVIEW_THEME_TOKENS.map((token) => token.name),+ ...EXTRA_PREVIEW_TOKENS,+];++/**+ * The host state token forwarding depends on. Injectable for the same reason+ * `computeLiveXtermTheme` takes a `TokenColorReader`: it keeps the mapping+ * testable without standing up a DOM substrate.+ */+export interface PreviewTokenEnv {+ /** Whether a color theme is selected — i.e. `data-color-theme` is present. */+ paletteActive: boolean;+ /** Resolve one custom property to a concrete value, or null when unset. */+ readToken: (name: string) => string | null;+}++/** The live host environment, or `null` when there is no document to read. */+export function domPreviewTokenEnv(): PreviewTokenEnv | null {+ if (typeof document === 'undefined') return null;+ const root = document.documentElement;+ return {+ paletteActive: root.hasAttribute(COLOR_THEME_ATTRIBUTE),+ readToken: (name) => {+ try {+ return getComputedStyle(root).getPropertyValue(name).trim() || null;+ } catch {+ return null;+ }+ },+ };+}++/**+ * Resolve the forwarded tokens against the host.+ *+ * Returns an EMPTY map when no color theme is selected, which is meaningfully+ * different from returning values: the baked light/dark blocks carry the+ * default theme correctly and can flip with the iframe's own `.dark` class,+ * whereas a live override is mode-agnostic and would pin the embed to whatever+ * mode was active when it mounted. Only a selected palette — which forces its+ * own mode anyway — should override them.+ *+ * Returns `null` only when there is no host to read.+ */+export function readLivePreviewTokens(+ env: PreviewTokenEnv | null = domPreviewTokenEnv(),+): Record<string, string> | null {+ if (!env) return null;+ if (!env.paletteActive) return {};+ const out: Record<string, string> = {};+ for (const name of PREVIEW_FORWARDED_TOKENS) {+ const value = env.readToken(name);+ // A value still containing `var(` means the environment didn't resolve the+ // chain and would be meaningless inside the null-origin frame.+ if (!value || value.includes('var(')) continue;+ out[name] = value;+ }+ return out;+}++/** Render a token map as `--name:value;` declarations. */+export function renderTokenDecls(tokens: Record<string, string>): string {+ return Object.entries(tokens)+ .map(([name, value]) => `${name}:${value}`)+ .join(';');+}diff --git a/packages/app/src/editor/source-mode-setup.ts b/packages/app/src/editor/source-mode-setup.tsindex f3eead340..9804a81ee 100644--- a/packages/app/src/editor/source-mode-setup.ts+++ b/packages/app/src/editor/source-mode-setup.ts@@ -22,14 +22,7 @@ import {completionKeymap,} from '@codemirror/autocomplete';import { defaultKeymap } from '@codemirror/commands';-import {- bracketMatching,- defaultHighlightStyle,- foldGutter,- foldKeymap,- indentOnInput,- syntaxHighlighting,-} from '@codemirror/language';+import { bracketMatching, foldGutter, foldKeymap, indentOnInput } from '@codemirror/language';import { lintKeymap } from '@codemirror/lint';import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';import { EditorState, type Extension } from '@codemirror/state';@@ -54,7 +47,6 @@ export const sourceModeSetup: Extension = [dropCursor(),EditorState.allowMultipleSelections.of(true),indentOnInput(),- syntaxHighlighting(defaultHighlightStyle, { fallback: true }),bracketMatching(),closeBrackets(),autocompletion(),diff --git a/packages/app/src/globals.css b/packages/app/src/globals.cssindex d38cd76ee..15141f691 100644--- a/packages/app/src/globals.css+++ b/packages/app/src/globals.css@@ -281,13 +281,13 @@@keyframes sidebar-push-pulse {0% {- box-shadow: inset 4px 0 0 0 hsl(var(--primary) / 0);+ box-shadow: inset 4px 0 0 0 color-mix(in oklab, var(--primary) 0%, transparent);}25% {- box-shadow: inset 4px 0 0 0 hsl(var(--primary) / 0.4);+ box-shadow: inset 4px 0 0 0 color-mix(in oklab, var(--primary) 40%, transparent);}100% {- box-shadow: inset 4px 0 0 0 hsl(var(--primary) / 0);+ box-shadow: inset 4px 0 0 0 color-mix(in oklab, var(--primary) 0%, transparent);}}@@ -298,15 +298,15 @@Outline-only so the field input itself is untouched. */@keyframes settings-flash {0% {- outline: 2px solid hsl(var(--destructive) / 0);+ outline: 2px solid color-mix(in oklab, var(--destructive) 0%, transparent);outline-offset: 2px;}20% {- outline: 2px solid hsl(var(--destructive) / 0.7);+ outline: 2px solid color-mix(in oklab, var(--destructive) 70%, transparent);outline-offset: 2px;}100% {- outline: 2px solid hsl(var(--destructive) / 0);+ outline: 2px solid color-mix(in oklab, var(--destructive) 0%, transparent);outline-offset: 2px;}}@@ -320,15 +320,15 @@className. */@keyframes settings-nav-flash {0% {- outline: 2px solid hsl(var(--primary) / 0);+ outline: 2px solid color-mix(in oklab, var(--primary) 0%, transparent);outline-offset: 2px;}25% {- outline: 2px solid hsl(var(--primary) / 0.7);+ outline: 2px solid color-mix(in oklab, var(--primary) 70%, transparent);outline-offset: 2px;}100% {- outline: 2px solid hsl(var(--primary) / 0);+ outline: 2px solid color-mix(in oklab, var(--primary) 0%, transparent);outline-offset: 2px;}}@@ -1239,7 +1239,8 @@.ProseMirror mark {color: inherit;- @apply py-0.5 px-1 rounded-sm bg-amber-100 dark:bg-amber-900/50;+ background: color-mix(in oklab, var(--syntax-type) 28%, var(--background));+ @apply py-0.5 px-1 rounded-sm;}/* Authoring annotations (`%%…%%`, `<!-- … -->`). The editing surface shows@@ -1414,7 +1415,7 @@appearance: none;width: 1rem;height: 1rem;- border: 1.5px solid var(--color-gray-400);+ border: 1.5px solid var(--border);border-radius: calc(var(--radius) * 0.4);background: transparent;cursor: pointer;@@ -1456,21 +1457,21 @@.ProseMirror li[data-type="taskItem"][data-checked="true"] > div {text-decoration: line-through;- color: var(--color-gray-400);+ color: var(--muted-foreground);}/* Blockquote */.ProseMirror blockquote {- border-left: 3px solid var(--color-gray-300);+ border-left: 3px solid var(--callout-quote-color);padding-left: 1em;margin-left: 0;margin-bottom: 0.5em;- color: var(--color-gray-600);+ color: var(--muted-foreground);}/* Code blocks — fallback for any <pre> not wrapped by the .ok-codeblock NodeView */.ProseMirror pre {- background: var(--color-gray-100);+ background: var(--syntax-bg);padding: 0.75em 1em;margin-bottom: 0.5em;overflow-x: auto;@@ -1489,17 +1490,12 @@}.ProseMirror .ok-codeblock-pre {- background: oklch(0.97 0 0);+ background: var(--syntax-bg);color: var(--foreground);border: 0;@apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50;}-.dark .ProseMirror .ok-codeblock-pre {- background: oklch(0.18 0.005 285);- color: oklch(0.92 0 0);-}-/* Strip the outer-pre fallback chrome — the NodeView's own .ok-codeblock-precarries the box. */.ProseMirror .ok-codeblock pre.ok-codeblock-pre {@@ -1707,7 +1703,7 @@/* Inline code */.ProseMirror code {- background: var(--color-gray-100);+ background: var(--syntax-bg);border-radius: 0.25em;padding: 0.15em 0.35em;font-family: var(--font-mono);@@ -1729,7 +1725,7 @@* ---------------------------------------------------------------------- */.ProseMirror .ok-codeblock code .hljs-comment,.ProseMirror .ok-codeblock code .hljs-quote {- color: #6a737d;+ color: var(--syntax-comment);font-style: italic;}@@ -1737,16 +1733,19 @@.ProseMirror .ok-codeblock code .hljs-selector-tag,.ProseMirror .ok-codeblock code .hljs-doctag,.ProseMirror .ok-codeblock code .hljs-formula {- color: #d73a49;+ color: var(--syntax-keyword);}.ProseMirror .ok-codeblock code .hljs-name,.ProseMirror .ok-codeblock code .hljs-section,.ProseMirror .ok-codeblock code .hljs-tag,-.ProseMirror .ok-codeblock code .hljs-attr,.ProseMirror .ok-codeblock code .hljs-template-variable,.ProseMirror .ok-codeblock code .hljs-variable {- color: #22863a;+ color: var(--syntax-var);+}++.ProseMirror .ok-codeblock code .hljs-attr {+ color: var(--syntax-attr);}.ProseMirror .ok-codeblock code .hljs-string,@@ -1756,37 +1755,40 @@.ProseMirror .ok-codeblock code .hljs-symbol,.ProseMirror .ok-codeblock code .hljs-bullet,.ProseMirror .ok-codeblock code .hljs-addition {- color: #032f62;+ color: var(--syntax-string);}.ProseMirror .ok-codeblock code .hljs-number,.ProseMirror .ok-codeblock code .hljs-built_in,-.ProseMirror .ok-codeblock code .hljs-type,.ProseMirror .ok-codeblock code .hljs-link {- color: #005cc5;+ color: var(--syntax-number);+}++.ProseMirror .ok-codeblock code .hljs-type {+ color: var(--syntax-type);}.ProseMirror .ok-codeblock code .hljs-title,.ProseMirror .ok-codeblock code .hljs-attribute,.ProseMirror .ok-codeblock code .hljs-meta {- color: #6f42c1;+ color: var(--syntax-func);}/* Descendant-combinator selectors come AFTER the simple-class rules sodocument order matches specificity order (biome's noDescendingSpecificity).- `.hljs-class .hljs-title` paints class names in number-blue;- `.hljs-function .hljs-title` keeps function names in title-purple. */+ `.hljs-class .hljs-title` paints class names as types; `.hljs-function+ .hljs-title` keeps function names in the function slot. */.ProseMirror .ok-codeblock code .hljs-class .hljs-title {- color: #005cc5;+ color: var(--syntax-type);}.ProseMirror .ok-codeblock code .hljs-function .hljs-title {- color: #6f42c1;+ color: var(--syntax-func);}.ProseMirror .ok-codeblock code .hljs-deletion {- color: #b31d28;- background: #ffeef0;+ color: var(--diff-removed);+ background: color-mix(in oklab, var(--diff-removed) 15%, transparent);}.ProseMirror .ok-codeblock code .hljs-emphasis {@@ -1797,71 +1799,11 @@font-weight: 600;}-/* Dark mode */-.dark .ProseMirror .ok-codeblock code .hljs-comment,-.dark .ProseMirror .ok-codeblock code .hljs-quote {- color: #8b949e;-}--.dark .ProseMirror .ok-codeblock code .hljs-keyword,-.dark .ProseMirror .ok-codeblock code .hljs-selector-tag,-.dark .ProseMirror .ok-codeblock code .hljs-doctag,-.dark .ProseMirror .ok-codeblock code .hljs-formula {- color: #ff7b72;-}--.dark .ProseMirror .ok-codeblock code .hljs-name,-.dark .ProseMirror .ok-codeblock code .hljs-section,-.dark .ProseMirror .ok-codeblock code .hljs-tag,-.dark .ProseMirror .ok-codeblock code .hljs-attr,-.dark .ProseMirror .ok-codeblock code .hljs-template-variable,-.dark .ProseMirror .ok-codeblock code .hljs-variable {- color: #7ee787;-}--.dark .ProseMirror .ok-codeblock code .hljs-string,-.dark .ProseMirror .ok-codeblock code .hljs-regexp,-.dark .ProseMirror .ok-codeblock code .hljs-literal,-.dark .ProseMirror .ok-codeblock code .hljs-meta-string,-.dark .ProseMirror .ok-codeblock code .hljs-symbol,-.dark .ProseMirror .ok-codeblock code .hljs-bullet,-.dark .ProseMirror .ok-codeblock code .hljs-addition {- color: #a5d6ff;-}--.dark .ProseMirror .ok-codeblock code .hljs-number,-.dark .ProseMirror .ok-codeblock code .hljs-built_in,-.dark .ProseMirror .ok-codeblock code .hljs-type,-.dark .ProseMirror .ok-codeblock code .hljs-link {- color: #79c0ff;-}--.dark .ProseMirror .ok-codeblock code .hljs-title,-.dark .ProseMirror .ok-codeblock code .hljs-attribute,-.dark .ProseMirror .ok-codeblock code .hljs-meta {- color: #d2a8ff;-}--/* Descendant-combinator selectors come AFTER the simple-class rules so- document order matches specificity order (biome's noDescendingSpecificity). */-.dark .ProseMirror .ok-codeblock code .hljs-class .hljs-title {- color: #79c0ff;-}--.dark .ProseMirror .ok-codeblock code .hljs-function .hljs-title {- color: #d2a8ff;-}--.dark .ProseMirror .ok-codeblock code .hljs-deletion {- color: #ffa198;- background: rgba(248, 81, 73, 0.15);-}-/* Links */.ProseMirror a {- color: var(--color-azure-blue);+ color: var(--link-color);cursor: pointer;- @apply font-medium dark:text-sky-blue dark:hover:text-azure-300 hover:underline hover:underline-offset-2;+ @apply font-medium hover:underline hover:underline-offset-2;}/* Chrome-bar anchor items (Embed, Mirror) must NOT inherit the prose-link* blue color or hover underline — they're icon buttons in the@@ -1890,18 +1832,17 @@.ProseMirror [data-wiki-link] {display: inline;cursor: pointer;- color: var(--color-azure-blue);+ color: var(--link-color);text-decoration: underline;text-decoration-style: solid;text-underline-offset: 2px;border-radius: 2px;- @apply font-medium dark:text-sky-blue;+ @apply font-medium;}.ProseMirror [data-link]:hover,.ProseMirror [data-wiki-link]:hover {text-decoration-thickness: 2px;- @apply dark:text-azure-300;}.ProseMirror [data-link]:focus-visible,@@ -1990,8 +1931,7 @@chip color when present. */.ProseMirror [data-resolution-state="resolved"] {- color: var(--color-azure-blue);- @apply dark:text-sky-blue;+ color: var(--link-color);}/* Folder chip — doc-reference to a directory rather than a page. Italicize@@ -2043,7 +1983,7 @@/* Horizontal rule */.ProseMirror hr {border: none;- border-top: 1px solid var(--color-gray-200);+ border-top: 1px solid var(--border);margin: 1em 0;}@@ -2056,7 +1996,7 @@}.ProseMirror img.ProseMirror-selectednode {- outline: 2px solid var(--color-azure-blue);+ outline: 2px solid var(--ring);outline-offset: 2px;}@@ -2107,7 +2047,7 @@.ProseMirror th,.ProseMirror td {- border: 1px solid var(--color-gray-200);+ border: 1px solid var(--border);padding: 0.4em 0.6em;vertical-align: top;position: relative;@@ -2116,7 +2056,7 @@}.ProseMirror th {- background: var(--color-gray-50);+ background: var(--muted);font-weight: 600;text-align: left;}@@ -2167,7 +2107,7 @@/* Corner cell (first column + header row) must clear both frozen row layer andsticky column layer when both are active simultaneously. */.ProseMirror .tableWrapper > table > tbody > tr > th:first-child {- background-color: var(--color-gray-50);+ background-color: var(--muted);z-index: 3;}@@ -2987,6 +2927,50 @@ button:active:not(:disabled) {--syntax-string: var(--color-green-800, #22863a);--syntax-number: var(--color-blue-800, #005cc5);--syntax-atom: var(--color-orange-700, #d2691e);+ /*+ The remaining syntax roles. A selected color theme overrides all of these+ from its base16 slots; the values here are the `default` theme's own, so+ the same rules paint correctly with no palette applied.+ */+ --syntax-comment: var(--color-gray-500, #6a737d);+ --syntax-func: var(--color-purple-700, #6f42c1);+ --syntax-var: var(--color-red-700, #b31d28);+ --syntax-type: var(--color-yellow-700, #8b6500);+ --syntax-operator: var(--foreground);+ --syntax-meta: var(--color-gray-600, #6a737d);+ /* Code-block canvas — a hair off `--background` so a fence reads as a slab. */+ --syntax-bg: oklch(0.97 0 0);++ /* Editor affordances a theme repaints. */+ --link-color: var(--color-azure-blue);+ --broken-link-color: oklch(55% 0.15 25);+ --lint-warning-color: oklch(70% 0.15 75);+ --lint-error-color: oklch(55% 0.15 25);+ --diff-added: var(--color-green-800, #22863a);+ --diff-removed: var(--color-red-700, #b31d28);++ /*+ Terminal ANSI slots. The docked terminal reads these live, so a base16+ theme repaints program output, not just the terminal's chrome. The+ `default` theme has no palette to derive from, so it keeps the curated+ VS Code values these were before — tuned for legibility.+ */+ --ansi-black: #000000;+ --ansi-red: #cd3131;+ --ansi-green: #00bc00;+ --ansi-yellow: #949800;+ --ansi-blue: #0451a5;+ --ansi-magenta: #bc05bc;+ --ansi-cyan: #0598bc;+ --ansi-white: #555555;+ --ansi-bright-black: #666666;+ --ansi-bright-red: #cd3131;+ --ansi-bright-green: #14ce14;+ --ansi-bright-yellow: #b5ba00;+ --ansi-bright-blue: #0451a5;+ --ansi-bright-magenta: #bc05bc;+ --ansi-bright-cyan: #0598bc;+ --ansi-bright-white: #a5a5a5;}.dark {@@ -3041,6 +3025,37 @@ button:active:not(:disabled) {--syntax-string: var(--color-green-300, #7ee787);--syntax-number: var(--color-blue-300, #79c0ff);--syntax-atom: var(--color-orange-300, #ffa657);+ --syntax-comment: var(--color-gray-400, #8b949e);+ --syntax-func: var(--color-purple-300, #d2a8ff);+ --syntax-var: var(--color-red-300, #ffa198);+ --syntax-type: var(--color-yellow-300, #e3b341);+ --syntax-operator: var(--foreground);+ --syntax-meta: var(--color-gray-400, #8b949e);+ --syntax-bg: oklch(0.18 0.005 285);++ --link-color: var(--color-sky-blue);+ --broken-link-color: oklch(72% 0.18 25);+ --lint-warning-color: oklch(80% 0.13 80);+ --lint-error-color: oklch(72% 0.18 25);+ --diff-added: var(--color-green-300, #7ee787);+ --diff-removed: var(--color-red-300, #ffa198);++ --ansi-black: #000000;+ --ansi-red: #cd3131;+ --ansi-green: #0dbc79;+ --ansi-yellow: #e5e510;+ --ansi-blue: #2472c8;+ --ansi-magenta: #bc3fbc;+ --ansi-cyan: #11a8cd;+ --ansi-white: #e5e5e5;+ --ansi-bright-black: #666666;+ --ansi-bright-red: #f14c4c;+ --ansi-bright-green: #23d18b;+ --ansi-bright-yellow: #f5f543;+ --ansi-bright-blue: #3b8eea;+ --ansi-bright-magenta: #d670d6;+ --ansi-bright-cyan: #29b8db;+ --ansi-bright-white: #ffffff;}/*@@ -5162,40 +5177,10 @@ html.electron-mode [data-slot="sidebar-inner"] {/* Sidebar: separate hover (neutral gray) from active (blue accent) *//* Dark overrides — ProseMirror content surfaces */-.dark .ProseMirror blockquote {- border-color: var(--color-gray-600);- color: var(--color-gray-300);-}--.dark .ProseMirror pre {- background: var(--color-gray-900);-}--.dark .ProseMirror code {- background: var(--color-gray-800);-}-.dark .ProseMirror pre code {background: none;}-.dark .ProseMirror hr {- border-color: var(--color-gray-700);-}--.dark .ProseMirror th,-.dark .ProseMirror td {- border-color: var(--color-gray-700);-}--.dark .ProseMirror th {- background: var(--color-gray-900);-}--.dark .ProseMirror .tableWrapper > table > tbody > tr > th:first-child {- background: var(--color-gray-900);-}-/* Dark overrides — agent flash keyframes with boosted alpha for dark canvas */@keyframes agent-flash-dark {0% {@@ -5272,14 +5257,6 @@ html.electron-mode [data-slot="sidebar-inner"] {}/* Dark overrides — MEDIUM-severity items */-.dark .ProseMirror li[data-type="taskItem"] > label input[type="checkbox"] {- border-color: var(--color-gray-600);-}--.dark .ProseMirror li[data-type="taskItem"][data-checked="true"] > div {- color: var(--color-gray-500);-}-.dark .ProseMirror .selectedCell::after {background: var(--color-azure-900);opacity: 0.4;@@ -5330,15 +5307,9 @@ html.electron-mode [data-slot="sidebar-inner"] {.cm-link-ref-broken,.cm-editor .cm-md-internal-link.cm-md-link-broken,.cm-editor .cm-wiki-link.cm-wiki-link-broken {- color: var(--broken-link-color, oklch(55% 0.15 25));+ color: var(--broken-link-color);text-decoration: underline wavy;- text-decoration-color: var(--broken-link-color, oklch(55% 0.15 25));-}--.dark .cm-link-ref-broken,-.dark .cm-editor .cm-md-internal-link.cm-md-link-broken,-.dark .cm-editor .cm-wiki-link.cm-wiki-link-broken {- --broken-link-color: oklch(72% 0.18 25);+ text-decoration-color: var(--broken-link-color);}/* Markdown linter (@codemirror/lint) — re-theme the default diagnostic surfaces@@ -5348,30 +5319,24 @@ html.electron-mode [data-slot="sidebar-inner"] {our oklch palette. Severity colors: amber for warning, red for error. */.cm-editor .cm-lintRange-warning {background: none;- text-decoration: underline wavy var(--lint-warning-color, oklch(70% 0.15 75));+ text-decoration: underline wavy var(--lint-warning-color);text-underline-offset: 0.2em;}.cm-editor .cm-lintRange-error {background: none;- text-decoration: underline wavy var(--lint-error-color, oklch(55% 0.15 25));+ text-decoration: underline wavy var(--lint-error-color);text-underline-offset: 0.2em;}-.dark .cm-editor .cm-lintRange-warning {- --lint-warning-color: oklch(80% 0.13 80);-}-.dark .cm-editor .cm-lintRange-error {- --lint-error-color: oklch(72% 0.18 25);-}/* File-tree problem-indicator tokens (file-tree-problem-indicators.ts). The- editor's --lint-*-color tokens are scoped under .dark .cm-editor / .dark- .ProseMirror and never reach the tree's shadow root, so the tree gets its- own inheritable pair: light mode rides the var() fallback literals inside- the shadow CSS (same values as the editor's light fallbacks); this .dark- block carries the dark overrides across the shadow boundary via custom-- property inheritance. Values mirror the editor's dark lint palette. */-.dark {- --ok-tree-problem-warning: oklch(80% 0.13 80);- --ok-tree-problem-error: oklch(72% 0.18 25);+ tree renders inside a shadow root, and its CSS names this tree-owned pair+ rather than the editor's --lint-*-color directly. Aliasing them here at+ :root is what carries the active theme's lint colors across the shadow+ boundary — custom properties inherit through it, so both light and dark+ follow whichever theme resolved --lint-*-color. The var() fallback literals+ in the shadow CSS only apply if this block is missing. */+:root {+ --ok-tree-problem-warning: var(--lint-warning-color);+ --ok-tree-problem-error: var(--lint-error-color);}/* Diagnostic tooltip + lint panel onto OK popover tokens. */.cm-tooltip.cm-tooltip-lint,@@ -5385,10 +5350,10 @@ html.electron-mode [data-slot="sidebar-inner"] {border-left-width: 3px;}.cm-diagnostic-warning {- border-left-color: var(--lint-warning-color, oklch(70% 0.15 75));+ border-left-color: var(--lint-warning-color);}.cm-diagnostic-error {- border-left-color: var(--lint-error-color, oklch(55% 0.15 25));+ border-left-color: var(--lint-error-color);}.cm-diagnosticAction {background-color: var(--primary);@@ -5407,18 +5372,12 @@ html.electron-mode [data-slot="sidebar-inner"] {.ProseMirror .ok-lint-block {text-decoration-line: underline;text-decoration-style: wavy;- text-decoration-color: var(--lint-warning-color, oklch(70% 0.15 75));+ text-decoration-color: var(--lint-warning-color);text-decoration-skip-ink: none;text-underline-offset: 0.2em;}.ProseMirror .ok-lint-block.ok-lint-block-error {- text-decoration-color: var(--lint-error-color, oklch(55% 0.15 25));-}-.dark .ProseMirror .ok-lint-block {- --lint-warning-color: oklch(80% 0.13 80);-}-.dark .ProseMirror .ok-lint-block.ok-lint-block-error {- --lint-error-color: oklch(72% 0.18 25);+ text-decoration-color: var(--lint-error-color);}/* Textless blocks (thematic break, block image) carry no inline text, so thewavy text-decoration above paints nothing. Swap it for an outline that reads@@ -5426,12 +5385,12 @@ html.electron-mode [data-slot="sidebar-inner"] {the hover-tooltip lookup; here we cancel its (invisible) underline. */.ProseMirror .ok-lint-block-atom {text-decoration: none;- outline: 2px dashed var(--lint-warning-color, oklch(70% 0.15 75));+ outline: 2px dashed var(--lint-warning-color);outline-offset: 3px;border-radius: 3px;}.ProseMirror .ok-lint-block-atom.ok-lint-block-error {- outline-color: var(--lint-error-color, oklch(55% 0.15 25));+ outline-color: var(--lint-error-color);}/* Hover tooltip for a decorated lint block (markdown-lint-decorations.ts). Astyled, instant alternative to the native `title` — OK popover tokens,diff --git a/packages/app/src/hooks/use-theme-bridge.dom.test.tsx b/packages/app/src/hooks/use-theme-bridge.dom.test.tsxindex 160512d53..c1dcf3f18 100644--- a/packages/app/src/hooks/use-theme-bridge.dom.test.tsx+++ b/packages/app/src/hooks/use-theme-bridge.dom.test.tsx@@ -63,11 +63,13 @@ function makeRejectingBridge(rejectionError: Error): StubBridge {function HookProbe({bridge,themeValue,+ colorThemeKey,}: {bridge: OkDesktopBridge | undefined;themeValue: string | undefined;+ colorThemeKey?: string;}) {- useThemeBridge(bridge, themeValue);+ useThemeBridge(bridge, themeValue, colorThemeKey);return <div data-testid="theme-bridge-probe" />;}@@ -279,6 +281,78 @@ describe('useThemeBridge (Tier-3 mount)', () => {expect(stubBridge.signalThemeAppliedCalls.length).toBe(2);});+ test('reports chrome as hex even when the token is authored in a syntax Electron cannot parse', async () => {+ // The default theme authors `--sidebar` as `oklch(...)`. Electron's+ // setBackgroundColor / titleBarOverlay accept hex, rgb, hsl or a name —+ // forwarding the authored text loses the default theme's chrome entirely.+ document.documentElement.style.setProperty('--sidebar', 'oklch(0.985 0 0)');+ document.documentElement.style.setProperty('--sidebar-foreground', 'oklch(0.145 0 0)');+ const stubBridge = makeStubBridge();+ try {+ render(+ <HookProbe+ bridge={stubBridge as unknown as OkDesktopBridge}+ themeValue="light"+ colorThemeKey="default:"+ />,+ );+ await waitFor(+ () => {+ expect(stubBridge.signalThemeAppliedCalls.length).toBe(1);+ },+ { timeout: ASYNC_EFFECT_TIMEOUT_MS },+ );+ const chrome = stubBridge.signalThemeAppliedCalls[0]?.chrome;+ // Either the environment resolved the color (then it must be hex) or it+ // could not (then chrome is omitted) — never raw `oklch(...)`.+ if (chrome) {+ expect(chrome.bg).toMatch(/^#[0-9a-f]{6}$/);+ expect(chrome.symbol).toMatch(/^#[0-9a-f]{6}$/);+ }+ } finally {+ document.documentElement.style.removeProperty('--sidebar');+ document.documentElement.style.removeProperty('--sidebar-foreground');+ }+ });++ test('a same-mode palette switch re-reports chrome even though themeValue is unchanged', async () => {+ // Switching between two dark palettes (Dracula -> Monokai) leaves+ // `themeValue` at 'dark', so only the `colorThemeKey` signal changes. The+ // hook must still re-fire `signalThemeApplied` so main repaints the+ // OS-drawn titlebar for the new palette. Without `colorThemeKey` in the+ // effect deps, the effect never re-runs and the chrome stays stale.+ const stubBridge = makeStubBridge();+ const { rerender } = render(+ <HookProbe+ bridge={stubBridge as unknown as OkDesktopBridge}+ themeValue="dark"+ colorThemeKey="dracula:"+ />,+ );++ await waitFor(+ () => {+ expect(stubBridge.signalThemeAppliedCalls.length).toBe(1);+ },+ { timeout: ASYNC_EFFECT_TIMEOUT_MS },+ );++ rerender(+ <HookProbe+ bridge={stubBridge as unknown as OkDesktopBridge}+ themeValue="dark"+ colorThemeKey="monokai:"+ />,+ );++ await waitFor(+ () => {+ expect(stubBridge.signalThemeAppliedCalls.length).toBe(2);+ },+ { timeout: ASYNC_EFFECT_TIMEOUT_MS },+ );+ });+test('rejection path: signalThemeApplied still fires via .finally so the show-gate releases', async () => {// The gate-release contract: when the// IPC roundtrip rejects (channel teardown race, bootstrap orderingdiff --git a/packages/app/src/hooks/use-theme-bridge.test.ts b/packages/app/src/hooks/use-theme-bridge.test.tsindex 1ae90f4db..471077551 100644--- a/packages/app/src/hooks/use-theme-bridge.test.ts+++ b/packages/app/src/hooks/use-theme-bridge.test.ts@@ -1,4 +1,5 @@import { describe, expect, test } from 'vitest';+import { cssColorToHex } from './use-theme-bridge';describe('useThemeBridge — module surface', () => {test('exports the useThemeBridge hook', async () => {@@ -6,3 +7,43 @@ describe('useThemeBridge — module surface', () => {expect(typeof mod.useThemeBridge).toBe('function');});});++describe('cssColorToHex', () => {+ test('converts legacy rgb / rgba to hex', () => {+ expect(cssColorToHex('rgb(250, 250, 250)')).toBe('#fafafa');+ expect(cssColorToHex('rgb(23, 23, 23)')).toBe('#171717');+ // Alpha is dropped: the window chrome is a solid surface.+ expect(cssColorToHex('rgba(250, 250, 250, 0.5)')).toBe('#fafafa');+ // Space-separated is the modern serialization of the same legacy form.+ expect(cssColorToHex('rgb(250 250 250)')).toBe('#fafafa');+ });++ test('never derives a hex from a non-rgb color syntax', () => {+ // The regression: matching bare numbers against `oklch(0.985 0 0)` read+ // 0.985/0/0 as the channel triple and produced `#010000`, painting the+ // Linux window chrome near-black for the default theme. Without a real+ // conversion available, the answer must be null so the caller falls back+ // to the snapshot.+ for (const value of [+ 'oklch(0.985 0 0)',+ 'oklch(0.145 0 0)',+ 'color(srgb 0.98 0.98 0.98)',+ 'lab(97 0 0)',+ 'color-mix(in srgb, red, blue)',+ ]) {+ const hex = cssColorToHex(value);+ // Whatever the environment can do, it is either a real hex or nothing —+ // and in a canvas-less environment specifically, never `#010000`.+ expect(hex === null || /^#[0-9a-f]{6}$/.test(hex), `${value} -> ${hex}`).toBe(true);+ expect(hex).not.toBe('#010000');+ }+ });++ test('rejects values that are not colors at all', () => {+ expect(cssColorToHex('')).toBeNull();+ expect(cssColorToHex('var(--sidebar)')).toBeNull();+ expect(cssColorToHex('not a color')).toBeNull();+ expect(cssColorToHex('rgb(300, 0, 0)')).toBeNull();+ expect(cssColorToHex('rgb(1, 2)')).toBeNull();+ });+});diff --git a/packages/app/src/hooks/use-theme-bridge.ts b/packages/app/src/hooks/use-theme-bridge.tsindex 42b8cb275..1e691d2df 100644--- a/packages/app/src/hooks/use-theme-bridge.ts+++ b/packages/app/src/hooks/use-theme-bridge.ts@@ -2,41 +2,120 @@ import { useEffect } from 'react';import type { OkDesktopBridge } from '@/lib/desktop-bridge-types';/**- * Push the user-intent theme value to Electron main's- * `nativeTheme.themeSource` and signal cold-launch + reduced-transparency- * state to the show-gate. Single source of truth for the renderer→main- * theme-bridge wiring shared by `ConfigProvider` (CRDT-backed editor flow)- * and `NavigatorApp` (next-themes-backed launcher flow).+ * `rgb(250, 250, 250)` / `rgba(…)` -> `#fafafa`, or null for any other syntax.*- * The hook owns three concerns:+ * The `rgb(` prefix check is load-bearing. Matching bare numbers against an+ * arbitrary color string reads `oklch(0.985 0 0)` as the channel triple+ * `0.985, 0, 0` and yields `#010000` — a plausible-looking hex that paints the+ * window chrome near-black. Anything that isn't legacy rgb belongs to+ * `canvasHex` below, and an unrecognized value must be null so the caller falls+ * back to the snapshot rather than painting garbage.+ */+function rgbToHex(value: string): string | null {+ const body = /^rgba?\(([^)]*)\)$/i.exec(value.trim())?.[1];+ if (body === undefined) return null;+ const parts = body.split(/[\s,/]+/).filter(Boolean);+ if (parts.length < 3) return null;+ let hex = '#';+ for (let i = 0; i < 3; i++) {+ const n = Math.round(Number(parts[i]));+ if (!Number.isFinite(n) || n < 0 || n > 255) return null;+ hex += n.toString(16).padStart(2, '0');+ }+ return hex;+}++/**+ * Normalize any engine-recognized CSS color to `#rrggbb` through a canvas+ * `fillStyle` round-trip, which is defined to resolve into sRGB.+ *+ * Needed because `getComputedStyle` does NOT convert modern color syntax to+ * legacy rgb: Chromium reports a token authored as `oklch(…)` back as+ * `oklch(…)`, so the probe alone resolves `var()` chains without ever reaching+ * a form Electron can paint with.*- * 1. setThemeSource on every cold-launch / theme change. The user-intent- * string is forwarded verbatim — `'system'` is the lever for OS- * auto-tracking; resolving it here (matchMedia / ternary) would freeze- * chrome to one theme even when the user later flips macOS appearance.+ * `fillStyle` silently keeps its previous value when assigned something it+ * can't parse, so a single assignment can't distinguish "converted" from+ * "ignored". Assigning against two different sentinels does: a parsed color+ * lands on the same result both times, an ignored one keeps each sentinel.+ */+function canvasHex(value: string): string | null {+ if (typeof document === 'undefined') return null;+ const ctx = document.createElement('canvas').getContext('2d');+ if (!ctx) return null;+ ctx.fillStyle = '#000000';+ ctx.fillStyle = value;+ const first = ctx.fillStyle;+ ctx.fillStyle = '#ffffff';+ ctx.fillStyle = value;+ if (ctx.fillStyle !== first) return null;+ return typeof first === 'string' && /^#[0-9a-f]{6}$/i.test(first) ? first.toLowerCase() : null;+}++/**+ * A resolved CSS color as `#rrggbb`, or null when it can't be resolved to one.+ * Exported for the regression tests that pin the `#010000` class above.+ */+export function cssColorToHex(value: string): string | null {+ return canvasHex(value) ?? rgbToHex(value);+}++/**+ * Resolve one design token to a concrete `#rrggbb`.*- * 2. signalThemeApplied in `.finally(...)` so the cold-launch show-gate- * releases on both success and failure paths. If the IPC roundtrip- * rejects (channel teardown race, bootstrap ordering regression,- * future bridge-contract divergence), the gate would otherwise stall- * blank for the full 5 s safety timeout. A transient frame of- * mismatched chrome is strictly preferable to no window at all; the- * structured warn in `.catch(...)` keeps the failure observable.+ * The raw custom property can hold any CSS color syntax — the default theme+ * authors `--sidebar` as `oklch(…)`, and a custom scheme could use+ * `color-mix()`. Electron's `setBackgroundColor` / `titleBarOverlay` accept+ * hex, rgb, hsl or a name, so forwarding the authored text loses the default+ * theme entirely.*- * 3. Mid-session `prefers-reduced-transparency` toggles. When the user- * flips System Settings → Accessibility → Display → Reduce- * transparency, push the new value to main so vibrancy material is- * enabled / disabled live without an app restart.+ * Two steps, because neither alone suffices: the probe resolves `var()` chains+ * and relative color syntax, and `cssColorToHex` converts whatever color space+ * that lands in down to sRGB hex. `getComputedStyle` does not do the second —+ * Chromium reports an `oklch(…)` token back as `oklch(…)`.+ */+function resolveTokenHex(token: string): string | null {+ const probe = document.createElement('span');+ probe.style.display = 'none';+ probe.style.backgroundColor = `var(${token})`;+ document.body.appendChild(probe);+ try {+ const resolved = getComputedStyle(probe).backgroundColor;+ // Unset computes to the transparent initial value; an unresolved chain+ // still contains `var(`. Neither is a color main can paint with.+ if (!resolved || resolved === 'rgba(0, 0, 0, 0)' || resolved.includes('var(')) return null;+ return cssColorToHex(resolved);+ } finally {+ probe.remove();+ }+}++/**+ * The active palette's window-chrome colors, read off the live cascade.*- * Web / CLI distribution: the bridge is undefined and every effect- * early-returns. The initial cold-launch reading of- * `prefers-reduced-transparency` is sampled at signal time so chrome- * reflects the OS preference from frame 1.+ * `--sidebar` is the chrome row's own surface, so it's what the OS-drawn+ * titlebar overlay and the window's solid background should match. Main can't+ * compute this itself — it has no CSS engine, and a user-imported scheme has+ * no build-time representation there at all.*/+function readChromeColors(): { bg: string; symbol: string } | undefined {+ if (typeof document === 'undefined') return undefined;+ try {+ const bg = resolveTokenHex('--sidebar');+ const symbol = resolveTokenHex('--sidebar-foreground');+ if (!bg || !symbol) return undefined;+ return { bg, symbol };+ } catch {+ return undefined;+ }+}+export function useThemeBridge(bridge: OkDesktopBridge | undefined,themeValue: string | undefined,+ colorThemeKey?: string,): void {+ // biome-ignore lint/correctness/useExhaustiveDependencies: colorThemeKey is a signal-only dependency — a palette switch (e.g. Dracula -> Monokai, both dark) must re-run this effect to re-read + re-report chrome even though themeValue is unchanged; it is intentionally not referenced in the body.useEffect(() => {if (themeValue !== 'light' && themeValue !== 'dark' && themeValue !== 'system') return;if (!bridge) return;@@ -57,18 +136,23 @@ export function useThemeBridge(const reducedTransparency = window.matchMedia('(prefers-reduced-transparency: reduce)',).matches;- bridge.signalThemeApplied({ reducedTransparency });+ bridge.signalThemeApplied({ reducedTransparency, chrome: readChromeColors() });});return () => {cancelled = true;};- }, [bridge, themeValue]);+ // `colorThemeKey` participates so a palette switch re-reports chrome —+ // the OS-drawn titlebar tracks the color theme, not just light/dark.+ }, [bridge, themeValue, colorThemeKey]);useEffect(() => {if (!bridge) return;const mql = window.matchMedia('(prefers-reduced-transparency: reduce)');const handler = (event: MediaQueryListEvent) => {- bridge.signalThemeApplied({ reducedTransparency: event.matches });+ bridge.signalThemeApplied({+ reducedTransparency: event.matches,+ chrome: readChromeColors(),+ });};mql.addEventListener('change', handler);return () => {diff --git a/packages/app/src/lib/color-theme-epoch.dom.test.tsx b/packages/app/src/lib/color-theme-epoch.dom.test.tsxnew file mode 100644index 000000000..78d34b426--- /dev/null+++ b/packages/app/src/lib/color-theme-epoch.dom.test.tsx@@ -0,0 +1,53 @@+import { act, cleanup, render } from '@testing-library/react';+import { afterEach, describe, expect, test } from 'vitest';+import { useColorThemeEpoch } from './color-theme-epoch';++function Probe() {+ const epoch = useColorThemeEpoch();+ return <div data-testid="epoch">{epoch}</div>;+}++function epochOf(view: ReturnType<typeof render>): number {+ return Number(view.getByTestId('epoch').textContent);+}++/**+ * MutationObserver callbacks are delivered on the microtask queue; a macrotask+ * flush guarantees they have run and any resulting React re-render is committed.+ */+async function setColorThemeAndFlush(value: string): Promise<void> {+ await act(async () => {+ document.documentElement.setAttribute('data-color-theme', value);+ await new Promise((resolve) => setTimeout(resolve, 0));+ });+}++describe('useColorThemeEpoch', () => {+ afterEach(() => {+ cleanup();+ document.documentElement.removeAttribute('data-color-theme');+ });++ test('bumps when the data-color-theme attribute changes', async () => {+ const view = render(<Probe />);+ const before = epochOf(view);+ await setColorThemeAndFlush('dracula');+ expect(epochOf(view)).toBeGreaterThan(before);+ });++ test('tears the observer down when all subscribers leave and re-creates it on remount', async () => {+ // A single shared observer backs every subscriber; when the last one+ // unmounts it must disconnect AND null itself so a later mount re-creates+ // it. A broken teardown (disconnect without null) would leave a dead+ // observer that never fires again — the failure that silently stalls+ // palette-switch propagation for every remounted consumer.+ const first = render(<Probe />);+ await setColorThemeAndFlush('dracula');+ first.unmount();++ const second = render(<Probe />);+ const before = epochOf(second);+ await setColorThemeAndFlush('monokai');+ expect(epochOf(second)).toBeGreaterThan(before);+ });+});diff --git a/packages/app/src/lib/color-theme-epoch.ts b/packages/app/src/lib/color-theme-epoch.tsnew file mode 100644index 000000000..3b7da67c7--- /dev/null+++ b/packages/app/src/lib/color-theme-epoch.ts@@ -0,0 +1,61 @@+/**+ * A counter that bumps whenever the active color theme changes.+ *+ * The light/dark axis reaches React through `next-themes`, but the color-theme+ * axis has no React signal — `useApplyConfigColorTheme` lands it as DOM+ * mutations (the `data-color-theme` attribute, plus the runtime `<style>` a+ * custom scheme injects into `<head>`). Components that must recompute on a+ * palette switch subscribe here.+ *+ * One `MutationObserver` backs every subscriber, not one per component. The+ * consumers are per-instance and unbounded — a document can hold many preview+ * blocks — and a DOM observer is not a React effect, so a per-instance+ * observer would scale with content rather than with the single thing being+ * watched.+ */++import { useSyncExternalStore } from 'react';+import { COLOR_THEME_ATTRIBUTE } from './use-apply-config-color-theme';++let epoch = 0;+const listeners = new Set<() => void>();+let observer: MutationObserver | null = null;++function notify(): void {+ epoch += 1;+ for (const listener of listeners) listener();+}++function subscribe(listener: () => void): () => void {+ listeners.add(listener);+ if (!observer && typeof document !== 'undefined') {+ observer = new MutationObserver(notify);+ observer.observe(document.documentElement, {+ attributes: true,+ attributeFilter: [COLOR_THEME_ATTRIBUTE, 'class'],+ });+ // A custom scheme's palette lives in a <style> upserted into <head>; watch+ // its insertion, removal, and text swaps so live edits register too.+ observer.observe(document.head, { childList: true, subtree: true, characterData: true });+ }+ return () => {+ listeners.delete(listener);+ if (listeners.size === 0) {+ observer?.disconnect();+ observer = null;+ }+ };+}++function getSnapshot(): number {+ return epoch;+}++/** Server snapshot — no DOM to observe, so the epoch never advances. */+function getServerSnapshot(): number {+ return 0;+}++export function useColorThemeEpoch(): number {+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);+}diff --git a/packages/app/src/lib/color-themes.test.ts b/packages/app/src/lib/color-themes.test.tsindex 195047d20..524b2fe61 100644--- a/packages/app/src/lib/color-themes.test.ts+++ b/packages/app/src/lib/color-themes.test.ts@@ -1,51 +1,61 @@import { readFileSync } from 'node:fs';-import { resolve } from 'node:path';-import { ConfigSchema, resolveLeafSchema } from '@inkeep/open-knowledge-core';+import { dirname, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { BASE16_SLOTS, ConfigSchema, resolveLeafSchema } from '@inkeep/open-knowledge-core';import { describe, expect, test } from 'vitest';import { getEnumOptions } from '../components/settings/schema-walker';import {+ base16ToTokens,buildCustomThemeCss,COLOR_THEMES,- type ColorThemeBase,- type CustomThemeSeed,customThemeKind,- DEFAULT_CUSTOM_SEED,+ customThemeWritePatch,+ DEFAULT_CUSTOM_SCHEME,defaultThemeTokens,- expandCustomSeed,- expandPalette,generateColorThemesCss,+ hasLegacyCustomSeed,isDarkColorTheme,isHexColor,relativeLuminance,resolveColorTheme,- resolveCustomSeed,+ resolveCustomScheme,} from './color-themes';+const here = dirname(fileURLToPath(import.meta.url));const HEX = /^#[0-9a-f]{6}$/;-// Themes whose palette isn't a static, fully-authored `base`: `default` (no-// overlay) and `custom` (built at runtime from the user seed).+// Themes whose palette isn't a static, fully-authored scheme: `default` (no+// overlay) and `custom` (built at runtime from the user's scheme).const NON_STATIC = new Set(['default', 'custom']);describe('color-themes registry', () => {test('default is first; default + custom are the system-kind (non-static) themes', () => {expect(COLOR_THEMES[0]?.id).toBe('default');- expect(COLOR_THEMES[0]?.base).toBeUndefined();+ expect(COLOR_THEMES[0]?.scheme).toBeUndefined();const systemThemes = COLOR_THEMES.filter((t) => t.kind === 'system');expect(systemThemes.map((t) => t.id).sort()).toEqual(['custom', 'default']);});- test('every static theme carries a full base palette of 6-digit hex colors', () => {+ test('every static theme carries all sixteen base16 slots as 6-digit hex', () => {for (const theme of COLOR_THEMES) {if (NON_STATIC.has(theme.id)) continue;// Static built-ins force their own mode — dark or light.expect(['dark', 'light']).toContain(theme.kind);- expect(theme.base).toBeDefined();- for (const [key, value] of Object.entries(theme.base as ColorThemeBase)) {- expect(value, `${theme.id}.${key}`).toMatch(HEX);+ expect(theme.scheme).toBeDefined();+ const palette = theme.scheme?.palette;+ expect(Object.keys(palette ?? {}).sort()).toEqual([...BASE16_SLOTS].sort());+ for (const slot of BASE16_SLOTS) {+ expect(palette?.[slot], `${theme.id}.${slot}`).toMatch(HEX);}}});+ test("a built-in's kind matches its scheme variant", () => {+ for (const theme of COLOR_THEMES) {+ if (NON_STATIC.has(theme.id)) continue;+ expect(theme.kind, theme.id).toBe(theme.scheme?.variant);+ }+ });+test('ids are unique', () => {const ids = COLOR_THEMES.map((t) => t.id);expect(new Set(ids).size).toBe(ids.length);@@ -65,10 +75,14 @@ describe('color-themes registry', () => {});});-describe('expandPalette', () => {- test('emits every shadcn surface token the base .dark block defines', () => {- const tokens = expandPalette(COLOR_THEMES[1]?.base as ColorThemeBase);- // A representative slice across surface, accent, sidebar, and syntax families.+describe('base16ToTokens', () => {+ test('emits every token family a theme is expected to repaint', () => {+ const scheme = COLOR_THEMES[1]?.scheme;+ expect(scheme).toBeDefined();+ const tokens = base16ToTokens(scheme as NonNullable<(typeof COLOR_THEMES)[number]['scheme']>);+ // A representative slice across every family the mapping owns. The+ // callout / lint / ansi entries are the ones a theme previously could not+ // reach at all.for (const required of ['background','foreground',@@ -79,22 +93,40 @@ describe('expandPalette', () => {'destructive','border','ring',+ 'selection-soft','sidebar','sidebar-accent-foreground','chart-1','syntax-keyword','syntax-string',+ 'syntax-comment',+ 'syntax-bg',+ 'link-color',+ 'lint-error-color',+ 'callout-warning-color',+ 'callout-quote-color',+ 'ansi-red',+ 'ansi-bright-white',]) {expect(tokens[required], required).toBeTruthy();}});++ test('every emitted value is a literal — a theme block can carry no var() indirection', () => {+ for (const theme of COLOR_THEMES) {+ if (!theme.scheme) continue;+ for (const [name, value] of Object.entries(base16ToTokens(theme.scheme))) {+ expect(value, `${theme.id} --${name}`).not.toContain('var(');+ }+ }+ });});describe('defaultThemeTokens', () => {- // The tokens a theme preview reads off `expandPalette` output. `default` has- // no palette to expand, so these come from the base stylesheet instead — and- // must be literals, since a preview can't read `var(--…)` out from under an- // active palette override.+ // The tokens a theme preview reads off the token map. `default` has no scheme+ // to map, so these come from the base stylesheet instead — and must be+ // literals, since a preview can't read `var(--…)` out from under an active+ // palette override.const SWATCH_TOKENS = ['sidebar','background',@@ -126,15 +158,15 @@ describe('defaultThemeTokens', () => {});describe('generated stylesheet', () => {- test('color-themes.generated.css is in sync with the registry (run `bun run gen:color-themes`)', () => {- const onDisk = readFileSync(resolve(import.meta.dir, '../color-themes.generated.css'), 'utf8');+ test('color-themes.generated.css is in sync with the registry (run `pnpm run gen:color-themes`)', () => {+ const onDisk = readFileSync(resolve(here, '../color-themes.generated.css'), 'utf8');expect(onDisk).toBe(generateColorThemesCss());});test('emits one attribute-scoped rule per static IDE theme and none for default/custom', () => {const css = generateColorThemesCss();expect(css).not.toContain('data-color-theme="default"');- // `custom` has no static base — its rule is built at runtime, not generated.+ // `custom` has no static scheme — its rule is built at runtime, not generated.expect(css).not.toContain('data-color-theme="custom"');for (const theme of COLOR_THEMES) {if (NON_STATIC.has(theme.id)) continue;@@ -154,7 +186,7 @@ describe('registry stays in sync with its consumers', () => {// The pre-paint script in index.html can't import this module, so it// hardcodes the id allowlist. `default` (no overlay) and `custom` (replayed// from a cached <style>, not the static allowlist) are handled separately.- const html = readFileSync(resolve(import.meta.dir, '../../index.html'), 'utf8');+ const html = readFileSync(resolve(here, '../../index.html'), 'utf8');for (const theme of COLOR_THEMES) {if (theme.id === 'default' || theme.id === 'custom') continue;expect(html, theme.id).toContain(`'${theme.id}'`);@@ -167,7 +199,7 @@ describe('registry stays in sync with its consumers', () => {// (`[...].includes(ct)`). Adding a light theme must update that array too, or// the new theme would flash dark on first paint. This asserts the two stay in// lockstep (the light-kind analog of the allowlist-presence check above).- const html = readFileSync(resolve(import.meta.dir, '../../index.html'), 'utf8');+ const html = readFileSync(resolve(here, '../../index.html'), 'utf8');const match = html.match(/\[([^\]]*)\]\.includes\(ct\)/);expect(match, 'FOUC light-theme array (`[...].includes(ct)`) not found in index.html').not.toBe(null,@@ -184,9 +216,18 @@ describe('registry stays in sync with its consumers', () => {const leaf = resolveLeafSchema(ConfigSchema, ['appearance', 'colorTheme']);expect([...(leaf ? (getEnumOptions(leaf) ?? []) : [])]).toContain('custom');});++ test('every base16 slot is settable under appearance.customTheme', () => {+ for (const slot of BASE16_SLOTS) {+ expect(+ resolveLeafSchema(ConfigSchema, ['appearance', 'customTheme', slot]),+ slot,+ ).toBeDefined();+ }+ });});-describe('custom theme seed', () => {+describe('custom theme scheme', () => {test('isHexColor accepts #rrggbb only', () => {expect(isHexColor('#0f172a')).toBe(true);expect(isHexColor('#FFF')).toBe(false);@@ -203,28 +244,77 @@ describe('custom theme seed', () => {expect(relativeLuminance('#f1f5f9')).toBeGreaterThan(0.5);});- test('customThemeKind derives mode from the background luminance', () => {- expect(customThemeKind({ ...DEFAULT_CUSTOM_SEED, background: '#0f172a' })).toBe('dark');- expect(customThemeKind({ ...DEFAULT_CUSTOM_SEED, background: '#fefefe' })).toBe('light');+ test('customThemeKind reports the scheme variant', () => {+ expect(customThemeKind(DEFAULT_CUSTOM_SCHEME)).toBe('dark');+ expect(customThemeKind({ ...DEFAULT_CUSTOM_SCHEME, variant: 'light' })).toBe('light');});- test('resolveCustomSeed merges valid fields over the default and drops bad hex', () => {- const seed = resolveCustomSeed({- background: '#123456',- primary: 'not-a-hex',- accent: undefined,+ test('resolveCustomScheme returns the full default for an absent value', () => {+ expect(resolveCustomScheme(undefined)).toEqual(DEFAULT_CUSTOM_SCHEME);+ });++ test('resolveCustomScheme merges valid slots over the default and drops bad hex', () => {+ const scheme = resolveCustomScheme({+ base00: '#123456',+ base0D: 'not-a-hex',+ base0B: undefined,});- expect(seed.background).toBe('#123456');- expect(seed.primary).toBe(DEFAULT_CUSTOM_SEED.primary);- expect(seed.accent).toBe(DEFAULT_CUSTOM_SEED.accent);+ expect(scheme.palette.base00).toBe('#123456');+ expect(scheme.palette.base0D).toBe(DEFAULT_CUSTOM_SCHEME.palette.base0D);+ expect(scheme.palette.base0B).toBe(DEFAULT_CUSTOM_SCHEME.palette.base0B);+ });++ test('resolveCustomScheme infers variant from the ramp when absent', () => {+ expect(resolveCustomScheme({ base00: '#0a0a0a', base05: '#fafafa' }).variant).toBe('dark');+ expect(resolveCustomScheme({ base00: '#fafafa', base05: '#0a0a0a' }).variant).toBe('light');});- test('resolveCustomSeed returns the full default for an absent seed', () => {- expect(resolveCustomSeed(undefined)).toEqual(DEFAULT_CUSTOM_SEED);+ test('resolveCustomScheme honors an explicit variant over the inferred one', () => {+ expect(resolveCustomScheme({ base00: '#0a0a0a', variant: 'light' }).variant).toBe('light');});- test('expandCustomSeed maps the six seeds onto the base palette', () => {- const seed: CustomThemeSeed = {+ test('upgrades a pre-base16 six-color seed instead of discarding it', () => {+ // Config written by an older build carries semantic seed names and no+ // slots; the palette must be reconstructed rather than silently reset.+ const scheme = resolveCustomScheme({+ background: '#101010',+ surface: '#202020',+ foreground: '#fafafa',+ primary: '#3366ff',+ accent: '#33ddcc',+ border: '#303030',+ });+ expect(scheme.palette.base00).toBe('#101010');+ expect(scheme.palette.base01).toBe('#202020');+ expect(scheme.palette.base02).toBe('#303030');+ expect(scheme.palette.base05).toBe('#fafafa');+ // `primary` drove the accent, which is base0D's role.+ expect(scheme.palette.base0D).toBe('#3366ff');+ expect(scheme.variant).toBe('dark');+ for (const slot of BASE16_SLOTS) {+ expect(scheme.palette[slot], slot).toMatch(HEX);+ }+ });++ test('a partial legacy seed merges over the default instead of resetting it', () => {+ // The old editor only wrote the fields a user changed, and configs get+ // hand-edited a field at a time — dropping a partial seed would silently+ // discard a customization.+ const scheme = resolveCustomScheme({ background: '#101010' });+ expect(scheme.palette.base00).toBe('#101010');+ expect(scheme.palette.base0D).toBe(DEFAULT_CUSTOM_SCHEME.palette.base0D);+ });++ test('an object carrying neither slots nor legacy fields yields the default', () => {+ expect(resolveCustomScheme({ unrelated: 'value' })).toEqual(DEFAULT_CUSTOM_SCHEME);+ });++ test('a half-migrated config keeps the legacy palette under the edited slot', () => {+ // The upgrade path a real user walks: they had a custom theme, then nudge+ // one slot in the new editor. If explicit slots layered over the DEFAULT+ // scheme rather than over their upgraded seed, the other fifteen would+ // snap back to slate and their theme would be gone.+ const legacy = {background: '#101010',surface: '#202020',foreground: '#fafafa',@@ -232,24 +322,82 @@ describe('custom theme seed', () => {accent: '#33ddcc',border: '#303030',};- const base = expandCustomSeed(seed);- expect(base.bg).toBe('#101010');- expect(base.bgElevated).toBe('#202020');- expect(base.fg).toBe('#fafafa');- expect(base.primary).toBe('#3366ff');- expect(base.blue).toBe('#33ddcc');- // Text on a dark primary is white; muted text is a derived color-mix.- expect(base.primaryFg).toBe('#ffffff');- expect(base.fgMuted).toContain('color-mix');- });-- test('buildCustomThemeCss emits a custom-scoped rule with the seed + matching color-scheme', () => {- const css = buildCustomThemeCss({ ...DEFAULT_CUSTOM_SEED, background: '#0a0a0a' });+ const scheme = resolveCustomScheme({ ...legacy, base0D: '#ff0000' });+ expect(scheme.palette.base0D).toBe('#ff0000');+ expect(scheme.palette.base00).toBe('#101010');+ expect(scheme.palette.base01).toBe('#202020');+ expect(scheme.palette.base02).toBe('#303030');+ expect(scheme.palette.base05).toBe('#fafafa');+ });+});++describe('customThemeWritePatch', () => {+ test('writes every slot plus the metadata', () => {+ const patch = customThemeWritePatch(DEFAULT_CUSTOM_SCHEME);+ expect(patch.name).toBe(DEFAULT_CUSTOM_SCHEME.name);+ expect(patch.variant).toBe(DEFAULT_CUSTOM_SCHEME.variant);+ for (const slot of BASE16_SLOTS) {+ expect(patch[slot], slot).toBe(DEFAULT_CUSTOM_SCHEME.palette[slot]);+ }+ });++ test('nulls the pre-base16 seed keys so a patch deletes them', () => {+ // `null` in a config patch is a key deletion. Without this the old six+ // colors linger in config.yml forever as dead, half-format data.+ const patch = customThemeWritePatch(DEFAULT_CUSTOM_SCHEME);+ for (const key of ['background', 'surface', 'foreground', 'primary', 'accent', 'border']) {+ expect(patch[key], key).toBeNull();+ }+ });++ test('the written patch resolves back to the same scheme', () => {+ // Round-trip through the reader: what we persist must reconstruct exactly,+ // including after the legacy keys are gone.+ const patch = customThemeWritePatch(DEFAULT_CUSTOM_SCHEME);+ const persisted = Object.fromEntries(+ Object.entries(patch).filter(([, v]) => v !== null),+ ) as Record<string, unknown>;+ expect(resolveCustomScheme(persisted)).toEqual(DEFAULT_CUSTOM_SCHEME);+ });++ test("carries an imported scheme's author credit through the round-trip", () => {+ // The reader accepts `author`, so a patch that omits it silently drops the+ // credit line of any upstream scheme the user imported.+ const credited = { ...DEFAULT_CUSTOM_SCHEME, author: 'Zeno Rocha' };+ const patch = customThemeWritePatch(credited);+ expect(patch.author).toBe('Zeno Rocha');++ const persisted = Object.fromEntries(+ Object.entries(patch).filter(([, v]) => v !== null),+ ) as Record<string, unknown>;+ expect(resolveCustomScheme(persisted)).toEqual(credited);+ });++ test('nulls author when the scheme has none, so a previous credit is cleared', () => {+ const patch = customThemeWritePatch(DEFAULT_CUSTOM_SCHEME);+ expect(patch.author).toBeNull();+ });+});++describe('hasLegacyCustomSeed', () => {+ test('detects a pre-base16 config and ignores a pure base16 one', () => {+ expect(hasLegacyCustomSeed({ background: '#101010' })).toBe(true);+ expect(hasLegacyCustomSeed({ base00: '#101010' })).toBe(false);+ expect(hasLegacyCustomSeed(undefined)).toBe(false);+ // A non-color value is not a seed to migrate.+ expect(hasLegacyCustomSeed({ background: 'nope' })).toBe(false);+ });++ test('buildCustomThemeCss emits a custom-scoped rule with a matching color-scheme', () => {+ const css = buildCustomThemeCss({+ ...DEFAULT_CUSTOM_SCHEME,+ palette: { ...DEFAULT_CUSTOM_SCHEME.palette, base00: '#0a0a0a' },+ });expect(css).toContain('html[data-color-theme="custom"] {');expect(css).toContain('color-scheme: dark;');expect(css).toContain('--background: #0a0a0a;');- const lightCss = buildCustomThemeCss({ ...DEFAULT_CUSTOM_SEED, background: '#fafafa' });+ const lightCss = buildCustomThemeCss({ ...DEFAULT_CUSTOM_SCHEME, variant: 'light' });expect(lightCss).toContain('color-scheme: light;');});});diff --git a/packages/app/src/lib/color-themes.ts b/packages/app/src/lib/color-themes.tsindex 0b415ade2..b8c032858 100644--- a/packages/app/src/lib/color-themes.ts+++ b/packages/app/src/lib/color-themes.ts@@ -1,36 +1,43 @@/*** App-facing barrel for the IDE color themes.*- * The built-in theme registry + its pure token logic now live in- * `@inkeep/open-knowledge-core` (`theme/theme-plugins.ts`) as a `ThemePlugin`- * registry — moved there so the `appearance.colorTheme` config enum can be- * DERIVED from it (core can't import app). This module re-exports those under the- * app's existing names and keeps the **custom theme** seed logic, which is- * app-only (built at runtime from the user's six-color seed; not part of the- * built-in plugin registry).+ * The built-in theme registry + its pure token logic live in+ * `@inkeep/open-knowledge-core` (`theme/theme-plugins.ts` + `theme/base16.ts`)+ * as a `ThemePlugin` registry — moved there so the `appearance.colorTheme`+ * config enum can be DERIVED from it (core can't import app). This module+ * re-exports those under the app's existing names and keeps the **custom+ * theme** resolution, which is app-only (built at runtime from the user's+ * imported or hand-edited scheme; not part of the built-in registry).*/import {+ BASE16_SLOTS,+ type Base16Palette,+ type Base16Scheme,+ base16ToTokens,CHROME_BG_DARK,CHROME_BG_LIGHT,- type ColorThemeBase,colorThemeMode,- expandPalette,generateColorThemesCss,+ isBase16Hex,isDarkTheme,+ mixHex,PREVIEW_THEME_TOKENS,+ relativeLuminance,+ renderThemeBlock,resolveThemePlugin,THEME_PLUGINS,type ThemePlugin,} from '@inkeep/open-knowledge-core';-export type { ColorThemeBase };+export type { Base16Scheme };// Re-export the core registry + pure token logic under the app's existing names.export {+ base16ToTokens,colorThemeMode,- expandPalette,generateColorThemesCss,isDarkTheme as isDarkColorTheme,+ relativeLuminance,resolveThemePlugin as resolveColorTheme,THEME_PLUGINS as COLOR_THEMES,};@@ -39,8 +46,8 @@ export type ColorTheme = ThemePlugin;// ---------------------------------------------------------------------------// Default theme — the base `:root` / `.dark` palette (`colorTheme: 'default'`).//-// `default` carries no `ColorThemeBase`: its palette is the app's own stylesheet.-// A preview of it therefore can't read `var(--background)` & co., because a+// `default` carries no scheme: its palette is the app's own stylesheet. A+// preview of it therefore can't read `var(--background)` & co., because a// selected palette overrides exactly those custom properties on `<html>` and the// preview inherits the override — the preview would mirror whatever theme is// active instead of showing what `default` looks like. So resolve the handful of@@ -60,7 +67,7 @@ function baseToken(name: string, mode: 'light' | 'dark'): string {}/**- * The subset of `expandPalette`-shaped tokens describing the default theme in a+ * The subset of `base16ToTokens`-shaped tokens describing the default theme in a* given light/dark mode, so a preview can paint it the same way it paints a* built-in palette. `--sidebar` comes from the chrome constants (the same token* the window chrome uses); the rest from the preview-token set. Syntax colors@@ -80,119 +87,213 @@ export function defaultThemeTokens(mode: 'light' | 'dark'): Record<string, strin}// ----------------------------------------------------------------------------// Custom theme — the user's own palette (`appearance.colorTheme: 'custom'`).+// Custom theme — the user's own scheme (`appearance.colorTheme: 'custom'`).//// Unlike the built-ins, a custom palette is unknown at build time, so its CSS-// is generated at runtime from a six-color seed and injected as a <style> tag-// (see `useApplyConfigColorTheme`). The seed expands to a full `ColorThemeBase`-// here, then through the same `expandPalette` the built-ins use — one-// token-mapping source for both.+// is generated at runtime and injected as a <style> tag (see+// `useApplyConfigColorTheme`). It runs through the same `base16ToTokens` the+// built-ins use — one token-mapping source for both, so an imported scheme and+// a shipped one are indistinguishable downstream.// ----------------------------------------------------------------------------/** The six user-editable seed colors for the custom theme. All `#rrggbb`. */-export interface CustomThemeSeed {- /** Editor canvas background. */+/** A tasteful slate/indigo dark scheme so a fresh custom theme is usable immediately. */+export const DEFAULT_CUSTOM_SCHEME: Base16Scheme = {+ name: 'Custom',+ variant: 'dark',+ palette: {+ base00: '#0f172a',+ base01: '#1e293b',+ base02: '#334155',+ base03: '#64748b',+ base04: '#94a3b8',+ base05: '#e2e8f0',+ base06: '#f1f5f9',+ base07: '#f8fafc',+ base08: '#e5534b',+ base09: '#db8d3f',+ base0A: '#d29922',+ base0B: '#3fb950',+ base0C: '#22d3ee',+ base0D: '#6366f1',+ base0E: '#a78bfa',+ base0F: '#c2703f',+ },+};++/**+ * The pre-base16 custom-theme shape: six seed colors the app expanded into a+ * full palette. Config written by an older build still carries it, so it is+ * upgraded on read rather than discarded.+ */+interface LegacyCustomSeed {background: string;- /** Elevated surfaces — cards, sidebar, popovers. */surface: string;- /** Primary text. */foreground: string;- /** Accent for buttons, links, focus ring. */primary: string;- /** Secondary accent — syntax highlights, charts. */accent: string;- /** Hairline borders + inputs. */border: string;}-const HEX_RE = /^#[0-9a-fA-F]{6}$/;+const LEGACY_SEED_KEYS: (keyof LegacyCustomSeed)[] = [+ 'background',+ 'surface',+ 'foreground',+ 'primary',+ 'accent',+ 'border',+];-/** A tasteful slate/indigo dark default so a fresh custom theme is usable immediately. */-export const DEFAULT_CUSTOM_SEED: CustomThemeSeed = {- background: '#0f172a',- surface: '#1e293b',- foreground: '#e2e8f0',- primary: '#6366f1',- accent: '#22d3ee',- border: '#334155',-};+/**+ * Widen a legacy six-color seed into a scheme. The tonal ramp is interpolated+ * between the seed's background and foreground; the accent slots reproduce the+ * old expansion exactly — `primary` took the blue slot, `accent` drove+ * cyan/purple, and red/green/yellow/orange were fixed legible defaults.+ */+function schemeFromLegacySeed(seed: LegacyCustomSeed): Base16Scheme {+ const { background: bg, foreground: fg } = seed;+ return {+ name: 'Custom',+ variant: relativeLuminance(bg) < relativeLuminance(fg) ? 'dark' : 'light',+ palette: {+ base00: bg,+ base01: seed.surface,+ base02: seed.border,+ base03: mixHex(bg, fg, 0.4),+ base04: mixHex(bg, fg, 0.55),+ base05: fg,+ base06: mixHex(fg, '#ffffff', 0.3),+ base07: mixHex(fg, '#ffffff', 0.6),+ base08: '#e5534b',+ base09: '#db8d3f',+ base0A: '#d29922',+ base0B: '#3fb950',+ base0C: seed.accent,+ base0D: seed.primary,+ base0E: seed.accent,+ base0F: mixHex('#e5534b', bg, 0.35),+ },+ };+}export function isHexColor(value: unknown): value is string {- return typeof value === 'string' && HEX_RE.test(value);+ return isBase16Hex(value);+}++type CustomThemeInput = Record<string, unknown> | undefined;++/** The default scheme expressed in the legacy seed's vocabulary. */+function defaultLegacySeed(): LegacyCustomSeed {+ const p = DEFAULT_CUSTOM_SCHEME.palette;+ return {+ background: p.base00,+ surface: p.base01,+ foreground: p.base05,+ primary: p.base0D,+ accent: p.base0C,+ border: p.base02,+ };}/**- * Merge a (possibly partial / hand-edited) config seed over the default,- * dropping any field that isn't a valid `#rrggbb` hex so a typo can't break the- * whole palette.+ * Collect whatever legacy seed fields a config carries, over the default.+ *+ * Partial is the common case, not an error: the old editor wrote only the+ * fields a user changed, and a hand-edited config may set one. Returns `null`+ * only when no legacy field is present at all, so the caller can tell "nothing+ * to upgrade" from "upgrade this".*/-export function resolveCustomSeed(- partial: Partial<Record<keyof CustomThemeSeed, unknown>> | undefined,-): CustomThemeSeed {- const seed = { ...DEFAULT_CUSTOM_SEED };- if (partial) {- for (const key of Object.keys(DEFAULT_CUSTOM_SEED) as (keyof CustomThemeSeed)[]) {- const v = partial[key];- if (isHexColor(v)) seed[key] = v;+function readLegacySeed(partial: Record<string, unknown>): LegacyCustomSeed | null {+ const seed = defaultLegacySeed();+ let found = false;+ for (const key of LEGACY_SEED_KEYS) {+ const v = partial[key];+ // A malformed value is dropped rather than propagated, so one typo can't+ // break the whole palette.+ if (isBase16Hex(v)) {+ seed[key] = v;+ found = true;}}- return seed;+ return found ? seed : null;}-/** sRGB relative luminance (WCAG) of a `#rrggbb` color, 0 (black) … 1 (white). */-export function relativeLuminance(hex: string): number {- const h = isHexColor(hex) ? hex : '#000000';- const channel = (i: number) => {- const c = Number.parseInt(h.slice(1 + i * 2, 3 + i * 2), 16) / 255;- return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;- };- return 0.2126 * channel(0) + 0.7152 * channel(1) + 0.0722 * channel(2);+/** True when a config still carries any of the pre-base16 seed colors. */+export function hasLegacyCustomSeed(partial: CustomThemeInput): boolean {+ return partial ? LEGACY_SEED_KEYS.some((key) => isBase16Hex(partial[key])) : false;}-/** A custom seed is dark when its background is dark — drives the `.dark` class + `color-scheme`. */-export function customThemeKind(seed: CustomThemeSeed): 'light' | 'dark' {- return relativeLuminance(seed.background) < 0.5 ? 'dark' : 'light';-}+/**+ * Resolve a (possibly partial / hand-edited / legacy) config value into a+ * scheme.+ *+ * Precedence is layered, lowest first: the default scheme, then a pre-base16+ * six-color seed upgraded into slots, then any explicit base16 slot. The+ * middle layer is what makes a half-migrated config safe — a user who had a+ * custom theme and then nudges ONE slot in the new editor keeps the other+ * fifteen instead of having them snap back to the default. Malformed values+ * are dropped at every layer, so one typo can't break the whole palette.+ */+export function resolveCustomScheme(partial: CustomThemeInput): Base16Scheme {+ if (!partial) return DEFAULT_CUSTOM_SCHEME;++ const legacy = readLegacySeed(partial);+ const base = legacy ? schemeFromLegacySeed(legacy) : DEFAULT_CUSTOM_SCHEME;-/** Text color that reads on top of `bg` — white on dark, near-black on light. */-function contrastingText(bg: string): string {- return relativeLuminance(bg) < 0.5 ? '#ffffff' : '#0a0a0a';+ const palette = { ...base.palette } as Base16Palette;+ for (const slot of BASE16_SLOTS) {+ const v = partial[slot];+ if (isBase16Hex(v)) palette[slot] = v;+ }+ const variant =+ partial.variant === 'light' || partial.variant === 'dark'+ ? partial.variant+ : relativeLuminance(palette.base00) < relativeLuminance(palette.base05)+ ? 'dark'+ : 'light';+ return {+ name: typeof partial.name === 'string' && partial.name.trim() ? partial.name.trim() : 'Custom',+ author: typeof partial.author === 'string' ? partial.author : undefined,+ variant,+ palette,+ };}/**- * Expand the six-color seed into a full `ColorThemeBase`. Text-on-accent and- * muted text are derived (luminance pick + `color-mix`); the semantic accent- * hues (red/green/yellow/orange) are fixed, legible-on-either-mode defaults,- * while blue/cyan/purple track the user's `accent` so syntax + charts stay- * on-brand.+ * The `appearance.customTheme` patch that writes `scheme` in full and retires+ * the pre-base16 seed keys.+ *+ * `null` deletes a key in a config patch, so a config that still carries the+ * old six colors is normalized to pure base16 the first time the user changes+ * anything — no stale half-format left behind, and no `ok config migrate` for+ * what is only a personal color preference.*/-export function expandCustomSeed(seed: CustomThemeSeed): ColorThemeBase {- return {- bg: seed.background,- bgElevated: seed.surface,- bgSubtle: seed.surface,- fg: seed.foreground,- fgMuted: `color-mix(in oklab, ${seed.foreground} 55%, ${seed.background})`,- border: seed.border,- primary: seed.primary,- primaryFg: contrastingText(seed.primary),- red: '#e5534b',- green: '#3fb950',- yellow: '#d29922',- blue: seed.accent,- cyan: seed.accent,- orange: '#db8d3f',- purple: seed.accent,+export function customThemeWritePatch(scheme: Base16Scheme): Record<string, string | null> {+ const out: Record<string, string | null> = {+ name: scheme.name,+ // A scheme without a credit line must clear a previous one, or the author+ // of an imported scheme would outlive the scheme it credited.+ author: scheme.author ?? null,+ variant: scheme.variant,};+ for (const slot of BASE16_SLOTS) out[slot] = scheme.palette[slot];+ for (const key of LEGACY_SEED_KEYS) out[key] = null;+ return out;+}++/** A custom scheme's forced light/dark mode — drives the `.dark` class + `color-scheme`. */+export function customThemeKind(scheme: Base16Scheme): 'light' | 'dark' {+ return scheme.variant;}/*** Build the runtime stylesheet for the active custom theme: one* `html[data-color-theme="custom"]` rule with the full expanded token set and a- * `color-scheme` matching the seed's light/dark kind.+ * `color-scheme` matching the scheme's variant.*/-export function buildCustomThemeCss(seed: CustomThemeSeed): string {- const tokens = expandPalette(expandCustomSeed(seed));- const lines = Object.entries(tokens).map(([name, value]) => ` --${name}: ${value};`);- return `html[data-color-theme="custom"] {\n color-scheme: ${customThemeKind(seed)};\n${lines.join('\n')}\n}`;+export function buildCustomThemeCss(scheme: Base16Scheme): string {+ return renderThemeBlock(+ 'html[data-color-theme="custom"]',+ scheme.variant,+ base16ToTokens(scheme),+ );}diff --git a/packages/app/src/lib/config-provider.tsx b/packages/app/src/lib/config-provider.tsxindex 724370643..12d94ec4a 100644--- a/packages/app/src/lib/config-provider.tsx+++ b/packages/app/src/lib/config-provider.tsx@@ -42,7 +42,7 @@ import { type ReactNode, useEffect, useState } from 'react';import * as Y from 'yjs';import { useThemeBridge } from '@/hooks/use-theme-bridge';import { buildAuthToken } from './auth-token';-import { colorThemeMode, customThemeKind, resolveCustomSeed } from './color-themes';+import { colorThemeMode, customThemeKind, resolveCustomScheme } from './color-themes';import { ConfigContext, type ConfigContextValue } from './config-context';import { useServerInstanceId } from './server-instance-store';import { useApplyConfigColorTheme } from './use-apply-config-color-theme';@@ -295,7 +295,7 @@ export function ConfigProvider({const effectiveMode = !colorThemeEnabled? themeValue: colorThemeValue === 'custom'- ? customThemeKind(resolveCustomSeed(customSeed))+ ? customThemeKind(resolveCustomScheme(customSeed)): (colorThemeMode(colorThemeValue) ?? themeValue);// Bridge the effective mode from the merged config into next-themes app-wide.// The hook owns the dependency discipline that prevents a cross-window@@ -324,9 +324,17 @@ export function ConfigProvider({// (`runBootstrap` sets `nativeTheme.themeSource = 'system'`) and// `next-themes`' `defaultTheme="system"`, so chrome reflects the OS// appearance from frame 1 and the gate releases promptly.+ //+ // The third argument re-fires the signal on a palette switch (not just a+ // light/dark flip) so the OS-drawn chrome tracks the active color theme. It+ // serializes the custom seed too — editing a custom scheme's `--sidebar`+ // should repaint the titlebar live.useThemeBridge(typeof window !== 'undefined' ? window.okDesktop : undefined,effectiveMode ?? 'system',+ `${colorThemeEnabled ? colorThemeValue : 'default'}:${+ colorThemeValue === 'custom' ? JSON.stringify(customSeed ?? null) : ''+ }`,);const value: ConfigContextValue = {diff --git a/packages/app/src/lib/desktop-bridge-types.ts b/packages/app/src/lib/desktop-bridge-types.tsindex 1e805db02..3e7fc9447 100644--- a/packages/app/src/lib/desktop-bridge-types.ts+++ b/packages/app/src/lib/desktop-bridge-types.ts@@ -998,7 +998,10 @@ export interface OkDesktopBridge {* value — main toggles vibrancy material accordingly. See canonical* JSDoc in `packages/desktop/src/shared/bridge-contract.ts`.*/- signalThemeApplied(opts?: { reducedTransparency?: boolean }): void;+ signalThemeApplied(opts?: {+ reducedTransparency?: boolean;+ chrome?: { bg: string; symbol: string };+ }): void;dialog: {openFolder(opts?: { defaultPath?: string }): Promise<string | null>;};diff --git a/packages/app/src/lib/use-apply-config-color-theme.ts b/packages/app/src/lib/use-apply-config-color-theme.tsindex d40b8599d..30b3e8dba 100644--- a/packages/app/src/lib/use-apply-config-color-theme.ts+++ b/packages/app/src/lib/use-apply-config-color-theme.ts@@ -1,10 +1,9 @@import { useEffect } from 'react';import {buildCustomThemeCss,- type CustomThemeSeed,customThemeKind,resolveColorTheme,- resolveCustomSeed,+ resolveCustomScheme,} from './color-themes';/** localStorage key the FOUC script in `index.html` reads pre-paint. Keep both in sync. */@@ -19,7 +18,7 @@ export const COLOR_THEME_ATTRIBUTE = 'data-color-theme';/** id of the runtime `<style>` element holding the active custom palette. */export const CUSTOM_THEME_STYLE_ID = 'ok-custom-theme';-type SeedInput = Partial<Record<keyof CustomThemeSeed, unknown>> | undefined;+type SeedInput = Record<string, unknown> | undefined;function upsertCustomStyle(css: string): void {let style = document.getElementById(CUSTOM_THEME_STYLE_ID) as HTMLStyleElement | null;@@ -69,10 +68,10 @@ export function applyColorThemeToDom(let customCacheEntry: string | null = null;if (theme.id === 'custom') {- const seed = resolveCustomSeed(customSeed);- const css = buildCustomThemeCss(seed);+ const scheme = resolveCustomScheme(customSeed);+ const css = buildCustomThemeCss(scheme);upsertCustomStyle(css);- customCacheEntry = JSON.stringify({ css, dark: customThemeKind(seed) === 'dark' });+ customCacheEntry = JSON.stringify({ css, dark: customThemeKind(scheme) === 'dark' });} else {removeCustomStyle();}diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.jsonindex f98e4a937..19b61c82f 100644--- a/packages/app/src/locales/en/messages.json+++ b/packages/app/src/locales/en/messages.json@@ -291,7 +291,6 @@"4g19V6": ["Failed to update property"],"4h3e0H": ["Couldn't update skills sharing — ", ["detail"], "."],"4hJhzz": ["Table"],- "4ieVh2": ["Pick “Custom” above to use this palette."],"4ivBhl": ["Toggle the right agents panel, where agent conversations live."],"4jDd0j": ["Anyone can see"],"4m-xuX": ["Auto-fix — nothing to fix"],@@ -302,6 +301,7 @@"4pDZ2N": ["Removed \"", ["0"], "\" from every other location — its source folder still loads"],"4rjwLG": ["Create with ", ["0"], " CLI"],"4sKwf6": ["File already exists"],+ "4sUdTJ": ["themed preview"],"4uNLmk": ["Pulling"],"4v2Yyz": ["Select every visible file-tree row when focus is in the Files sidebar."],"4wo5UV": ["Install selected"],@@ -456,6 +456,7 @@"Validate document frontmatter against JSON Schema files, scoped to doc sets by glob."],"7Bj3x9": ["Failed"],+ "7EmDc7": ["Import scheme"],"7FamGZ": ["Go to line"],"7Fkcej": ["+ Add ", ["addChildName"]],"7H4UHD": ["Documents tagged <0>#", ["tagName"], "</0>"],@@ -623,6 +624,7 @@"9fvog2": ["Preview unavailable: ", ["errorDetail"]],"9i21pa": ["Commits happen automatically"],"9ieZhu": ["Installed at ", ["path"], " — click to remove"],+ "9j1tqo": ["Couldn’t reach the clipboard — the scheme is in the box below."],"9jnjV0": ["Embed an audio file with native player controls."],"9lso1Y": ["Creates the <0>", ["folderPart"], "/</0> folder"],"9m4D_h": ["GitHub, a git URL, or a local path."],@@ -764,6 +766,7 @@"CFnavk": ["This project isn't a git repository, so worktrees aren't available."],"CHfFN_": ["Remove OpenKnowledge from ", ["0"]],"CKyk7Q": ["Go back"],+ "CMyafZ": [["slot"], " hex value"],"COr1Y7": ["Pick <0>openknowledge.skill</0> from your <1>Downloads</1> folder. It enables automatically."],@@ -901,7 +904,6 @@],"E_tNGD": ["Connected as @", ["login"]],"EarrCe": ["Search emoji"],- "Eax_et": ["Accent"],"EbMUlU": ["Agent mode"],"EbZT7P": ["Toggle the left file sidebar."],"EbjWsS": ["Current commit"],@@ -1055,7 +1057,6 @@"Gp_twO": ["Local path"],"GsBUCk": ["Loading settings"],"Gt4gOO": ["This folder has unpushed changes. Recipients will see the last pushed version."],- "GtJbUa": ["Background"],"GuLeuE": ["Search matches file names, paths, and folders. Open a file to search its body <0>",["0"],@@ -1119,7 +1120,6 @@"Move or rename this file inside the skill — the path stays under references/ or scripts/."],"HzVv6g": ["Paste"],- "I-xnra": [["0"], " hex value"],"I1gRhX": ["Failed to rename"],"I5685_": ["Try a prompt"],"I5AfhE": ["Sync status unavailable — server unreachable."],@@ -1143,6 +1143,7 @@"IYciRC": ["Thanks for the report!"],"IZXuGP": ["Couldn't open the terminal — the comments stay queued."],"IajAbS": ["Add a starter pack"],+ "IbTC7z": ["Paste a base16 scheme"],"If0crP": ["Open with AI ", ["targetDisplayName"], ", ", ["hint"]],"IgN3LY": ["On selected text in <0>", ["address"], "</0>"],"IgTwLt": ["Open this document in the editor and collapse the graph."],@@ -1604,6 +1605,7 @@"QlkiD5": ["Re-place on selected text"],"QlxHAH": ["Showing results for \"", ["semanticResultsLabel"], "\""],"QqBQu1": ["Label <0>(visible link text)</0>"],+ "Quz_Qu": ["Edits apply live. Light or dark comes from the scheme."],"Qvls7J": ["Eng specs"],"Qw-7Ie": ["A simple place to write, with one file per topic and a daily journal. Pick this if you just want to start writing and let the links between notes build up over time."@@ -1739,7 +1741,6 @@"TQJCR6": [["0", "plural", { "one": ["#", " result"], "other": ["#", " results"] }]],"TTDXD8": ["New worktree…"],"TUzThQ": ["Share skills"],- "T_R-Qz": ["Primary"],"T_wG4n": ["We couldn't check your GitHub connection."],"Ta25TG": ["No history yet"],"TbjyhA": ["Docs"],@@ -1828,6 +1829,7 @@["src"],"</1> is no longer available."],+ "UeQEbk": ["Browse hundreds of schemes"],"UfW9Kr": ["Your search queries and the full text of matching pages are sent to your embeddings provider (OpenAI by default) to compute embeddings."],@@ -1855,6 +1857,7 @@],"V48OUT": ["You deleted <0>", ["filePath"], "</0> locally, but it was modified upstream."],"V6AIOn": ["Workspace navigation"],+ "V6e25h": ["Theme preview"],"V7QxyT": ["Connection dropped"],"VAHWL_": ["Connected as <0>@", ["signedInLogin"], "</0>"],"VBE2dw": [@@ -2029,7 +2032,6 @@"Lint plugins — which rule families run and their per-rule settings — are configured on their own tab under This project → Plugins."],"YDX9lo": ["Remove this comment from the queue"],- "YEIS9T": ["Edits apply live. Light or dark is chosen from the background."],"YEP3X2": ["Delete a table when the active table cell selection covers the full table."],"YGIi_c": ["Reinstall"],"YGNRB5": ["— except"],@@ -2200,6 +2202,7 @@"Semantic search adds meaning-based ranking to the search tool so conceptually-related pages surface even without shared keywords."],"aM23Wr": ["page-name"],+ "aNb3JH": ["Copy as YAML"],"aOp3hw": ["Couldn't move to Trash"],"aQD_86": ["Failed to update the embeddings provider — ", ["detail"]],"aQyGJc": ["Something else"],@@ -2253,6 +2256,7 @@"b6Fgpe": ["Each pack scaffolds your project with ready-made folders and templates."],"bBE5tC": ["Detected on this machine"],"bBcFK_": ["Open emoji picker for ", ["keyName"]],+ "bD2SLZ": ["Scheme copied as base16 YAML"],"bD8I7O": ["Complete"],"bF22t6": ["Remove field ", ["field"]],"bGOTXx": [@@ -2364,7 +2368,6 @@],"d2uTPx": ["Server error (HTTP ", ["status"], ")"],"d5rK4X": [["chars", "plural", { "one": ["char"], "other": ["chars"] }]],- "dCIGNG": ["Border"],"dD7NPy": ["Outline"],"dDpCOp": ["Rename succeeded but the sidebar may be out of date — refresh to resync"],"dEgA5A": ["Cancel"],@@ -2542,6 +2545,7 @@". That folder becomes a symlink to this one, so its agent reads everything placed here. This folder stays real. Conflicting skills abort the merge."],"g85bAo": ["Synced ", ["lastSyncedRelative"]],+ "g9Nj4l": ["// note"],"gAhHu7": ["Auto-fix applies only to problems with a known mechanical fix."],"gBbxn_": ["Checking sign-in status"],"gGVP4q": ["Click <0>+</0> <1/> <2>Create skill</2> <3/> <4>Upload skill</4>."],@@ -2563,6 +2567,7 @@"gYz2ep": ["Expires in ", ["timeLabel"]],"gZElfU": ["Fixing ", ["0"], " of ", ["1"], " files"],"gZiT5e": ["Replace these symlinks with independent copies?"],+ "gayL_Q": ["Release plan"],"gbHcbI": ["Failed to delete property"],"gfb-CM": ["Could not fetch branch — sign in to GitHub and try again."],"gfdqcY": ["Couldn't apply the change: ", ["0"]],@@ -2589,7 +2594,9 @@"gwEcOD": ["Your local copy is behind."],"gwykHF": ["This doc hasn't synced to GitHub yet. The link will work after the next sync."],"gyHDWC": ["Fix all with AI (", ["count"], ")"],+ "gyWc8_": ["Accents"],"h-AdvS": ["The folders and templates are already here, so there's nothing to add."],+ "h-Y9pw": ["Pick “Custom” above to use this scheme."],"h06R3C": ["No pages are missing outgoing graph links."],"h16FyT": ["Lists"],"h2N-1n": ["Installed in ", ["0"]],@@ -3177,6 +3184,7 @@"pbwTg6": [["seconds"], "s ago"],"pckX1A": [["0", "plural", { "one": ["#", " use"], "other": ["#", " uses"] }]],"pcqlQu": [["0", "plural", { "one": ["Folder"], "other": ["Folders"] }]],+ "pfkaJ2": ["YAML or JSON, in either base16 layout."],"pgDlbM": ["Toggle Developer Tools"],"pgq_xf": [["0"], "/", ["1"], " ", ["2"]],"phM8Kh": ["Found the repo but could not open the project. Please try again."],@@ -3228,7 +3236,6 @@"qbfj1f": ["Receiving objects"],"qdBUHP": ["Couldn't load ", ["fileName"]],"qi1F96": ["Reveal in File Explorer"],- "qiN9NB": ["Surface"],"qiRoLb": ["Summarize everything I changed this week"],"qioCwA": ["Jump to page ", ["pageNumber"]],"qjHMHf": ["Failed to disable sync — ", ["detail"]],@@ -3330,6 +3337,7 @@"sJK6pq": ["Permission denied"],"sJWhgo": ["Unknown component: ", ["unregisteredComponentName"]],"sKEgGd": ["Send to chat"],+ "sKMhJz": ["Background to foreground"],"sLcbHt": ["Symlink another folder into one of these so both agents read the same skills; unlink to manage a folder's skills one by one again."],@@ -3479,6 +3487,7 @@],"uksqrP": ["Repository not found. It may have been renamed, deleted, or moved."],"ul1Atu": ["Converting..."],+ "um-es7": ["Ship the editor with a"],"un-K1H": ["Stays on this computer. Not committed to git."],"un8kBM": ["Creating page: ", ["linkTitle"], "."],"uoJF_D": ["It was too hard to set up or get started"],diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex 66334f71e..e344eb96c 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -250,11 +250,6 @@ msgstr "{0} at line {displayLine}"msgid "{0} can't continue this conversation — the transcript is kept, but the agent session is gone."msgstr "{0} can't continue this conversation — the transcript is kept, but the agent session is gone."-#. placeholder {0}: labels[key]-#: src/components/settings/CustomThemeEditor.tsx-msgid "{0} hex value"-msgstr "{0} hex value"-#. placeholder {0}: resolvedTarget.displayName#. placeholder {0}: target.displayName#: src/comments/use-comment-delivery.ts@@ -688,6 +683,10 @@ msgstr "{sizeText} · secrets redacted · crash dump not redacted"msgid "{skillCount, plural, one {skill} other {skills}}"msgstr "{skillCount, plural, one {skill} other {skills}}"+#: src/components/settings/CustomThemeEditor.tsx+msgid "{slot} hex value"+msgstr "{slot} hex value"+#: src/components/SkillPluginBundleBanner.tsxmsgid "{source} publishes {count} skills. Install any of them together."msgstr "{source} publishes {count} skills. Install any of them together."@@ -737,6 +736,10 @@ msgstr "{userName}, {tabCount, plural, one {# concurrent tab} other {# concurrenmsgid "{words, plural, one {word} other {words}}"msgstr "{words, plural, one {word} other {words}}"+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "// note"+msgstr "// note"+#: src/components/ConnectingBanner.tsxmsgid "/api/config returned a malformed body"msgstr "/api/config returned a malformed body"@@ -982,8 +985,8 @@ msgid "absent"msgstr "absent"#: src/components/settings/CustomThemeEditor.tsx-msgid "Accent"-msgstr "Accent"+msgid "Accents"+msgstr "Accents"#: src/components/DiffView.tsxmsgid "Accept"@@ -1632,8 +1635,8 @@ msgid "Back to document view"msgstr "Back to document view"#: src/components/settings/CustomThemeEditor.tsx-msgid "Background"-msgstr "Background"+msgid "Background to foreground"+msgstr "Background to foreground"#: src/components/LinksPanel.tsxmsgid "Backlinks"@@ -1704,10 +1707,6 @@ msgstr "blog-post"msgid "Bold"msgstr "Bold"-#: src/components/settings/CustomThemeEditor.tsx-msgid "Border"-msgstr "Border"-#: src/components/GraphPanel.tsxmsgid "Both"msgstr "Both"@@ -1778,6 +1777,10 @@ msgstr "Browse all"msgid "Browse folder"msgstr "Browse folder"+#: src/components/settings/CustomThemeEditor.tsx+msgid "Browse hundreds of schemes"+msgstr "Browse hundreds of schemes"+#: src/components/ImportSkillDialog.tsxmsgid "Browse or upload a skill for this project."msgstr "Browse or upload a skill for this project."@@ -2668,6 +2671,10 @@ msgstr "Copy a prompt and paste it into your agent to set up your project."msgid "Copy a prompt for your agent, start a blank file, or scaffold from a template."msgstr "Copy a prompt for your agent, start a blank file, or scaffold from a template."+#: src/components/settings/CustomThemeEditor.tsx+msgid "Copy as YAML"+msgstr "Copy as YAML"+#: src/editor/extensions/CodeBlockView.tsxmsgid "Copy code"msgstr "Copy code"@@ -3070,6 +3077,10 @@ msgstr "Couldn't reach GitHub. Try again?"msgid "Couldn't reach the agent registry."msgstr "Couldn't reach the agent registry."+#: src/components/settings/CustomThemeEditor.tsx+msgid "Couldn’t reach the clipboard — the scheme is in the box below."+msgstr "Couldn’t reach the clipboard — the scheme is in the box below."+#: src/components/CommandPalette.tsxmsgid "Couldn't reach the embeddings provider — retry"msgstr "Couldn't reach the embeddings provider — retry"@@ -4087,8 +4098,8 @@ msgid "Editor status bar"msgstr "Editor status bar"#: src/components/settings/CustomThemeEditor.tsx-msgid "Edits apply live. Light or dark is chosen from the background."-msgstr "Edits apply live. Light or dark is chosen from the background."+msgid "Edits apply live. Light or dark comes from the scheme."+msgstr "Edits apply live. Light or dark comes from the scheme."#: src/editor/slash-command/component-items.tsxmsgid "Edits at the source land here — no copy-paste drift."@@ -5479,6 +5490,10 @@ msgstr "Import as template"msgid "Import failed: {0}"msgstr "Import failed: {0}"+#: src/components/settings/CustomThemeEditor.tsx+msgid "Import scheme"+msgstr "Import scheme"+#. placeholder {0}: result.name#: src/lib/skill-import-toast.tsmsgid "Imported \"{0}\"."@@ -7808,6 +7823,10 @@ msgstr "Part of the {plugin} plugin"msgid "Paste"msgstr "Paste"+#: src/components/settings/CustomThemeEditor.tsx+msgid "Paste a base16 scheme"+msgstr "Paste a base16 scheme"+#: src/components/AuthModal.tsxmsgid "Paste a personal access token for <0>{host}</0>."msgstr "Paste a personal access token for <0>{host}</0>."@@ -7914,8 +7933,8 @@ msgid "Personal to this device — stored in your user config, not shared."msgstr "Personal to this device — stored in your user config, not shared."#: src/components/settings/CustomThemeEditor.tsx-msgid "Pick “Custom” above to use this palette."-msgstr "Pick “Custom” above to use this palette."+msgid "Pick “Custom” above to use this scheme."+msgstr "Pick “Custom” above to use this scheme."#: src/components/InstallInClaudeDesktopDialog.tsxmsgid "Pick <0>openknowledge.skill</0> from your <1>Downloads</1> folder. It enables automatically."@@ -8049,10 +8068,6 @@ msgstr "Previous reports"msgid "Previous tab"msgstr "Previous tab"-#: src/components/settings/CustomThemeEditor.tsx-msgid "Primary"-msgstr "Primary"-#: src/components/PublishToGitHubDialog.tsxmsgid "Private"msgstr "Private"@@ -8403,6 +8418,10 @@ msgstr "Relaunching to install the update…"msgid "Release notes"msgstr "Release notes"+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "Release plan"+msgstr "Release plan"+#: src/components/ExploreSkills.tsxmsgid "Relevance"msgstr "Relevance"@@ -9020,6 +9039,7 @@ msgstr "Sandboxed HTML embed — write HTML, see the rendered preview live."#: src/components/AuthModal.tsx#: src/components/settings/SearchSection.tsx+#: src/components/settings/ThemePreviewCanvas.tsx#: src/editor/components/CodePreviewEditModal.tsx#: src/editor/extensions/InternalLinkPropPanel.tsx#: src/editor/extensions/WikiLinkPropPanel.tsx@@ -9080,6 +9100,10 @@ msgstr "Saving"msgid "schema {deleteTarget}"msgstr "schema {deleteTarget}"+#: src/components/settings/CustomThemeEditor.tsx+msgid "Scheme copied as base16 YAML"+msgstr "Scheme copied as base16 YAML"+#: src/components/ImportSkillForm.tsx#: src/components/PanelScopeHeader.tsxmsgid "Scope"@@ -9563,6 +9587,10 @@ msgstr "Shared with everyone on this project — committed to config.yml via gitmsgid "Sharing a doc needs a GitHub repository. Create one for this project."msgstr "Sharing a doc needs a GitHub repository. Create one for this project."+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "Ship the editor with a"+msgstr "Ship the editor with a"+#: src/components/FileSidebar.tsxmsgid "Show"msgstr "Show"@@ -10107,10 +10135,6 @@ msgstr "Suggestion menu open"msgid "Summarize everything I changed this week"msgstr "Summarize everything I changed this week"-#: src/components/settings/CustomThemeEditor.tsx-msgid "Surface"-msgstr "Surface"-#: src/components/ShareBranchSwitchDialog.tsxmsgid "Switch and update branch"msgstr "Switch and update branch"@@ -10464,7 +10488,6 @@ msgid "Testing"msgstr "Testing"#: src/components/PropertyWidgets.tsx-#: src/components/settings/CustomThemeEditor.tsxmsgid "Text"msgstr "Text"@@ -10695,6 +10718,14 @@ msgstr "The token needs the repo and read:user scopes."msgid "Theme"msgstr "Theme"+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "Theme preview"+msgstr "Theme preview"++#: src/components/settings/ThemePreviewCanvas.tsx+msgid "themed preview"+msgstr "themed preview"+#: src/components/settings/LintingSection.tsx#: src/components/settings/SettingsDialogShell.tsx#: src/components/settings/ThemePluginSection.tsx@@ -11646,6 +11677,7 @@ msgid "Waiting for your approval"msgstr "Waiting for your approval"#: src/components/settings/ContentRulesSection.tsx+#: src/components/settings/ThemePreviewCanvas.tsxmsgid "Warning"msgstr "Warning"@@ -11862,6 +11894,10 @@ msgstr "Writes a project-MCP config for each selected tool."msgid "writing"msgstr "writing"+#: src/components/settings/CustomThemeEditor.tsx+msgid "YAML or JSON, in either base16 layout."+msgstr "YAML or JSON, in either base16 layout."+#: src/components/TimelinePanel.tsxmsgid "yesterday"msgstr "yesterday"diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.jsonindex 694990fae..d31fa9e77 100644--- a/packages/app/src/locales/pseudo/messages.json+++ b/packages/app/src/locales/pseudo/messages.json@@ -291,7 +291,6 @@"4g19V6": ["Ƒàĩĺēď ţō ũƥďàţē ƥŕōƥēŕţŷ"],"4h3e0H": ["Ćōũĺďń'ţ ũƥďàţē śķĩĺĺś śĥàŕĩńĝ — ", ["detail"], "."],"4hJhzz": ["Ţàƀĺē"],- "4ieVh2": ["Ƥĩćķ “Ćũśţōḿ” àƀōvē ţō ũśē ţĥĩś ƥàĺēţţē."],"4ivBhl": ["Ţōĝĝĺē ţĥē ŕĩĝĥţ àĝēńţś ƥàńēĺ, ŵĥēŕē àĝēńţ ćōńvēŕśàţĩōńś ĺĩvē."],"4jDd0j": ["Àńŷōńē ćàń śēē"],"4m-xuX": ["Àũţō-ƒĩx — ńōţĥĩńĝ ţō ƒĩx"],@@ -302,6 +301,7 @@"4pDZ2N": ["Ŕēḿōvēď \"", ["0"], "\" ƒŕōḿ ēvēŕŷ ōţĥēŕ ĺōćàţĩōń — ĩţś śōũŕćē ƒōĺďēŕ śţĩĺĺ ĺōàďś"],"4rjwLG": ["Ćŕēàţē ŵĩţĥ ", ["0"], " ĆĹĨ"],"4sKwf6": ["Ƒĩĺē àĺŕēàďŷ ēxĩśţś"],+ "4sUdTJ": ["ţĥēḿēď ƥŕēvĩēŵ"],"4uNLmk": ["Ƥũĺĺĩńĝ"],"4v2Yyz": ["Śēĺēćţ ēvēŕŷ vĩśĩƀĺē ƒĩĺē-ţŕēē ŕōŵ ŵĥēń ƒōćũś ĩś ĩń ţĥē Ƒĩĺēś śĩďēƀàŕ."],"4wo5UV": ["Ĩńśţàĺĺ śēĺēćţēď"],@@ -456,6 +456,7 @@"Vàĺĩďàţē ďōćũḿēńţ ƒŕōńţḿàţţēŕ àĝàĩńśţ ĵŚŌŃ Śćĥēḿà ƒĩĺēś, śćōƥēď ţō ďōć śēţś ƀŷ ĝĺōƀ."],"7Bj3x9": ["Ƒàĩĺēď"],+ "7EmDc7": ["Ĩḿƥōŕţ śćĥēḿē"],"7FamGZ": ["Ĝō ţō ĺĩńē"],"7Fkcej": ["+ Àďď ", ["addChildName"]],"7H4UHD": ["Ďōćũḿēńţś ţàĝĝēď <0>#", ["tagName"], "</0>"],@@ -623,6 +624,7 @@"9fvog2": ["Ƥŕēvĩēŵ ũńàvàĩĺàƀĺē: ", ["errorDetail"]],"9i21pa": ["Ćōḿḿĩţś ĥàƥƥēń àũţōḿàţĩćàĺĺŷ"],"9ieZhu": ["Ĩńśţàĺĺēď àţ ", ["path"], " — ćĺĩćķ ţō ŕēḿōvē"],+ "9j1tqo": ["Ćōũĺďń’ţ ŕēàćĥ ţĥē ćĺĩƥƀōàŕď — ţĥē śćĥēḿē ĩś ĩń ţĥē ƀōx ƀēĺōŵ."],"9jnjV0": ["Ēḿƀēď àń àũďĩō ƒĩĺē ŵĩţĥ ńàţĩvē ƥĺàŷēŕ ćōńţŕōĺś."],"9lso1Y": ["Ćŕēàţēś ţĥē <0>", ["folderPart"], "/</0> ƒōĺďēŕ"],"9m4D_h": ["ĜĩţĤũƀ, à ĝĩţ ŨŔĹ, ōŕ à ĺōćàĺ ƥàţĥ."],@@ -764,6 +766,7 @@"CFnavk": ["Ţĥĩś ƥŕōĴēćţ ĩśń'ţ à ĝĩţ ŕēƥōśĩţōŕŷ, śō ŵōŕķţŕēēś àŕēń'ţ àvàĩĺàƀĺē."],"CHfFN_": ["Ŕēḿōvē ŌƥēńĶńōŵĺēďĝē ƒŕōḿ ", ["0"]],"CKyk7Q": ["Ĝō ƀàćķ"],+ "CMyafZ": [["slot"], " ĥēx vàĺũē"],"COr1Y7": ["Ƥĩćķ <0>ōƥēńķńōŵĺēďĝē.śķĩĺĺ</0> ƒŕōḿ ŷōũŕ <1>Ďōŵńĺōàďś</1> ƒōĺďēŕ. Ĩţ ēńàƀĺēś àũţōḿàţĩćàĺĺŷ."],@@ -901,7 +904,6 @@],"E_tNGD": ["Ćōńńēćţēď àś @", ["login"]],"EarrCe": ["Śēàŕćĥ ēḿōĴĩ"],- "Eax_et": ["Àććēńţ"],"EbMUlU": ["Àĝēńţ ḿōďē"],"EbZT7P": ["Ţōĝĝĺē ţĥē ĺēƒţ ƒĩĺē śĩďēƀàŕ."],"EbjWsS": ["Ćũŕŕēńţ ćōḿḿĩţ"],@@ -1055,7 +1057,6 @@"Gp_twO": ["Ĺōćàĺ ƥàţĥ"],"GsBUCk": ["Ĺōàďĩńĝ śēţţĩńĝś"],"Gt4gOO": ["Ţĥĩś ƒōĺďēŕ ĥàś ũńƥũśĥēď ćĥàńĝēś. Ŕēćĩƥĩēńţś ŵĩĺĺ śēē ţĥē ĺàśţ ƥũśĥēď vēŕśĩōń."],- "GtJbUa": ["ßàćķĝŕōũńď"],"GuLeuE": ["Śēàŕćĥ ḿàţćĥēś ƒĩĺē ńàḿēś, ƥàţĥś, àńď ƒōĺďēŕś. Ōƥēń à ƒĩĺē ţō śēàŕćĥ ĩţś ƀōďŷ <0>",["0"],@@ -1119,7 +1120,6 @@"Ḿōvē ōŕ ŕēńàḿē ţĥĩś ƒĩĺē ĩńśĩďē ţĥē śķĩĺĺ — ţĥē ƥàţĥ śţàŷś ũńďēŕ ŕēƒēŕēńćēś/ ōŕ śćŕĩƥţś/."],"HzVv6g": ["Ƥàśţē"],- "I-xnra": [["0"], " ĥēx vàĺũē"],"I1gRhX": ["Ƒàĩĺēď ţō ŕēńàḿē"],"I5685_": ["Ţŕŷ à ƥŕōḿƥţ"],"I5AfhE": ["Śŷńć śţàţũś ũńàvàĩĺàƀĺē — śēŕvēŕ ũńŕēàćĥàƀĺē."],@@ -1143,6 +1143,7 @@"IYciRC": ["Ţĥàńķś ƒōŕ ţĥē ŕēƥōŕţ!"],"IZXuGP": ["Ćōũĺďń'ţ ōƥēń ţĥē ţēŕḿĩńàĺ — ţĥē ćōḿḿēńţś śţàŷ ǫũēũēď."],"IajAbS": ["Àďď à śţàŕţēŕ ƥàćķ"],+ "IbTC7z": ["Ƥàśţē à ƀàśē16 śćĥēḿē"],"If0crP": ["Ōƥēń ŵĩţĥ ÀĨ ", ["targetDisplayName"], ", ", ["hint"]],"IgN3LY": ["Ōń śēĺēćţēď ţēxţ ĩń <0>", ["address"], "</0>"],"IgTwLt": ["Ōƥēń ţĥĩś ďōćũḿēńţ ĩń ţĥē ēďĩţōŕ àńď ćōĺĺàƥśē ţĥē ĝŕàƥĥ."],@@ -1604,6 +1605,7 @@"QlkiD5": ["Ŕē-ƥĺàćē ōń śēĺēćţēď ţēxţ"],"QlxHAH": ["Śĥōŵĩńĝ ŕēśũĺţś ƒōŕ \"", ["semanticResultsLabel"], "\""],"QqBQu1": ["Ĺàƀēĺ <0>(vĩśĩƀĺē ĺĩńķ ţēxţ)</0>"],+ "Quz_Qu": ["Ēďĩţś àƥƥĺŷ ĺĩvē. Ĺĩĝĥţ ōŕ ďàŕķ ćōḿēś ƒŕōḿ ţĥē śćĥēḿē."],"Qvls7J": ["Ēńĝ śƥēćś"],"Qw-7Ie": ["À śĩḿƥĺē ƥĺàćē ţō ŵŕĩţē, ŵĩţĥ ōńē ƒĩĺē ƥēŕ ţōƥĩć àńď à ďàĩĺŷ Ĵōũŕńàĺ. Ƥĩćķ ţĥĩś ĩƒ ŷōũ Ĵũśţ ŵàńţ ţō śţàŕţ ŵŕĩţĩńĝ àńď ĺēţ ţĥē ĺĩńķś ƀēţŵēēń ńōţēś ƀũĩĺď ũƥ ōvēŕ ţĩḿē."@@ -1739,7 +1741,6 @@"TQJCR6": [["0", "plural", { "one": ["#", " ŕēśũĺţ"], "other": ["#", " ŕēśũĺţś"] }]],"TTDXD8": ["Ńēŵ ŵōŕķţŕēē…"],"TUzThQ": ["Śĥàŕē śķĩĺĺś"],- "T_R-Qz": ["Ƥŕĩḿàŕŷ"],"T_wG4n": ["Ŵē ćōũĺďń'ţ ćĥēćķ ŷōũŕ ĜĩţĤũƀ ćōńńēćţĩōń."],"Ta25TG": ["Ńō ĥĩśţōŕŷ ŷēţ"],"TbjyhA": ["Ďōćś"],@@ -1828,6 +1829,7 @@["src"],"</1> ĩś ńō ĺōńĝēŕ àvàĩĺàƀĺē."],+ "UeQEbk": ["ßŕōŵśē ĥũńďŕēďś ōƒ śćĥēḿēś"],"UfW9Kr": ["Ŷōũŕ śēàŕćĥ ǫũēŕĩēś àńď ţĥē ƒũĺĺ ţēxţ ōƒ ḿàţćĥĩńĝ ƥàĝēś àŕē śēńţ ţō ŷōũŕ ēḿƀēďďĩńĝś ƥŕōvĩďēŕ (ŌƥēńÀĨ ƀŷ ďēƒàũĺţ) ţō ćōḿƥũţē ēḿƀēďďĩńĝś."],@@ -1855,6 +1857,7 @@],"V48OUT": ["Ŷōũ ďēĺēţēď <0>", ["filePath"], "</0> ĺōćàĺĺŷ, ƀũţ ĩţ ŵàś ḿōďĩƒĩēď ũƥśţŕēàḿ."],"V6AIOn": ["Ŵōŕķśƥàćē ńàvĩĝàţĩōń"],+ "V6e25h": ["Ţĥēḿē ƥŕēvĩēŵ"],"V7QxyT": ["Ćōńńēćţĩōń ďŕōƥƥēď"],"VAHWL_": ["Ćōńńēćţēď àś <0>@", ["signedInLogin"], "</0>"],"VBE2dw": [@@ -2029,7 +2032,6 @@"Ĺĩńţ ƥĺũĝĩńś — ŵĥĩćĥ ŕũĺē ƒàḿĩĺĩēś ŕũń àńď ţĥēĩŕ ƥēŕ-ŕũĺē śēţţĩńĝś — àŕē ćōńƒĩĝũŕēď ōń ţĥēĩŕ ōŵń ţàƀ ũńďēŕ Ţĥĩś ƥŕōĴēćţ → Ƥĺũĝĩńś."],"YDX9lo": ["Ŕēḿōvē ţĥĩś ćōḿḿēńţ ƒŕōḿ ţĥē ǫũēũē"],- "YEIS9T": ["Ēďĩţś àƥƥĺŷ ĺĩvē. Ĺĩĝĥţ ōŕ ďàŕķ ĩś ćĥōśēń ƒŕōḿ ţĥē ƀàćķĝŕōũńď."],"YEP3X2": ["Ďēĺēţē à ţàƀĺē ŵĥēń ţĥē àćţĩvē ţàƀĺē ćēĺĺ śēĺēćţĩōń ćōvēŕś ţĥē ƒũĺĺ ţàƀĺē."],"YGIi_c": ["Ŕēĩńśţàĺĺ"],"YGNRB5": ["— ēxćēƥţ"],@@ -2200,6 +2202,7 @@"Śēḿàńţĩć śēàŕćĥ àďďś ḿēàńĩńĝ-ƀàśēď ŕàńķĩńĝ ţō ţĥē śēàŕćĥ ţōōĺ śō ćōńćēƥţũàĺĺŷ-ŕēĺàţēď ƥàĝēś śũŕƒàćē ēvēń ŵĩţĥōũţ śĥàŕēď ķēŷŵōŕďś."],"aM23Wr": ["ƥàĝē-ńàḿē"],+ "aNb3JH": ["Ćōƥŷ àś ŶÀḾĹ"],"aOp3hw": ["Ćōũĺďń'ţ ḿōvē ţō Ţŕàśĥ"],"aQD_86": ["Ƒàĩĺēď ţō ũƥďàţē ţĥē ēḿƀēďďĩńĝś ƥŕōvĩďēŕ — ", ["detail"]],"aQyGJc": ["Śōḿēţĥĩńĝ ēĺśē"],@@ -2253,6 +2256,7 @@"b6Fgpe": ["Ēàćĥ ƥàćķ śćàƒƒōĺďś ŷōũŕ ƥŕōĴēćţ ŵĩţĥ ŕēàďŷ-ḿàďē ƒōĺďēŕś àńď ţēḿƥĺàţēś."],"bBE5tC": ["Ďēţēćţēď ōń ţĥĩś ḿàćĥĩńē"],"bBcFK_": ["Ōƥēń ēḿōĴĩ ƥĩćķēŕ ƒōŕ ", ["keyName"]],+ "bD2SLZ": ["Śćĥēḿē ćōƥĩēď àś ƀàśē16 ŶÀḾĹ"],"bD8I7O": ["Ćōḿƥĺēţē"],"bF22t6": ["Ŕēḿōvē ƒĩēĺď ", ["field"]],"bGOTXx": [@@ -2364,7 +2368,6 @@],"d2uTPx": ["Śēŕvēŕ ēŕŕōŕ (ĤŢŢƤ ", ["status"], ")"],"d5rK4X": [["chars", "plural", { "one": ["ćĥàŕ"], "other": ["ćĥàŕś"] }]],- "dCIGNG": ["ßōŕďēŕ"],"dD7NPy": ["Ōũţĺĩńē"],"dDpCOp": ["Ŕēńàḿē śũććēēďēď ƀũţ ţĥē śĩďēƀàŕ ḿàŷ ƀē ōũţ ōƒ ďàţē — ŕēƒŕēśĥ ţō ŕēśŷńć"],"dEgA5A": ["Ćàńćēĺ"],@@ -2542,6 +2545,7 @@". Ţĥàţ ƒōĺďēŕ ƀēćōḿēś à śŷḿĺĩńķ ţō ţĥĩś ōńē, śō ĩţś àĝēńţ ŕēàďś ēvēŕŷţĥĩńĝ ƥĺàćēď ĥēŕē. Ţĥĩś ƒōĺďēŕ śţàŷś ŕēàĺ. Ćōńƒĺĩćţĩńĝ śķĩĺĺś àƀōŕţ ţĥē ḿēŕĝē."],"g85bAo": ["Śŷńćēď ", ["lastSyncedRelative"]],+ "g9Nj4l": ["// ńōţē"],"gAhHu7": ["Àũţō-ƒĩx àƥƥĺĩēś ōńĺŷ ţō ƥŕōƀĺēḿś ŵĩţĥ à ķńōŵń ḿēćĥàńĩćàĺ ƒĩx."],"gBbxn_": ["Ćĥēćķĩńĝ śĩĝń-ĩń śţàţũś"],"gGVP4q": ["Ćĺĩćķ <0>+</0> <1/> <2>Ćŕēàţē śķĩĺĺ</2> <3/> <4>Ũƥĺōàď śķĩĺĺ</4>."],@@ -2563,6 +2567,7 @@"gYz2ep": ["Ēxƥĩŕēś ĩń ", ["timeLabel"]],"gZElfU": ["Ƒĩxĩńĝ ", ["0"], " ōƒ ", ["1"], " ƒĩĺēś"],"gZiT5e": ["Ŕēƥĺàćē ţĥēśē śŷḿĺĩńķś ŵĩţĥ ĩńďēƥēńďēńţ ćōƥĩēś?"],+ "gayL_Q": ["Ŕēĺēàśē ƥĺàń"],"gbHcbI": ["Ƒàĩĺēď ţō ďēĺēţē ƥŕōƥēŕţŷ"],"gfb-CM": ["Ćōũĺď ńōţ ƒēţćĥ ƀŕàńćĥ — śĩĝń ĩń ţō ĜĩţĤũƀ àńď ţŕŷ àĝàĩń."],"gfdqcY": ["Ćōũĺďń'ţ àƥƥĺŷ ţĥē ćĥàńĝē: ", ["0"]],@@ -2589,7 +2594,9 @@"gwEcOD": ["Ŷōũŕ ĺōćàĺ ćōƥŷ ĩś ƀēĥĩńď."],"gwykHF": ["Ţĥĩś ďōć ĥàśń'ţ śŷńćēď ţō ĜĩţĤũƀ ŷēţ. Ţĥē ĺĩńķ ŵĩĺĺ ŵōŕķ àƒţēŕ ţĥē ńēxţ śŷńć."],"gyHDWC": ["Ƒĩx àĺĺ ŵĩţĥ ÀĨ (", ["count"], ")"],+ "gyWc8_": ["Àććēńţś"],"h-AdvS": ["Ţĥē ƒōĺďēŕś àńď ţēḿƥĺàţēś àŕē àĺŕēàďŷ ĥēŕē, śō ţĥēŕē'ś ńōţĥĩńĝ ţō àďď."],+ "h-Y9pw": ["Ƥĩćķ “Ćũśţōḿ” àƀōvē ţō ũśē ţĥĩś śćĥēḿē."],"h06R3C": ["Ńō ƥàĝēś àŕē ḿĩśśĩńĝ ōũţĝōĩńĝ ĝŕàƥĥ ĺĩńķś."],"h16FyT": ["Ĺĩśţś"],"h2N-1n": ["Ĩńśţàĺĺēď ĩń ", ["0"]],@@ -3177,6 +3184,7 @@"pbwTg6": [["seconds"], "ś àĝō"],"pckX1A": [["0", "plural", { "one": ["#", " ũśē"], "other": ["#", " ũśēś"] }]],"pcqlQu": [["0", "plural", { "one": ["Ƒōĺďēŕ"], "other": ["Ƒōĺďēŕś"] }]],+ "pfkaJ2": ["ŶÀḾĹ ōŕ ĵŚŌŃ, ĩń ēĩţĥēŕ ƀàśē16 ĺàŷōũţ."],"pgDlbM": ["Ţōĝĝĺē Ďēvēĺōƥēŕ Ţōōĺś"],"pgq_xf": [["0"], "/", ["1"], " ", ["2"]],"phM8Kh": ["Ƒōũńď ţĥē ŕēƥō ƀũţ ćōũĺď ńōţ ōƥēń ţĥē ƥŕōĴēćţ. Ƥĺēàśē ţŕŷ àĝàĩń."],@@ -3228,7 +3236,6 @@"qbfj1f": ["Ŕēćēĩvĩńĝ ōƀĴēćţś"],"qdBUHP": ["Ćōũĺďń'ţ ĺōàď ", ["fileName"]],"qi1F96": ["Ŕēvēàĺ ĩń Ƒĩĺē Ēxƥĺōŕēŕ"],- "qiN9NB": ["Śũŕƒàćē"],"qiRoLb": ["Śũḿḿàŕĩźē ēvēŕŷţĥĩńĝ Ĩ ćĥàńĝēď ţĥĩś ŵēēķ"],"qioCwA": ["ĵũḿƥ ţō ƥàĝē ", ["pageNumber"]],"qjHMHf": ["Ƒàĩĺēď ţō ďĩśàƀĺē śŷńć — ", ["detail"]],@@ -3330,6 +3337,7 @@"sJK6pq": ["Ƥēŕḿĩśśĩōń ďēńĩēď"],"sJWhgo": ["Ũńķńōŵń ćōḿƥōńēńţ: ", ["unregisteredComponentName"]],"sKEgGd": ["Śēńď ţō ćĥàţ"],+ "sKMhJz": ["ßàćķĝŕōũńď ţō ƒōŕēĝŕōũńď"],"sLcbHt": ["Śŷḿĺĩńķ àńōţĥēŕ ƒōĺďēŕ ĩńţō ōńē ōƒ ţĥēśē śō ƀōţĥ àĝēńţś ŕēàď ţĥē śàḿē śķĩĺĺś; ũńĺĩńķ ţō ḿàńàĝē à ƒōĺďēŕ'ś śķĩĺĺś ōńē ƀŷ ōńē àĝàĩń."],@@ -3479,6 +3487,7 @@],"uksqrP": ["Ŕēƥōśĩţōŕŷ ńōţ ƒōũńď. Ĩţ ḿàŷ ĥàvē ƀēēń ŕēńàḿēď, ďēĺēţēď, ōŕ ḿōvēď."],"ul1Atu": ["Ćōńvēŕţĩńĝ..."],+ "um-es7": ["Śĥĩƥ ţĥē ēďĩţōŕ ŵĩţĥ à"],"un-K1H": ["Śţàŷś ōń ţĥĩś ćōḿƥũţēŕ. Ńōţ ćōḿḿĩţţēď ţō ĝĩţ."],"un8kBM": ["Ćŕēàţĩńĝ ƥàĝē: ", ["linkTitle"], "."],"uoJF_D": ["Ĩţ ŵàś ţōō ĥàŕď ţō śēţ ũƥ ōŕ ĝēţ śţàŕţēď"],diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex 36be551b1..776fade64 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -250,11 +250,6 @@ msgstr ""msgid "{0} can't continue this conversation — the transcript is kept, but the agent session is gone."msgstr ""-#. placeholder {0}: labels[key]-#: src/components/settings/CustomThemeEditor.tsx-msgid "{0} hex value"-msgstr ""-#. placeholder {0}: resolvedTarget.displayName#. placeholder {0}: target.displayName#: src/comments/use-comment-delivery.ts@@ -688,6 +683,10 @@ msgstr ""msgid "{skillCount, plural, one {skill} other {skills}}"msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "{slot} hex value"+msgstr ""+#: src/components/SkillPluginBundleBanner.tsxmsgid "{source} publishes {count} skills. Install any of them together."msgstr ""@@ -737,6 +736,10 @@ msgstr ""msgid "{words, plural, one {word} other {words}}"msgstr ""+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "// note"+msgstr ""+#: src/components/ConnectingBanner.tsxmsgid "/api/config returned a malformed body"msgstr ""@@ -978,7 +981,7 @@ msgid "absent"msgstr ""#: src/components/settings/CustomThemeEditor.tsx-msgid "Accent"+msgid "Accents"msgstr ""#: src/components/DiffView.tsx@@ -1628,7 +1631,7 @@ msgid "Back to document view"msgstr ""#: src/components/settings/CustomThemeEditor.tsx-msgid "Background"+msgid "Background to foreground"msgstr ""#: src/components/LinksPanel.tsx@@ -1700,10 +1703,6 @@ msgstr ""msgid "Bold"msgstr ""-#: src/components/settings/CustomThemeEditor.tsx-msgid "Border"-msgstr ""-#: src/components/GraphPanel.tsxmsgid "Both"msgstr ""@@ -1774,6 +1773,10 @@ msgstr ""msgid "Browse folder"msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "Browse hundreds of schemes"+msgstr ""+#: src/components/ImportSkillDialog.tsxmsgid "Browse or upload a skill for this project."msgstr ""@@ -2664,6 +2667,10 @@ msgstr ""msgid "Copy a prompt for your agent, start a blank file, or scaffold from a template."msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "Copy as YAML"+msgstr ""+#: src/editor/extensions/CodeBlockView.tsxmsgid "Copy code"msgstr ""@@ -3066,6 +3073,10 @@ msgstr ""msgid "Couldn't reach the agent registry."msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "Couldn’t reach the clipboard — the scheme is in the box below."+msgstr ""+#: src/components/CommandPalette.tsxmsgid "Couldn't reach the embeddings provider — retry"msgstr ""@@ -4083,7 +4094,7 @@ msgid "Editor status bar"msgstr ""#: src/components/settings/CustomThemeEditor.tsx-msgid "Edits apply live. Light or dark is chosen from the background."+msgid "Edits apply live. Light or dark comes from the scheme."msgstr ""#: src/editor/slash-command/component-items.tsx@@ -5475,6 +5486,10 @@ msgstr ""msgid "Import failed: {0}"msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "Import scheme"+msgstr ""+#. placeholder {0}: result.name#: src/lib/skill-import-toast.tsmsgid "Imported \"{0}\"."@@ -7804,6 +7819,10 @@ msgstr ""msgid "Paste"msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "Paste a base16 scheme"+msgstr ""+#: src/components/AuthModal.tsxmsgid "Paste a personal access token for <0>{host}</0>."msgstr ""@@ -7910,7 +7929,7 @@ msgid "Personal to this device — stored in your user config, not shared."msgstr ""#: src/components/settings/CustomThemeEditor.tsx-msgid "Pick “Custom” above to use this palette."+msgid "Pick “Custom” above to use this scheme."msgstr ""#: src/components/InstallInClaudeDesktopDialog.tsx@@ -8045,10 +8064,6 @@ msgstr ""msgid "Previous tab"msgstr ""-#: src/components/settings/CustomThemeEditor.tsx-msgid "Primary"-msgstr ""-#: src/components/PublishToGitHubDialog.tsxmsgid "Private"msgstr ""@@ -8399,6 +8414,10 @@ msgstr ""msgid "Release notes"msgstr ""+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "Release plan"+msgstr ""+#: src/components/ExploreSkills.tsxmsgid "Relevance"msgstr ""@@ -9016,6 +9035,7 @@ msgstr ""#: src/components/AuthModal.tsx#: src/components/settings/SearchSection.tsx+#: src/components/settings/ThemePreviewCanvas.tsx#: src/editor/components/CodePreviewEditModal.tsx#: src/editor/extensions/InternalLinkPropPanel.tsx#: src/editor/extensions/WikiLinkPropPanel.tsx@@ -9076,6 +9096,10 @@ msgstr ""msgid "schema {deleteTarget}"msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "Scheme copied as base16 YAML"+msgstr ""+#: src/components/ImportSkillForm.tsx#: src/components/PanelScopeHeader.tsxmsgid "Scope"@@ -9559,6 +9583,10 @@ msgstr ""msgid "Sharing a doc needs a GitHub repository. Create one for this project."msgstr ""+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "Ship the editor with a"+msgstr ""+#: src/components/FileSidebar.tsxmsgid "Show"msgstr ""@@ -10103,10 +10131,6 @@ msgstr ""msgid "Summarize everything I changed this week"msgstr ""-#: src/components/settings/CustomThemeEditor.tsx-msgid "Surface"-msgstr ""-#: src/components/ShareBranchSwitchDialog.tsxmsgid "Switch and update branch"msgstr ""@@ -10460,7 +10484,6 @@ msgid "Testing"msgstr ""#: src/components/PropertyWidgets.tsx-#: src/components/settings/CustomThemeEditor.tsxmsgid "Text"msgstr ""@@ -10691,6 +10714,14 @@ msgstr ""msgid "Theme"msgstr ""+#: src/components/settings/ThemePreviewCanvas.tsx+msgid "Theme preview"+msgstr ""++#: src/components/settings/ThemePreviewCanvas.tsx+msgid "themed preview"+msgstr ""+#: src/components/settings/LintingSection.tsx#: src/components/settings/SettingsDialogShell.tsx#: src/components/settings/ThemePluginSection.tsx@@ -11642,6 +11673,7 @@ msgid "Waiting for your approval"msgstr ""#: src/components/settings/ContentRulesSection.tsx+#: src/components/settings/ThemePreviewCanvas.tsxmsgid "Warning"msgstr ""@@ -11858,6 +11890,10 @@ msgstr ""msgid "writing"msgstr ""+#: src/components/settings/CustomThemeEditor.tsx+msgid "YAML or JSON, in either base16 layout."+msgstr ""+#: src/components/TimelinePanel.tsxmsgid "yesterday"msgstr ""diff --git a/packages/core/src/config/field-registry.test.ts b/packages/core/src/config/field-registry.test.tsindex d524554b6..b284b8e34 100644--- a/packages/core/src/config/field-registry.test.ts+++ b/packages/core/src/config/field-registry.test.ts@@ -154,12 +154,27 @@ describe('ConfigSchema coverage (NR3 — every leaf has fieldRegistry metadata)''agents.autoApproveOkTools','appearance.colorTheme','appearance.colorThemeEnabled',- 'appearance.customTheme.accent',- 'appearance.customTheme.background',- 'appearance.customTheme.border',- 'appearance.customTheme.foreground',- 'appearance.customTheme.primary',- 'appearance.customTheme.surface',+ // The custom theme is a base16 scheme: sixteen palette slots plus the+ // three metadata fields an imported scheme carries.+ 'appearance.customTheme.author',+ 'appearance.customTheme.base00',+ 'appearance.customTheme.base01',+ 'appearance.customTheme.base02',+ 'appearance.customTheme.base03',+ 'appearance.customTheme.base04',+ 'appearance.customTheme.base05',+ 'appearance.customTheme.base06',+ 'appearance.customTheme.base07',+ 'appearance.customTheme.base08',+ 'appearance.customTheme.base09',+ 'appearance.customTheme.base0A',+ 'appearance.customTheme.base0B',+ 'appearance.customTheme.base0C',+ 'appearance.customTheme.base0D',+ 'appearance.customTheme.base0E',+ 'appearance.customTheme.base0F',+ 'appearance.customTheme.name',+ 'appearance.customTheme.variant','appearance.preview.autoOpen','appearance.theme','editor.wordWrap',diff --git a/packages/core/src/config/schema.ts b/packages/core/src/config/schema.tsindex 263affa5d..a446af6bc 100644--- a/packages/core/src/config/schema.ts+++ b/packages/core/src/config/schema.ts@@ -1,10 +1,45 @@import { z } from 'zod';import { DEFAULT_ATTACHMENT_FOLDER_PATH } from '../constants/upload.ts';import { DEFAULT_LINKS_VALIDATION, LINKS_VALIDATION_SETTINGS } from '../markdown/lint/types.ts';+import { BASE16_SLOT_ROLES, BASE16_SLOTS } from '../theme/base16.ts';import { THEME_PLUGIN_IDS } from '../theme/theme-plugins.ts';import { STORED_SYNC_ACTIVE_MODES, STORED_SYNC_MODES } from './auto-sync-mode.ts';import { fieldRegistry } from './field-registry.ts';+/**+ * The sixteen `appearance.customTheme` slot fields. Built from the slot list so+ * the config surface can't drift from the format, and so each field's+ * description carries the slot's role rather than repeating "a hex string".+ */+function base16SlotFields() {+ return Object.fromEntries(+ BASE16_SLOTS.map((slot) => [+ slot,+ z+ .string()+ .register(fieldRegistry, {+ scope: 'user',+ agentSettable: false,+ defaultScope: 'user',+ description: `Custom theme: base16 ${slot} — ${BASE16_SLOT_ROLES[slot]}, as a #rrggbb hex string.`,+ })+ .optional(),+ ]),+ );+}++/**+ * The self-contained palettes, quoted for prose — every theme id except the two+ * that defer to something else (`default` → the light/dark mode, `custom` → the+ * user's own scheme). Derived so the `colorTheme` description can't fall out of+ * step with the registry the enum itself comes from.+ */+function namedThemeIds() {+ return THEME_PLUGIN_IDS.filter((id) => id !== 'default' && id !== 'custom')+ .map((id) => `'${id}'`)+ .join(', ');+}+// Credential attribute key denylist for the local telemetry file sink. The// `ScrubbingSpanProcessor` reads the resolved `telemetry.localSink.attributeDenylist`// at runtime, which defaults to this list (see the `.default(...)` chain below).@@ -226,8 +261,7 @@ export const ConfigSchema = z.looseObject({scope: 'user',agentSettable: false,defaultScope: 'user',- description:- "IDE color palette: 'default' (follows the light/dark theme), one of 'dracula', 'catppuccin-frappe', 'catppuccin-latte', 'monokai', 'gruvbox', 'solarized', or 'custom' (your own colors from appearance.customTheme). A personal preference (user scope) — not shared with the project.",+ description: `IDE color palette: 'default' (follows the light/dark theme), 'custom' (your own colors from appearance.customTheme), or one of ${namedThemeIds()}. A personal preference (user scope) — not shared with the project.`,}).optional(),// Whether the Themes plugin appears under Settings → Plugins. The theme is@@ -243,70 +277,46 @@ export const ConfigSchema = z.looseObject({'Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.',}).optional(),- // Six seed colors for the `custom` color theme. The app derives the full- // token set from these (text contrast, muted text, accents) — see- // `expandCustomSeed` in `packages/app/src/lib/color-themes.ts`. Each value- // is a `#rrggbb` hex string; light-vs-dark mode is auto-detected from the- // background's luminance. A personal preference (user scope).+ // The `custom` color theme's base16 scheme — the same sixteen-slot format+ // the built-ins are authored in, so a scheme copied from the base16+ // ecosystem can be pasted in and used as-is. Each slot is a `#rrggbb` hex+ // string; `variant` is auto-detected from the tonal ramp when absent.+ // Config written before base16 carried six semantic seed colors instead+ // (`background`/`surface`/`foreground`/`primary`/`accent`/`border`); the+ // object stays loose so that shape still parses, and the app upgrades it+ // on read (`resolveCustomScheme`). A personal preference (user scope).customTheme: z.looseObject({- background: z+ name: z.string().register(fieldRegistry, {scope: 'user',agentSettable: false,defaultScope: 'user',- description: 'Custom theme: editor canvas background, as a #rrggbb hex string.',+ description: "Custom theme: the scheme's display name.",}).optional(),- surface: z+ author: z.string().register(fieldRegistry, {scope: 'user',agentSettable: false,defaultScope: 'user',description:- 'Custom theme: elevated surfaces (cards, sidebar, popovers), as a #rrggbb hex string.',+ "Custom theme: the scheme's author credit, carried through from an imported base16 scheme.",}).optional(),- foreground: z- .string()- .register(fieldRegistry, {- scope: 'user',- agentSettable: false,- defaultScope: 'user',- description: 'Custom theme: primary text color, as a #rrggbb hex string.',- })- .optional(),- primary: z- .string()+ variant: z+ .enum(['dark', 'light']).register(fieldRegistry, {scope: 'user',agentSettable: false,defaultScope: 'user',description:- 'Custom theme: accent color for buttons, links, and focus, as a #rrggbb hex string.',- })- .optional(),- accent: z- .string()- .register(fieldRegistry, {- scope: 'user',- agentSettable: false,- defaultScope: 'user',- description:- 'Custom theme: secondary accent (syntax highlights, charts), as a #rrggbb hex string.',- })- .optional(),- border: z- .string()- .register(fieldRegistry, {- scope: 'user',- agentSettable: false,- defaultScope: 'user',- description: 'Custom theme: hairline border + input color, as a #rrggbb hex string.',+ "Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.",}).optional(),+ ...base16SlotFields(),}).optional(),preview: zdiff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.tsindex e5d167876..0ee5132b6 100644--- a/packages/core/src/desktop-bridge.ts+++ b/packages/core/src/desktop-bridge.ts@@ -1146,10 +1146,17 @@ export interface OkDesktopBridge {** Optional `opts.reducedTransparency` carries the renderer's live* `matchMedia('(prefers-reduced-transparency: reduce)').matches` value;- * main toggles vibrancy material accordingly. See canonical JSDoc in+ * main toggles vibrancy material accordingly. Optional `opts.chrome`+ * carries the active color theme's window-chrome colors (`bg` from+ * `--sidebar`, `symbol` from `--sidebar-foreground`) so main can paint the+ * OS-drawn titlebar to match the palette rather than its build-time+ * snapshot. See canonical JSDoc in* `packages/desktop/src/shared/bridge-contract.ts`.*/- signalThemeApplied(opts?: { reducedTransparency?: boolean }): void;+ signalThemeApplied(opts?: {+ reducedTransparency?: boolean;+ chrome?: { bg: string; symbol: string };+ }): void;/** Native folder-picker dialog surfaces. */dialog: {diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 89078bfb9..f9998e9ab 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -1270,12 +1270,30 @@ export {type DerivedViewChannel,DerivedViewChannelSchema,} from './schemas/cc1.ts';-export type { ColorThemeBase, ThemePlugin, ThemePluginId } from './theme/theme-plugins.ts';+export type {+ AnsiSlotName,+ Base16Palette,+ Base16ParseError,+ Base16ParseResult,+ Base16Scheme,+ Base16Slot,+} from './theme/base16.ts';+export {+ BASE16_SLOT_ROLES,+ BASE16_SLOTS,+ base16ToTokens,+ base16ToYaml,+ isBase16Hex,+ mixHex,+ parseBase16Scheme,+ relativeLuminance,+} from './theme/base16.ts';+export type { ThemePlugin, ThemePluginId } from './theme/theme-plugins.ts';export {colorThemeMode,- expandPalette,generateColorThemesCss,isDarkTheme,+ renderThemeBlock,resolveThemePlugin,THEME_PLUGIN_IDS,THEME_PLUGINS,diff --git a/packages/core/src/theme/base16.test.ts b/packages/core/src/theme/base16.test.tsnew file mode 100644index 000000000..8a14c0717--- /dev/null+++ b/packages/core/src/theme/base16.test.ts@@ -0,0 +1,355 @@+import { describe, expect, test } from 'vitest';+import {+ BASE16_SLOT_ROLES,+ BASE16_SLOTS,+ type Base16Scheme,+ base16ToTokens,+ base16ToYaml,+ isBase16Hex,+ mixHex,+ parseBase16Scheme,+ relativeLuminance,+} from './base16.ts';++const HEX = /^#[0-9a-f]{6}$/;++/** The upstream Tinted Theming layout, verbatim. */+const CURRENT_LAYOUT = `system: "base16"+name: "Ayu Dark"+author: "Khue Nguyen <[email protected]>"+variant: "dark"+palette:+ base00: "#0f1419"+ base01: "#131721"+ base02: "#272d38"+ base03: "#3e4b59"+ base04: "#bfbdb6"+ base05: "#e6e1cf"+ base06: "#e6e1cf"+ base07: "#f3f4f5"+ base08: "#f07178"+ base09: "#ff8f40"+ base0A: "#ffb454"+ base0B: "#b8cc52"+ base0C: "#95e6cb"+ base0D: "#59c2ff"+ base0E: "#d2a6ff"+ base0F: "#e6b673"+`;++/** The original chriskempson layout: top-level slots, bare hex, no variant. */+const LEGACY_LAYOUT = `scheme: "Tomorrow Night"+author: "Chris Kempson"+base00: "1d1f21"+base01: "282a2e"+base02: "373b41"+base03: "969896"+base04: "b4b7b4"+base05: "c5c8c6"+base06: "e0e0e0"+base07: "ffffff"+base08: "cc6666"+base09: "de935f"+base0A: "f0c674"+base0B: "b5bd68"+base0C: "8abeb7"+base0D: "81a2be"+base0E: "b294bb"+base0F: "a3685a"+`;++function paletteOf(entries: Partial<Record<string, string>> = {}): Base16Scheme['palette'] {+ const palette = {} as Base16Scheme['palette'];+ for (const [i, slot] of BASE16_SLOTS.entries()) {+ palette[slot] = entries[slot] ?? `#${i.toString(16).repeat(6)}`;+ }+ return palette;+}++describe('slot list', () => {+ test('is the sixteen spec slots in order', () => {+ expect(BASE16_SLOTS).toHaveLength(16);+ expect(BASE16_SLOTS[0]).toBe('base00');+ expect(BASE16_SLOTS[15]).toBe('base0F');+ });++ test('every slot carries a role description', () => {+ for (const slot of BASE16_SLOTS) {+ expect(BASE16_SLOT_ROLES[slot], slot).toBeTruthy();+ }+ });+});++describe('parseBase16Scheme', () => {+ test('reads the current Tinted Theming layout', () => {+ const result = parseBase16Scheme(CURRENT_LAYOUT);+ expect(result.ok).toBe(true);+ if (!result.ok) return;+ expect(result.scheme.name).toBe('Ayu Dark');+ expect(result.scheme.author).toContain('Khue Nguyen');+ expect(result.scheme.variant).toBe('dark');+ expect(result.scheme.palette.base00).toBe('#0f1419');+ expect(result.scheme.palette.base0F).toBe('#e6b673');+ });++ test('reads the legacy layout: top-level slots, bare hex, inferred variant', () => {+ const result = parseBase16Scheme(LEGACY_LAYOUT);+ expect(result.ok).toBe(true);+ if (!result.ok) return;+ expect(result.scheme.palette.base00).toBe('#1d1f21');+ expect(result.scheme.palette.base0A).toBe('#f0c674');+ // No `variant` key — derived from the ramp, background darker than foreground.+ expect(result.scheme.variant).toBe('dark');+ });++ test('infers a light variant when the background is lighter than the foreground', () => {+ const result = parseBase16Scheme(+ JSON.stringify({ name: 'L', palette: paletteOf({ base00: '#fafafa', base05: '#111111' }) }),+ );+ expect(result.ok).toBe(true);+ if (!result.ok) return;+ expect(result.scheme.variant).toBe('light');+ });++ test('accepts JSON, since YAML is a superset', () => {+ const result = parseBase16Scheme(+ JSON.stringify({ name: 'JSON scheme', variant: 'dark', palette: paletteOf() }),+ );+ expect(result.ok).toBe(true);+ if (!result.ok) return;+ expect(result.scheme.name).toBe('JSON scheme');+ });++ test('reads unquoted scalars as written, including exponent-shaped hex', () => {+ // A bare legacy hex is ambiguous once YAML types it: `1e5` is valid+ // three-digit hex but reads as the number 100000 under the core schema,+ // and `001122` loses its leading zeros. Reconstructing digits from the+ // parsed number silently yields the wrong color, so the parser keeps+ // scalars as their source text instead.+ const result = parseBase16Scheme(+ [+ 'base00: 112233',+ 'base01: "#abc"',+ 'base02: 001122',+ 'base03: 1e5',+ 'base04: 0e0',+ ...BASE16_SLOTS.slice(5).map((s) => `${s}: "#010101"`),+ ].join('\n'),+ );+ expect(result.ok).toBe(true);+ if (!result.ok) return;+ expect(result.scheme.palette.base00).toBe('#112233');+ expect(result.scheme.palette.base01).toBe('#aabbcc');+ expect(result.scheme.palette.base02).toBe('#001122');+ // `1e5` is three-digit hex, not 100000.+ expect(result.scheme.palette.base03).toBe('#11ee55');+ expect(result.scheme.palette.base04).toBe('#00ee00');+ });++ test('names the missing slots rather than failing opaquely', () => {+ const result = parseBase16Scheme('base00: "#111111"\nbase01: "#222222"');+ expect(result.ok).toBe(false);+ if (result.ok) return;+ expect(result.error.kind).toBe('missing-slots');+ if (result.error.kind !== 'missing-slots') return;+ expect(result.error.slots).toContain('base02');+ expect(result.error.slots).not.toContain('base00');+ });++ test('names the slots whose value is not a color', () => {+ const palette = paletteOf();+ const result = parseBase16Scheme(+ JSON.stringify({ palette: { ...palette, base08: 'rebeccapurple' } }),+ );+ expect(result.ok).toBe(false);+ if (result.ok) return;+ expect(result.error.kind).toBe('bad-hex');+ if (result.error.kind !== 'bad-hex') return;+ expect(result.error.slots).toEqual(['base08']);+ });++ test('rejects input that is not a mapping', () => {+ expect(parseBase16Scheme('- a\n- b')).toMatchObject({ error: { kind: 'not-a-scheme' } });+ expect(parseBase16Scheme('')).toMatchObject({ error: { kind: 'not-a-scheme' } });+ });++ test('rejects unparseable input and names the offending line', () => {+ const result = parseBase16Scheme('{[unclosed');+ expect(result).toMatchObject({ error: { kind: 'unparseable' } });+ if (result.ok || result.error.kind !== 'unparseable') return;+ // A pasted scheme is ~20 lines; without a position the user has nothing to+ // go on but "it didn't parse".+ expect(result.error.line).toBe(1);+ });++ test('an unparseable input with no reported position still classifies', () => {+ // `line` is optional — the parser may reject without a position, and the+ // caller must not depend on it being present.+ const result = parseBase16Scheme('a: b: c: d');+ expect(result.ok).toBe(false);+ if (result.ok) return;+ expect(result.error.kind).toBe('unparseable');+ });++ test('falls back to a usable name when the scheme carries none', () => {+ const result = parseBase16Scheme(JSON.stringify({ palette: paletteOf() }));+ expect(result.ok).toBe(true);+ if (!result.ok) return;+ expect(result.scheme.name).toBeTruthy();+ });+});++describe('base16ToTokens', () => {+ const scheme: Base16Scheme = { name: 'T', variant: 'dark', palette: paletteOf() };++ test('maps the slots onto their documented roles', () => {+ const t = base16ToTokens(scheme);+ const p = scheme.palette;+ expect(t.background).toBe(p.base00);+ expect(t.foreground).toBe(p.base05);+ expect(t.card).toBe(p.base01);+ expect(t.sidebar).toBe(p.base01);+ expect(t.border).toBe(p.base02);+ // base02 IS the selection slot — no alpha-derived approximation.+ expect(t['selection-soft']).toBe(p.base02);+ expect(t['muted-foreground']).toBe(p.base04);+ expect(t.primary).toBe(p.base0D);+ expect(t.destructive).toBe(p.base08);+ expect(t['syntax-string']).toBe(p.base0B);+ expect(t['syntax-keyword']).toBe(p.base0E);+ expect(t['syntax-comment']).toBe(p.base03);+ });++ test('covers the surfaces that a palette without slot roles could not reach', () => {+ const t = base16ToTokens(scheme);+ // Fifteen callout accents, the lint pair, and sixteen ANSI slots. These+ // are only derivable because the accent slots carry fixed roles; drop one+ // and that surface falls back to a hardcoded literal no theme can override.+ for (const name of [+ 'callout-note-color',+ 'callout-warning-color',+ 'callout-quote-color',+ 'lint-warning-color',+ 'lint-error-color',+ 'broken-link-color',+ 'link-color',+ 'diff-added',+ 'diff-removed',+ 'syntax-bg',+ ]) {+ expect(t[name], name).toBeTruthy();+ }+ for (const token of [+ 'ansi-black',+ 'ansi-red',+ 'ansi-green',+ 'ansi-yellow',+ 'ansi-blue',+ 'ansi-magenta',+ 'ansi-cyan',+ 'ansi-white',+ 'ansi-bright-black',+ 'ansi-bright-red',+ 'ansi-bright-green',+ 'ansi-bright-yellow',+ 'ansi-bright-blue',+ 'ansi-bright-magenta',+ 'ansi-bright-cyan',+ 'ansi-bright-white',+ ]) {+ expect(t[token], token).toBeTruthy();+ }+ });++ test('spreads the callout accents across distinct slots', () => {+ const t = base16ToTokens(scheme);+ // Adjacent callout types must stay visually distinguishable; collapsing+ // them onto one accent is the failure this guards.+ const accents = new Set([+ t['callout-note-color'],+ t['callout-abstract-color'],+ t['callout-tip-color'],+ t['callout-important-color'],+ t['callout-warning-color'],+ t['callout-caution-color'],+ t['callout-failure-color'],+ t['callout-quote-color'],+ ]);+ expect(accents.size).toBe(8);+ });++ test('emits only literals — a generated theme block cannot carry indirection', () => {+ for (const [name, value] of Object.entries(base16ToTokens(scheme))) {+ expect(value, name).not.toContain('var(');+ }+ });+});++describe('base16ToYaml', () => {+ test('round-trips through the parser', () => {+ // The point of exporting is portability, which only holds if the output is+ // a scheme every base16 tool — including this one — can read back.+ const original = parseBase16Scheme(CURRENT_LAYOUT);+ expect(original.ok).toBe(true);+ if (!original.ok) return;+ const reparsed = parseBase16Scheme(base16ToYaml(original.scheme));+ expect(reparsed.ok).toBe(true);+ if (!reparsed.ok) return;+ expect(reparsed.scheme).toEqual(original.scheme);+ });++ test('emits the current Tinted Theming layout', () => {+ const yaml = base16ToYaml({ name: 'T', variant: 'light', palette: paletteOf() });+ expect(yaml).toContain('system: "base16"');+ expect(yaml).toContain('name: "T"');+ expect(yaml).toContain('variant: "light"');+ expect(yaml).toContain('palette:');+ for (const slot of BASE16_SLOTS) expect(yaml).toContain(` ${slot}: "`);+ });++ test('omits author when the scheme has none, and emits it when it does', () => {+ expect(base16ToYaml({ name: 'T', variant: 'dark', palette: paletteOf() })).not.toContain(+ 'author:',+ );+ expect(+ base16ToYaml({ name: 'T', author: 'Ada', variant: 'dark', palette: paletteOf() }),+ ).toContain('author: "Ada"');+ });++ test('escapes quotes and backslashes so a hostile name cannot break the document', () => {+ const yaml = base16ToYaml({+ name: 'He said "hi" \\ bye',+ variant: 'dark',+ palette: paletteOf(),+ });+ expect(yaml).toContain('name: "He said \\"hi\\" \\\\ bye"');+ const reparsed = parseBase16Scheme(yaml);+ expect(reparsed.ok).toBe(true);+ if (!reparsed.ok) return;+ expect(reparsed.scheme.name).toBe('He said "hi" \\ bye');+ });+});++describe('color helpers', () => {+ test('isBase16Hex accepts #rrggbb only', () => {+ expect(isBase16Hex('#0f172a')).toBe(true);+ expect(isBase16Hex('#FFF')).toBe(false);+ expect(isBase16Hex('0f172a')).toBe(false);+ expect(isBase16Hex(42)).toBe(false);+ });++ test('relativeLuminance orders black < mid < white', () => {+ expect(relativeLuminance('#000000')).toBeCloseTo(0, 5);+ expect(relativeLuminance('#ffffff')).toBeCloseTo(1, 5);+ expect(relativeLuminance('#0f172a')).toBeLessThan(relativeLuminance('#f1f5f9'));+ });++ test('mixHex interpolates and always yields a literal hex', () => {+ expect(mixHex('#000000', '#ffffff', 0)).toBe('#000000');+ expect(mixHex('#000000', '#ffffff', 1)).toBe('#ffffff');+ expect(mixHex('#000000', '#ffffff', 0.5)).toMatch(HEX);+ // Out-of-range ratios clamp rather than producing an invalid channel.+ expect(mixHex('#000000', '#ffffff', 5)).toBe('#ffffff');+ expect(mixHex('#000000', '#ffffff', -5)).toBe('#000000');+ });+});diff --git a/packages/core/src/theme/base16.ts b/packages/core/src/theme/base16.tsnew file mode 100644index 000000000..43e7dd59e--- /dev/null+++ b/packages/core/src/theme/base16.ts@@ -0,0 +1,420 @@+/**+ * base16 — the interchange format every OK color theme is authored in.+ *+ * Sixteen slots: `base00`–`base07` are shades of one tone (backgrounds through+ * foregrounds), `base08`–`base0F` are the accents. The ordering of the tonal+ * ramp flips with `variant` — dark schemes run base00 (darkest) → base07+ * (lightest), light schemes run the other way.+ *+ * Two properties earn the format its place over a bespoke one:+ *+ * 1. The accent slots have fixed *roles*, not fixed hues — `base08` is+ * "variables / tags / diff-deleted" and conventionally red, `base0B` is+ * "strings / diff-inserted" and conventionally green. That role fixing is+ * what lets one scheme drive syntax highlighting, callout accents, lint+ * squigglies and the terminal's 16 ANSI slots from a single source.+ * 2. The slots map onto ANSI, so a scheme is directly expressible as a+ * terminal palette (the `--ansi-*` tokens below). A palette keyed by+ * app-semantic names ("primary", "surface") is not, which is what keeps a+ * terminal's sixteen slots reachable from a theme at all.+ *+ * Reference: the Tinted Theming styling guidelines (base16 v0.4.2).+ */++import { parse as parseYaml } from 'yaml';++/** The sixteen slots, in spec order. Iteration order is stable for CSS generation. */+export const BASE16_SLOTS = [+ 'base00',+ 'base01',+ 'base02',+ 'base03',+ 'base04',+ 'base05',+ 'base06',+ 'base07',+ 'base08',+ 'base09',+ 'base0A',+ 'base0B',+ 'base0C',+ 'base0D',+ 'base0E',+ 'base0F',+] as const;++export type Base16Slot = (typeof BASE16_SLOTS)[number];++/**+ * Short human role per slot, for config-field descriptions and the settings+ * editor's swatch labels. Kept beside the slot list so a reader of either+ * surface sees the same wording.+ */+export const BASE16_SLOT_ROLES: Record<Base16Slot, string> = {+ base00: 'default background',+ base01: 'alt background — cards, popovers, sidebar',+ base02: 'selection background, borders',+ base03: 'comments, invisibles',+ base04: 'secondary text',+ base05: 'default foreground',+ base06: 'light foreground',+ base07: 'lightest foreground',+ base08: 'red — variables, tags, diff deleted',+ base09: 'orange — numbers, constants',+ base0A: 'yellow — classes, search highlight',+ base0B: 'green — strings, diff inserted',+ base0C: 'cyan — support, escapes, quotes',+ base0D: 'blue — functions, headings, accent',+ base0E: 'magenta — keywords, storage',+ base0F: 'deprecated markers, embedded tags',+};++/**+ * Sixteen `#rrggbb` values. Slot roles, per the styling guidelines:+ *+ * | slot | ANSI | role |+ * | ------ | --------------- | -------------------------------------------------------- |+ * | base00 | black | default background |+ * | base01 | — | lighter/alt background — status bars, cards, sidebar |+ * | base02 | — | selection background |+ * | base03 | bright black | comments, invisibles, line highlighting |+ * | base04 | — | dark foreground — status bars, secondary text |+ * | base05 | white | default foreground, caret, delimiters, operators |+ * | base06 | — | light foreground |+ * | base07 | bright white | lightest foreground |+ * | base08 | red | variables, tags, markup lists, diff deleted |+ * | base09 | — | integers, booleans, constants, markup link url |+ * | base0A | yellow | classes, markup bold, search highlight |+ * | base0B | green | strings, inherited class, markup code, diff inserted |+ * | base0C | cyan | support, regexes, escape characters, markup quotes |+ * | base0D | blue | functions, methods, attribute ids, headings |+ * | base0E | magenta | keywords, storage, selectors, markup italic, diff changed |+ * | base0F | — | deprecated, embedded-language tags |+ */+export type Base16Palette = Record<Base16Slot, string>;++/** A scheme: the palette plus the metadata the spec's YAML files carry. */+export interface Base16Scheme {+ /** Display name, e.g. `Dracula`. A brand proper-noun — not translated. */+ name: string;+ /** Credit line from the upstream scheme, when it has one. */+ author?: string;+ /**+ * Which end of the tonal ramp `base00` sits at. Also the light/dark mode the+ * theme forces, so Tailwind `dark:` variants and `color-scheme` stay correct.+ */+ variant: 'dark' | 'light';+ palette: Base16Palette;+}++const HEX_RE = /^#[0-9a-fA-F]{6}$/;++export function isBase16Hex(value: unknown): value is string {+ return typeof value === 'string' && HEX_RE.test(value);+}++/**+ * Map a scheme onto the app's CSS custom properties (token name → value, keyed+ * without the leading `--`). Insertion order is stable so generated CSS diffs+ * stay readable.+ *+ * Surface derivation uses `base01` for every elevated surface — cards,+ * popovers, sidebar. Real schemes disagree on whether `base01` sits lighter or+ * darker than `base00` (Dracula and Catppuccin author it darker even though+ * both are dark schemes), so treating it as "a distinct shade of the same+ * tone" rather than "one step lighter" is the only reading that holds across+ * the ecosystem. Either direction reads as a separate surface.+ */+export function base16ToTokens(scheme: Base16Scheme): Record<string, string> {+ const p = scheme.palette;+ return {+ // --- shadcn core -------------------------------------------------------+ background: p.base00,+ foreground: p.base05,+ card: p.base01,+ 'card-foreground': p.base05,+ popover: p.base01,+ 'popover-foreground': p.base05,+ primary: p.base0D,+ 'primary-foreground': p.base00,+ secondary: p.base01,+ 'secondary-foreground': p.base05,+ muted: p.base01,+ 'muted-foreground': p.base04,+ accent: p.base02,+ 'accent-foreground': p.base05,+ destructive: p.base08,+ border: p.base02,+ input: p.base02,+ ring: p.base0D,+ // base02 *is* the selection background by definition — no alpha-derived+ // approximation needed the way a palette without the slot required.+ 'selection-soft': p.base02,++ // --- charts ------------------------------------------------------------+ 'chart-1': p.base0D,+ 'chart-2': p.base0B,+ 'chart-3': p.base0A,+ 'chart-4': p.base0E,+ 'chart-5': p.base08,++ // --- sidebar / chrome --------------------------------------------------+ sidebar: p.base01,+ 'sidebar-foreground': p.base05,+ 'sidebar-primary': p.base0D,+ 'sidebar-primary-foreground': p.base00,+ 'sidebar-accent': p.base02,+ 'sidebar-accent-foreground': p.base0D,+ 'sidebar-hover': p.base02,+ 'sidebar-border': p.base02,+ 'sidebar-ring': p.base0D,++ // --- syntax ------------------------------------------------------------+ 'syntax-keyword': p.base0E,+ 'syntax-tag': p.base08,+ 'syntax-attr': p.base0D,+ 'syntax-string': p.base0B,+ 'syntax-number': p.base09,+ 'syntax-atom': p.base0C,+ // Slots the previous palette had no room for. These are what let the+ // source editor and fenced code blocks drop their hardcoded highlight+ // styles.+ 'syntax-comment': p.base03,+ 'syntax-func': p.base0D,+ 'syntax-var': p.base08,+ 'syntax-type': p.base0A,+ 'syntax-operator': p.base05,+ 'syntax-meta': p.base0F,+ 'syntax-bg': p.base01,++ // --- editor affordances ------------------------------------------------+ 'link-color': p.base0D,+ 'broken-link-color': p.base08,+ 'lint-warning-color': p.base0A,+ 'lint-error-color': p.base08,+ 'diff-added': p.base0B,+ 'diff-removed': p.base08,++ // --- callouts ----------------------------------------------------------+ // Spread across all eight accents so adjacent types stay distinguishable;+ // `quote` takes the comment slot to keep its deliberate near-gray.+ 'callout-note-color': p.base0D,+ 'callout-info-color': p.base0D,+ 'callout-todo-color': p.base0D,+ 'callout-abstract-color': p.base0C,+ 'callout-tip-color': p.base0B,+ 'callout-success-color': p.base0B,+ 'callout-important-color': p.base0E,+ 'callout-example-color': p.base0E,+ 'callout-question-color': p.base0E,+ 'callout-warning-color': p.base0A,+ 'callout-caution-color': p.base09,+ 'callout-danger-color': p.base09,+ 'callout-failure-color': p.base08,+ 'callout-bug-color': p.base08,+ 'callout-quote-color': p.base03,++ // --- terminal ----------------------------------------------------------+ // Emitted as tokens rather than resolved in TS so the terminal picks them+ // up through the same live-token read it already uses for its surfaces,+ // and so custom schemes work with no extra plumbing.+ ...ansiTokens(p),+ };+}++/** xterm's `ITheme` ANSI slot names, in the order the spec's table lists them. */+const ANSI_BY_SLOT = {+ black: 'base00',+ red: 'base08',+ green: 'base0B',+ yellow: 'base0A',+ blue: 'base0D',+ magenta: 'base0E',+ cyan: 'base0C',+ white: 'base05',+ brightBlack: 'base03',+ brightRed: 'base08',+ brightGreen: 'base0B',+ brightYellow: 'base0A',+ brightBlue: 'base0D',+ brightMagenta: 'base0E',+ brightCyan: 'base0C',+ brightWhite: 'base07',+} as const satisfies Record<string, Base16Slot>;++export type AnsiSlotName = keyof typeof ANSI_BY_SLOT;++const ANSI_SLOT_NAMES = Object.keys(ANSI_BY_SLOT) as AnsiSlotName[];++/** `--ansi-*` custom properties, keyed without the leading `--`. */+function ansiTokens(p: Base16Palette): Record<string, string> {+ const out: Record<string, string> = {};+ for (const name of ANSI_SLOT_NAMES) out[`ansi-${kebab(name)}`] = p[ANSI_BY_SLOT[name]];+ return out;+}++/** `brightBlack` → `bright-black`; the ANSI names are the only camelCase input. */+function kebab(name: string): string {+ return name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();+}++/** Double-quoted YAML scalar — the one form that needs no context to be safe. */+function yamlString(value: string): string {+ return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;+}++/**+ * Serialize a scheme back to base16 YAML, in the current Tinted Theming+ * layout. Round-trips through {@link parseBase16Scheme}.+ *+ * The point is portability: a scheme a user tuned here should be pasteable+ * into any other base16-aware tool, not trapped in OK's config.+ */+export function base16ToYaml(scheme: Base16Scheme): string {+ const lines = [+ 'system: "base16"',+ `name: ${yamlString(scheme.name)}`,+ ...(scheme.author ? [`author: ${yamlString(scheme.author)}`] : []),+ `variant: ${yamlString(scheme.variant)}`,+ 'palette:',+ ...BASE16_SLOTS.map((slot) => ` ${slot}: ${yamlString(scheme.palette[slot])}`),+ ];+ return `${lines.join('\n')}\n`;+}++/** Why a pasted scheme was rejected, for a field-level error message. */+export type Base16ParseError =+ /** `line` is the 1-based YAML line the parser rejected, when it reported one. */+ | { kind: 'unparseable'; line?: number }+ | { kind: 'not-a-scheme' }+ | { kind: 'missing-slots'; slots: Base16Slot[] }+ | { kind: 'bad-hex'; slots: Base16Slot[] };++export type Base16ParseResult =+ | { ok: true; scheme: Base16Scheme }+ | { ok: false; error: Base16ParseError };++/**+ * Parse a pasted scheme. Accepts the current Tinted Theming layout (`palette:`+ * nested, `#`-prefixed hex, `variant`) and the original chriskempson layout+ * (slots at the top level, bare hex, no `variant`) — both are widely published,+ * so accepting only one would reject roughly half the ecosystem. JSON parses+ * too, since YAML is a superset.+ *+ * `variant` is inferred when absent by comparing the tonal ramp's endpoints:+ * dark schemes run base00 darker than base05.+ */+export function parseBase16Scheme(text: string): Base16ParseResult {+ let raw: unknown;+ try {+ // The failsafe schema resolves every scalar to a string. That matters+ // because a bare legacy hex is ambiguous once YAML has typed it: `1e5` is+ // valid three-digit hex, but the core schema reads it as the number 100000+ // and the original digits are then unrecoverable. Keeping scalars as+ // written removes the whole class rather than guessing per-shape.+ raw = parseYaml(text, { schema: 'failsafe' });+ } catch (error) {+ // `yaml` throws a YAMLParseError carrying `linePos`; a scheme is ~20 lines,+ // so naming the line is the difference between a fixable error and a shrug.+ const linePos = (error as { linePos?: [{ line?: number }] })?.linePos;+ const line = typeof linePos?.[0]?.line === 'number' ? linePos[0].line : undefined;+ return { ok: false, error: { kind: 'unparseable', line } };+ }+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {+ return { ok: false, error: { kind: 'not-a-scheme' } };+ }++ const doc = raw as Record<string, unknown>;+ const nested = doc.palette;+ const source: Record<string, unknown> =+ nested && typeof nested === 'object' && !Array.isArray(nested)+ ? (nested as Record<string, unknown>)+ : doc;++ const palette = {} as Base16Palette;+ const missing: Base16Slot[] = [];+ const badHex: Base16Slot[] = [];+ for (const slot of BASE16_SLOTS) {+ // The legacy layout is case-sensitive about `base0A`-`base0F`, but hand-+ // edited files drift to lowercase; accept either rather than fail on case.+ const value = source[slot] ?? source[slot.toLowerCase()];+ if (value === undefined || value === null) {+ missing.push(slot);+ continue;+ }+ const hex = normalizeHex(value);+ if (!hex) {+ badHex.push(slot);+ continue;+ }+ palette[slot] = hex;+ }+ if (missing.length) return { ok: false, error: { kind: 'missing-slots', slots: missing } };+ if (badHex.length) return { ok: false, error: { kind: 'bad-hex', slots: badHex } };++ return {+ ok: true,+ scheme: {+ name: typeof doc.name === 'string' && doc.name.trim() ? doc.name.trim() : 'Imported',+ author: typeof doc.author === 'string' && doc.author.trim() ? doc.author.trim() : undefined,+ variant:+ doc.variant === 'light' || doc.variant === 'dark' ? doc.variant : inferVariant(palette),+ palette,+ },+ };+}++/**+ * Accept `#rrggbb`, bare `rrggbb` (the legacy layout), and `#rgb`.+ *+ * Values arrive as their source text (see the failsafe parse above), so an+ * unquoted legacy hex needs no un-coercion — `112233`, `001122` and `1e5` all+ * read as written.+ */+function normalizeHex(value: unknown): string | null {+ if (typeof value !== 'string') return null;+ let s = value.trim();+ if (!s.startsWith('#')) s = `#${s}`;+ if (/^#[0-9a-fA-F]{3}$/.test(s)) {+ s = `#${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}`;+ }+ return HEX_RE.test(s) ? s.toLowerCase() : null;+}++/**+ * Blend two `#rrggbb` colors in sRGB, `t` of the way from `a` to `b`.+ *+ * Deliberately not `color-mix()`: every slot of a `Base16Palette` must be a+ * literal hex, because consumers that can't resolve CSS — xterm's ANSI slots+ * and the settings swatches, which paint outside the cascade on purpose — read+ * the palette directly.+ */+export function mixHex(a: string, b: string, t: number): string {+ const ca = isBase16Hex(a) ? a : '#000000';+ const cb = isBase16Hex(b) ? b : '#000000';+ const k = Math.min(1, Math.max(0, t));+ let out = '#';+ for (let i = 0; i < 3; i++) {+ const va = Number.parseInt(ca.slice(1 + i * 2, 3 + i * 2), 16);+ const vb = Number.parseInt(cb.slice(1 + i * 2, 3 + i * 2), 16);+ out += Math.round(va + (vb - va) * k)+ .toString(16)+ .padStart(2, '0');+ }+ return out;+}++/** sRGB relative luminance (WCAG), 0 (black) … 1 (white). */+export function relativeLuminance(hex: string): number {+ const h = isBase16Hex(hex) ? hex : '#000000';+ const channel = (i: number) => {+ const c = Number.parseInt(h.slice(1 + i * 2, 3 + i * 2), 16) / 255;+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;+ };+ return 0.2126 * channel(0) + 0.7152 * channel(1) + 0.0722 * channel(2);+}++/** A scheme is dark when its background reads darker than its foreground. */+function inferVariant(p: Base16Palette): 'dark' | 'light' {+ return relativeLuminance(p.base00) < relativeLuminance(p.base05) ? 'dark' : 'light';+}diff --git a/packages/core/src/theme/theme-plugins.test.ts b/packages/core/src/theme/theme-plugins.test.tsindex 292f3f6f4..c98a29efd 100644--- a/packages/core/src/theme/theme-plugins.test.ts+++ b/packages/core/src/theme/theme-plugins.test.ts@@ -1,37 +1,40 @@import { describe, expect, test } from 'vitest';+import { BASE16_SLOTS, base16ToTokens } from './base16.ts';import {- type ColorThemeBase,colorThemeMode,- expandPalette,generateColorThemesCss,isDarkTheme,+ renderThemeBlock,resolveThemePlugin,THEME_PLUGIN_IDS,THEME_PLUGINS,} from './theme-plugins.ts';-// Themes without a static, fully-authored `base`: `default` (no overlay) and-// `custom` (built at runtime from the user seed).+// Themes without a static, fully-authored scheme: `default` (no overlay) and+// `custom` (built at runtime from the user's scheme).const NON_STATIC = new Set(['default', 'custom']);describe('THEME_PLUGINS registry', () => {test('default is first; default + custom are the system-kind (non-static) themes', () => {expect(THEME_PLUGINS[0]?.id).toBe('default');- expect(THEME_PLUGINS[0]?.base).toBeUndefined();+ expect(THEME_PLUGINS[0]?.scheme).toBeUndefined();const systemThemes = THEME_PLUGINS.filter((t) => t.kind === 'system');expect(systemThemes.map((t) => t.id).sort()).toEqual(['custom', 'default']);});- test('every static theme carries a full base palette + a toTokens behavior', () => {+ test('every static theme carries a full base16 scheme + a toTokens behavior', () => {for (const theme of THEME_PLUGINS) {if (NON_STATIC.has(theme.id)) continue;- // Every static built-in forces its own mode — dark or light.+ // Every static built-in forces the mode its scheme declares.expect(['dark', 'light']).toContain(theme.kind);- expect(theme.base).toBeDefined();+ expect(theme.kind, theme.id).toBe(theme.scheme?.variant);+ expect(theme.scheme).toBeDefined();// The descriptor owns its behavior (the analog of LintPlugin.lint).expect(typeof theme.toTokens).toBe('function');- for (const [key, value] of Object.entries(theme.base as ColorThemeBase)) {- expect(value, `${theme.id}.${key}`).toMatch(/^#[0-9a-f]{6}$/);+ const palette = theme.scheme?.palette;+ expect(Object.keys(palette ?? {}).sort()).toEqual([...BASE16_SLOTS].sort());+ for (const slot of BASE16_SLOTS) {+ expect(palette?.[slot], `${theme.id}.${slot}`).toMatch(/^#[0-9a-f]{6}$/);}}});@@ -77,24 +80,25 @@ describe('resolveThemePlugin / isDarkTheme', () => {});});-describe('expandPalette + generateColorThemesCss', () => {- test('expandPalette emits a representative slice of shadcn tokens', () => {- const tokens = expandPalette(THEME_PLUGINS[1]?.base as ColorThemeBase);- for (const required of [- 'background',- 'foreground',- 'primary',- 'muted-foreground',- 'border',- 'ring',- 'sidebar',- 'chart-1',- 'syntax-keyword',- ]) {- expect(tokens[required], required).toBeTruthy();+describe('token mapping + generateColorThemesCss', () => {+ test("a descriptor's toTokens matches mapping its scheme directly", () => {+ for (const theme of THEME_PLUGINS) {+ if (!theme.scheme || !theme.toTokens) continue;+ expect(theme.toTokens(), theme.id).toEqual(base16ToTokens(theme.scheme));}});+ test('renderThemeBlock emits the selector, color-scheme, and every token', () => {+ const block = renderThemeBlock('html[data-color-theme="x"]', 'light', {+ background: '#ffffff',+ 'syntax-keyword': '#112233',+ });+ expect(block).toContain('html[data-color-theme="x"] {');+ expect(block).toContain('color-scheme: light;');+ expect(block).toContain('--background: #ffffff;');+ expect(block).toContain('--syntax-keyword: #112233;');+ });+test('generated CSS emits one attribute rule per dark theme; none for default/custom', () => {const css = generateColorThemesCss();expect(css).not.toContain('data-color-theme="default"');diff --git a/packages/core/src/theme/theme-plugins.ts b/packages/core/src/theme/theme-plugins.tsindex b2416777b..036d46661 100644--- a/packages/core/src/theme/theme-plugins.ts+++ b/packages/core/src/theme/theme-plugins.ts@@ -11,44 +11,20 @@* `LintPlugin`. Adding a built-in theme = append one descriptor here; the config* enum, the picker list, and the generated CSS all follow with no edit elsewhere.*- * Each non-`default` built-in is a self-contained palette — `dark` or `light`:- * selecting one layers its tokens via a `data-color-theme` attribute on `<html>`- * and forces its own mode (dark or light) so Tailwind `dark:` variants stay- * correct. `default` carries no palette (defers to the light/dark- * `appearance.theme` mode); `custom` is built at runtime from the user's seed- * (app-side; see `buildCustomThemeCss`).+ * Every palette is a `Base16Scheme` (see `base16.ts`) reproduced verbatim from+ * the upstream Tinted Theming scheme of the same name, so a built-in and a+ * user-imported scheme travel the exact same code path. Selecting one layers its+ * tokens via a `data-color-theme` attribute on `<html>` and forces the scheme's+ * own `variant` so Tailwind `dark:` variants stay correct. `default` carries no+ * palette (defers to the light/dark `appearance.theme` mode); `custom` is built+ * at runtime from the user's imported or hand-edited scheme.** The CSS that applies the built-in palettes is GENERATED from this registry into* `packages/app/src/color-themes.generated.css`; the app's `color-themes.test.ts`* regenerates and fails on drift.*/-/** A theme's authored base colors. `expandPalette` derives every shadcn token from these. */-export interface ColorThemeBase {- /** Editor canvas background. */- bg: string;- /** Elevated surfaces (cards, popovers, hover states). Lighter than `bg`. */- bgElevated: string;- /** Chrome / sidebar background. Darker than `bg` for the "island" depth cue. */- bgSubtle: string;- /** Primary body text. */- fg: string;- /** Secondary / descriptive text. Must stay legible on `bg`. */- fgMuted: string;- /** Hairline borders + inputs. */- border: string;- /** Accent for buttons, links, focus ring. */- primary: string;- /** Text painted on top of `primary` — pick for contrast. */- primaryFg: string;- red: string;- green: string;- yellow: string;- blue: string;- cyan: string;- orange: string;- purple: string;-}+import { type Base16Scheme, base16ToTokens } from './base16.ts';/*** A theme plugin descriptor — the theming analog of the content-rules@@ -62,193 +38,170 @@ export interface ThemePlugin<Id extends string = string> {label: string;/** `dark`/`light` palettes force that mode; `system` follows `appearance.theme`. */kind: 'dark' | 'light' | 'system';- /** Authored colors. Absent on `default` (no palette) and `custom` (runtime seed). */- base?: ColorThemeBase;+ /** The authored scheme. Absent on `default` (no palette) and `custom` (runtime import). */+ scheme?: Base16Scheme;/*** The plugin's behavior: derive the CSS token map this theme applies. Present- * only on built-ins with a static `base` (the analog of `LintPlugin.lint`);+ * only on built-ins with a static `scheme` (the analog of `LintPlugin.lint`);* `default`/`custom` have none. The generated CSS calls this per descriptor.*/toTokens?(): Record<string, string>;}-const DRACULA: ColorThemeBase = {- bg: '#282a36',- bgElevated: '#343746',- bgSubtle: '#21222c',- fg: '#f8f8f2',- fgMuted: '#9aa0c5',- border: '#44475a',- primary: '#bd93f9',- primaryFg: '#282a36',- red: '#ff5555',- green: '#50fa7b',- yellow: '#f1fa8c',- blue: '#8be9fd',- cyan: '#8be9fd',- orange: '#ffb86c',- purple: '#ff79c6',+const DRACULA: Base16Scheme = {+ name: 'Dracula',+ author: 'clach04 (https://github.com/clach04)',+ variant: 'dark',+ palette: {+ base00: '#282a36',+ base01: '#21222c',+ base02: '#44475a',+ base03: '#6272a4',+ base04: '#9ea8c7',+ base05: '#f8f8f2',+ base06: '#f8f8f2',+ base07: '#ffffff',+ base08: '#ff5555',+ base09: '#ffb86c',+ base0A: '#f1fa8c',+ base0B: '#50fa7b',+ base0C: '#8be9fd',+ base0D: '#bd93f9',+ base0E: '#ff79c6',+ base0F: '#993333',+ },};-// Catppuccin Frappé — the warm, mid-tone dark flavor. Mauve is the signature accent.-const CATPPUCCIN_FRAPPE: ColorThemeBase = {- bg: '#303446', // base- bgElevated: '#414559', // surface0- bgSubtle: '#292c3c', // mantle- fg: '#c6d0f5', // text- fgMuted: '#a5adce', // subtext0- border: '#51576d', // surface1- primary: '#ca9ee6', // mauve- primaryFg: '#303446', // base (reads on mauve)- red: '#e78284',- green: '#a6d189',- yellow: '#e5c890',- blue: '#8caaee',- cyan: '#81c8be', // teal- orange: '#ef9f76', // peach- purple: '#ca9ee6', // mauve+const CATPPUCCIN_FRAPPE: Base16Scheme = {+ name: 'Catppuccin Frappé',+ author: 'https://github.com/catppuccin/catppuccin',+ variant: 'dark',+ palette: {+ base00: '#303446',+ base01: '#292c3c',+ base02: '#414559',+ base03: '#51576d',+ base04: '#626880',+ base05: '#c6d0f5',+ base06: '#f2d5cf',+ base07: '#babbf1',+ base08: '#e78284',+ base09: '#ef9f76',+ base0A: '#e5c890',+ base0B: '#a6d189',+ base0C: '#81c8be',+ base0D: '#8caaee',+ base0E: '#ca9ee6',+ base0F: '#eebebe',+ },};-// Catppuccin Latte — the light flavor. bgElevated is white so cards lift off the-// soft-gray canvas; bgSubtle is a touch darker for the sidebar "island" depth.-const CATPPUCCIN_LATTE: ColorThemeBase = {- bg: '#eff1f5', // base- bgElevated: '#ffffff', // white cards/popovers lift off the canvas- bgSubtle: '#e6e9ef', // mantle (sidebar, slightly darker than base)- fg: '#4c4f69', // text- fgMuted: '#6c6f85', // subtext0- border: '#ccd0da', // surface0- primary: '#8839ef', // mauve- primaryFg: '#ffffff', // white reads on mauve- red: '#d20f39',- green: '#40a02b',- yellow: '#df8e1d',- blue: '#1e66f5',- cyan: '#179299', // teal- orange: '#fe640b', // peach- purple: '#8839ef', // mauve+const CATPPUCCIN_LATTE: Base16Scheme = {+ name: 'Catppuccin Latte',+ author: 'https://github.com/catppuccin/catppuccin',+ variant: 'light',+ palette: {+ base00: '#eff1f5',+ base01: '#e6e9ef',+ base02: '#ccd0da',+ base03: '#bcc0cc',+ base04: '#acb0be',+ base05: '#4c4f69',+ base06: '#dc8a78',+ base07: '#7287fd',+ base08: '#d20f39',+ base09: '#fe640b',+ base0A: '#df8e1d',+ base0B: '#40a02b',+ base0C: '#179299',+ base0D: '#1e66f5',+ base0E: '#8839ef',+ base0F: '#dd7878',+ },};-const MONOKAI: ColorThemeBase = {- bg: '#272822',- bgElevated: '#31322b',- bgSubtle: '#1e1f1a',- fg: '#f8f8f2',- fgMuted: '#a6a28c',- border: '#49483e',- primary: '#66d9ef',- primaryFg: '#272822',- red: '#f92672',- green: '#a6e22e',- yellow: '#e6db74',- blue: '#66d9ef',- cyan: '#66d9ef',- orange: '#fd971f',- purple: '#ae81ff',+const MONOKAI: Base16Scheme = {+ name: 'Monokai',+ author: 'Wimer Hazenberg (http://www.monokai.nl)',+ variant: 'dark',+ palette: {+ base00: '#272822',+ base01: '#383830',+ base02: '#49483e',+ base03: '#75715e',+ base04: '#a59f85',+ base05: '#f8f8f2',+ base06: '#f5f4f1',+ base07: '#f9f8f5',+ base08: '#f92672',+ base09: '#fd971f',+ base0A: '#f4bf75',+ base0B: '#a6e22e',+ base0C: '#a1efe4',+ base0D: '#66d9ef',+ base0E: '#ae81ff',+ base0F: '#cc6633',+ },};-const GRUVBOX: ColorThemeBase = {- bg: '#282828',- bgElevated: '#32302f',- bgSubtle: '#1d2021',- fg: '#ebdbb2',- fgMuted: '#a89984',- border: '#3c3836',- primary: '#83a598',- primaryFg: '#1d2021',- red: '#fb4934',- green: '#b8bb26',- yellow: '#fabd2f',- blue: '#83a598',- cyan: '#8ec07c',- orange: '#fe8019',- purple: '#d3869b',+const GRUVBOX: Base16Scheme = {+ name: 'Gruvbox dark, medium',+ author: 'Dawid Kurek, morhetz (https://github.com/morhetz/gruvbox)',+ variant: 'dark',+ palette: {+ base00: '#282828',+ base01: '#3c3836',+ base02: '#504945',+ base03: '#665c54',+ base04: '#bdae93',+ base05: '#d5c4a1',+ base06: '#ebdbb2',+ base07: '#fbf1c7',+ base08: '#fb4934',+ base09: '#fe8019',+ base0A: '#fabd2f',+ base0B: '#b8bb26',+ base0C: '#8ec07c',+ base0D: '#83a598',+ base0E: '#d3869b',+ base0F: '#d65d0e',+ },};-const SOLARIZED: ColorThemeBase = {- bg: '#002b36',- bgElevated: '#073642',- bgSubtle: '#00252e',- fg: '#93a1a1',- fgMuted: '#6a7f86',- border: '#0e4a56',- primary: '#268bd2',- primaryFg: '#fdf6e3',- red: '#dc322f',- green: '#859900',- yellow: '#b58900',- blue: '#268bd2',- cyan: '#2aa198',- orange: '#cb4b16',- purple: '#6c71c4',+const SOLARIZED: Base16Scheme = {+ name: 'Solarized Dark',+ author: 'Ethan Schoonover (modified by aramisgithub)',+ variant: 'dark',+ palette: {+ base00: '#002b36',+ base01: '#073642',+ base02: '#586e75',+ base03: '#657b83',+ base04: '#839496',+ base05: '#93a1a1',+ base06: '#eee8d5',+ base07: '#fdf6e3',+ base08: '#dc322f',+ base09: '#cb4b16',+ base0A: '#b58900',+ base0B: '#859900',+ base0C: '#2aa198',+ base0D: '#268bd2',+ base0E: '#6c71c4',+ base0F: '#d33682',+ },};/**- * Map a base palette to the full shadcn token set (token name → CSS value),- * keyed without the leading `--`. Order is stable for deterministic CSS- * generation. Alpha-derived tokens reference `var(--primary)` via relative- * color syntax so they track the primary with no duplicated literal.+ * Build a built-in descriptor from a scheme. `kind` comes from the scheme's own+ * `variant` — a light scheme forces light mode, not merely "not dark".*/-export function expandPalette(b: ColorThemeBase): Record<string, string> {- return {- background: b.bg,- foreground: b.fg,- card: b.bgElevated,- 'card-foreground': b.fg,- popover: b.bgElevated,- 'popover-foreground': b.fg,- primary: b.primary,- 'primary-foreground': b.primaryFg,- secondary: b.bgElevated,- 'secondary-foreground': b.fg,- muted: b.bgElevated,- 'muted-foreground': b.fgMuted,- accent: b.bgElevated,- 'accent-foreground': b.fg,- destructive: b.red,- border: b.border,- input: b.border,- ring: b.primary,- 'selection-soft': 'oklch(from var(--primary) l c h / 0.3)',- 'chart-1': b.primary,- 'chart-2': b.green,- 'chart-3': b.yellow,- 'chart-4': b.purple,- 'chart-5': b.red,- sidebar: b.bgSubtle,- 'sidebar-foreground': b.fg,- 'sidebar-primary': b.primary,- 'sidebar-primary-foreground': b.primaryFg,- 'sidebar-accent': 'oklch(from var(--primary) l c h / 0.14)',- 'sidebar-accent-foreground': b.primary,- 'sidebar-hover': b.bgElevated,- 'sidebar-border': b.border,- 'sidebar-ring': b.primary,- 'syntax-keyword': b.purple,- 'syntax-tag': b.red,- 'syntax-attr': b.blue,- 'syntax-string': b.green,- 'syntax-number': b.orange,- 'syntax-atom': b.cyan,- };-}--/** Build a `dark` built-in descriptor whose `toTokens` derives from its palette. */-function darkTheme<const Id extends string>(- id: Id,- label: string,- base: ColorThemeBase,-): ThemePlugin<Id> {- return { id, label, kind: 'dark', base, toTokens: () => expandPalette(base) };-}--/** Build a `light` built-in descriptor whose `toTokens` derives from its palette. */-function lightTheme<const Id extends string>(+function builtIn<const Id extends string>(id: Id,label: string,- base: ColorThemeBase,+ scheme: Base16Scheme,): ThemePlugin<Id> {- return { id, label, kind: 'light', base, toTokens: () => expandPalette(base) };+ return { id, label, kind: scheme.variant, scheme, toTokens: () => base16ToTokens(scheme) };}/** Build a `system`-kind descriptor (no static palette): `default` and `custom`. */@@ -263,16 +216,16 @@ function systemTheme<const Id extends string>(id: Id, label: string): ThemePlugi*/export const THEME_PLUGINS = [systemTheme('default', 'Default'),- darkTheme('dracula', 'Dracula', DRACULA),- darkTheme('catppuccin-frappe', 'Catppuccin Frappé', CATPPUCCIN_FRAPPE),- lightTheme('catppuccin-latte', 'Catppuccin Latte', CATPPUCCIN_LATTE),- darkTheme('monokai', 'Monokai', MONOKAI),- darkTheme('gruvbox', 'Gruvbox', GRUVBOX),- darkTheme('solarized', 'Solarized', SOLARIZED),- // `custom` carries no static `base`: its palette is built at runtime from the- // user's `appearance.customTheme` seed (app-side `buildCustomThemeCss`). `kind`- // is a placeholder — the real light/dark mode is derived per-seed. Excluded- // from the generated CSS (no `toTokens`).+ builtIn('dracula', 'Dracula', DRACULA),+ builtIn('catppuccin-frappe', 'Catppuccin Frappé', CATPPUCCIN_FRAPPE),+ builtIn('catppuccin-latte', 'Catppuccin Latte', CATPPUCCIN_LATTE),+ builtIn('monokai', 'Monokai', MONOKAI),+ builtIn('gruvbox', 'Gruvbox', GRUVBOX),+ builtIn('solarized', 'Solarized', SOLARIZED),+ // `custom` carries no static scheme: its palette is built at runtime from the+ // user's `appearance.customTheme` (an imported or hand-edited base16 scheme).+ // `kind` is a placeholder — the real mode comes from the scheme's `variant`.+ // Excluded from the generated CSS (no `toTokens`).systemTheme('custom', 'Custom'),] as const;@@ -314,22 +267,34 @@ export function colorThemeMode(id: string | undefined): 'light' | 'dark' | undef}/**- * Render the generated stylesheet that applies every built-in palette. One rule- * per dark theme, selected by `html[data-color-theme="<id>"]`. The attribute- * selector out-specifies the base `:root` / `.dark` blocks, so a single block- * per theme overrides both regardless of source order. `color-scheme` (the- * theme's own kind) keeps native scrollbars / form controls correct even before- * the `.dark` class settles on first paint. The descriptor's own `toTokens`- * produces the tokens.+ * Render one `html[data-color-theme="<id>"]` block. The attribute selector+ * out-specifies the base `:root` / `.dark` blocks, so a single block per theme+ * overrides both regardless of source order. `color-scheme` keeps native+ * scrollbars / form controls correct even before the `.dark` class settles on+ * first paint.+ */+export function renderThemeBlock(+ selector: string,+ variant: 'dark' | 'light',+ tokens: Record<string, string>,+): string {+ const lines = Object.entries(tokens).map(([name, value]) => ` --${name}: ${value};`);+ return `${selector} {\n color-scheme: ${variant};\n${lines.join('\n')}\n}`;+}++/**+ * Render the generated stylesheet that applies every built-in palette. The+ * descriptor's own `toTokens` produces the tokens.*/export function generateColorThemesCss(): string {const header =- '/* GENERATED by `bun run gen:color-themes` from src/lib/color-themes.ts — do not edit by hand. */\n';- const blocks = THEME_PLUGINS.filter((t) => t.toTokens).map((theme) => {- const tokens = (theme.toTokens as () => Record<string, string>)();- const lines = Object.entries(tokens).map(([name, value]) => ` --${name}: ${value};`);- const colorScheme = theme.kind === 'light' ? 'light' : 'dark';- return `html[data-color-theme="${theme.id}"] {\n color-scheme: ${colorScheme};\n${lines.join('\n')}\n}`;- });+ '/* GENERATED by `pnpm run gen:color-themes` from packages/core/src/theme/theme-plugins.ts — do not edit by hand. */\n';+ const blocks = THEME_PLUGINS.filter((t) => t.toTokens).map((theme) =>+ renderThemeBlock(+ `html[data-color-theme="${theme.id}"]`,+ theme.kind === 'light' ? 'light' : 'dark',+ (theme.toTokens as () => Record<string, string>)(),+ ),+ );return `${header}\n${blocks.join('\n\n')}\n`;}diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.tsindex 291c1d798..b2bff7dcf 100644--- a/packages/desktop/src/main/index.ts+++ b/packages/desktop/src/main/index.ts@@ -133,7 +133,12 @@ import {shell,utilityProcess,} from 'electron';-import type { ClaudeReadiness, CliReadiness, OkMenuAction } from '../shared/bridge-contract.ts';+import type {+ ClaudeReadiness,+ CliReadiness,+ OkChromeColors,+ OkMenuAction,+} from '../shared/bridge-contract.ts';import { type EntryPoint, isEntryPoint } from '../shared/entry-point.ts';import type {EditorActiveTargetSnapshot,@@ -473,6 +478,19 @@ const VIBRANCY_DEFAULT: VibrancyMaterial = 'sidebar';// module load for the initial chrome; a `nativeTheme.on('updated')`// listener (registered in bootstrap below) re-applies via// `applyThemeToWindow`, and covers windows created after a theme flip.+// The active color theme's chrome colors, as last reported by a renderer over+// `ok:theme:applied`. Undefined until the first renderer mounts, which is when+// the default-theme snapshot in `window-chrome.ts` is the correct answer.+let lastChromeColors: OkChromeColors | undefined;++/** Repaint every live window's OS-drawn chrome from the active palette. */+function fanOutChromeColors(): void {+ if (process.platform === 'darwin') return;+ for (const win of BrowserWindow.getAllWindows()) {+ applyThemeToWindow(win, process.platform, nativeTheme.shouldUseDarkColors, lastChromeColors);+ }+}+const DEFAULT_WIN_OPTS: BrowserWindowConstructorOptions = {width: 1280,height: 800,@@ -4700,6 +4718,10 @@ function registerIpcHandlers() {fireThemeApplied: (w) => showGate.fireThemeApplied(w as BrowserWindowLike),applyReducedTransparency: (reduced) =>applyReducedTransparency(reducedTransparencyDeps, reduced),+ applyChromeColors: (chrome) => {+ lastChromeColors = chrome;+ fanOutChromeColors();+ },warn: (line) => console.warn(line),},win as unknown as object | null,@@ -6425,11 +6447,7 @@ function bootPrimaryInstance(): void {// the solid background (+ overlay colors on win32) to every live// window. macOS is untouched — vibrancy tracks nativeTheme natively.if (process.platform !== 'darwin') {- nativeTheme.on('updated', () => {- for (const win of BrowserWindow.getAllWindows()) {- applyThemeToWindow(win, process.platform, nativeTheme.shouldUseDarkColors);- }- });+ nativeTheme.on('updated', fanOutChromeColors);}// AppImage deep-link self-registration (windows-linux-port deep-link posture): fire-and-forget — adiff --git a/packages/desktop/src/main/theme-applied-handler.ts b/packages/desktop/src/main/theme-applied-handler.tsindex d7235cfa1..cfd1529a2 100644--- a/packages/desktop/src/main/theme-applied-handler.ts+++ b/packages/desktop/src/main/theme-applied-handler.ts@@ -31,11 +31,19 @@* function only sees the structural collaborators it actually invokes.*/+import type { OkChromeColors } from '../shared/bridge-contract.ts';+interface ApplyThemeAppliedDeps {/** Forward to `showGate.fireThemeApplied(window)`. */fireThemeApplied: (window: object) => void;/** Forward to `applyReducedTransparency(reducedTransparencyDeps, reduced)`. */applyReducedTransparency: (reduced: boolean) => void;+ /**+ * Fan the active color theme's chrome colors out to every window (and+ * remember them for windows opened later). No-op on darwin, where vibrancy+ * owns the chrome surface.+ */+ applyChromeColors: (chrome: OkChromeColors) => void;/** Diagnostic sink for structured warn lines. Production wires console.warn. */warn: (line: string) => void;}@@ -66,11 +74,17 @@ interface ApplyThemeAppliedDeps {export function applyThemeApplied(deps: ApplyThemeAppliedDeps,senderWindow: object | null,- opts: { reducedTransparency?: boolean } | undefined,+ opts: { reducedTransparency?: boolean; chrome?: OkChromeColors } | undefined,): void {if (opts?.reducedTransparency !== undefined) {deps.applyReducedTransparency(opts.reducedTransparency);}+ // Before the show-gate release, for the same reason vibrancy goes first: the+ // first composited frame should already carry the active palette's chrome+ // rather than the default theme's snapshot.+ if (opts?.chrome) {+ deps.applyChromeColors(opts.chrome);+ }if (senderWindow !== null) {deps.fireThemeApplied(senderWindow);} else {diff --git a/packages/desktop/src/main/window-chrome.test.ts b/packages/desktop/src/main/window-chrome.test.tsindex 9ebdbe271..2ff3e2147 100644--- a/packages/desktop/src/main/window-chrome.test.ts+++ b/packages/desktop/src/main/window-chrome.test.ts@@ -1,4 +1,5 @@import { describe, expect, test } from 'vitest';+import type { OkChromeColors } from '../shared/bridge-contract.ts';import {applyThemeToWindow,buildNonDarwinChromeOpts,@@ -8,6 +9,9 @@ import {TITLEBAR_OVERLAY_HEIGHT,} from './window-chrome.ts';+/** An active palette's resolved chrome, as the renderer reports it. */+const LIVE: OkChromeColors = { bg: '#282a36', symbol: '#f8f8f2' };+describe('computeTitleBarOverlay', () => {test('light theme uses light bg + dark symbols', () => {expect(computeTitleBarOverlay(false)).toEqual({@@ -36,6 +40,25 @@ describe('computeTitleBarOverlay', () => {expect(CHROME_BG.light).toBe('#fafafa');expect(CHROME_BG.dark).toBe('#171717');});++ test("the renderer's live colors take precedence over the default-theme snapshot", () => {+ // Without this the OS-drawn chrome stays on #fafafa/#171717 no matter+ // which palette is active — the gap the live report exists to close.+ expect(computeTitleBarOverlay(true, LIVE)).toEqual({+ color: LIVE.bg,+ symbolColor: LIVE.symbol,+ height: TITLEBAR_OVERLAY_HEIGHT,+ });+ });++ test('live colors win in either mode — the palette, not isDark, picks them', () => {+ // A light-mode scheme reporting dark chrome must not be re-lightened.+ expect(computeTitleBarOverlay(false, LIVE)).toEqual(computeTitleBarOverlay(true, LIVE));+ });++ test('falls back to the snapshot when live is absent (pre-renderer-mount)', () => {+ expect(computeTitleBarOverlay(true, undefined)).toEqual(computeTitleBarOverlay(true));+ });});describe('buildNonDarwinChromeOpts', () => {@@ -102,4 +125,17 @@ describe('applyThemeToWindow', () => {expect(() => applyThemeToWindow(win, 'win32', false)).not.toThrow();expect(calls.bg).toEqual([CHROME_BG.light]);});++ test('win32 repaints background AND overlay from the live palette', () => {+ const { win, calls } = makeWin();+ applyThemeToWindow(win, 'win32', true, LIVE);+ expect(calls.bg).toEqual([LIVE.bg]);+ expect(calls.overlay).toEqual([computeTitleBarOverlay(true, LIVE)]);+ });++ test('linux repaints the background from the live palette', () => {+ const { win, calls } = makeWin();+ applyThemeToWindow(win, 'linux', false, LIVE);+ expect(calls.bg).toEqual([LIVE.bg]);+ });});diff --git a/packages/desktop/src/main/window-chrome.ts b/packages/desktop/src/main/window-chrome.tsindex b302dd7e1..3c245e85b 100644--- a/packages/desktop/src/main/window-chrome.ts+++ b/packages/desktop/src/main/window-chrome.ts@@ -25,6 +25,7 @@*/import type { BrowserWindowConstructorOptions } from 'electron';+import type { OkChromeColors } from '../shared/bridge-contract.ts';export const TITLEBAR_OVERLAY_HEIGHT = 48;@@ -38,10 +39,30 @@ export interface TitleBarOverlayOptions {height: number;}-export function computeTitleBarOverlay(isDark: boolean): TitleBarOverlayOptions {+/**+ * Chrome colors for a mode, with the renderer's live report taking precedence.+ *+ * `CHROME_BG` / `CHROME_SYMBOL` are the DEFAULT theme's `--sidebar` snapshot,+ * so on their own they leave the OS-drawn chrome on `#fafafa`/`#171717` no+ * matter which color theme is active. `live` carries the active theme's+ * resolved values (see `ok:theme:applied`); it's absent before the renderer+ * has mounted, which is exactly when the snapshot is the right answer.+ */+function chromeColors(isDark: boolean, live?: OkChromeColors): OkChromeColors {+ return {+ bg: live?.bg ?? (isDark ? CHROME_BG.dark : CHROME_BG.light),+ symbol: live?.symbol ?? (isDark ? CHROME_SYMBOL.dark : CHROME_SYMBOL.light),+ };+}++export function computeTitleBarOverlay(+ isDark: boolean,+ live?: OkChromeColors,+): TitleBarOverlayOptions {+ const { bg, symbol } = chromeColors(isDark, live);return {- color: isDark ? CHROME_BG.dark : CHROME_BG.light,- symbolColor: isDark ? CHROME_SYMBOL.dark : CHROME_SYMBOL.light,+ color: bg,+ symbolColor: symbol,height: TITLEBAR_OVERLAY_HEIGHT,};}@@ -80,16 +101,18 @@ export function applyThemeToWindow(win: ThemeableWindow,platform: NodeJS.Platform,isDark: boolean,+ live?: OkChromeColors,): void {if (platform === 'darwin' || win.isDestroyed()) return;+ const { bg } = chromeColors(isDark, live);try {- win.setBackgroundColor(isDark ? CHROME_BG.dark : CHROME_BG.light);+ win.setBackgroundColor(bg);} catch {// destroyed mid-iteration — nothing to recolor}if (platform === 'win32' && typeof win.setTitleBarOverlay === 'function') {try {- win.setTitleBarOverlay(computeTitleBarOverlay(isDark));+ win.setTitleBarOverlay(computeTitleBarOverlay(isDark, live));} catch {// overlay-less window (or platform refusal) — cosmetic, skip}diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.tsindex a26332186..5af42fe24 100644--- a/packages/desktop/src/preload/index.ts+++ b/packages/desktop/src/preload/index.ts@@ -35,6 +35,7 @@ import type {} from '@inkeep/open-knowledge-core';import { contextBridge, type IpcRendererEvent, ipcRenderer, webUtils } from 'electron';import type {+ OkChromeColors,OkDesktopBridge,OkDesktopConfig,OkEditorActiveTargetSnapshot,@@ -389,7 +390,7 @@ const bridge: OkDesktopBridge = {setThemeSource: (source: OkThemeSource) => invoke('ok:theme:set-source', { source }),- signalThemeApplied: (opts?: { reducedTransparency?: boolean }) => {+ signalThemeApplied: (opts?: { reducedTransparency?: boolean; chrome?: OkChromeColors }) => {// Fire-and-forget renderer→main signal. Mirror of mcpWiring.signalReady's// shape: invoke (not raw send) so it composes through the typed// createInvoker wrapper and clears the IPC-discipline ratchet. Thediff --git a/packages/desktop/src/shared/bridge-contract.ts b/packages/desktop/src/shared/bridge-contract.tsindex 5ff4d2379..ab1568e19 100644--- a/packages/desktop/src/shared/bridge-contract.ts+++ b/packages/desktop/src/shared/bridge-contract.ts@@ -324,6 +324,18 @@ export interface HeadBranchInfo {export type CheckTargetExistsResult = 'exists' | 'missing' | 'unreadable';/** Payload passed to `onUpdateDownloaded` subscribers. Mirrors ok:update:downloaded. */+/**+ * Window-chrome colors resolved from the ACTIVE color theme, reported by the+ * renderer so the OS-drawn chrome matches the palette rather than the+ * default theme's build-time snapshot. `bg` is the theme's `--sidebar`+ * (the chrome row's own surface); `symbol` is the glyph color for the+ * Windows/Linux overlay's min/max/close controls.+ */+export interface OkChromeColors {+ bg: string;+ symbol: string;+}+export interface OkUpdateDownloadedInfo {readonly version: string;}@@ -1233,7 +1245,7 @@ export interface OkDesktopBridge {* fires before any further hand-rolled channel additions, so payload-* widening on an existing channel is the right fit.*/- signalThemeApplied(opts?: { reducedTransparency?: boolean }): void;+ signalThemeApplied(opts?: { reducedTransparency?: boolean; chrome?: OkChromeColors }): void;dialog: {openFolder(opts?: { defaultPath?: string }): Promise<string | null>;diff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.tsindex c07ad4703..8f1700342 100644--- a/packages/desktop/src/shared/ipc-channels.ts+++ b/packages/desktop/src/shared/ipc-channels.ts@@ -108,6 +108,7 @@ import type {ClaudeReadiness,CliReadiness,HeadBranchInfo,+ OkChromeColors,OkDesktopConfig,OkLocalOpAuthReposResponse,OkLocalOpAuthStatusResponse,@@ -1323,7 +1324,7 @@ export interface RequestChannels {* from the single handler.*/'ok:theme:applied': {- args: [opts?: { reducedTransparency?: boolean }];+ args: [opts?: { reducedTransparency?: boolean; chrome?: OkChromeColors }];result: undefined;};/**diff --git a/packages/desktop/tests/main/theme-applied-handler.test.ts b/packages/desktop/tests/main/theme-applied-handler.test.tsindex 729689105..b1811e303 100644--- a/packages/desktop/tests/main/theme-applied-handler.test.ts+++ b/packages/desktop/tests/main/theme-applied-handler.test.ts@@ -14,7 +14,12 @@* `undefined` to falsy and re-set every window's vibrancy on every* fire — observable as a flicker on cold-launch.*- * 3. The win-null × reducedTransparency-defined edge case — vibrancy+ * 3. The cross-window chrome fan-out — applyChromeColors runs only when+ * `opts.chrome` is present, and lands before the show-gate release so+ * the first composited frame already carries the active palette's+ * chrome rather than the default theme's snapshot.+ *+ * 4. The win-null × fan-out-defined edge cases — vibrancy and chrome* fan-out must still run for OTHER windows even when the signal's* sender window is gone, because the fan-out targets all open* windows, not the sender alone.@@ -29,12 +34,15 @@import { describe, expect, test } from 'vitest';import { applyThemeApplied } from '../../src/main/theme-applied-handler.ts';+import type { OkChromeColors } from '../../src/shared/bridge-contract.ts';interface TraceEvent {- step: 'fireThemeApplied' | 'applyReducedTransparency' | 'warn';+ step: 'fireThemeApplied' | 'applyReducedTransparency' | 'applyChromeColors' | 'warn';args?: unknown;}+const CHROME: OkChromeColors = { bg: '#282a36', symbol: '#f8f8f2' };+function makeDeps() {const trace: TraceEvent[] = [];return {@@ -46,6 +54,9 @@ function makeDeps() {applyReducedTransparency: (reduced: boolean) => {trace.push({ step: 'applyReducedTransparency', args: { reduced } });},+ applyChromeColors: (chrome: OkChromeColors) => {+ trace.push({ step: 'applyChromeColors', args: { chrome } });+ },warn: (line: string) => {trace.push({ step: 'warn', args: { line } });},@@ -117,7 +128,50 @@ describe('applyThemeApplied — reduced-transparency gate', () => {});});+describe('applyThemeApplied — chrome-colors gate', () => {+ test('does NOT call applyChromeColors when opts is undefined (cold-launch path)', () => {+ const { deps, trace } = makeDeps();+ applyThemeApplied(deps, { id: 'win-1' }, undefined);+ expect(trace.filter((t) => t.step === 'applyChromeColors')).toHaveLength(0);+ });++ test('does NOT call applyChromeColors when opts.chrome is absent', () => {+ const { deps, trace } = makeDeps();+ applyThemeApplied(deps, { id: 'win-1' }, { reducedTransparency: true });+ expect(trace.filter((t) => t.step === 'applyChromeColors')).toHaveLength(0);+ });++ test('forwards the palette chrome colors when opts.chrome is present', () => {+ const { deps, trace } = makeDeps();+ applyThemeApplied(deps, { id: 'win-1' }, { chrome: CHROME });+ expect(trace.filter((t) => t.step === 'applyChromeColors')).toEqual([+ { step: 'applyChromeColors', args: { chrome: CHROME } },+ ]);+ });+});+describe('applyThemeApplied — composition edge cases', () => {+ test('chrome fan-out still runs when window is null (fan-out targets ALL windows, not sender alone)', () => {+ const { deps, trace } = makeDeps();+ applyThemeApplied(deps, null, { chrome: CHROME });+ expect(trace.filter((t) => t.step === 'fireThemeApplied')).toHaveLength(0);+ expect(trace.filter((t) => t.step === 'applyChromeColors')).toEqual([+ { step: 'applyChromeColors', args: { chrome: CHROME } },+ ]);+ });++ test('chrome fan-out fires before show-gate when both apply', () => {+ // Same cold-launch reason as vibrancy: the window becomes visible at the+ // show-gate release, so chrome must already be the active palette's or+ // the first composited frame carries the default theme's snapshot.+ const { deps, trace } = makeDeps();+ applyThemeApplied(deps, { id: 'win-1' }, { chrome: CHROME });+ const sequence = trace+ .filter((t) => t.step === 'fireThemeApplied' || t.step === 'applyChromeColors')+ .map((t) => t.step);+ expect(sequence).toEqual(['applyChromeColors', 'fireThemeApplied']);+ });+test('vibrancy fan-out still runs when window is null (fan-out targets ALL windows, not sender alone)', () => {const { deps, trace } = makeDeps();applyThemeApplied(deps, null, { reducedTransparency: true });@@ -143,13 +197,12 @@ describe('applyThemeApplied — composition edge cases', () => {expect(sequence).toEqual(['applyReducedTransparency', 'fireThemeApplied']);});- test('narrow dep surface — the handler does not require any dep beyond fireThemeApplied / applyReducedTransparency / warn', () => {+ test('narrow dep surface — the handler does not require any dep beyond fireThemeApplied / applyReducedTransparency / applyChromeColors / warn', () => {// Lock: future drift that grows the dep surface (e.g., adds a- // setBackgroundColor fan-out, or a state.json write) trips this- // assertion at the type level.+ // state.json write) trips this assertion at the type level.const { deps } = makeDeps();expect(new Set(Object.keys(deps))).toEqual(- new Set(['fireThemeApplied', 'applyReducedTransparency', 'warn']),+ new Set(['fireThemeApplied', 'applyReducedTransparency', 'applyChromeColors', 'warn']),);});});diff --git a/packages/desktop/tests/smoke/report-bug.e2e.ts b/packages/desktop/tests/smoke/report-bug.e2e.tsindex 1065cd84f..37924c005 100644--- a/packages/desktop/tests/smoke/report-bug.e2e.ts+++ b/packages/desktop/tests/smoke/report-bug.e2e.ts@@ -118,8 +118,12 @@ test.describe('Report-a-bug entry points', () => {// App-mounted gate: menu actions delivered before the renderer attaches// its onMenuAction subscription are dropped, so wait for stable App UI- // (the sidebar toolbar) before driving the menu.- await expect(page.getByRole('button', { name: 'New file' })).toBeVisible({ timeout: 30_000 });+ // (the sidebar toolbar) before driving the menu. Scoped to the toolbar+ // because `name` matches a substring: the empty-state "or create a new+ // file" button also carries "new file" in its accessible name.+ await expect(+ page.getByTestId('sidebar-toolbar').getByRole('button', { name: 'New file' }),+ ).toBeVisible({ timeout: 30_000 });// Entry point 1 — Help menu. Label lookup walks every top-level submenu// rather than assuming the Help menu's resolved label/role shape.diff --git a/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.ts b/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.tsindex 8aae18e01..ba25635de 100644--- a/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.ts+++ b/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.ts@@ -98,7 +98,9 @@ async function createSidebarFileAndType(docName: string,bodyText: string,): Promise<void> {- await page.getByRole('button', { name: 'New file' }).click();+ // `exact` because `name` matches a substring by default, and the empty-state+ // "or create a new file" button also carries "new file" in its name.+ await page.getByRole('button', { name: 'New file', exact: true }).click();const renameInput = page.getByRole('textbox', { name: /rename Untitled\.md/i });await renameInput.fill(docName);await renameInput.press('Enter');diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3df577142..816df9fb7 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -473,9 +473,6 @@ importers:'@u-wave/react-vimeo':specifier: ^0.9.12version: 0.9.12([email protected])- '@uiw/codemirror-theme-basic':- specifier: ^4.25.9- version: 4.25.11(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])'@visimer/core':specifier: ^0.1.0version: 0.1.0@@ -6205,16 +6202,6 @@ packages:peerDependencies:react: 19.2.5- '@uiw/[email protected]':- resolution: {integrity: sha512-YGVUxlVi6kzoB2tW0TDUrcEFCs6acJSiqTI8+GyfiYtb10ikfaM8eh+n5u0p1rnhzgPCgA8PSdUvmMJ/MAtgDw==}-- '@uiw/[email protected]':- resolution: {integrity: sha512-SBNCOgRsCtewGNocRbmjbCkltGXlFcPJsvhxQ351VynQjnWUiPbUrFcEU/haQ3HanROdAAjWXZJPk5bMBxl2jw==}- peerDependencies:- '@codemirror/language': '>=6.0.0'- '@codemirror/state': 6.6.0- '@codemirror/view': 6.43.3-'@ungap/[email protected]':resolution: {integrity: sha512-60YRaenCQcVjYEKOcG824+DRGGIQ3VKErcBoAEDJZz5bKIs2ZG+X/H9Nk+Q6EVkwJk5QNApxbrc5QtBSwtrXAg==}@@ -16452,20 +16439,6 @@ snapshots:prop-types: 15.8.1react: 19.2.5- '@uiw/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])':- dependencies:- '@uiw/codemirror-themes': 4.25.11(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])- transitivePeerDependencies:- - '@codemirror/language'- - '@codemirror/state'- - '@codemirror/view'-- '@uiw/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])':- dependencies:- '@codemirror/language': 6.12.4- '@codemirror/state': 6.6.0- '@codemirror/view': 6.43.3-'@ungap/[email protected]': {}'@upsetjs/[email protected]':