Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): stop the Default theme tile borrowing the active palette (#2980)

serafin-garciab2bc23f092d1
diff --git a/.changeset/default-theme-tile-own-colors.md b/.changeset/default-theme-tile-own-colors.md
new file mode 100644
index 000000000..5fc8dc7bd
--- /dev/null
+++ b/.changeset/default-theme-tile-own-colors.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+The Default tile in Settings → Plugins → Themes now previews its own colors instead of borrowing the palette you currently have selected. Picking Dracula used to repaint the Default preview in Dracula's colors, so the grid gave you no way to see what switching back would actually look like. The Default tile now shows the app's own light or dark palette, following your light/dark preference, whichever theme is active.
diff --git a/packages/app/package.json b/packages/app/package.json
index ac812cc30..32ea56ecf 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -26,7 +26,7 @@
"measure:fuzz": "bash scripts/measure-fuzz.sh",
"measure:stress": "bash scripts/measure-stress.sh",
"perf:compare": "bash scripts/perf-compare.sh",
- "test:e2e": "playwright test tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/file-tree-drag-to-root.e2e.ts tests/stress/file-tree-deselect-to-root.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/lint-config-toggle.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/navigation-history.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts tests/stress/showall-lazy-tree.e2e.ts tests/stress/tabs-component-strip.e2e.ts tests/stress/source-find-scroll.e2e.ts tests/stress/harness-app-warmth.e2e.ts tests/stress/qa-canary-authoring-both-modes.e2e.ts tests/stress/qa-canary-live-typing.e2e.ts tests/stress/keystroke-cadence-danger-space.e2e.ts tests/stress/jsx-unregistered-backspace-delete.e2e.ts tests/stress/jsx-unregistered-ime-concurrent.e2e.ts tests/stress/jsx-backspace-delete.e2e.ts tests/stress/link-authoring-bytes.e2e.ts tests/stress/link-authoring-apex.e2e.ts tests/stress/command-palette-parity.e2e.ts tests/stress/settings-search.e2e.ts tests/stress/chip-popover-positioning.e2e.ts tests/stress/docs-open-scroll-restore.e2e.ts tests/stress/file-tree-decoration-chip-strip-repro.e2e.ts tests/stress/grip-click-nodeselect.e2e.ts tests/stress/jsx-halo-semantics.e2e.ts tests/stress/jsx-image-body-click.e2e.ts tests/stress/jsx-prop-panel-placeholder.e2e.ts tests/stress/jsx-range-encompass-halo.e2e.ts tests/stress/jsx-wildcard-convert.e2e.ts tests/stress/markdown-lint.e2e.ts tests/stress/unified-problems.e2e.ts tests/stress/mid-type-recovery.e2e.ts tests/stress/observer-a-multi-client.e2e.ts tests/stress/outline-toolbar-occlusion.e2e.ts tests/stress/quiet-tree-hidden-doc.e2e.ts tests/stress/raw-mdx-fallback-onblur-upgrade.e2e.ts tests/stress/rename-noext-probe.e2e.ts tests/stress/show-ok-folders.e2e.ts tests/stress/source-polish.e2e.ts tests/stress/warm-skeleton-scroll-restore.e2e.ts tests/stress/props-toggle-scroll-preserve.e2e.ts tests/stress/yjs-no-dual-import.e2e.ts tests/stress/slash-command-auto-open.e2e.ts tests/stress/graph-panel-surfaces.e2e.ts tests/stress/clipboard-relative-url-source-fallback.e2e.ts tests/stress/asset-embed-real-fidelity.e2e.ts tests/stress/prop-upload.e2e.ts tests/stress/rename-content-preservation.e2e.ts tests/stress/rename-consolidation.e2e.ts tests/stress/outline-navigation.e2e.ts tests/stress/clipboard-dollar-math-source-fallback.e2e.ts",
+ "test:e2e": "playwright test tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/file-tree-drag-to-root.e2e.ts tests/stress/file-tree-deselect-to-root.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/lint-config-toggle.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/navigation-history.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts tests/stress/showall-lazy-tree.e2e.ts tests/stress/tabs-component-strip.e2e.ts tests/stress/source-find-scroll.e2e.ts tests/stress/harness-app-warmth.e2e.ts tests/stress/qa-canary-authoring-both-modes.e2e.ts tests/stress/qa-canary-live-typing.e2e.ts tests/stress/keystroke-cadence-danger-space.e2e.ts tests/stress/jsx-unregistered-backspace-delete.e2e.ts tests/stress/jsx-unregistered-ime-concurrent.e2e.ts tests/stress/jsx-backspace-delete.e2e.ts tests/stress/link-authoring-bytes.e2e.ts tests/stress/link-authoring-apex.e2e.ts tests/stress/command-palette-parity.e2e.ts tests/stress/settings-search.e2e.ts tests/stress/chip-popover-positioning.e2e.ts tests/stress/docs-open-scroll-restore.e2e.ts tests/stress/file-tree-decoration-chip-strip-repro.e2e.ts tests/stress/grip-click-nodeselect.e2e.ts tests/stress/jsx-halo-semantics.e2e.ts tests/stress/jsx-image-body-click.e2e.ts tests/stress/jsx-prop-panel-placeholder.e2e.ts tests/stress/jsx-range-encompass-halo.e2e.ts tests/stress/jsx-wildcard-convert.e2e.ts tests/stress/markdown-lint.e2e.ts tests/stress/unified-problems.e2e.ts tests/stress/mid-type-recovery.e2e.ts tests/stress/observer-a-multi-client.e2e.ts tests/stress/outline-toolbar-occlusion.e2e.ts tests/stress/quiet-tree-hidden-doc.e2e.ts tests/stress/raw-mdx-fallback-onblur-upgrade.e2e.ts tests/stress/rename-noext-probe.e2e.ts tests/stress/show-ok-folders.e2e.ts tests/stress/source-polish.e2e.ts tests/stress/warm-skeleton-scroll-restore.e2e.ts tests/stress/props-toggle-scroll-preserve.e2e.ts tests/stress/yjs-no-dual-import.e2e.ts tests/stress/slash-command-auto-open.e2e.ts tests/stress/graph-panel-surfaces.e2e.ts tests/stress/clipboard-relative-url-source-fallback.e2e.ts tests/stress/asset-embed-real-fidelity.e2e.ts tests/stress/prop-upload.e2e.ts tests/stress/rename-content-preservation.e2e.ts tests/stress/rename-consolidation.e2e.ts tests/stress/outline-navigation.e2e.ts tests/stress/prd-7627-default-swatch.e2e.ts tests/stress/clipboard-dollar-math-source-fallback.e2e.ts",
"test:e2e:install-browsers": "playwright install chromium webkit firefox",
"test:visual": "playwright test --config playwright.visual.config.ts",
"test:visual:update": "playwright test --config playwright.visual.config.ts --update-snapshots",
diff --git a/packages/app/src/components/settings/ColorThemePicker.dom.test.tsx b/packages/app/src/components/settings/ColorThemePicker.dom.test.tsx
index 73591183f..8b5b89ff8 100644
--- a/packages/app/src/components/settings/ColorThemePicker.dom.test.tsx
+++ b/packages/app/src/components/settings/ColorThemePicker.dom.test.tsx
@@ -1,7 +1,7 @@
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import type { ReactNode } from 'react';
import { afterEach, describe, expect, test, vi } from 'vitest';
-import { COLOR_THEMES } from '@/lib/color-themes';
+import { COLOR_THEMES, defaultThemeTokens } from '@/lib/color-themes';
import { renderLinguiTemplate } from '@/test-utils/lingui-mock';
vi.doMock('@lingui/react/macro', () => ({
@@ -9,9 +9,28 @@ vi.doMock('@lingui/react/macro', () => ({
useLingui: () => ({ t: renderLinguiTemplate }),
}));
-async function renderPicker(value: string, onSelect: (id: string) => void) {
+async function renderPicker(
+ value: string,
+ onSelect: (id: string) => void,
+ defaultMode?: 'light' | 'dark',
+) {
const { ColorThemePicker } = await import('./ColorThemePicker');
- return render(<ColorThemePicker value={value} onSelect={onSelect} aria-label="Color theme" />);
+ return render(
+ <ColorThemePicker
+ value={value}
+ onSelect={onSelect}
+ defaultMode={defaultMode}
+ aria-label="Color theme"
+ />,
+ );
+}
+
+/** Every inline `style` attribute inside a tile's preview, concatenated. */
+function swatchStyles(themeLabel: RegExp): string {
+ const tile = screen.getByRole('radio', { name: themeLabel });
+ return Array.from(tile.querySelectorAll<HTMLElement>('[style]'))
+ .map((el) => el.getAttribute('style') ?? '')
+ .join(' ');
}
describe('ColorThemePicker', () => {
@@ -47,6 +66,32 @@ describe('ColorThemePicker', () => {
expect(picks).toEqual(['catppuccin-frappe']);
});
+ test('paints the Default tile from literal base tokens, not cascaded CSS vars', async () => {
+ // The regression: the preview used to read `var(--sidebar)` & co. Those are
+ // exactly the properties a selected palette overrides on <html>, so the
+ // Default tile inherited the override and mirrored the chosen theme.
+ await renderPicker('default', () => {});
+ const styles = swatchStyles(/Default/);
+ expect(styles).not.toContain('var(--');
+ const tokens = defaultThemeTokens('light');
+ expect(styles).toContain(tokens.background);
+ expect(styles).toContain(tokens.primary);
+ expect(styles).toContain(tokens['syntax-keyword']);
+ });
+
+ test('follows defaultMode for the Default tile only', async () => {
+ await renderPicker('default', () => {}, 'light');
+ const lightDefault = swatchStyles(/Default/);
+ const lightDracula = swatchStyles(/Dracula/);
+ cleanup();
+ await renderPicker('default', () => {}, 'dark');
+ // The base palette flips with the user's light/dark mode; an authored
+ // palette is mode-independent.
+ expect(swatchStyles(/Default/)).not.toBe(lightDefault);
+ expect(swatchStyles(/Default/)).toContain(defaultThemeTokens('dark').background);
+ expect(swatchStyles(/Dracula/)).toBe(lightDracula);
+ });
+
test('tags themes by their forced mode: default is Auto, Latte is Light, the rest Dark', async () => {
await renderPicker('default', () => {});
// Default is the only Auto; Catppuccin Latte is the only Light palette; every
diff --git a/packages/app/src/components/settings/ColorThemePicker.tsx b/packages/app/src/components/settings/ColorThemePicker.tsx
index cf928c6db..b437e5c05 100644
--- a/packages/app/src/components/settings/ColorThemePicker.tsx
+++ b/packages/app/src/components/settings/ColorThemePicker.tsx
@@ -5,6 +5,7 @@ import {
type ColorTheme,
type CustomThemeSeed,
customThemeKind,
+ defaultThemeTokens,
expandCustomSeed,
expandPalette,
resolveCustomSeed,
@@ -20,6 +21,13 @@ interface ColorThemePickerProps {
onSelect: (id: string) => void;
/** The user's custom-theme seed (partial), used to paint the Custom tile preview. */
customSeed?: SeedInput;
+ /**
+ * Light or dark for the Default tile — the mode `appearance.theme` resolves to,
+ * NOT the mode the active palette forces. Picking a dark IDE palette must not
+ * repaint the Default preview dark: the tile advertises what switching back to
+ * `default` would look like.
+ */
+ defaultMode?: 'light' | 'dark';
/** Forwarded id (from the settings form's `<FormControl>` Slot) onto the radio group root. */
id?: string;
'aria-label'?: string;
@@ -45,27 +53,34 @@ function swatchFromTokens(t: Record<string, string>): SwatchColors {
};
}
-function swatchColors(theme: ColorTheme, customSeed: SeedInput): SwatchColors {
+function swatchColors(
+ theme: ColorTheme,
+ customSeed: SeedInput,
+ defaultMode: 'light' | 'dark',
+): SwatchColors {
if (theme.id === 'custom') {
return swatchFromTokens(expandPalette(expandCustomSeed(resolveCustomSeed(customSeed))));
}
if (!theme.base) {
- // `default` tracks the user's live theme — read the cascaded CSS vars so the
- // tile reflects their current light/dark appearance.
- return {
- chrome: 'var(--sidebar)',
- surface: 'var(--background)',
- bar: 'var(--primary)',
- line: 'var(--border)',
- dots: ['var(--chart-2)', 'var(--chart-4)', 'var(--chart-3)'],
- };
+ // `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));
}
/** A miniature editor-window preview, à la the Vivaldi theme tiles. */
-function ThemeSwatch({ theme, customSeed }: { theme: ColorTheme; customSeed: SeedInput }) {
- const c = swatchColors(theme, customSeed);
+function ThemeSwatch({
+ theme,
+ customSeed,
+ defaultMode,
+}: {
+ theme: ColorTheme;
+ customSeed: SeedInput;
+ defaultMode: 'light' | 'dark';
+}) {
+ const c = swatchColors(theme, customSeed, defaultMode);
return (
<div
aria-hidden
@@ -122,6 +137,7 @@ export function ColorThemePicker({
value,
onSelect,
customSeed,
+ defaultMode = 'light',
id,
'aria-label': ariaLabel,
'aria-describedby': ariaDescribedby,
@@ -147,7 +163,7 @@ export function ColorThemePicker({
'data-checked:border-primary',
)}
>
- <ThemeSwatch theme={theme} customSeed={customSeed} />
+ <ThemeSwatch theme={theme} customSeed={customSeed} defaultMode={defaultMode} />
<div className="flex items-center justify-between px-0.5">
<span className="text-1sm font-medium text-foreground">{theme.label}</span>
<span className="text-[10px] font-medium uppercase tracking-wide text-muted-foreground">
diff --git a/packages/app/src/components/settings/field-controls.tsx b/packages/app/src/components/settings/field-controls.tsx
index 161e08959..88a01d3a3 100644
--- a/packages/app/src/components/settings/field-controls.tsx
+++ b/packages/app/src/components/settings/field-controls.tsx
@@ -279,19 +279,33 @@ function FieldControlBody({
// <ThemeProvider> is mounted (e.g. in unit harnesses), and the app always
// mounts one in `main.tsx`. The actual flip is gated to the theme field in
// the enum-toggle branch below, so non-theme controls are unaffected.
- const { setTheme } = useTheme();
+ // `systemTheme` is the OS preference, independent of the mode a palette
+ // forces — it's what `appearance.theme: 'system'` resolves to.
+ const { setTheme, systemTheme } = useTheme();
// Optional: the theme-tiles control reads the custom-theme seed from config,
// but FieldControlBody also renders in provider-less unit harnesses.
const merged = useConfigContextOptional()?.merged ?? null;
if (field.control === 'theme-tiles') {
const { id: forwardedId, ...wrapperSlotProps } = slotForwarded;
const customSeed = merged?.appearance?.customTheme;
+ // The Default tile previews the base palette in the user's own light/dark
+ // mode. Source it from `appearance.theme` (falling back to the OS for
+ // 'system'/unset), never from next-themes' resolved mode — that one carries
+ // whatever the selected palette forced.
+ const configuredMode = merged?.appearance?.theme;
+ const defaultMode =
+ configuredMode === 'light' || configuredMode === 'dark'
+ ? configuredMode
+ : systemTheme === 'dark'
+ ? 'dark'
+ : 'light';
return (
<ColorThemePicker
{...wrapperSlotProps}
id={forwardedId}
value={typeof ctl.value === 'string' ? ctl.value : 'default'}
customSeed={customSeed}
+ defaultMode={defaultMode}
aria-label={t(field.label)}
onSelect={(next) => {
// Optimistic apply: paint the palette overlay synchronously and flip
diff --git a/packages/app/src/lib/color-themes.test.ts b/packages/app/src/lib/color-themes.test.ts
index f0e4a77e9..195047d20 100644
--- a/packages/app/src/lib/color-themes.test.ts
+++ b/packages/app/src/lib/color-themes.test.ts
@@ -10,6 +10,7 @@ import {
type CustomThemeSeed,
customThemeKind,
DEFAULT_CUSTOM_SEED,
+ defaultThemeTokens,
expandCustomSeed,
expandPalette,
generateColorThemesCss,
@@ -89,6 +90,41 @@ describe('expandPalette', () => {
});
});
+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.
+ const SWATCH_TOKENS = [
+ 'sidebar',
+ 'background',
+ 'primary',
+ 'border',
+ 'syntax-string',
+ 'syntax-keyword',
+ 'syntax-atom',
+ ];
+
+ test('resolves every token a swatch reads, with no var() indirection left', () => {
+ for (const mode of ['light', 'dark'] as const) {
+ const tokens = defaultThemeTokens(mode);
+ expect(Object.keys(tokens).sort()).toEqual([...SWATCH_TOKENS].sort());
+ for (const [name, value] of Object.entries(tokens)) {
+ expect(value, `${mode} ${name}`).toBeTruthy();
+ expect(value, `${mode} ${name}`).not.toContain('var(');
+ }
+ }
+ });
+
+ test('light and dark differ on every surface token', () => {
+ const light = defaultThemeTokens('light');
+ const dark = defaultThemeTokens('dark');
+ for (const name of ['sidebar', 'background', 'primary', 'border']) {
+ expect(dark[name], name).not.toBe(light[name]);
+ }
+ });
+});
+
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');
diff --git a/packages/app/src/lib/color-themes.ts b/packages/app/src/lib/color-themes.ts
index 7d616d6ce..0b415ade2 100644
--- a/packages/app/src/lib/color-themes.ts
+++ b/packages/app/src/lib/color-themes.ts
@@ -11,11 +11,14 @@
*/
import {
+ CHROME_BG_DARK,
+ CHROME_BG_LIGHT,
type ColorThemeBase,
colorThemeMode,
expandPalette,
generateColorThemesCss,
isDarkTheme,
+ PREVIEW_THEME_TOKENS,
resolveThemePlugin,
THEME_PLUGINS,
type ThemePlugin,
@@ -33,6 +36,49 @@ export {
};
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
+// 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
+// tokens a preview needs to literals, sourced from the chrome-background
+// constants (`CHROME_BG_*`) and the preview-token snapshot
+// (`PREVIEW_THEME_TOKENS`) — both generated from, and drift-checked against,
+// `globals.css`.
+// ---------------------------------------------------------------------------
+
+/** Literal light/dark values per `globals.css` preview token, keyed by token name. */
+const PREVIEW_TOKEN_BY_NAME = new Map(PREVIEW_THEME_TOKENS.map((token) => [token.name, token]));
+
+function baseToken(name: string, mode: 'light' | 'dark'): string {
+ const token = PREVIEW_TOKEN_BY_NAME.get(name);
+ if (!token) throw new Error(`color-themes: ${name} is not a generated base-theme token`);
+ return token[mode];
+}
+
+/**
+ * The subset of `expandPalette`-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
+ * map onto the chart palette — the base theme's own `--syntax-*` tokens resolve
+ * through Tailwind color vars, which don't survive as literals here.
+ */
+export function defaultThemeTokens(mode: 'light' | 'dark'): Record<string, string> {
+ return {
+ sidebar: mode === 'dark' ? CHROME_BG_DARK : CHROME_BG_LIGHT,
+ background: baseToken('--background', mode),
+ primary: baseToken('--primary', mode),
+ border: baseToken('--border', mode),
+ 'syntax-string': baseToken('--chart-2', mode),
+ 'syntax-keyword': baseToken('--chart-4', mode),
+ 'syntax-atom': baseToken('--chart-3', mode),
+ };
+}
+
// ---------------------------------------------------------------------------
// Custom theme — the user's own palette (`appearance.colorTheme: 'custom'`).
//
diff --git a/packages/app/src/lib/config-provider.user-synced.dom.test.tsx b/packages/app/src/lib/config-provider.user-synced.dom.test.tsx
index 6fd1aa577..5c813781c 100644
--- a/packages/app/src/lib/config-provider.user-synced.dom.test.tsx
+++ b/packages/app/src/lib/config-provider.user-synced.dom.test.tsx
@@ -196,6 +196,19 @@ vi.doMock('@inkeep/open-knowledge-core', () => ({
isDarkTheme: (id?: string) => Boolean(id) && id !== 'default' && id !== 'custom',
resolveThemePlugin: (id?: string) => ({ id: id ?? 'default', label: 'Default', kind: 'system' }),
THEME_PLUGINS: [],
+ // The base-theme tokens `defaultThemeTokens` composes for the Default tile's
+ // preview. Values are placeholders — no assertion here reads them; they only
+ // need to cover the token names the preview looks up.
+ CHROME_BG_LIGHT: '#fafafa',
+ CHROME_BG_DARK: '#171717',
+ PREVIEW_THEME_TOKENS: [
+ { name: '--background', light: '#ffffff', dark: '#0a0a0a' },
+ { name: '--primary', light: '#2563eb', dark: '#69a3ff' },
+ { name: '--border', light: '#e5e5e5', dark: '#2a2a2a' },
+ { name: '--chart-2', light: '#16a34a', dark: '#4ade80' },
+ { name: '--chart-3', light: '#ca8a04', dark: '#facc15' },
+ { name: '--chart-4', light: '#7c3aed', dark: '#a78bfa' },
+ ],
}));
// Module-level toggle for the second case (mount-time pre-synced seed).
diff --git a/packages/app/tests/stress/prd-7627-default-swatch.e2e.ts b/packages/app/tests/stress/prd-7627-default-swatch.e2e.ts
new file mode 100644
index 000000000..c4dc3df81
--- /dev/null
+++ b/packages/app/tests/stress/prd-7627-default-swatch.e2e.ts
@@ -0,0 +1,47 @@
+/**
+ * The Default theme tile must preview the base palette, not whichever palette
+ * is currently applied.
+ *
+ * Real-browser only: the regression is a CSS cascade effect. A selected palette
+ * sets `data-color-theme` on `<html>`, and the generated stylesheet overrides
+ * `--background` / `--sidebar` / `--primary` / … there. The Default tile used to
+ * paint itself from those same `var(--…)` references, so it inherited the
+ * override and mirrored the active theme. jsdom applies no stylesheet, so it
+ * cannot reach this seam — the DOM test next to `ColorThemePicker.tsx` can only
+ * guard the structural half (no `var(--` in the tile).
+ *
+ * The palette is applied by setting the attribute directly rather than by
+ * clicking a tile: `appearance.colorTheme` is USER-scoped config, and the dev
+ * server resolves user scope against the real `~/.ok/global.yml`, so a click
+ * here would rewrite the developer's own theme. Poking the attribute drives the
+ * identical cascade with no write and no dependence on incoming config.
+ */
+import { expect, test } from './_helpers';
+
+/** Dracula's `--background`, as the generated stylesheet sets it. */
+const DRACULA_BG = 'rgb(40, 42, 54)';
+
+test('the Default tile does not inherit the applied palette', async ({ page }) => {
+ await page.goto('/#settings');
+ await expect(page.getByTestId('settings-dialog')).toBeVisible({ timeout: 15_000 });
+
+ // The tile picker lives under Settings → Plugins → Themes; reach it via search.
+ await page.getByTestId('settings-search-input').fill('Color theme');
+ await page.getByTestId('settings-search-results').getByText('Color theme').first().click();
+
+ const surfaceOf = (label: RegExp) =>
+ page
+ .getByRole('radio', { name: label })
+ .locator('[aria-hidden]')
+ .first()
+ .evaluate((el) => getComputedStyle(el).backgroundColor);
+
+ await expect(page.getByRole('radio', { name: /Default/ })).toBeVisible({ timeout: 10_000 });
+ await page.evaluate(() => document.documentElement.setAttribute('data-color-theme', 'dracula'));
+
+ // The palette really is cascading — the Dracula tile paints Dracula's canvas.
+ await expect.poll(() => surfaceOf(/Dracula/)).toBe(DRACULA_BG);
+ // …and the Default tile is unmoved by it. Asserted against the palette rather
+ // than a fixed base color so the check holds in either light or dark mode.
+ expect(await surfaceOf(/Default/)).not.toBe(DRACULA_BG);
+});
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 52bd003b7..089b62d46 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -243,6 +243,7 @@ export {
SYSTEM_DOC_NAME,
skillLiveDocName,
} from './constants/cc1.ts';
+export { CHROME_BG_DARK, CHROME_BG_LIGHT } from './constants/chrome.ts';
export {
CODE_FILE_BARE_NAMES_TO_LANGUAGE,
CODE_FILE_EXTENSIONS_TO_LANGUAGE,