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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(society): a calm working animation for agent faces (#652)
Ruben Lütkede2b6d106966
diff --git a/jarvis/ui/web/frontend/src/components/society/AgentSwatch.test.tsx b/jarvis/ui/web/frontend/src/components/society/AgentSwatch.test.tsxindex 087864d3d4..d749606277 100644--- a/jarvis/ui/web/frontend/src/components/society/AgentSwatch.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/AgentSwatch.test.tsx@@ -24,8 +24,10 @@ describe("an agent that never picked a look", () => {expect(face().dataset.creatureState).toBe("idle");rerender(<AgentSwatch agent={{ ...agent, state: "working" }} />);expect(face().dataset.creatureState).toBe("working");+ expect(face().querySelector("[data-agent-working]")).not.toBeNull();rerender(<AgentSwatch agent={{ ...agent, state: "waiting" }} />);expect(face().dataset.creatureState).toBe("asking");+ expect(face().querySelector("[data-agent-working]")).toBeNull();});});@@ -42,8 +44,11 @@ describe("agent vector identities", () => {expect(container.querySelector("[data-thinking=true]")).toBeNull();}rerender(<AgentSwatch agent={{ ...agent, tier: "lead", state: "working" }} />);+ // The lead stays in the picture at work and carries the same bubble as everyone else.expect(container.querySelector("[data-agent-mascot=gigi]")).not.toBeNull();expect(container.querySelector("[data-thinking=true]")).not.toBeNull();+ expect(container.querySelector("[data-agent-working]")).not.toBeNull();+ expect(container.querySelector(".society-agent-symbol [data-agent-mascot=gigi]")).toBeNull();});it("renders a symbol immediately without a portrait, image request or canvas", () => {const { container } = render(<AgentSwatch agent={agent} size={40} />);diff --git a/jarvis/ui/web/frontend/src/components/society/AgentSwatch.tsx b/jarvis/ui/web/frontend/src/components/society/AgentSwatch.tsxindex 59870282a3..13f91e777c 100644--- a/jarvis/ui/web/frontend/src/components/society/AgentSwatch.tsx+++ b/jarvis/ui/web/frontend/src/components/society/AgentSwatch.tsx@@ -1,10 +1,10 @@import { GigiAvatar } from "./GigiAvatar";import { cn } from "@/lib/utils";-import { SymbolThinkingDots } from "./AgentSymbol";import { resolveCompanion } from "./companion/appearance";import { creatureColor } from "./companion/creature";import { CompanionMark } from "./companion/CompanionMark";+import { WorkingBadge } from "./companion/WorkingBadge";import type { SocietyAgent } from "./data";type SwatchAgent = Pick<SocietyAgent, "figure" | "palette" | "name"> &@@ -53,14 +53,14 @@ export function AgentSwatch({return (<spanaria-hidden- className={cn("relative inline-flex shrink-0 items-center justify-center select-none", isJarvis && "society-agent-symbol", className)}+ className={cn("relative inline-flex shrink-0 items-center justify-center select-none", className)}data-thinking={isJarvis && thinking ? "true" : undefined}style={{ width: size, height: size }}>{isJarvis ? (<><GigiAvatar size={size} />- {thinking && <svg aria-hidden viewBox="0 0 40 44" className="pointer-events-none absolute inset-0 h-full w-full"><SymbolThinkingDots color="#ffcf45" /></svg>}+ {thinking && <WorkingBadge size={size} />}</>) : (<CompanionMark appearance={appearance} size={size} thinking={thinking} expressive={expressive} run={agent.state} />diff --git a/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx b/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsxindex fdb49287b7..76fcf39c86 100644--- a/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx+++ b/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx@@ -172,17 +172,18 @@ function symbolEyeY(shape: SymbolShape): number {/*** An agent's shape: a small 3D figure of its body, eyes and accessories, or- * the flat symbol where figures cannot be drawn. A working agent shows the- * three flat dots either way.+ * the flat symbol where figures cannot be drawn. At work the figure stays in+ * the picture: it nods over what it does, under the working bubble. Only the+ * flat symbol still turns into three dots.*/export function AgentSymbol(props: SymbolProps) {const supported = useFiguresSupported();- if (!supported || props.thinking) return <FlatSymbol {...props} />;+ if (!supported) return <FlatSymbol {...props} />;return <FigureSymbol {...props} />;}function FigureSymbol(props: SymbolProps) {- const { shape, color, size, eyes = "lines", accessories, expressive = false, skin } = props;+ const { shape, color, size, eyes = "lines", accessories, expressive = false, skin, thinking = false } = props;const id = useId().replace(/[^a-zA-Z0-9_-]/g, "");const worn = wornAccessories(accessories);// Living eyes are drawn on top of an eyeless figure; glasses cover them, so the figure keeps its own.@@ -197,7 +198,7 @@ function FigureSymbol(props: SymbolProps) {}), [shape, color, eyes, wornKey, skinKey, blind]);const effect = skin ? skinEffect(skin) : "none";const eyeY = symbolEyeY(shape);- return <ShapeFigure look={look} size={size} shape={shape} fallback={<FlatSymbol {...props} />}+ return <ShapeFigure look={look} size={size} shape={shape} fallback={<FlatSymbol {...props} />} working={thinking}eyes={blind && !moving ? { kind: eyes, y: eyeY, color: companionEyeColors(color).eye } : undefined}flow={skin && effect === "flow" ? { colors: skin.colors, angle: skin.angle } : undefined} shine={effect === "shimmer"}inside={effect === "stars" ? <SkinStars /> : undefined}diff --git a/jarvis/ui/web/frontend/src/components/society/agentSymbol.css b/jarvis/ui/web/frontend/src/components/society/agentSymbol.cssindex 0382140cc2..9366fb9ab7 100644--- a/jarvis/ui/web/frontend/src/components/society/agentSymbol.css+++ b/jarvis/ui/web/frontend/src/components/society/agentSymbol.css@@ -296,3 +296,34 @@.agent-figure-flow > i > b { animation: none !important; }.agent-figure-shine > i { animation: none; transform: translateX(230%) skewX(-22deg); opacity: 0.5; }}++/* At work (ShapeFigure `working`): the figure leans over what it does and nods in a typing rhythm,+ two short beats and a longer one, then lifts its head; its eyes stay on the work. The same motion+ a pixel creature has (companion/faceMotion.css). */+.society-agent-figure[data-working="true"] > .agent-figure-body {+ animation: agent-figure-work 2.6s cubic-bezier(0.45, 0, 0.3, 1) infinite;+ animation-delay: var(--agent-figure-delay, 0ms);+}+@keyframes agent-figure-work {+ 0%, 100% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 9% { transform: translateY(4%) rotate(3.5deg) scale(1.012, 0.985); }+ 18% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 27% { transform: translateY(4%) rotate(3.5deg) scale(1.012, 0.985); }+ 36% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 48% { transform: translateY(4.5%) rotate(4deg) scale(1.016, 0.98); }+ 62% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 78% { transform: translateY(-1.5%) rotate(-1.5deg) scale(0.994, 1.012); }+ 90% { transform: translateY(-1.5%) rotate(-1.5deg) scale(0.994, 1.012); }+}+.society-agent-figure[data-working="true"] > .agent-figure-body > .agent-figure-eyes {+ animation: agent-figure-focus 2.6s cubic-bezier(0.45, 0, 0.3, 1) infinite;+ animation-delay: var(--agent-figure-delay, 0ms);+}+@keyframes agent-figure-focus {+ 0%, 62%, 100% { transform: translate(0.2em, 0.8em); }+ 78%, 90% { transform: translate(-0.3em, -0.3em); }+}+@media (prefers-reduced-motion: reduce) {+ .society-agent-figure[data-working="true"] > .agent-figure-body,+ .society-agent-figure[data-working="true"] > .agent-figure-body > .agent-figure-eyes { animation: none; }+}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.test.tsx b/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.test.tsxindex 740a17a729..a8256af5fe 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.test.tsx@@ -44,6 +44,8 @@ describe("CompanionMark", () => {client.setQueryData(petKeys.all, PETS);rerender(<QueryClientProvider client={client}><CompanionMark appearance={look({ pet: "cocoa" })} size={30} thinking /></QueryClientProvider>);expect(screen.getByTestId("pet-sprite").dataset.state).toBe("working");+ // At work the pet keeps its face and carries the working bubble.+ expect(container.querySelector("[data-agent-pet='cocoa'] [data-agent-working]")).not.toBeNull();});it("plays the row a surrounding stage asks for", () => {@@ -74,6 +76,29 @@ describe("CompanionMark", () => {expect(face().dataset.creatureState).toBe("talking");});+ it("shows the working bubble on a creature at work, but not where a stage or a preview already says so", () => {+ const creature = { seed: 24, palette: "neon", eyes: "dot" };+ const mark = (node: JSX.Element) => <QueryClientProvider client={new QueryClient()}>{node}</QueryClientProvider>;+ const { container, rerender } = render(mark(<CompanionMark appearance={look({ creature })} size={36} />));+ const bubble = () => container.querySelector("[data-agent-creature] [data-agent-working]");+ expect(bubble()).toBeNull();+ rerender(mark(<CompanionMark appearance={look({ creature })} size={36} run="working" />));+ expect(bubble()).not.toBeNull();+ rerender(mark(<CompanionMark appearance={look({ creature })} size={36} thinking />));+ expect(bubble()).not.toBeNull();+ for (const quiet of [{ run: "waiting" }, { run: "paused" }, { run: "working", mood: "working" }] as const) {+ rerender(mark(<CompanionMark appearance={look({ creature })} size={36} {...quiet} />));+ expect(bubble()).toBeNull();+ }+ // A small face (a stack of members, a name in a line) still works, without a bubble over it.+ rerender(mark(<CompanionMark appearance={look({ creature })} size={26} run="working" />));+ expect(container.querySelector<HTMLElement>("[data-agent-creature]")!.dataset.creatureState).toBe("working");+ expect(bubble()).toBeNull();+ rerender(mark(<PetStageContext.Provider value="working"><CompanionMark appearance={look({ creature })} size={36} run="working" /></PetStageContext.Provider>));+ expect(container.querySelector<HTMLElement>("[data-agent-creature]")!.dataset.creatureState).toBe("working");+ expect(bubble()).toBeNull();+ });+it("keeps the worn pet over a creature, and shows the creature when that pet is missing here", () => {const creature = { seed: 24, palette: "neon", eyes: "dot" };const worn = renderWith(<CompanionMark appearance={look({ creature, pet: "cocoa" })} size={30} />);diff --git a/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.tsx b/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.tsxindex 56c573f1bc..89e52ac8e4 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.tsx+++ b/jarvis/ui/web/frontend/src/components/society/companion/CompanionMark.tsx@@ -10,11 +10,12 @@ import type { CompanionAppearance } from "./appearance";import type { CreatureState } from "./creature";import { useShownCreature } from "./creatureDefault";import { PixelCreature } from "./PixelCreature";+import { WorkingBadge } from "./WorkingBadge";type MarkProps = {appearance: CompanionAppearance;size: number;- /** The agent is at work: the shape shows thinking dots, a pet plays its working row. */+ /** The agent is at work: every look shows the working bubble; a creature nods, a pet plays its working row. */thinking?: boolean;/** Eyes a stage can animate (shapes only; a pet acts through its own rows). */expressive?: boolean;@@ -49,8 +50,11 @@ export function CompanionMark(props: MarkProps) {const creature = useShownCreature(appearance);const staged = useContext(PetStageContext);const pose = state ?? staged;+ // At work in a roster or a list: the face says so with its bubble. A stage (the chat's own+ // line about what the agent does) and the look editor's preview already say it in words.+ const busy = !pose && mood === undefined && (thinking || run === "working");const shape = creature- ? <PixelCreature creature={creature} size={size} state={mood ?? (pose ? CREATURE_FOR_PET[pose] : thinking ? "working" : CREATURE_FOR_RUN[run ?? "idle"])} />+ ? <PixelCreature creature={creature} size={size} busy={busy} state={mood ?? (pose ? CREATURE_FOR_PET[pose] : thinking ? "working" : CREATURE_FOR_RUN[run ?? "idle"])} />: <AgentSymbol {...appearance} size={size} thinking={thinking} expressive={expressive} />;// Outside a query client (an isolated render, a bare preview) there is no catalog to read.const client = useContext(QueryClientContext);@@ -63,7 +67,8 @@ function PetFace({ petId, size, thinking = false, state, fallback }: MarkProps &const staged = useContext(PetStageContext);if (pet === undefined) return <span aria-hidden className="inline-block shrink-0" style={{ width: size, height: size }} />;if (pet === null) return fallback;- return <span className="agent-pet-face inline-flex shrink-0" data-agent-pet={pet.id}>+ return <span className="agent-pet-face relative inline-flex shrink-0" data-agent-pet={pet.id}><PetSprite pet={pet} state={state ?? staged ?? (thinking ? "working" : "idle")} px={size} />+ {thinking && !state && !staged && <WorkingBadge size={size} />}</span>;}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/PixelCreature.tsx b/jarvis/ui/web/frontend/src/components/society/companion/PixelCreature.tsxindex 1bb2f8c181..48fe5af915 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/PixelCreature.tsx+++ b/jarvis/ui/web/frontend/src/components/society/companion/PixelCreature.tsx@@ -1,10 +1,12 @@-import { useEffect, useRef } from "react";+import { useEffect, useRef, type CSSProperties } from "react";import { useReducedMotion } from "framer-motion";import {creatureBody, creaturePose, CREATURE_STILL_FRAME, CREATURE_TICK_MS, GRID, STAGE_H, STAGE_W, STAGE_X, STAGE_Y,type CreatureLook, type CreatureState,} from "./creature";import { FACE_YAW, paintCreature } from "./creaturePaint";+import { WorkingBadge } from "./WorkingBadge";+import "./faceMotion.css";/*** One clock for every creature on screen. It only runs while a visible@@ -75,10 +77,17 @@ function softwareContext(canvas: HTMLCanvasElement): CanvasRenderingContext2D |/*** An agent's pixel creature at `size` pixels, acting out `state`. The figure* fills the square like every other agent face; the canvas reaches a little- * past it on each side, so a question mark or a spark can play beside the- * head without a wider layout. Reduced motion shows one still frame per state.+ * past it on each side, so a question mark or confetti can play beside the+ * head without a wider layout. The canvas paints what changes in whole cells+ * (eyes, signs); the body's own motion (a breath, the rhythm of work) is a+ * smooth layer around it (faceMotion.css). With `busy`, the working bubble+ * sits at its corner. Reduced motion shows one still frame per state.*/-export function PixelCreature({ creature, size, state = "idle" }: { creature: CreatureLook; size: number; state?: CreatureState }) {+export function PixelCreature({ creature, size, state = "idle", busy = false }: {+ creature: CreatureLook; size: number; state?: CreatureState;+ /** Shows the working bubble; a stage that already says what the agent does leaves it off. */+ busy?: boolean;+}) {const canvas = useRef<HTMLCanvasElement>(null);const reduced = useReducedMotion() ?? false;const { seed, palette, eyes } = creature;@@ -123,9 +132,14 @@ export function PixelCreature({ creature, size, state = "idle" }: { creature: Crreturn () => { observer.disconnect(); watch(false); };}, [seed, palette, eyes, size, state, reduced]);const cell = size / GRID;- return <span className="relative inline-block shrink-0" data-agent-creature={seed} data-creature-state={state} style={{ width: size, height: size }}>- <canvas ref={canvas} aria-hidden className="pointer-events-none absolute max-w-none"- style={{ left: -STAGE_X * cell, top: -STAGE_Y * cell, width: STAGE_W * cell, height: STAGE_H * cell }} />+ // Each creature keeps its own beat, so a roster never nods as one.+ const pace = { "--agent-face-delay": `${-((seed * 37) % 4000)}ms` } as CSSProperties;+ return <span className="agent-creature relative inline-block shrink-0" data-agent-creature={seed} data-creature-state={state} style={{ width: size, height: size, ...pace }}>+ <span className="agent-creature-body">+ <canvas ref={canvas} aria-hidden className="pointer-events-none absolute max-w-none"+ style={{ left: -STAGE_X * cell, top: -STAGE_Y * cell, width: STAGE_W * cell, height: STAGE_H * cell }} />+ </span>+ {busy && <WorkingBadge size={size} />}</span>;}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx b/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsxindex ba4b077941..f243b50104 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx+++ b/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx@@ -1,5 +1,6 @@import { useCallback, useLayoutEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from "react";import { figureKey, type FigureLook, type FigureSmoke } from "./figureScene";+import { WorkingBadge } from "./WorkingBadge";import { FIGURE_BROKEN, figuresSupported, readFigure, watchFigure, watchFigureSupport, type Figure } from "./figureStore";/** True while agent shapes can be drawn as 3D figures here; re-renders when that changes. */@@ -88,7 +89,7 @@ function LivingEyes({ figure, size, eyes }: { figure: Figure; size: number; eyes* a roster of faces costs the UI thread nothing while it idles; each figure* runs a little out of step with the others.*/-export function ShapeFigure({ look, size, shape, behind, children, overlay, fallback, flow, shine, inside, smoke, eyes }: {+export function ShapeFigure({ look, size, shape, behind, children, overlay, fallback, flow, shine, inside, smoke, eyes, working = false }: {look: FigureLook; size: number;/** Shown when this look could not be drawn and no earlier picture is there. */fallback: ReactNode;@@ -106,6 +107,8 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fallinside?: ReactNode;/** Living eyes over an eyeless picture: their kind, their height in symbol units and their ink. */eyes?: { kind: "dots" | "lines"; y: number; color: string };+ /** The agent is at work: the figure nods over what it does, under the working bubble. */+ working?: boolean;/** Draws one plume of smoke, in symbol units around its source. */smoke?: (plume: FigureSmoke, index: number) => ReactNode;children?: ReactNode;@@ -146,7 +149,7 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, falllet beat = 0;for (let i = 0; i < key.length; i++) beat = (beat * 31 + key.charCodeAt(i)) % 9973;const pace = { "--agent-figure-delay": `${-beat}ms` } as CSSProperties;- return <span className="society-agent-figure" data-agent-figure={shape} data-ready={ready ? "true" : undefined} style={{ width: size, height: size, ...pace }}>+ return <span className="society-agent-figure" data-agent-figure={shape} data-ready={ready ? "true" : undefined} data-working={working ? "true" : undefined} style={{ width: size, height: size, ...pace }}>{behind}<span className="agent-figure-body"><span className="agent-figure-picture" style={flow ? masked(current?.whole) : undefined}>@@ -172,5 +175,6 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fall</svg>}</span>{shown && overlay}+ {working && <WorkingBadge size={size} />}</span>;}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/WorkingBadge.tsx b/jarvis/ui/web/frontend/src/components/society/companion/WorkingBadge.tsxnew file mode 100644index 0000000000..052e27b900--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/companion/WorkingBadge.tsx@@ -0,0 +1,21 @@+import "./faceMotion.css";++/**+ * Three dots in a small bubble at the corner of an agent's face: the agent+ * is at work. Every look shows it the same way (a pixel creature, a shape, a+ * pet, the lead), so the roster reads at a glance, and the face itself stays+ * in the picture instead of turning into an indicator. The bubble sits on+ * the page's own surface colours; the dots rise one after the other, moved+ * by transforms only.+ *+ * Its host must be positioned (`position: relative`) and `size` pixels wide.+ * A face smaller than WORKING_BADGE_MIN_PX goes without: in a stack of small+ * faces or beside a name in running text the bubble would cover the face it+ * belongs to, and the face still nods at its work.+ */+export const WORKING_BADGE_MIN_PX = 30;++export function WorkingBadge({ size }: { size: number }) {+ if (size < WORKING_BADGE_MIN_PX) return null;+ return <span aria-hidden className="agent-working-badge" data-agent-working style={{ fontSize: size }}><i /><i /><i /></span>;+}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/creature.test.ts b/jarvis/ui/web/frontend/src/components/society/companion/creature.test.tsindex 9192c96b71..05a17fd019 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/creature.test.ts+++ b/jarvis/ui/web/frontend/src/components/society/companion/creature.test.ts@@ -49,7 +49,22 @@ describe("growing a pixel creature", () => {});describe("what a creature acts out", () => {- it("keeps every sign and spark of every state inside the stage", () => {+ it("works without leaving its place: no jump of whole cells and nothing flying about", () => {+ const eyes = new Set<string>();+ for (let frame = 0; frame < 120; frame++) {+ const pose = creaturePose("working", frame);+ expect([pose.dx, pose.dy, pose.head, pose.squash]).toEqual([0, 0, 0, false]);+ expect(pose.bits).toHaveLength(0);+ eyes.add(`${pose.eyes}:${pose.ex}:${pose.ey}`);+ }+ // The eyes carry the scene: down at the work, a look to each side, a blink.+ expect(eyes).toContain("open:0:1");+ expect(eyes).toContain("open:-1:1");+ expect(eyes).toContain("open:1:0");+ expect(eyes).toContain("shut:0:1");+ });++ it("keeps every sign of every state inside the stage", () => {for (const state of CREATURE_STATES) for (let frame = 0; frame < 120; frame++) {for (const bit of creaturePose(state, frame).bits) {expect(bit.x).toBeGreaterThanOrEqual(-STAGE_X);diff --git a/jarvis/ui/web/frontend/src/components/society/companion/creature.ts b/jarvis/ui/web/frontend/src/components/society/companion/creature.tsindex adde09a95e..f1d557223e 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/creature.ts+++ b/jarvis/ui/web/frontend/src/components/society/companion/creature.ts@@ -250,7 +250,6 @@ function stamp(bits: CreatureBit[], glyph: keyof typeof GLYPHS, x: number, y: nu}const CONFETTI: readonly (readonly [number, number, 0 | 1 | 2])[] = [[-1.2, -.9, 0], [-.6, -1.3, 2], [.5, -1.4, 1], [1.1, -1, 0], [-1.6, -.3, 1], [1.6, -.4, 2]];-const SPARK_PATH: readonly (readonly [number, number, number])[] = [[-1, 8, 1], [-2, 7, 1], [-2, 6, .7], [-2, 5, .4]];export function creaturePose(state: CreatureState, frame: number): CreaturePose {const f = Math.max(0, Math.floor(frame));@@ -278,13 +277,13 @@ export function creaturePose(state: CreatureState, frame: number): CreaturePosebreak;}case "working": {- p.dy = [0, 0, -1, -1][f % 4]!;+ // Eyes on the work, a look to each side now and then, a blink. How the body moves while it+ // works is the face's own, smooth layer (faceMotion.css), never a jump of whole cells here.+ const k = f % 52;p.ey = 1;- const spark = SPARK_PATH[f % 6];- if (spark) {- const [x, y, alpha] = spark;- p.bits.push({ x, y, color: 0, alpha }, { x: GRID - 1 - x, y, color: 0, alpha });- }+ if (k < 2) p.eyes = "shut";+ else if (k >= 18 && k < 24) p.ex = -1;+ else if (k >= 38 && k < 46) { p.ey = 0; p.ex = 1; }break;}case "talking": {@@ -335,7 +334,7 @@ export function creaturePose(state: CreatureState, frame: number): CreaturePose/** One representative frame per state, for people who asked for less motion. */export const CREATURE_STILL_FRAME: Readonly<Record<CreatureState, number>> = {- idle: 5, listening: 6, thinking: 12, working: 1, talking: 1, asking: 0, success: 8, error: 7, sleeping: 10,+ idle: 5, listening: 6, thinking: 12, working: 6, talking: 1, asking: 0, success: 8, error: 7, sleeping: 10,};/** Eye cells per kind as [row, column]; the lower row is the one a lid closes. */diff --git a/jarvis/ui/web/frontend/src/components/society/companion/faceMotion.css b/jarvis/ui/web/frontend/src/components/society/companion/faceMotion.cssnew file mode 100644index 0000000000..bd02c76629--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/companion/faceMotion.css@@ -0,0 +1,91 @@+/* How an agent's face moves, whatever it looks like: the bubble that says it+ is at work, and the smooth motion of a pixel creature's body. Everything+ here is a transform or an opacity, so a roster of faces animates on the+ compositor. Lengths are in em of the face's width. */++/* At work: three dots in a bubble at the upper right corner. */+.agent-working-badge {+ position: absolute;+ top: -0.07em;+ right: -0.2em;+ z-index: 1;+ display: flex;+ align-items: center;+ gap: max(1.5px, 0.05em);+ height: max(8px, 0.3em);+ padding: 0 max(2.5px, 0.085em);+ border-radius: 999px;+ background: hsl(var(--popover));+ box-shadow: 0 0 0 1px hsl(var(--border)), 0 1px 3px rgb(0 0 0 / 0.22);+ pointer-events: none;+ animation: agent-working-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;+}+.agent-working-badge > i {+ display: block;+ width: max(2px, 0.08em);+ height: max(2px, 0.08em);+ border-radius: 50%;+ background: hsl(var(--foreground));+ opacity: 0.32;+ animation: agent-working-dot 1.2s ease-in-out infinite;+ /* Out of step from face to face: a roster of working agents never pulses as one. */+ animation-delay: var(--agent-face-delay, var(--agent-figure-delay, 0ms));+}+.agent-working-badge > i:nth-child(2) { animation-delay: calc(var(--agent-face-delay, var(--agent-figure-delay, 0ms)) + 0.16s); }+.agent-working-badge > i:nth-child(3) { animation-delay: calc(var(--agent-face-delay, var(--agent-figure-delay, 0ms)) + 0.32s); }+@keyframes agent-working-in {+ from { opacity: 0; transform: translateY(18%) scale(0.7); }+ to { opacity: 1; transform: none; }+}+@keyframes agent-working-dot {+ 0%, 62%, 100% { transform: translateY(0); opacity: 0.32; }+ 30% { transform: translateY(-38%); opacity: 1; }+}++/* A pixel creature's body. The cubes themselves are painted on a canvas at+ whole cells (eyes, signs, a blink); how the body moves through space is+ this layer's, so it glides instead of jumping a cell at a time. Each+ creature keeps its own beat (--agent-face-delay). */+.agent-creature > .agent-creature-body {+ position: absolute;+ inset: 0;+ transform-origin: 50% 92%;+ animation-delay: var(--agent-face-delay, 0ms);+}+.agent-creature:is([data-creature-state="idle"], [data-creature-state="listening"], [data-creature-state="thinking"], [data-creature-state="talking"], [data-creature-state="asking"]) > .agent-creature-body {+ animation-name: agent-creature-breathe;+ animation-duration: 3.8s;+ animation-timing-function: ease-in-out;+ animation-iteration-count: infinite;+}+@keyframes agent-creature-breathe {+ 0%, 100% { transform: translateY(0) scale(1, 1); }+ 50% { transform: translateY(-1.6%) scale(0.992, 1.018); }+}++/* At work: it leans over what it does and nods in a typing rhythm, two short+ beats and a longer one, then lifts its head for a moment. */+.agent-creature[data-creature-state="working"] > .agent-creature-body {+ animation-name: agent-creature-work;+ animation-duration: 2.6s;+ animation-timing-function: cubic-bezier(0.45, 0, 0.3, 1);+ animation-iteration-count: infinite;+}+@keyframes agent-creature-work {+ 0%, 100% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 9% { transform: translateY(4%) rotate(3.5deg) scale(1.012, 0.985); }+ 18% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 27% { transform: translateY(4%) rotate(3.5deg) scale(1.012, 0.985); }+ 36% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 48% { transform: translateY(4.5%) rotate(4deg) scale(1.016, 0.98); }+ 62% { transform: translateY(1.5%) rotate(2.5deg) scale(1, 1); }+ 78% { transform: translateY(-1.5%) rotate(-1.5deg) scale(0.994, 1.012); }+ 90% { transform: translateY(-1.5%) rotate(-1.5deg) scale(0.994, 1.012); }+}++@media (prefers-reduced-motion: reduce) {+ .agent-working-badge,+ .agent-working-badge > i,+ .agent-creature > .agent-creature-body { animation: none; }+ .agent-working-badge > i { opacity: 0.75; }+}