Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(a11y): an app-wide floor for prefers-reduced-motion

rubenluetke10-beep99d8c1b0bbfc
diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.css
index e331dfacaf..07d9ce88c1 100644
--- a/jarvis/ui/web/frontend/src/index.css
+++ b/jarvis/ui/web/frontend/src/index.css
@@ -2979,3 +2979,65 @@
}
}
}
+
+/* ----------------------------------------------------------------------
+ prefers-reduced-motion — the app-wide floor
+
+ The individual reduced-motion rules above (and the matchMedia checks in the
+ orb, the 3-D stage and the waveform) each handle one animation. This block
+ is the floor underneath all of them: whatever a component animates, and
+ whatever gets added later, stops moving here without anyone having to
+ remember the variant.
+
+ Deliberately OUTSIDE @layer, so it lands after every Tailwind utility and
+ after the component rules above. The !important is what makes it a floor
+ rather than another opinion.
+
+ Reduced motion is not "no feedback" — that trade is the reason this cannot
+ be a single blanket `animation: none`:
+
+ * A SPINNER that stops reads as a hang. It keeps turning, just slower and
+ at a constant rate, which is rotation without the jitter that triggers
+ vestibular symptoms.
+ * A PULSING skeleton is a loading state, so it becomes a still, dimmed
+ surface rather than a blank one — the state is still legible, it just
+ stops breathing.
+ * A PING ring exists only to draw the eye by expanding. Frozen mid-expand
+ it is a stray halo, so it is dimmed to a quiet static ring.
+
+ Everything else collapses to its end state in ~1ms, which is what turns a
+ slide or a zoom into an instant state change while React still sees the
+ animation start and finish.
+ ---------------------------------------------------------------------- */
+@media (prefers-reduced-motion: reduce) {
+ *,
+ *::before,
+ *::after {
+ animation-duration: 1ms !important;
+ animation-delay: 0ms !important;
+ animation-iteration-count: 1 !important;
+ transition-duration: 1ms !important;
+ transition-delay: 0ms !important;
+ scroll-behavior: auto !important;
+ }
+
+ /* Still says "working", without the fast spin. */
+ .animate-spin {
+ animation-duration: 1.4s !important;
+ animation-iteration-count: infinite !important;
+ animation-timing-function: linear !important;
+ }
+
+ /* Loading surfaces: visible and quiet, never blank. */
+ .animate-pulse {
+ animation: none !important;
+ opacity: 0.55;
+ }
+
+ /* Attention rings: a static halo instead of a repeating expansion. */
+ .animate-ping {
+ animation: none !important;
+ opacity: 0.35;
+ transform: none !important;
+ }
+}
diff --git a/jarvis/ui/web/frontend/src/reduced-motion.test.ts b/jarvis/ui/web/frontend/src/reduced-motion.test.ts
new file mode 100644
index 0000000000..41ecdfd0ea
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/reduced-motion.test.ts
@@ -0,0 +1,105 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+
+/**
+ * The app-wide `prefers-reduced-motion` floor must stay a floor.
+ *
+ * Individual components each guard their own animation, and they can be
+ * removed, renamed or forgotten. The block at the end of index.css is what
+ * makes the app honour the OS setting regardless — so these tests pin the two
+ * properties that make it work at all: that it applies to everything, and that
+ * it is written where nothing can override it.
+ *
+ * They also pin the three deliberate exceptions. Reduced motion is not "no
+ * feedback": a spinner frozen mid-turn reads as a hang, a skeleton frozen at
+ * the wrong point of its pulse can render invisible, and a ping ring frozen
+ * mid-expand is a stray halo. Delete an exception and the app looks broken to
+ * exactly the people the setting is meant to help.
+ */
+
+const CSS = readFileSync(join(process.cwd(), "src", "index.css"), "utf8");
+
+/** The last reduced-motion block in the file — the app-wide one. */
+function floorBlock(): string {
+ const marker = "prefers-reduced-motion: reduce";
+ const start = CSS.lastIndexOf(marker);
+ expect(start).toBeGreaterThan(-1);
+ return CSS.slice(start);
+}
+
+describe("the reduced-motion floor", () => {
+ it("exists and applies to every element, including pseudo-elements", () => {
+ const block = floorBlock();
+ expect(block).toContain("*::before");
+ expect(block).toContain("*::after");
+ });
+
+ it("collapses duration, delay and repeat for animations and transitions", () => {
+ const block = floorBlock();
+ for (const property of [
+ "animation-duration",
+ "animation-delay",
+ "animation-iteration-count",
+ "transition-duration",
+ "transition-delay",
+ ]) {
+ expect(block).toContain(property);
+ }
+ });
+
+ it("stops smooth scrolling, which is motion the animation rules do not reach", () => {
+ expect(floorBlock()).toContain("scroll-behavior: auto");
+ });
+
+ it("wins over Tailwind utilities by being marked important", () => {
+ const block = floorBlock();
+ // Every rule in the floor carries !important; a rule without it would be
+ // silently outranked by the utility class it is meant to tame.
+ const declarations = block.match(/^\s+[a-z-]+:[^;]+;/gm) ?? [];
+ expect(declarations.length).toBeGreaterThan(5);
+ const unimportant = declarations.filter(
+ (d) => !d.includes("!important") && !/opacity:/.test(d),
+ );
+ expect(unimportant).toEqual([]);
+ });
+
+ it("sits outside @layer, so layer ordering cannot demote it", () => {
+ // Count braces from the start of the file to the block: inside a layer the
+ // running depth would be 1 or more when the block opens.
+ const start = CSS.lastIndexOf("@media (prefers-reduced-motion: reduce)");
+ const before = CSS.slice(0, start);
+ const depth =
+ (before.match(/\{/g) ?? []).length - (before.match(/\}/g) ?? []).length;
+ expect(depth).toBe(0);
+ });
+});
+
+describe("the deliberate exceptions keep feedback visible", () => {
+ it("keeps a spinner turning, slower, so it does not read as a hang", () => {
+ const block = floorBlock();
+ const spin = block.slice(block.indexOf(".animate-spin"));
+ expect(spin).toMatch(/animation-iteration-count:\s*infinite\s*!important/);
+ // Slower than the default 1s spin, or it defeats the point.
+ const duration = spin.match(/animation-duration:\s*([\d.]+)s/);
+ expect(duration).not.toBeNull();
+ expect(Number(duration![1])).toBeGreaterThan(1);
+ });
+
+ it("turns a pulsing skeleton into a still, still-visible surface", () => {
+ const block = floorBlock();
+ const pulse = block.slice(block.indexOf(".animate-pulse"));
+ expect(pulse).toMatch(/animation:\s*none\s*!important/);
+ const opacity = pulse.match(/opacity:\s*([\d.]+)/);
+ expect(opacity).not.toBeNull();
+ // Dimmed, but never invisible — a blank area is not a loading state.
+ expect(Number(opacity![1])).toBeGreaterThan(0.2);
+ });
+
+ it("turns an attention ring into a static halo rather than freezing it mid-expand", () => {
+ const block = floorBlock();
+ const ping = block.slice(block.indexOf(".animate-ping"));
+ expect(ping).toMatch(/animation:\s*none\s*!important/);
+ expect(ping).toMatch(/transform:\s*none\s*!important/);
+ });
+});