diff --git a/docs/4-implementation/web-ui/css-vars.md b/docs/4-implementation/web-ui/css-vars.md
index daf8b2b00..cbe7bf86b 100644
--- a/docs/4-implementation/web-ui/css-vars.md
+++ b/docs/4-implementation/web-ui/css-vars.md
@@ -67,15 +67,18 @@ default palette). Default hexes shown are Catppuccin Mocha.
| `--blue` | `base0D` | `#89b4fa` | links, interactive accent (distinct from cyan) |
| `--purple` | `base0E` | `#cba6f7` | accent — active tabs, links, highlights |
| `--pink` | `base0F` | `#f5c2e7` | thinking events |
-| `--crust` | `mix(base00 58%, #000000)` | `#11111b` | terminal / code block background (below `--bg`) |
-| `--muted` | `mix(base05 55.5%, base00)` | `#7f849c` | secondary / dimmed text |
+| `--crust` | `mix(base00 58%, #000000)` | `#11111b` | scrims and shadows (below `--bg`) |
+| `--code-bg` | `mix(base00 58%, #000000)` | `#11111b` | terminal / code block background |
+| `--muted` | `mix(base05 58%, base00)` | `#8489a1` | secondary / dimmed text |
| `--subtext0` | `mix(base05 77.7%, base00)` | `#a6adc8` | toolbar/status text; dimmer than `--fg`, lighter than `--muted` |
-The shares in the `--muted` and `--subtext0` rows are the dark palette's. The light
-palette keeps more of the text colour (85% and 93%, set in `colors.css` as
+The shares in the `--muted`, `--subtext0` and `--code-bg` rows are the dark palette's.
+The light palette keeps more of the text colour (85% and 93%, set in `colors.css` as
`--muted-share` and `--subtext0-share`), because the dark shares leave its dimmed
-text at 2.4:1 against a card, short of the 4.5:1 AA asks for. A palette that sets
-neither variable, such as a generated one, keeps the dark shares.
+text at 2.4:1 against a card, short of the 4.5:1 AA asks for. For the same reason it
+keeps 95% of its background in `--code-bg` (`--code-bg-share`), as `--crust` is a mid
+grey on a light palette and text on it fell to 2:1. A palette that sets none of these
+variables, such as a generated one, keeps the dark shares.
## Common mistakes
@@ -150,7 +153,7 @@ wholesale (for example the stylix path, which writes a single unconditional
| Slot | Default | Standard base16 role | Mapped to |
| -------- | --------- | -------------------- | ---------------------------------------------------------- |
-| `base00` | `#1e1e2e` | default bg | `--bg`, (darkened) `--crust` |
+| `base00` | `#1e1e2e` | default bg | `--bg`, (darkened) `--crust` and `--code-bg` |
| `base01` | `#181825` | lighter bg | `--bg-elev` |
| `base02` | `#313244` | selection/surface | `--border` |
| `base03` | `#45475a` | comments/dim surface | `--purple-dim` |
@@ -169,8 +172,9 @@ wholesale (for example the stylix path, which writes a single unconditional
Notes for theme authors:
-- **`--crust`, `--muted`, `--subtext0` have no own slot** — they're
- derived via `color-mix()` over base16 (`--crust` = a darkened `base00`;
+- **`--crust`, `--code-bg`, `--muted`, `--subtext0` have no own slot** — they're
+ derived via `color-mix()` over base16 (`--crust` and `--code-bg` = a darkened
+ `base00`, `--code-bg` less so on a light palette;
`--muted`/`--subtext0` = `base05`↔`base00` blends). They still track a
swap automatically; no generator action needed.
- A standard Catppuccin base16 scheme uses **teal** for `base0C`;
diff --git a/frontend/packages/agent/src/agent.css b/frontend/packages/agent/src/agent.css
index e4c1cc47c..f9808613d 100644
--- a/frontend/packages/agent/src/agent.css
+++ b/frontend/packages/agent/src/agent.css
@@ -73,7 +73,7 @@ body.screen-shell {
right: 0;
max-height: 40vh;
overflow-y: auto;
- background: color-mix(in srgb, var(--crust) 95%, transparent);
+ background: color-mix(in srgb, var(--code-bg) 95%, transparent);
border-top: 1px solid var(--purple-dim);
font-size: 0.72rem;
font-family: ui-monospace, monospace;
diff --git a/frontend/packages/dashboard/src/dashboard.css b/frontend/packages/dashboard/src/dashboard.css
index 7b6ab0d52..e9eb822bd 100644
--- a/frontend/packages/dashboard/src/dashboard.css
+++ b/frontend/packages/dashboard/src/dashboard.css
@@ -142,6 +142,17 @@ body.dashboard-shell {
.banner.active {
animation: banner-shimmer 1.8s linear infinite;
}
+@media (prefers-reduced-motion: reduce) {
+ .banner.active {
+ animation: none;
+ }
+}
+:root[data-motion="reduce"] .banner.active {
+ animation: none;
+}
+:root[data-motion="allow"] .banner.active {
+ animation: banner-shimmer 1.8s linear infinite;
+}
@keyframes banner-shimmer {
from {
background-position: 200% 0;
@@ -329,6 +340,21 @@ hive-agent-menu {
animation: container-icon-spin 0.9s linear infinite;
pointer-events: none;
}
+@media (prefers-reduced-motion: reduce) {
+ .container-row.pending-running > .container-icon::after {
+ animation: none;
+ }
+}
+:root[data-motion="reduce"]
+ .container-row.pending-running
+ > .container-icon::after {
+ animation: none;
+}
+:root[data-motion="allow"]
+ .container-row.pending-running
+ > .container-icon::after {
+ animation: container-icon-spin 0.9s linear infinite;
+}
.container-row .head {
display: flex;
align-items: center;
@@ -436,6 +462,17 @@ hive-agent-menu {
text-shadow: 0 0 6px color-mix(in srgb, var(--amber) 55%, transparent);
animation: badge-pulse 1.6s ease-in-out infinite;
}
+@media (prefers-reduced-motion: reduce) {
+ .pending-state {
+ animation: none;
+ }
+}
+:root[data-motion="reduce"] .pending-state {
+ animation: none;
+}
+:root[data-motion="allow"] .pending-state {
+ animation: badge-pulse 1.6s ease-in-out infinite;
+}
@keyframes badge-pulse {
0%,
100% {
diff --git a/frontend/packages/shared/src/base.css b/frontend/packages/shared/src/base.css
index 7bdf6b11f..1c6ddf13c 100644
--- a/frontend/packages/shared/src/base.css
+++ b/frontend/packages/shared/src/base.css
@@ -5,6 +5,13 @@
`theme.css` + docs/4-implementation/web-ui/css-vars.md. Per-page stylesheets append on
top of this and must NOT redeclare the colour variables; `theme.css`
is the one source of truth. */
+/* A visible ring on keyboard focus wherever a component has not drawn its own.
+ `:where` keeps the specificity at zero, so every component rule wins. The UA
+ ring is close to invisible on the dark, translucent surfaces. */
+:where(:focus-visible) {
+ outline: 2px solid var(--purple);
+ outline-offset: 2px;
+}
body {
/* The default UA stylesheet gives `body` an 8px margin — every page
using this shared base had it as a `--bg`-coloured strip visible
@@ -34,6 +41,17 @@ body {
animation: spin 1s linear infinite;
color: var(--amber);
}
+@media (prefers-reduced-motion: reduce) {
+ .spinner {
+ animation: none;
+ }
+}
+:root[data-motion="reduce"] .spinner {
+ animation: none;
+}
+:root[data-motion="allow"] .spinner {
+ animation: spin 1s linear infinite;
+}
@keyframes spin {
from {
transform: rotate(0deg);
diff --git a/frontend/packages/shared/src/colors.css b/frontend/packages/shared/src/colors.css
index df38153fd..2be296306 100644
--- a/frontend/packages/shared/src/colors.css
+++ b/frontend/packages/shared/src/colors.css
@@ -96,6 +96,9 @@
--base0D: var(--mocha-base0D);
--base0E: var(--mocha-base0E);
--base0F: var(--mocha-base0F);
+ /* The browser's own controls, scrollbars and dialog backdrops follow the
+ palette, so a forced theme does not leave them on the OS's. */
+ color-scheme: dark;
}
/* OS/browser-level light-mode default. This is a *default*, not a user
@@ -131,6 +134,8 @@
/* Dimmed text on the light palette: see `--muted-share` in theme.css. */
--muted-share: 85%;
--subtext0-share: 93%;
+ --code-bg-share: 95%;
+ color-scheme: light;
}
}
@@ -165,6 +170,8 @@
/* Dimmed text on the light palette: see `--muted-share` in theme.css. */
--muted-share: 85%;
--subtext0-share: 93%;
+ --code-bg-share: 95%;
+ color-scheme: light;
}
:root[data-theme="dark"] {
--base00: var(--mocha-base00);
@@ -185,6 +192,8 @@
--base0F: var(--mocha-base0F);
/* A dark pick over a light OS preference: the media query's shares must not
carry over, so the dark palette sets its own, the defaults of theme.css. */
- --muted-share: 55.5%;
+ --muted-share: 58%;
--subtext0-share: 77.7%;
+ --code-bg-share: 58%;
+ color-scheme: dark;
}
diff --git a/frontend/packages/shared/src/hive-warn/hive-warn.css b/frontend/packages/shared/src/hive-warn/hive-warn.css
index f347fb224..06edc9fb3 100644
--- a/frontend/packages/shared/src/hive-warn/hive-warn.css
+++ b/frontend/packages/shared/src/hive-warn/hive-warn.css
@@ -41,6 +41,13 @@
text-shadow: 0 0 6px color-mix(in srgb, currentColor 40%, transparent);
animation: hive-warn-pulse 2.4s ease-in-out infinite;
}
+/* Inside a shadow tree, so the page's `data-motion` setting cannot reach it:
+ the system preference only. */
+@media (prefers-reduced-motion: reduce) {
+ :host([level="error"]) {
+ animation: none;
+ }
+}
@keyframes hive-warn-pulse {
0%,
100% {
diff --git a/frontend/packages/shared/src/jobq-graph/jobq-graph.css b/frontend/packages/shared/src/jobq-graph/jobq-graph.css
index 81d362d47..714f68c53 100644
--- a/frontend/packages/shared/src/jobq-graph/jobq-graph.css
+++ b/frontend/packages/shared/src/jobq-graph/jobq-graph.css
@@ -174,7 +174,10 @@
.jg-cancel-btn:focus-visible {
color: var(--red);
border-color: var(--red);
- outline: none;
+}
+.jg-cancel-btn:focus-visible {
+ outline: 2px solid var(--red);
+ outline-offset: 2px;
}
.jg-data {
diff --git a/frontend/packages/shared/src/settings/solid-backgrounds.css b/frontend/packages/shared/src/settings/solid-backgrounds.css
index afacf1a76..7d9146ecd 100644
--- a/frontend/packages/shared/src/settings/solid-backgrounds.css
+++ b/frontend/packages/shared/src/settings/solid-backgrounds.css
@@ -14,7 +14,7 @@ html:root[data-solid="true"] .ui-badge:not(.ui-badge-quiet) {
backdrop-filter: none;
}
html:root[data-solid="true"] .terminal-wrap {
- background: var(--crust);
+ background: var(--code-bg);
-webkit-backdrop-filter: none;
backdrop-filter: none;
}
diff --git a/frontend/packages/shared/src/terminal/terminal.css b/frontend/packages/shared/src/terminal/terminal.css
index 67980427d..4dd9e4620 100644
--- a/frontend/packages/shared/src/terminal/terminal.css
+++ b/frontend/packages/shared/src/terminal/terminal.css
@@ -18,7 +18,7 @@
.terminal-wrap {
position: relative;
- background: color-mix(in srgb, var(--crust) 78%, transparent);
+ background: color-mix(in srgb, var(--code-bg) 78%, transparent);
-webkit-backdrop-filter: blur(8px) saturate(120%);
backdrop-filter: blur(8px) saturate(120%);
border: 1px solid var(--purple-dim);
diff --git a/frontend/packages/shared/src/theme.css b/frontend/packages/shared/src/theme.css
index cad07c332..3d8784569 100644
--- a/frontend/packages/shared/src/theme.css
+++ b/frontend/packages/shared/src/theme.css
@@ -33,10 +33,19 @@
in srgb,
var(--base00) 58%,
#000000
- ); /* terminal / code bg, below --bg */
+ ); /* scrims and shadows: a darkened bg, in both themes */
+ /* The surface text sits on in a terminal or a code block. In the dark theme
+ it is `--crust`, below `--bg`. A light palette keeps nearly all of its
+ background (`--code-bg-share` in `colors.css`), as `--crust` is a mid
+ grey there and the text on it fell to 2:1. */
+ --code-bg: color-mix(
+ in srgb,
+ var(--base00) var(--code-bg-share, 58%),
+ #000000
+ );
--muted: color-mix(
in srgb,
- var(--base05) var(--muted-share, 55.5%),
+ var(--base05) var(--muted-share, 58%),
var(--base00)
); /* secondary / dimmed text */
--subtext0: color-mix(
@@ -46,7 +55,7 @@
); /* toolbar/status text; dimmer than --fg, lighter than --muted */
/* `--muted-share` and `--subtext0-share` are how much of the text colour each
mix keeps. A palette whose background is light sets them higher in
- `colors.css`: at the dark palette's 55.5% the light one's muted text was
+ `colors.css`: at the dark palette's 58% the light one's muted text was
2.4:1 against its card background, short of the 4.5:1 AA asks for. A palette
that sets neither keeps the shares above. */
diff --git a/frontend/packages/shared/src/warn-banner/WarnBanner.css b/frontend/packages/shared/src/warn-banner/WarnBanner.css
index c89d211f5..15feed961 100644
--- a/frontend/packages/shared/src/warn-banner/WarnBanner.css
+++ b/frontend/packages/shared/src/warn-banner/WarnBanner.css
@@ -27,6 +27,17 @@
text-shadow: 0 0 6px color-mix(in srgb, currentColor 40%, transparent);
animation: warn-banner-pulse 2.4s ease-in-out infinite;
}
+@media (prefers-reduced-motion: reduce) {
+ .warn-banner-error {
+ animation: none;
+ }
+}
+:root[data-motion="reduce"] .warn-banner-error {
+ animation: none;
+}
+:root[data-motion="allow"] .warn-banner-error {
+ animation: warn-banner-pulse 2.4s ease-in-out infinite;
+}
@keyframes warn-banner-pulse {
0%,
100% {
diff --git a/frontend/packages/swarm-ui/build.mjs b/frontend/packages/swarm-ui/build.mjs
index 251430cda..964c42842 100644
--- a/frontend/packages/swarm-ui/build.mjs
+++ b/frontend/packages/swarm-ui/build.mjs
@@ -121,6 +121,24 @@ const hashedCssResult = await build({
const themeCssUrl = toUrl(outputFor(hashedCssResult, src("theme.css"))[0]);
const swarmUiCssUrl = toUrl(outputFor(hashedCssResult, src("swarm-ui.css"))[0]);
+// theme-boot.js: the stored theme and motion overrides, set before first
+// paint by a blocking script in the head (the page's policy allows no inline
+// script). Hashed like the rest.
+const bootResult = await build({
+ absWorkingDir: here,
+ entryPoints: [src("theme-boot.js")],
+ outdir: staticDir(""),
+ entryNames: "[name]-[hash]",
+ bundle: true,
+ format: "iife",
+ platform: "browser",
+ target: ["es2022"],
+ minify: true,
+ logLevel: "info",
+ metafile: true,
+});
+const themeBootUrl = toUrl(outputFor(bootResult, src("theme-boot.js"))[0]);
+
// colors.css: fixed, unhashed path — see the top comment.
await build({
absWorkingDir: here,
@@ -137,7 +155,15 @@ await build({
// makes the SW's own `activate` handler evict the old cache in full —
// no more hand-bumping a CACHE_VERSION const on every shell change.
const buildVersion = createHash("sha256")
- .update(JSON.stringify([mainJsUrl, mainCssUrl, themeCssUrl, swarmUiCssUrl]))
+ .update(
+ JSON.stringify([
+ mainJsUrl,
+ mainCssUrl,
+ themeCssUrl,
+ swarmUiCssUrl,
+ themeBootUrl,
+ ]),
+ )
.digest("hex")
.slice(0, 12);
@@ -146,7 +172,8 @@ const rewriteAssetUrls = (text) =>
.replaceAll("/static/main.js", mainJsUrl)
.replaceAll("/static/main.css", mainCssUrl)
.replaceAll("/static/theme.css", themeCssUrl)
- .replaceAll("/static/swarm-ui.css", swarmUiCssUrl);
+ .replaceAll("/static/swarm-ui.css", swarmUiCssUrl)
+ .replaceAll("/static/theme-boot.js", themeBootUrl);
writeFileSync(
dist("index.html"),
diff --git a/frontend/packages/swarm-ui/src/agent/terminal/ConnectionDot.css b/frontend/packages/swarm-ui/src/agent/terminal/ConnectionDot.css
index a91202527..2834ad542 100644
--- a/frontend/packages/swarm-ui/src/agent/terminal/ConnectionDot.css
+++ b/frontend/packages/swarm-ui/src/agent/terminal/ConnectionDot.css
@@ -30,12 +30,24 @@
right: -0.2em;
bottom: -0.2em;
}
-@media (prefers-reduced-motion: no-preference) {
+.ui-conn-dot-connecting,
+.ui-conn-dot-reconnecting {
+ animation: ui-conn-dot-pulse 1.2s ease-in-out infinite;
+}
+@media (prefers-reduced-motion: reduce) {
.ui-conn-dot-connecting,
.ui-conn-dot-reconnecting {
- animation: ui-conn-dot-pulse 1.2s ease-in-out infinite;
+ animation: none;
}
}
+:root[data-motion="reduce"] .ui-conn-dot-connecting,
+:root[data-motion="reduce"] .ui-conn-dot-reconnecting {
+ animation: none;
+}
+:root[data-motion="allow"] .ui-conn-dot-connecting,
+:root[data-motion="allow"] .ui-conn-dot-reconnecting {
+ animation: ui-conn-dot-pulse 1.2s ease-in-out infinite;
+}
@keyframes ui-conn-dot-pulse {
50% {
opacity: 0.45;
diff --git a/frontend/packages/swarm-ui/src/index.html b/frontend/packages/swarm-ui/src/index.html
index dfd9d6722..295cfe030 100644
--- a/frontend/packages/swarm-ui/src/index.html
+++ b/frontend/packages/swarm-ui/src/index.html
@@ -18,6 +18,8 @@
+
+
diff --git a/frontend/packages/swarm-ui/src/sw.js b/frontend/packages/swarm-ui/src/sw.js
index c34b2d70a..1e6c1b595 100644
--- a/frontend/packages/swarm-ui/src/sw.js
+++ b/frontend/packages/swarm-ui/src/sw.js
@@ -42,6 +42,7 @@ const SHELL_ASSETS = [
"/static/colors.css",
"/static/theme.css",
"/static/swarm-ui.css",
+ "/static/theme-boot.js",
"/manifest.webmanifest",
];
diff --git a/frontend/packages/swarm-ui/src/theme-boot.js b/frontend/packages/swarm-ui/src/theme-boot.js
new file mode 100644
index 000000000..b3f921ece
--- /dev/null
+++ b/frontend/packages/swarm-ui/src/theme-boot.js
@@ -0,0 +1,22 @@
+// Sets the stored theme and motion overrides on before the first paint.
+// The app applies them again once it mounts (`useApplyThemeOverride`,
+// `useApplyMotionOverride`), but that is after the page has painted, so a light
+// OS showed a light flash before the dark default took over. This runs from a
+// blocking script in the head, as the page's policy allows no inline script. The
+// keys and the fallbacks ("dark" for the theme, "system" for motion) are those of
+// `shell/Shell.tsx`; `test/theme-boot.test.mjs` keeps them in step.
+(function () {
+ function read(key, fallback) {
+ try {
+ var raw = localStorage.getItem(key);
+ return raw === null ? fallback : JSON.parse(raw);
+ } catch (e) {
+ return fallback;
+ }
+ }
+ var root = document.documentElement;
+ var theme = read("swarm-ui:theme-override", "dark");
+ if (theme === "light" || theme === "dark") root.dataset.theme = theme;
+ var motion = read("swarm-ui:motion-override", "system");
+ if (motion === "reduce" || motion === "allow") root.dataset.motion = motion;
+})();
diff --git a/frontend/packages/swarm-ui/src/ui/pane-tree/PaneTree.css b/frontend/packages/swarm-ui/src/ui/pane-tree/PaneTree.css
index f47c42fe6..f17f85a89 100644
--- a/frontend/packages/swarm-ui/src/ui/pane-tree/PaneTree.css
+++ b/frontend/packages/swarm-ui/src/ui/pane-tree/PaneTree.css
@@ -35,7 +35,10 @@
.ui-pane-divider:hover,
.ui-pane-divider:focus-visible {
background: var(--purple);
- outline: none;
+}
+.ui-pane-divider:focus-visible {
+ outline: 2px solid var(--purple);
+ outline-offset: 1px;
}
/* The half of a pane a drop would take, lit while an agent is dragged over. */
.ui-pane-drop-zone {
diff --git a/frontend/packages/swarm-ui/src/ui/preformatted/Preformatted.css b/frontend/packages/swarm-ui/src/ui/preformatted/Preformatted.css
index d61e4e4cd..7c6db1275 100644
--- a/frontend/packages/swarm-ui/src/ui/preformatted/Preformatted.css
+++ b/frontend/packages/swarm-ui/src/ui/preformatted/Preformatted.css
@@ -4,7 +4,7 @@
overflow: auto;
border: 1px solid var(--border, currentColor);
border-radius: 0.4em;
- background: color-mix(in srgb, var(--crust) 60%, transparent);
+ background: color-mix(in srgb, var(--code-bg) 60%, transparent);
font-family: var(--mono, ui-monospace, monospace);
font-size: 0.85em;
}
diff --git a/frontend/packages/swarm-ui/test/theme-boot.test.mjs b/frontend/packages/swarm-ui/test/theme-boot.test.mjs
new file mode 100644
index 000000000..ee96b654e
--- /dev/null
+++ b/frontend/packages/swarm-ui/test/theme-boot.test.mjs
@@ -0,0 +1,69 @@
+// The boot script that sets the stored theme and motion overrides before the
+// first paint: what it sets for each stored value, and that its keys are the
+// ones the shell reads. Run by `npm test`.
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import { test } from "node:test";
+import vm from "node:vm";
+
+const script = readFileSync(
+ new URL("../src/theme-boot.js", import.meta.url),
+ "utf8",
+);
+const shell = readFileSync(
+ new URL("../src/shell/Shell.tsx", import.meta.url),
+ "utf8",
+);
+
+function boot(stored) {
+ const dataset = {};
+ const localStorage = {
+ getItem: (key) => (key in stored ? stored[key] : null),
+ };
+ vm.runInNewContext(script, {
+ localStorage,
+ document: { documentElement: { dataset } },
+ });
+ return dataset;
+}
+
+test("nothing stored sets the dark default and leaves motion to the system", () => {
+ assert.deepEqual(boot({}), { theme: "dark" });
+});
+
+test("a stored light theme and a motion override are set", () => {
+ const set = boot({
+ "swarm-ui:theme-override": '"light"',
+ "swarm-ui:motion-override": '"reduce"',
+ });
+ assert.deepEqual(set, { theme: "light", motion: "reduce" });
+});
+
+test("system leaves the attribute off, so the media query decides", () => {
+ assert.deepEqual(boot({ "swarm-ui:theme-override": '"system"' }), {});
+});
+
+test("a value that is not JSON, or not one of the choices, is ignored", () => {
+ assert.deepEqual(boot({ "swarm-ui:theme-override": "light" }), {
+ theme: "dark",
+ });
+ assert.deepEqual(boot({ "swarm-ui:theme-override": '"blue"' }), {});
+});
+
+test("storage that throws behaves as if nothing were stored", () => {
+ const dataset = {};
+ vm.runInNewContext(script, {
+ localStorage: {
+ getItem() {
+ throw new Error("blocked");
+ },
+ },
+ document: { documentElement: { dataset } },
+ });
+ assert.deepEqual(dataset, { theme: "dark" });
+});
+
+test("the keys are the shell's", () => {
+ assert.match(shell, /THEME_KEY = "swarm-ui:theme-override"/);
+ assert.match(shell, /MOTION_KEY = "swarm-ui:motion-override"/);
+});