Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(theme): bring the remaining button paints under --ds-* tokens

v_wyxgwang2c527db2761b
diff --git a/apps/desktop/src/features/voice/VoiceMicButton.tsx b/apps/desktop/src/features/voice/VoiceMicButton.tsx
index c381c6b73..c070854e5 100644
--- a/apps/desktop/src/features/voice/VoiceMicButton.tsx
+++ b/apps/desktop/src/features/voice/VoiceMicButton.tsx
@@ -96,7 +96,7 @@ function MicIcon({ active, phase }: { active: boolean; phase: VoicePhase }) {
/>
{/* Recording indicator */}
{phase === "listening" && (
- <circle cx="13" cy="3" r="2.5" fill="var(--color-danger, #ef4444)">
+ <circle cx="13" cy="3" r="2.5" fill="var(--ds-error)">
<animate
attributeName="opacity"
values="1;0.3;1"
diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.css
index af8bb1437..1b795414c 100644
--- a/apps/desktop/src/styles/chrome.css
+++ b/apps/desktop/src/styles/chrome.css
@@ -819,7 +819,7 @@
border: 2px solid var(--ds-bg-sidebar);
border-radius: var(--radius-full);
background: var(--ds-error);
- color: var(--gray-0);
+ color: var(--ds-bg-primary);
font-size: var(--text-3xs);
font-weight: var(--font-weight-semibold);
line-height: var(--leading-none);
@@ -1128,7 +1128,7 @@
}
.window-control-btn.window-control-close:hover {
- color: var(--gray-0);
+ color: var(--ds-bg-primary);
background: var(--ds-error);
}
diff --git a/apps/desktop/src/styles/composer-menus.css b/apps/desktop/src/styles/composer-menus.css
index f7a1c507e..40218c4b2 100644
--- a/apps/desktop/src/styles/composer-menus.css
+++ b/apps/desktop/src/styles/composer-menus.css
@@ -22,16 +22,16 @@
}
:root[data-theme="dark"] .composer-input {
- color: var(--gray-0);
+ color: var(--ds-text-primary);
}
:root[data-theme="dark"] .composer-toolbar .icon-btn,
:root[data-theme="dark"] .mode-chip {
- color: color-mix(in oklab, var(--gray-0) 78%, transparent);
+ color: color-mix(in oklab, var(--ds-text-primary) 78%, transparent);
}
:root[data-theme="dark"] .empty-hero-icon {
- color: var(--gray-0);
+ color: var(--ds-text-primary);
opacity: 1;
}
diff --git a/apps/desktop/src/styles/composer.css b/apps/desktop/src/styles/composer.css
index ed8301eec..97ef5ff6e 100644
--- a/apps/desktop/src/styles/composer.css
+++ b/apps/desktop/src/styles/composer.css
@@ -415,8 +415,8 @@
align-items: center;
justify-content: center;
border-radius: var(--radius-full);
- background: var(--gray-0);
- color: var(--gray-1000);
+ background: var(--ds-accent);
+ color: var(--ds-bg-primary);
transition: opacity var(--motion-duration-fast) var(--motion-ease-out), transform var(--motion-duration-fast) var(--motion-ease-out);
}
@@ -484,11 +484,6 @@
color: var(--ds-text-primary);
}
-:root[data-theme="light"] .send-btn {
- background: var(--gray-1000);
- color: var(--gray-0);
-}
-
.send-btn:hover:not(:disabled) {
opacity: 0.9;
}
@@ -499,18 +494,6 @@
color: var(--ds-send-disabled-fg);
}
-/*
- `.send-btn:disabled` scores (0,2,0), but light paints the *enabled* chip from
- a `:root[data-theme="light"] .send-btn` rule at (0,3,0), which would strand the
- disabled state on the near-black enabled fill. The disabled state therefore
- keeps a light-qualified companion — it reads the same tokens, so a contributed
- theme can still move the chip, and the built-in paint is unchanged.
-*/
-:root[data-theme="light"] .send-btn:disabled {
- background: var(--ds-send-disabled-bg);
- color: var(--ds-send-disabled-fg);
-}
-
.stop-btn {
display: inline-flex;
height: 28px;
diff --git a/apps/desktop/src/styles/projects.css b/apps/desktop/src/styles/projects.css
index adcc1086d..69e5ed480 100644
--- a/apps/desktop/src/styles/projects.css
+++ b/apps/desktop/src/styles/projects.css
@@ -871,5 +871,5 @@
}
.project-delete-dialog-confirm:hover:not(:disabled) {
- background: color-mix(in oklab, var(--ds-error) 85%, var(--gray-1000));
+ background: color-mix(in oklab, var(--ds-error) 85%, black);
}
diff --git a/apps/desktop/src/styles/prose.css b/apps/desktop/src/styles/prose.css
index 720eea278..51ec3095c 100644
--- a/apps/desktop/src/styles/prose.css
+++ b/apps/desktop/src/styles/prose.css
@@ -480,7 +480,7 @@
width: 28px;
height: 28px;
border-radius: var(--radius-xs);
- color: color-mix(in oklab, #abb2bf 72%, transparent);
+ color: var(--ds-text-muted);
transition: background var(--motion-duration-fast) var(--motion-ease-out), color var(--motion-duration-fast) var(--motion-ease-out), opacity var(--motion-duration-fast) var(--motion-ease-out);
opacity: 0.75;
}
@@ -492,7 +492,7 @@
}
.code-block .code-copy-btn:hover {
- color: #d7dae0;
+ color: var(--ds-text-secondary);
background: var(--ds-code-hover-bg);
}
diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.css
index 8054dc1f5..453135e9c 100644
--- a/apps/desktop/src/styles/settings.css
+++ b/apps/desktop/src/styles/settings.css
@@ -2277,12 +2277,14 @@
}
/*
- The menu floats over a `#212121` panel, and the shared elevated gray is only
- `#282828` — too close to read as detached. Light mode keeps the plain white
- surface, where the ring and drop shadow already separate it.
+ The menu floats over the settings panel (--ds-bg-secondary, #212121 in the
+ built-in dark) and the shared elevated gray is only #282828 — too close to
+ read as detached. Light mode keeps the plain white surface, where the ring
+ and drop shadow already separate it. Both colours ride tokens so a
+ contributed theme can move the plate with the rest of the settings chrome.
*/
:root[data-theme="dark"] .agent-capability-menu {
- background: color-mix(in oklab, var(--gray-0) 8%, var(--gray-800));
+ background: color-mix(in oklab, var(--ds-text-primary) 8%, var(--ds-bg-secondary));
box-shadow:
0 0 0 0.5px var(--ds-border-strong),
0 12px 32px rgb(0 0 0 / 44%);
@@ -2866,7 +2868,7 @@
}
.mcpm-search .field-input:focus-visible {
- border-color: color-mix(in oklab, var(--gray-0) 32%, transparent);
+ border-color: color-mix(in oklab, var(--ds-text-primary) 32%, transparent);
box-shadow: 0 0 0 3px var(--ds-tile-deep);
}
@@ -2931,7 +2933,7 @@
.mcpm-card:hover {
transform: translateY(-2px);
- border-color: color-mix(in oklab, var(--gray-0) 20%, transparent);
+ border-color: color-mix(in oklab, var(--ds-text-primary) 20%, transparent);
background: var(--ds-tile-hover);
box-shadow: 0 10px 28px color-mix(in oklab, #000 24%, transparent);
}
@@ -3371,7 +3373,7 @@
}
.sklm-search .field-input:focus-visible {
- border-color: color-mix(in oklab, var(--gray-0) 32%, transparent);
+ border-color: color-mix(in oklab, var(--ds-text-primary) 32%, transparent);
box-shadow: 0 0 0 3px var(--ds-tile-deep);
}
@@ -3436,7 +3438,7 @@
.sklm-card:hover {
transform: translateY(-2px);
- border-color: color-mix(in oklab, var(--gray-0) 20%, transparent);
+ border-color: color-mix(in oklab, var(--ds-text-primary) 20%, transparent);
background: var(--ds-tile-hover);
box-shadow: 0 10px 28px color-mix(in oklab, #000 24%, transparent);
}
diff --git a/apps/desktop/src/styles/voice.css b/apps/desktop/src/styles/voice.css
index c4e4cafd7..5d0f94d7d 100644
--- a/apps/desktop/src/styles/voice.css
+++ b/apps/desktop/src/styles/voice.css
@@ -1,7 +1,9 @@
-/* Voice input styles */
+/* Voice input styles. Every colour rides a --ds-* token: the old --color-*
+ aliases never existed in tokens.css, so each value below used to fall back
+ to a hardcoded literal that no contributed theme could reach. */
.voice-active {
- color: var(--color-danger, #ef4444) !important;
+ color: var(--ds-error) !important;
}
.voice-mic-active {
@@ -30,8 +32,8 @@
justify-content: space-between;
padding: 6px 12px;
border-radius: var(--radius-xs);
- background: var(--color-surface-elevated, #1e1e2e);
- border: 1px solid var(--color-border, #333);
+ background: var(--ds-bg-elevated-opaque);
+ border: 1px solid var(--ds-border-default);
font-size: var(--text-md);
gap: 12px;
}
@@ -52,7 +54,7 @@
width: 8px;
height: 8px;
border-radius: var(--radius-round);
- background: var(--color-danger, #ef4444);
+ background: var(--ds-error);
animation: voice-pulse 1.2s ease-in-out infinite;
}
@@ -64,8 +66,8 @@
.voice-spinner {
width: 14px;
height: 14px;
- border: 2px solid var(--color-border, #555);
- border-top-color: var(--color-primary, #3b82f6);
+ border: 2px solid var(--ds-border-strong);
+ border-top-color: var(--ds-text-primary);
border-radius: var(--radius-round);
animation: voice-spin 0.8s linear infinite;
}
@@ -78,13 +80,13 @@
width: 80px;
height: 4px;
border-radius: var(--radius-3xs);
- background: var(--color-border, #333);
+ background: var(--ds-bg-active);
overflow: hidden;
}
.voice-volume-fill {
height: 100%;
- background: var(--color-primary, #3b82f6);
+ background: var(--ds-accent);
border-radius: var(--radius-3xs);
transition: width 100ms ease-out;
}
@@ -94,18 +96,18 @@
border-radius: var(--radius-3xs);
font-size: var(--text-sm);
background: transparent;
- color: var(--color-text-secondary, #999);
- border: 1px solid var(--color-border, #444);
+ color: var(--ds-text-secondary);
+ border: 1px solid var(--ds-border-strong);
cursor: pointer;
transition: background 150ms;
}
.voice-cancel-btn:hover {
- background: var(--color-surface-hover, #2a2a3e);
+ background: var(--ds-bg-hover);
}
.voice-error {
- color: var(--color-danger, #ef4444);
+ color: var(--ds-error);
}
/* ---- Voice settings: wider control column ---- */
diff --git a/apps/desktop/test/theme-surface-tokens.test.mjs b/apps/desktop/test/theme-surface-tokens.test.mjs
index 41ebee177..008a8d807 100644
--- a/apps/desktop/test/theme-surface-tokens.test.mjs
+++ b/apps/desktop/test/theme-surface-tokens.test.mjs
@@ -85,3 +85,29 @@ test("surface guard covers the tokenized families and every opaque colour form",
],
);
});
+
+test("surface guard rejects static non-token variable references", () => {
+ /*
+ The gray/accent scales are static root literals and the legacy color-*
+ family never existed, so a declaration riding those variables is pinned
+ out of every contributed theme's reach. Theme roots (where the scales are
+ defined) and the enumerated fixed-palette rules stay exempt.
+ the enumerated fixed-palette rules stay exempt.
+ */
+ const violations = findLiteralSurfaceColors(`
+.send-btn { background: var(--gray-0); color: var(--gray-1000); }
+:root[data-theme="dark"] .composer-input { color: var(--gray-0); }
+.voice-error { color: var(--color-danger, #ef4444); }
+:root { --ds-bg-hover: color-mix(in oklab, var(--gray-0) 6%, transparent); }
+.composer-image-preview button:hover { background: var(--gray-700); }
+.projects-glyph { color: var(--gray-0); }`);
+ assert.deepEqual(
+ violations.map(({ line, property }) => [line, property]),
+ [
+ [2, "background"],
+ [2, "color"],
+ [3, "color"],
+ [4, "color"],
+ ],
+ );
+});
diff --git a/scripts/check-style-tokens.mjs b/scripts/check-style-tokens.mjs
index a6a593557..894562911 100644
--- a/scripts/check-style-tokens.mjs
+++ b/scripts/check-style-tokens.mjs
@@ -6,7 +6,9 @@
*
* Checked:
* - CSS: migrated settings/composer/plugin search fills cannot contain raw
- * hex, color functions, white, or black (see style-surface-tokens.mjs).
+ * hex, color functions, white, or black, nor non-token `--gray-*` /
+ * `--accent-*` / `--color-*` variable references (see
+ * style-surface-tokens.mjs).
* - CSS: font-size / font-weight / line-height / letter-spacing /
* border-radius values must be var(...) based (token definitions on
* `--custom-property` lines are exempt).
diff --git a/scripts/style-surface-tokens.mjs b/scripts/style-surface-tokens.mjs
index 5bed88e7a..395a10ec5 100644
--- a/scripts/style-surface-tokens.mjs
+++ b/scripts/style-surface-tokens.mjs
@@ -27,6 +27,15 @@
* selector in the renderer: it catches a regression in a migrated surface,
* not a brand-new literal on a selector nobody has reviewed yet.
*
+ * 3. NON-TOKEN VARIABLE RULE — a colour declaration that references
+ * `var(--gray-*)`, `var(--accent-*)` or `var(--color-*)` escapes the
+ * theme system no matter which rule carries it: the gray/accent scales
+ * are static root literals, and the `--color-*` family is not defined at
+ * all (its consumers silently paint hardcoded fallbacks). Colour-bearing
+ * declarations must resolve through a `--ds-*` surface token. The theme
+ * root blocks are exempt — they are where the tokens themselves are
+ * defined.
+ *
* Exemptions are enumerated here with reasons instead of being invisible gaps:
*
* - `SHIKI_PALETTE` — the `one-dark-pro` / `one-light` syntax plate and its
@@ -41,6 +50,9 @@
* mix still paints a surface and is checked.
* - `ALLOWED_LITERALS` — base-rule fills the guard deliberately allows, each
* with the decision it answers to.
+ * - `ALLOWED_NON_DS_VARS` — base rules that deliberately track a fixed,
+ * non-theme palette (the image-viewer lightbox chrome, the project-tile
+ * glyph ink over the fixed tile colours), each with the reason.
*
* Known boundary: this guard is static CSS text analysis. It cannot see a
* cascade conflict between two token rules (#339's root cause) or a plugin's
@@ -54,6 +66,9 @@ const CHROME_FAMILY =
/** A selector that is a theme root: `:root` or `:root[data-theme="…"]`. */
const THEME_ROOT = /^:root(?:\[data-theme=["'][^"']*["']\])?$/;
+/** References to variables that contributed themes cannot move (rule 3). */
+const NON_DS_VAR = /var\(\s*--(?:gray|accent|color)-/;
+
/** Colour literals: hex, colour functions, and the `white` / `black` keywords. */
const LITERAL = /#[\da-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch)\(|\b(?:white|black)\b/i;
@@ -82,6 +97,27 @@ export const ALLOWED_LITERALS = [
},
];
+/**
+ * Rules that deliberately track a fixed, non-theme palette (rule 3). Keyed by
+ * the selector text the declaration appears in.
+ */
+export const ALLOWED_NON_DS_VARS = [
+ {
+ selector: /\.composer-image-preview/,
+ reason:
+ "The full-screen image viewer keeps a fixed dark lightbox chrome in every palette — backdrop scrim, controls bar, and focus ring travel together — so its paint is deliberately theme-independent. Tokenizing would tint the scrim and wash out image viewing.",
+ },
+ {
+ selector: /\.projects-glyph/,
+ reason:
+ "The glyph is the ink for the fixed project-tile palette (lib/recent-projects COLORS) that is painted inline beside it; white stays legible over every tile colour in both modes, so the ink tracks the tile, not the theme.",
+ },
+];
+
+function allowedNonDsVar(selector) {
+ return ALLOWED_NON_DS_VARS.some((entry) => entry.selector.test(selector));
+}
+
function replaceAll(value, patterns) {
let out = value;
for (const pattern of patterns) out = out.replace(pattern, " ");
@@ -109,7 +145,7 @@ function allowed(selector, property) {
);
}
/**
- * Report literal surface colours in a stylesheet.
+ * Report theme-escaping surface colours in a stylesheet.
* @param {string} css
* @returns {Array<{line: number, property: string, value: string, reason: string}>}
*/
@@ -120,9 +156,13 @@ export function findLiteralSurfaceColors(css) {
for (const rule of source.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
const selector = rule[1].trim();
const isThemeOverride = /data-theme/.test(selector);
- const isThemeRoot = isThemeOverride && selector.split(",").some((part) => THEME_ROOT.test(part.trim()));
+ // Plain `:root` blocks count as theme roots too: they are where tokens
+ // and their static scales are defined.
+ const isThemeRootSelector = selector.split(",").some((part) => THEME_ROOT.test(part.trim()));
+ const isThemeRoot = isThemeOverride && isThemeRootSelector;
const inChromeFamily = CHROME_FAMILY.test(selector);
- if (!isThemeOverride && !inChromeFamily) continue;
+ const inLiteralScope = isThemeOverride || inChromeFamily;
+ if (!inLiteralScope && !NON_DS_VAR.test(rule[2])) continue;
for (const declaration of rule[2].matchAll(/([-\w]+)\s*:\s*([^;{}]+)/g)) {
const [, property, raw] = declaration;
const value = raw.trim();
@@ -131,12 +171,26 @@ export function findLiteralSurfaceColors(css) {
const isShadow = property === "box-shadow" || property === "text-shadow" || property === "filter";
const checkable = COLOR_PROPERTIES.test(property) || isShadow || isCustomProperty;
if (!checkable) continue;
+ const offset = rule.index + rule[1].length + 1 + declaration.index;
+ const line = source.slice(0, offset).split("\n").length;
+ // Rule 3 — a reference to a static (or undefined) non-`--ds-*` variable
+ // is a theme escape regardless of which rule carries it.
+ if (!isThemeRootSelector && NON_DS_VAR.test(value) && !allowedNonDsVar(selector)) {
+ violations.push({
+ line,
+ property,
+ value: value.replace(/\s+/g, " "),
+ reason:
+ "references a static --gray-*/--accent-*/--color-* variable that contributed themes cannot move — use a --ds-* surface token",
+ });
+ continue;
+ }
+ if (!inLiteralScope) continue;
const residual = residualLiterals(value, { shadow: isShadow });
if (!LITERAL.test(residual)) continue;
if (allowed(selector, property)) continue;
- const offset = rule.index + rule[1].length + 1 + declaration.index;
violations.push({
- line: source.slice(0, offset).split("\n").length,
+ line,
property,
value: value.replace(/\s+/g, " "),
reason: isCustomProperty