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(deck): the whole orb moves with the voice — one level, one look

Harald5eb6c6f04ee0
diff --git a/jarvis/ui/web/frontend/src/components/deck/DeckOrb.test.tsx b/jarvis/ui/web/frontend/src/components/deck/DeckOrb.test.tsx
index 9bef3e1418..9647311c56 100644
--- a/jarvis/ui/web/frontend/src/components/deck/DeckOrb.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/deck/DeckOrb.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, describe, expect, test, vi } from "vitest";
// framer-motion's motion.img is a plain <img> for these assertions.
@@ -11,6 +11,8 @@ vi.mock("framer-motion", async () => {
});
import { DeckOrb } from "@/components/deck/DeckOrb";
+import { useEventStore } from "@/store/events";
+import { clearVoiceInputLevel, setVoiceInputLevel } from "@/lib/voiceInputLevel";
/**
* The orb is the click-shaped wake word (maintainer, 2026-08-18): pressing
@@ -39,6 +41,27 @@ describe("DeckOrb", () => {
// The satellite steps aside for the busy sweep — one signal on the bezel.
rerender(<DeckOrb steps={[]} busy />);
expect(screen.queryByTestId("deck-orb-satellite")).toBeNull();
+ // The meter, the corona and the ripple host are there, at rest at zero.
+ expect(screen.getByTestId("deck-orb-vu")).toBeTruthy();
+ expect(screen.getByTestId("deck-orb-ripples").childElementCount).toBe(0);
+ expect(screen.getByTestId("deck-orb").style.getPropertyValue("--orb-level")).toBe("0");
+ });
+
+ test("moves with the voice: the real microphone level while listening, one variable for all", async () => {
+ useEventStore.setState({ voiceState: "listening" });
+ setVoiceInputLevel(0.8, "native");
+ try {
+ render(<DeckOrb steps={[]} busy={false} />);
+ const root = screen.getByTestId("deck-orb");
+ await waitFor(() => {
+ expect(Number(root.style.getPropertyValue("--orb-level"))).toBeGreaterThan(0.3);
+ });
+ // A word landing sent a ripple from the sun towards the bezel.
+ expect(screen.getByTestId("deck-orb-ripples").childElementCount).toBeGreaterThan(0);
+ } finally {
+ clearVoiceInputLevel();
+ useEventStore.setState({ voiceState: "idle" });
+ }
});
test("the centre is the Jarvis orb artwork, and nothing rides in its core", () => {
diff --git a/jarvis/ui/web/frontend/src/components/deck/DeckOrb.tsx b/jarvis/ui/web/frontend/src/components/deck/DeckOrb.tsx
index b7ea1f0c69..0dbb619ea9 100644
--- a/jarvis/ui/web/frontend/src/components/deck/DeckOrb.tsx
+++ b/jarvis/ui/web/frontend/src/components/deck/DeckOrb.tsx
@@ -3,6 +3,8 @@ import { useEventStore, type VoiceState } from "@/store/events";
import { JarvisOrb } from "@/components/deck/JarvisOrb";
import type { ThinkingStep } from "@/lib/thinkingSteps";
import { HudHaloDefs } from "@/components/deck/HudFrame";
+import { readVoiceInputLevel } from "@/lib/voiceInputLevel";
+import { driveTarget, isOnset, orbDriveFor, smoothOrbLevel } from "@/lib/orbLevel";
import { cn } from "@/lib/utils";
/**
@@ -30,6 +32,17 @@ import { cn } from "@/lib/utils";
* with a CSS transform/opacity animation (index.css) — so the browser turns
* it on the compositor and the main thread never hears of it; the halo
* filter stays on the still reticle. Reduced motion stops all of it.
+ *
+ * And it MOVES WITH THE VOICE, all of it (maintainer, 2026-08-19: "when you
+ * speak the sun moved — that, on the next level; not just the core, all of
+ * it, smooth"). One animation-frame loop computes the orb's LEVEL
+ * (`lib/orbLevel.ts`: the real microphone while listening, a speech-shaped
+ * envelope while the assistant speaks, a heartbeat while it thinks), smooths
+ * it, and writes it to ONE CSS variable on the root (`--orb-level`); the
+ * core's size and brightness, the glow, the corona's rays, the rings and the
+ * level arc on the bezel all read that variable in CSS (index.css). A jump
+ * in the level — a word landing — sends one ripple from the sun to the
+ * bezel. One number, one smoothing, so every part moves as one thing.
*/
export interface OrbReadouts {
nw: string;
@@ -110,8 +123,51 @@ export function DeckOrb({
const B = 16; // bracket arm
const haloId = useId();
+ // The level loop: one number for everything that moves with the voice,
+ // written to the root as `--orb-level`. Runs only while a voice state
+ // drives it; idle (and reduced motion) is a still 0 and no loop at all.
+ const rootRef = useRef<HTMLDivElement>(null);
+ const ripplesRef = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ const root = rootRef.current;
+ if (!root) return;
+ const drive = orbDriveFor(voiceState);
+ if (reduced || drive === "idle") {
+ root.style.setProperty("--orb-level", "0");
+ return;
+ }
+ let raf = 0;
+ let level = 0;
+ const t0 = performance.now();
+ let last = t0;
+ let lastRipple = Number.NEGATIVE_INFINITY;
+ const tick = (now: number) => {
+ const dt = Math.min(0.1, (now - last) / 1000);
+ last = now;
+ const target = driveTarget(drive, (now - t0) / 1000, readVoiceInputLevel(now));
+ const next = smoothOrbLevel(level, target, dt);
+ if (isOnset(level, next, now - lastRipple)) {
+ lastRipple = now;
+ spawnRipple(ripplesRef.current);
+ }
+ level = next;
+ root.style.setProperty("--orb-level", level.toFixed(3));
+ raf = requestAnimationFrame(tick);
+ };
+ raf = requestAnimationFrame(tick);
+ return () => {
+ cancelAnimationFrame(raf);
+ root.style.setProperty("--orb-level", "0");
+ };
+ }, [voiceState, reduced]);
+
return (
- <div className={cn("relative shrink-0", className)} style={{ width: size, height: size }}>
+ <div
+ ref={rootRef}
+ className={cn("deck-orb-root relative shrink-0", className)}
+ style={{ width: size, height: size }}
+ data-testid="deck-orb"
+ >
<svg viewBox={`0 0 ${size} ${size}`} className="absolute inset-0 h-full w-full" aria-hidden>
<HudHaloDefs id={haloId} />
<g filter={`url(#${haloId})`}>
@@ -183,26 +239,28 @@ export function DeckOrb({
{/* The living parts, each its own layer (CSS, index.css): the dashed
inner scale turning one way, a sparse orbit the other, a satellite
- on the bezel while nothing runs, and the idle ping. */}
- <OrbitLayer size={size} r={R * 0.66} className="deck-orb-orbit-a" dash="2 6" opacity={0.55} />
- <OrbitLayer size={size} r={R * 0.76} className="deck-orb-orbit-b" dash="18 54" opacity={0.32} />
- {!busy && (
- <svg
- viewBox={`0 0 ${size} ${size}`}
- className="deck-orb-satellite pointer-events-none absolute inset-0 h-full w-full"
- aria-hidden
- data-testid="deck-orb-satellite"
- >
- <path
- d={`M ${point(-16, R * 0.94)[0]} ${point(-16, R * 0.94)[1]} A ${R * 0.94} ${R * 0.94} 0 0 1 ${R} ${R - R * 0.94}`}
- fill="none"
- stroke="hsl(var(--primary))"
- strokeWidth={1.5}
- opacity={0.45}
- />
- <circle cx={R} cy={R - R * 0.94} r={2.2} fill="hsl(var(--primary))" />
- </svg>
- )}
+ on the bezel while nothing runs, and the idle ping. The rings sit
+ in one wrapper that swells and brightens with the level. */}
+ <div className="deck-orb-rings pointer-events-none absolute inset-0" aria-hidden>
+ <OrbitLayer size={size} r={R * 0.66} className="deck-orb-orbit-a" dash="2 6" opacity={0.55} />
+ <OrbitLayer size={size} r={R * 0.76} className="deck-orb-orbit-b" dash="18 54" opacity={0.32} />
+ {!busy && (
+ <svg
+ viewBox={`0 0 ${size} ${size}`}
+ className="deck-orb-satellite pointer-events-none absolute inset-0 h-full w-full"
+ data-testid="deck-orb-satellite"
+ >
+ <path
+ d={`M ${point(-16, R * 0.94)[0]} ${point(-16, R * 0.94)[1]} A ${R * 0.94} ${R * 0.94} 0 0 1 ${R} ${R - R * 0.94}`}
+ fill="none"
+ stroke="hsl(var(--primary))"
+ strokeWidth={1.5}
+ opacity={0.45}
+ />
+ <circle cx={R} cy={R - R * 0.94} r={2.2} fill="hsl(var(--primary))" />
+ </svg>
+ )}
+ </div>
{voiceState === "idle" && (
<div
aria-hidden
@@ -212,6 +270,41 @@ export function DeckOrb({
/>
)}
+ {/* The level arc on the bezel: grows from the top down both sides with
+ the voice — a meter, reading `--orb-level` (CSS). */}
+ <svg
+ viewBox={`0 0 ${size} ${size}`}
+ className="deck-orb-vu pointer-events-none absolute inset-0 h-full w-full"
+ aria-hidden
+ data-testid="deck-orb-vu"
+ >
+ <path
+ d={`M ${R} ${R - R * 0.94} A ${R * 0.94} ${R * 0.94} 0 0 1 ${R} ${R + R * 0.94}`}
+ pathLength={1}
+ fill="none"
+ stroke="hsl(var(--primary))"
+ strokeWidth={3}
+ strokeLinecap="round"
+ />
+ <path
+ d={`M ${R} ${R - R * 0.94} A ${R * 0.94} ${R * 0.94} 0 0 0 ${R} ${R + R * 0.94}`}
+ pathLength={1}
+ fill="none"
+ stroke="hsl(var(--primary))"
+ strokeWidth={3}
+ strokeLinecap="round"
+ />
+ </svg>
+
+ {/* Ripples: one ring per word landing, from the sun to the bezel.
+ Spawned by the level loop, gone when their animation ends. */}
+ <div
+ ref={ripplesRef}
+ className="pointer-events-none absolute inset-0 grid place-items-center"
+ aria-hidden
+ data-testid="deck-orb-ripples"
+ />
+
<div className="absolute inset-0 grid place-items-center">
{onPress ? (
<button
@@ -261,7 +354,7 @@ function OrbFace({ voiceState, orbSize }: { voiceState: VoiceState; orbSize: num
<>
<div
aria-hidden
- className="deck-orb-glow pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full"
+ className="deck-orb-glow pointer-events-none absolute left-1/2 top-1/2 rounded-full"
data-voice={voiceState}
style={{ width: glow, height: glow }}
/>
@@ -270,6 +363,18 @@ function OrbFace({ voiceState, orbSize }: { voiceState: VoiceState; orbSize: num
);
}
+/** The most ripples alive at once — a burst is a few waves, not a strobe. */
+const MAX_RIPPLES = 4;
+
+/** One ripple ring, leaving the sun for the bezel; removes itself when done. */
+function spawnRipple(host: HTMLDivElement | null): void {
+ if (!host || host.childElementCount >= MAX_RIPPLES) return;
+ const el = document.createElement("div");
+ el.className = "deck-orb-ripple rounded-full";
+ el.addEventListener("animationend", () => el.remove(), { once: true });
+ host.appendChild(el);
+}
+
/**
* One turning ring of the reticle: a dashed circle in its own root `<svg>`,
* so its CSS rotation is a compositor transform (a transform on a group
diff --git a/jarvis/ui/web/frontend/src/components/deck/JarvisOrb.tsx b/jarvis/ui/web/frontend/src/components/deck/JarvisOrb.tsx
index db5ade5eb4..c20d4a003f 100644
--- a/jarvis/ui/web/frontend/src/components/deck/JarvisOrb.tsx
+++ b/jarvis/ui/web/frontend/src/components/deck/JarvisOrb.tsx
@@ -15,10 +15,16 @@ import { cn } from "@/lib/utils";
* 2026-08-18); with the live mascot on the wallpaper that made two ghosts on
* one stage, and the maintainer took it out (2026-08-19): the orb is the orb.
*
- * Voice state moves it a little, honestly and cheaply: a slow breath at rest,
- * a brighter, quicker pulse while listening, quicker still while it speaks, a
- * steady heartbeat while it thinks, dimmed and drained on an error. Nothing
- * turns — a rotating highlight on a glass sphere reads as a broken image.
+ * Voice moves it, honestly and cheaply. At rest a slow breath (framer, a
+ * gentle loop). While something is happening, the VOICE itself: the deck orb
+ * (DeckOrb.tsx) computes one level — the real microphone while listening, a
+ * speech-shaped envelope while the assistant speaks, a heartbeat while it
+ * thinks — and writes it to `--orb-level`; the reactor wrapper here scales
+ * and brightens the sun with it, and the corona behind it — slow-turning
+ * rays — comes up in the light of it (CSS, index.css). The framer loops for
+ * those states are therefore tiny: the level is the motion. Nothing in the
+ * picture turns — a rotating highlight on a glass sphere reads as a broken
+ * image; the corona turns BEHIND it. Dimmed and drained on an error.
* `prefers-reduced-motion` gets the still picture.
*/
const MOTION: Record<VoiceState, { animate: TargetAndTransition; duration: number }> = {
@@ -27,20 +33,20 @@ const MOTION: Record<VoiceState, { animate: TargetAndTransition; duration: numbe
duration: 6.5,
},
connecting: {
- animate: { scale: [1, 1.01, 1], filter: ["brightness(0.9)", "brightness(1.05)", "brightness(0.9)"] },
+ animate: { scale: [1, 1.006, 1], filter: ["brightness(0.94)", "brightness(1.02)", "brightness(0.94)"] },
duration: 1.4,
},
listening: {
- animate: { scale: [1, 1.03, 1], filter: ["brightness(1)", "brightness(1.22)", "brightness(1)"] },
- duration: 1.6,
+ animate: { scale: [1, 1.006, 1], filter: ["brightness(1)", "brightness(1.03)", "brightness(1)"] },
+ duration: 2.2,
},
thinking: {
- animate: { scale: [1, 1.02, 1], filter: ["brightness(1)", "brightness(1.12)", "brightness(1)"] },
- duration: 0.9,
+ animate: { scale: [1, 1.006, 1], filter: ["brightness(1)", "brightness(1.03)", "brightness(1)"] },
+ duration: 1.8,
},
speaking: {
- animate: { scale: [1, 1.035, 1], filter: ["brightness(1)", "brightness(1.3)", "brightness(1)"] },
- duration: 0.55,
+ animate: { scale: [1, 1.006, 1], filter: ["brightness(1)", "brightness(1.03)", "brightness(1)"] },
+ duration: 2.2,
},
paused: {
animate: { scale: 1, filter: "brightness(0.85) saturate(0.7)" },
@@ -72,20 +78,25 @@ export function JarvisOrb({
className={cn("relative select-none", className)}
style={{ width: size, height: size }}
>
- <motion.img
- src="/deck-orb.png"
- alt=""
- draggable={false}
- className="absolute inset-0 h-full w-full"
- animate={reduced ? undefined : spec.animate}
- transition={
- reduced
- ? undefined
- : looping
- ? { duration: spec.duration, repeat: Infinity, ease: "easeInOut" }
- : { duration: 0.4 }
- }
- />
+ {/* the corona: slow-turning rays behind the sun, lit by the level */}
+ <div aria-hidden className="deck-orb-corona pointer-events-none absolute rounded-full" />
+ {/* the reactor: the sun, sized and lit by the level */}
+ <div className="deck-orb-reactor absolute inset-0">
+ <motion.img
+ src="/deck-orb.png"
+ alt=""
+ draggable={false}
+ className="absolute inset-0 h-full w-full"
+ animate={reduced ? undefined : spec.animate}
+ transition={
+ reduced
+ ? undefined
+ : looping
+ ? { duration: spec.duration, repeat: Infinity, ease: "easeInOut" }
+ : { duration: 0.4 }
+ }
+ />
+ </div>
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.css
index 8a46abc958..57f30df064 100644
--- a/jarvis/ui/web/frontend/src/index.css
+++ b/jarvis/ui/web/frontend/src/index.css
@@ -2146,6 +2146,20 @@
filter: drop-shadow(0 0 7px rgba(0, 0, 0, 0.55)) hue-rotate(-40deg) saturate(1.4);
}
+ /* -----------------------------------------------------------
+ The orb moves with the voice (DeckOrb.tsx, JarvisOrb.tsx).
+ `--orb-level` is ONE number, 0..1, on the orb's root — the real
+ microphone while listening, a speech-shaped envelope while the
+ assistant speaks, a heartbeat while it thinks (lib/orbLevel.ts)
+ — smoothed once, written once per frame. Everything below
+ reads it: the sun's size and brightness, the glow, the corona's
+ rays, the rings, the level arc on the bezel. Transform, opacity
+ and a GPU brightness only, so it all moves as one and costs
+ the main thread one style write.
+ ----------------------------------------------------------- */
+ .deck-orb-root {
+ --orb-level: 0;
+ }
.deck-orb-glow {
background: radial-gradient(
circle,
@@ -2154,32 +2168,70 @@
rgba(210, 147, 24, 0.1) 58%,
rgba(210, 147, 24, 0) 70%
);
- opacity: 0.6;
- transition: opacity 600ms ease;
+ opacity: calc(0.6 + var(--orb-level, 0) * 0.4);
+ transform: translate(-50%, -50%) scale(calc(1 + var(--orb-level, 0) * 0.18));
+ will-change: transform, opacity;
+ }
+ /* at rest the glow breathes slowly — alive, not busy */
+ .deck-orb-glow[data-voice="idle"] {
+ animation: deck-orb-glow-idle 5.5s ease-in-out infinite;
+ }
+ /* the sun itself: bigger and brighter with the voice */
+ .deck-orb-reactor {
+ transform: scale(calc(1 + var(--orb-level, 0) * 0.09));
+ filter: brightness(calc(1 + var(--orb-level, 0) * 0.55));
+ will-change: transform, filter;
+ }
+ /* the corona: slow-turning rays behind the sun, seen only in the voice */
+ .deck-orb-corona {
+ inset: -18%;
+ background: repeating-conic-gradient(
+ from 0deg,
+ hsl(var(--primary) / 0) 0deg 5deg,
+ hsl(var(--primary) / 0.55) 8deg,
+ hsl(var(--primary) / 0) 11deg 20deg
+ );
+ -webkit-mask-image: radial-gradient(circle, transparent 30%, #000 42%, #000 58%, transparent 68%);
+ mask-image: radial-gradient(circle, transparent 30%, #000 42%, #000 58%, transparent 68%);
+ opacity: calc(var(--orb-level, 0) * 0.9);
+ animation: deck-orb-turn 30s linear infinite;
+ will-change: transform, opacity;
}
- .deck-orb-glow[data-voice="connecting"],
- .deck-orb-glow[data-voice="thinking"] {
+ /* the rings swell and brighten a little with it */
+ .deck-orb-rings {
+ transform: scale(calc(1 + var(--orb-level, 0) * 0.035));
+ opacity: calc(0.75 + var(--orb-level, 0) * 0.25);
+ will-change: transform, opacity;
+ }
+ /* the level arc on the bezel: two half-circles from the top, drawn as far
+ as the level goes; nothing at 0 */
+ .deck-orb-vu path {
+ stroke-dasharray: 1;
+ stroke-dashoffset: calc(1 - var(--orb-level, 0));
opacity: 0.9;
- animation: deck-orb-glow-breathe 2.6s ease-in-out infinite;
}
- .deck-orb-glow[data-voice="listening"],
- .deck-orb-glow[data-voice="speaking"] {
- opacity: 1;
- animation: deck-orb-glow-breathe 1.6s ease-in-out infinite;
+ .deck-orb-vu {
+ filter: drop-shadow(0 0 4px hsl(var(--primary) / 0.6));
}
- @keyframes deck-orb-glow-breathe {
- 0%,
- 100% {
- transform: translate(-50%, -50%) scale(1);
+ /* a ripple: one ring from the sun to the bezel per word landing */
+ .deck-orb-ripple {
+ width: 78%;
+ height: 78%;
+ border: 1.5px solid hsl(var(--primary) / 0.85);
+ box-shadow: 0 0 8px hsl(var(--primary) / 0.4);
+ animation: deck-orb-ripple 800ms cubic-bezier(0.1, 0.6, 0.3, 1) forwards;
+ will-change: transform, opacity;
+ }
+ @keyframes deck-orb-ripple {
+ 0% {
+ transform: scale(0.92);
+ opacity: 0.75;
}
- 50% {
- transform: translate(-50%, -50%) scale(1.07);
+ 100% {
+ transform: scale(1.24);
+ opacity: 0;
}
}
- /* at rest the glow breathes slowly — alive, not busy */
- .deck-orb-glow[data-voice="idle"] {
- animation: deck-orb-glow-idle 5.5s ease-in-out infinite;
- }
@keyframes deck-orb-glow-idle {
0%,
100% {
@@ -2259,10 +2311,14 @@
.deck-orb-orbit-b,
.deck-orb-satellite,
.deck-orb-ping,
+ .deck-orb-corona,
+ .deck-orb-ripple,
.deck-ring-orbit {
animation: none !important;
}
- .deck-orb-ping {
+ .deck-orb-ping,
+ .deck-orb-corona,
+ .deck-orb-ripple {
display: none;
}
}
diff --git a/jarvis/ui/web/frontend/src/lib/orbLevel.test.ts b/jarvis/ui/web/frontend/src/lib/orbLevel.test.ts
new file mode 100644
index 0000000000..6cbc732311
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/orbLevel.test.ts
@@ -0,0 +1,94 @@
+import { describe, expect, test } from "vitest";
+import {
+ driveTarget,
+ flickerEnvelope,
+ isOnset,
+ orbDriveFor,
+ pulseEnvelope,
+ smoothOrbLevel,
+ speechEnvelope,
+ ONSET_FLOOR,
+ RIPPLE_MIN_GAP_MS,
+} from "@/lib/orbLevel";
+
+/**
+ * The orb's level (2026-08-19): the real microphone while listening, a
+ * speech-shaped envelope while the assistant speaks, a heartbeat while it
+ * thinks — one smoothed number everything on the orb reads.
+ */
+describe("orbLevel", () => {
+ test("each voice state has its drive; idle and trouble have none", () => {
+ expect(orbDriveFor("listening")).toBe("mic");
+ expect(orbDriveFor("speaking")).toBe("speech");
+ expect(orbDriveFor("thinking")).toBe("pulse");
+ expect(orbDriveFor("connecting")).toBe("flicker");
+ expect(orbDriveFor("idle")).toBe("idle");
+ expect(orbDriveFor("error")).toBe("idle");
+ expect(orbDriveFor("paused")).toBe("idle");
+ });
+
+ test("the microphone drives the level directly, clipped to 0..1", () => {
+ expect(driveTarget("mic", 3, 0.4)).toBe(0.4);
+ expect(driveTarget("mic", 3, 1.7)).toBe(1);
+ expect(driveTarget("mic", 3, -1)).toBe(0);
+ expect(driveTarget("mic", 3, Number.NaN)).toBe(0);
+ expect(driveTarget("idle", 3, 0.9)).toBe(0);
+ });
+
+ test("attack is quick, release is soft", () => {
+ const up = smoothOrbLevel(0, 1, 1 / 60);
+ const down = 1 - smoothOrbLevel(1, 0, 1 / 60);
+ expect(up).toBeGreaterThan(down);
+ expect(up).toBeGreaterThan(0.25);
+ expect(down).toBeLessThan(0.2);
+ // Converges, never overshoots.
+ let v = 0;
+ for (let i = 0; i < 120; i++) v = smoothOrbLevel(v, 0.7, 1 / 60);
+ expect(v).toBeCloseTo(0.7, 2);
+ expect(smoothOrbLevel(0.5, 0.5, 1)).toBe(0.5);
+ });
+
+ test("the speech envelope swells in, moves like syllables, and stays in 0..1", () => {
+ expect(speechEnvelope(0)).toBe(0);
+ expect(speechEnvelope(0.18)).toBeGreaterThan(0.1);
+ let lo = 1;
+ let hi = 0;
+ let turns = 0;
+ let lastSign = 0;
+ let prev = speechEnvelope(0.2);
+ for (let t = 0.2; t < 4; t += 1 / 60) {
+ const v = speechEnvelope(t);
+ expect(v).toBeGreaterThanOrEqual(0);
+ expect(v).toBeLessThanOrEqual(1);
+ lo = Math.min(lo, v);
+ hi = Math.max(hi, v);
+ const s = Math.sign(v - prev);
+ if (s !== 0 && lastSign !== 0 && s !== lastSign) turns++;
+ if (s !== 0) lastSign = s;
+ prev = v;
+ }
+ // It breathes over a real range and turns around many times in 4 s — not
+ // a sine, not a flat line.
+ expect(hi - lo).toBeGreaterThan(0.4);
+ expect(turns).toBeGreaterThan(6);
+ });
+
+ test("the heartbeat and the flicker are small, periodic and bounded", () => {
+ for (let t = 0; t < 3; t += 0.05) {
+ expect(pulseEnvelope(t)).toBeGreaterThanOrEqual(0);
+ expect(pulseEnvelope(t)).toBeLessThanOrEqual(0.6);
+ expect(flickerEnvelope(t)).toBeGreaterThanOrEqual(0.1);
+ expect(flickerEnvelope(t)).toBeLessThanOrEqual(0.2);
+ }
+ expect(pulseEnvelope(0.07)).toBeGreaterThan(pulseEnvelope(0.6));
+ expect(pulseEnvelope(0.07)).toBeCloseTo(pulseEnvelope(0.97), 2);
+ });
+
+ test("an onset is a real jump above the floor, rate-limited", () => {
+ expect(isOnset(0.1, 0.4, 1000)).toBe(true);
+ expect(isOnset(0.3, 0.36, 1000)).toBe(false); // too small a jump
+ expect(isOnset(0.0, 0.15, 1000)).toBe(false); // under the floor
+ expect(isOnset(0.1, 0.4, RIPPLE_MIN_GAP_MS - 1)).toBe(false); // too soon
+ expect(isOnset(0.1, ONSET_FLOOR, RIPPLE_MIN_GAP_MS)).toBe(true);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/orbLevel.ts b/jarvis/ui/web/frontend/src/lib/orbLevel.ts
new file mode 100644
index 0000000000..36a0d9398b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/orbLevel.ts
@@ -0,0 +1,123 @@
+import type { VoiceState } from "@/store/events";
+
+/**
+ * The one number the orb lives by — its LEVEL, 0..1 — and where it comes
+ * from in each voice state. The deck orb (DeckOrb.tsx) runs a single
+ * animation-frame loop that computes this and writes it to one CSS custom
+ * property (`--orb-level`) on the orb's root; everything that reacts — the
+ * core's size and brightness, the glow, the corona's rays, the rings, the
+ * level arc on the bezel — reads that variable in CSS. One source, one
+ * smoothing, one look; nothing fights.
+ *
+ * What drives it (maintainer, 2026-08-19: "when you speak the sun moved —
+ * that, on the next level — and not just the core, all of it, smooth"):
+ *
+ * listening the REAL microphone level (`lib/voiceInputLevel`), the same
+ * samples the header's waveform draws — loud is big and bright,
+ * a consonant is a flick, silence is still
+ * speaking the assistant's speech — there is no output-level tap on
+ * any platform (the audio plays in the backend or the browser
+ * without a meter), so this is a speech-shaped envelope keyed
+ * to the truthful speaking state: syllables, not a sine
+ * thinking a steady heartbeat
+ * connecting a small, quick flicker while the line comes up
+ * else 0 — the idle breathing and the listening ping are CSS of
+ * their own (index.css) and do not go through the level
+ *
+ * Smoothing is asymmetric — a quick attack so a consonant lands at once, a
+ * softer release so syllables do not make the orb nervous — the same
+ * figures the classic surface's orb uses. An ONSET (a jump up) spawns one
+ * ripple, rate-limited, so a burst of speech reads as waves leaving the sun.
+ *
+ * Pure: no DOM, no timers, so orbLevel.test.ts can pin the curves.
+ */
+export type OrbDrive = "idle" | "mic" | "speech" | "pulse" | "flicker";
+
+export function orbDriveFor(state: VoiceState): OrbDrive {
+ switch (state) {
+ case "listening":
+ return "mic";
+ case "speaking":
+ return "speech";
+ case "thinking":
+ return "pulse";
+ case "connecting":
+ return "flicker";
+ default:
+ return "idle";
+ }
+}
+
+/** Attack and release rates, per second (the exponential ease constants). */
+export const ATTACK = 24;
+export const RELEASE = 9;
+
+/** One smoothing step towards `target` over `dt` seconds. */
+export function smoothOrbLevel(prev: number, target: number, dt: number): number {
+ const t = clamp01(target);
+ const rate = t > prev ? ATTACK : RELEASE;
+ const ease = 1 - Math.exp(-Math.max(0, dt) * rate);
+ return prev + (t - prev) * ease;
+}
+
+/**
+ * A speech-shaped envelope at `t` seconds since speaking began: three slow
+ * modulations at speech-like rates (syllables ~4/s, words ~1.5/s, phrases
+ * ~0.4/s) on a floor, clipped to 0..1, with a short swell at the onset so
+ * the first word lands. Deterministic, so two orbs speak the same.
+ */
+export function speechEnvelope(t: number): number {
+ if (t < 0) return 0;
+ const onset = Math.min(1, t / 0.18);
+ const syllables = 0.5 + 0.5 * Math.sin(t * 2 * Math.PI * 4.1);
+ const words = 0.5 + 0.5 * Math.sin(t * 2 * Math.PI * 1.4 + 0.9);
+ const phrase = 0.6 + 0.4 * Math.sin(t * 2 * Math.PI * 0.37 + 2.1);
+ const v = (0.18 + 0.62 * syllables * (0.55 + 0.45 * words)) * phrase;
+ return clamp01(v * onset);
+}
+
+/** The thinking heartbeat: a double beat, 0.9 s apart. */
+export function pulseEnvelope(t: number): number {
+ if (t < 0) return 0;
+ const beat = (t % 0.9) / 0.9;
+ const a = Math.exp(-Math.pow((beat - 0.08) / 0.06, 2));
+ const b = 0.55 * Math.exp(-Math.pow((beat - 0.3) / 0.07, 2));
+ return clamp01(0.06 + 0.38 * (a + b));
+}
+
+/** The connecting flicker: small and quick. */
+export function flickerEnvelope(t: number): number {
+ if (t < 0) return 0;
+ return clamp01(0.1 + 0.1 * (0.5 + 0.5 * Math.sin(t * 2 * Math.PI * 2.6)));
+}
+
+export function driveTarget(drive: OrbDrive, t: number, mic: number): number {
+ switch (drive) {
+ case "mic":
+ return clamp01(mic);
+ case "speech":
+ return speechEnvelope(t);
+ case "pulse":
+ return pulseEnvelope(t);
+ case "flicker":
+ return flickerEnvelope(t);
+ default:
+ return 0;
+ }
+}
+
+/** How much the level must jump in one step to count as an onset. */
+export const ONSET_JUMP = 0.1;
+/** The least time between two ripples — a burst is one wave, not a strobe. */
+export const RIPPLE_MIN_GAP_MS = 260;
+/** Only a level this high rings at all — breath and room noise do not. */
+export const ONSET_FLOOR = 0.22;
+
+export function isOnset(prev: number, next: number, sinceLastRippleMs: number): boolean {
+ return next >= ONSET_FLOOR && next - prev >= ONSET_JUMP && sinceLastRippleMs >= RIPPLE_MIN_GAP_MS;
+}
+
+function clamp01(v: number): number {
+ if (!Number.isFinite(v)) return 0;
+ return v < 0 ? 0 : v > 1 ? 1 : v;
+}