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): bring 3D agent shapes to life at rest (#624)
Ruben Lütke580d2f976dc7
diff --git a/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx b/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsxindex a2efa72972..fdb49287b7 100644--- a/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx+++ b/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx@@ -185,17 +185,20 @@ function FigureSymbol(props: SymbolProps) {const { shape, color, size, eyes = "lines", accessories, expressive = false, skin } = props;const id = useId().replace(/[^a-zA-Z0-9_-]/g, "");const worn = wornAccessories(accessories);- // Moving eyes are drawn on top of an eyeless figure; glasses cover them, so the figure keeps its own.- const moving = expressive && !worn.some(item => item.slot === "face");+ // Living eyes are drawn on top of an eyeless figure; glasses cover them, so the figure keeps its own.+ const blind = !worn.some(item => item.slot === "face");+ // A stage plays its own expressions on vector eyes; everywhere else the eyes blink and glance by themselves.+ const moving = expressive && blind;const wornKey = worn.map(item => item.id).join(","), skinKey = skin ? JSON.stringify(skin) : "";const look = useMemo<FigureLook>(() => ({- shape, color, eyes, accessories, blind: moving,+ shape, color, eyes, accessories, blind,skin: skin && { colors: skin.colors, radial: skin.pattern === "radial", angle: skin.angle, effect: SKIN_EFFECTS.indexOf(skinEffect(skin)), highlight: skinHighlight(skin.colors) },// eslint-disable-next-line react-hooks/exhaustive-deps -- accessories and skin are read through their keys- }), [shape, color, eyes, wornKey, skinKey, moving]);+ }), [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} />}+ 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}smoke={(plume, index) => <SmokePuffs c={[0, 0, 0]} size={plume.size} fill={plume.fill} id={`${id}-smoke-${index}`} />}diff --git a/jarvis/ui/web/frontend/src/components/society/agentSymbol.css b/jarvis/ui/web/frontend/src/components/society/agentSymbol.cssindex 2761e6ad6c..0382140cc2 100644--- a/jarvis/ui/web/frontend/src/components/society/agentSymbol.css+++ b/jarvis/ui/web/frontend/src/components/society/agentSymbol.css@@ -106,15 +106,42 @@}/* The 3D figure (companion/ShapeFigure): a canvas at the face's size, with- optional vector layers over it. It fades in once, when its first picture+ optional layers over it. It fades in once, when its first picturearrives; later pictures replace it without a flicker. */.society-agent-figure {position: relative;display: inline-block;flex-shrink: 0;}+/* Everything that belongs to the body moves as one: it breathes from the ground up, a little out of step+ with every other figure (--agent-figure-delay), and gives a small hop when the pointer finds it. */+.society-agent-figure > .agent-figure-body {+ position: relative;+ display: block;+ width: 100%;+ height: 100%;+ transform-origin: 50% 88%;+ animation: agent-figure-breathe 4.2s ease-in-out infinite;+ animation-delay: var(--agent-figure-delay, 0ms);+}+@keyframes agent-figure-breathe {+ 0%, 100% { transform: translateY(0) scale(1, 1); }+ 50% { transform: translateY(-1.2%) scale(1.014, 0.984); }+}+:is(button, a, [role="button"], [role="tab"], li):hover > .society-agent-figure > .agent-figure-body,+:is(button, a, [role="button"], [role="tab"], li):hover :is(span, div) > .society-agent-figure > .agent-figure-body,+.society-agent-figure:hover > .agent-figure-body {+ animation: agent-figure-hop 0.55s cubic-bezier(0.3, 0.7, 0.4, 1), agent-figure-breathe 4.2s ease-in-out 0.55s infinite;+}+@keyframes agent-figure-hop {+ 0% { transform: translateY(0) scale(1, 1); }+ 22% { transform: translateY(1.5%) scale(1.06, 0.92); }+ 52% { transform: translateY(-9%) scale(0.97, 1.05); }+ 78% { transform: translateY(0) scale(1.03, 0.96); }+ 100% { transform: translateY(0) scale(1, 1); }+}/* The picture and what is blended onto it: flowing colours meet the picture only, never the page behind. */-.society-agent-figure > .agent-figure-picture {+.agent-figure-body > .agent-figure-picture {position: relative;display: block;width: 100%;@@ -125,13 +152,14 @@opacity: 0;transition: opacity 0.18s ease-out;}-.society-agent-figure[data-ready="true"] > .agent-figure-picture { opacity: 1; }+.society-agent-figure[data-ready="true"] .agent-figure-picture { opacity: 1; }.agent-figure-picture > canvas {display: block;width: 100%;height: 100%;}-.society-agent-figure > svg {+.society-agent-figure > svg,+.agent-figure-body > svg {position: absolute;inset: 0;width: 100%;@@ -140,6 +168,48 @@pointer-events: none;}+/* Living eyes: the pair glances about now and then, each eye blinks. Lengths in em of one symbol unit. */+.agent-figure-body > .agent-figure-eyes {+ position: absolute;+ inset: 0;+ pointer-events: none;+ opacity: 0;+ animation: agent-figure-glance 11s ease-in-out infinite;+ animation-delay: var(--agent-figure-delay, 0ms);+}+.society-agent-figure[data-ready="true"] .agent-figure-eyes { opacity: 1; }+.agent-figure-eyes > i {+ position: absolute;+ display: block;+}+.agent-figure-eyes > i > b {+ position: absolute;+ inset: 0;+ border-radius: 50%;+ animation: agent-figure-blink 5.4s ease-in-out infinite;+ animation-delay: var(--agent-figure-delay, 0ms);+}+@keyframes agent-figure-glance {+ 0%, 18%, 30%, 56%, 70%, 100% { transform: translate(0, 0); }+ 21%, 27% { transform: translate(-1em, 0.15em); }+ 59%, 66% { transform: translate(0.9em, -0.35em); }+}+@keyframes agent-figure-blink {+ 0%, 44%, 50%, 90%, 94.5%, 97%, 100% { transform: scaleY(1); }+ 47% { transform: scaleY(0.08); }+ 92% { transform: scaleY(0.08); }+ 95.8% { transform: scaleY(0.08); }+}+/* The pointer has found it: wide eyes for the hop. */+:is(button, a, [role="button"], [role="tab"], li):hover .agent-figure-eyes > i > b,+.society-agent-figure:hover .agent-figure-eyes > i > b {+ animation: agent-figure-wide 0.55s ease-out, agent-figure-blink 5.4s ease-in-out 0.55s infinite;+}+@keyframes agent-figure-wide {+ 0%, 100% { transform: scale(1); }+ 40% { transform: scale(1.18, 1.22); }+}+/* A glowing design: a soft halo of its brightest colour breathes behind the figure. */.society-agent-figure > .agent-figure-halo {position: absolute;@@ -157,8 +227,8 @@/* Effects that move across the body: layers over the still picture, cut to the body's outline by a maskof the same picture and moved by transforms only. */.agent-figure-picture > .agent-figure-flow,-.society-agent-figure > .agent-figure-shine,-.society-agent-figure > .agent-figure-inside {+.agent-figure-body > .agent-figure-shine,+.agent-figure-body > .agent-figure-inside {position: absolute;inset: 0;overflow: hidden;@@ -218,8 +288,11 @@}@media (prefers-reduced-motion: reduce) {- .society-agent-figure > .agent-figure-picture { transition: none; }- .society-agent-figure > .agent-figure-halo { animation: none; }- .agent-figure-flow > i > b { animation: none; }+ .agent-figure-body > .agent-figure-picture { transition: none; }+ .society-agent-figure > .agent-figure-body,+ .agent-figure-body > .agent-figure-eyes,+ .agent-figure-eyes > i > b,+ .society-agent-figure > .agent-figure-halo,+ .agent-figure-flow > i > b { animation: none !important; }.agent-figure-shine > i { animation: none; transform: translateX(230%) skewX(-22deg); opacity: 0.5; }}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/CompanionPreview.tsx b/jarvis/ui/web/frontend/src/components/society/companion/CompanionPreview.tsxindex f8efd3c515..19066a69b0 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/CompanionPreview.tsx+++ b/jarvis/ui/web/frontend/src/components/society/companion/CompanionPreview.tsx@@ -1,5 +1,6 @@import { Component, Suspense, useEffect, useRef, type ReactNode } from "react";-import { Canvas, useThree } from "@react-three/fiber";+import { Canvas, useFrame, useThree } from "@react-three/fiber";+import type { Group } from "three";import { ContactShadows, Environment, Lightformer, OrbitControls } from "@react-three/drei";import { useReducedMotion } from "framer-motion";import { useCanvasAwake } from "@/hooks/useCanvasAwake";@@ -78,6 +79,24 @@ function Frame({ framing }: { framing: Framing }) {return null;}+/**+ * A shape at rest on the table: it sways a little to each side and breathes,+ * so the preview shows its volume without being turned by hand. A pet brings+ * its own life (PetModel) and is left alone.+ */+function Idle({ enabled, children }: { enabled: boolean; children: ReactNode }) {+ const group = useRef<Group>(null);+ useFrame(({ clock }) => {+ const node = group.current;+ if (!node || !enabled) return;+ const t = clock.getElapsedTime();+ const breath = Math.sin(t * 1.5) * 0.012;+ node.rotation.y = Math.sin(t * 0.6) * 0.3;+ node.scale.set(1 + breath, 1 - breath, 1 + breath);+ });+ return <group ref={group}>{children}</group>;+}+export function CompanionPreview({ appearance, lead = false }: { appearance: CompanionAppearance; lead?: boolean }) {const host = useRef<HTMLDivElement>(null);const { generation } = useWebglSurface(host);@@ -90,17 +109,18 @@ export function CompanionPreview({ appearance, lead = false }: { appearance: Comconst framing = pet? previewFraming(pet.heightM, companionFlies(pet) ? WORN_PET_LIFT_M : 0): previewFraming(appearance.sizeM, 0);- // A pet breathes, blinks and turns on the table; a still preview only draws when asked.- const live = !!pet && !reduced;+ // A pet breathes, blinks and turns on the table; a shape sways and breathes. Reduced motion draws only when asked.+ const live = !reduced;+ const turning = !!pet && live;return <div ref={host} className="h-56 w-full touch-none" data-testid="companion-preview">{supported && awake && <PreviewBoundary key={generation}><Canvas frameloop={live ? "always" : "demand"} shadows dpr={[1, 2]}camera={{ position: framing.position, fov: FOV, near: 0.02, far: 20 }} gl={{ alpha: true, antialias: true }}><Studio /><Frame framing={framing} />- <Suspense fallback={null}><CompanionModel appearance={appearance} lead={lead} /></Suspense>+ <Suspense fallback={null}><Idle enabled={live && !pet}><CompanionModel appearance={appearance} lead={lead} /></Idle></Suspense><ContactShadows position={[0, 0.001, 0]} opacity={0.5} scale={Math.max(1, framing.target[1] * 6)} blur={2.6} far={1} resolution={512} frames={live ? Infinity : 1} />- <OrbitControls makeDefault target={framing.target} enablePan={false} enableZoom={false} autoRotate={live} autoRotateSpeed={0.9}+ <OrbitControls makeDefault target={framing.target} enablePan={false} enableZoom={false} autoRotate={turning} autoRotateSpeed={0.9}minPolarAngle={0.25} maxPolarAngle={Math.PI * 0.55} /></Canvas></PreviewBoundary>}diff --git a/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx b/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsxindex c661cd0956..ba4b077941 100644--- a/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx+++ b/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx@@ -1,4 +1,4 @@-import { useCallback, useLayoutEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react";+import { useCallback, useLayoutEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from "react";import { figureKey, type FigureLook, type FigureSmoke } from "./figureScene";import { FIGURE_BROKEN, figuresSupported, readFigure, watchFigure, watchFigureSupport, type Figure } from "./figureStore";@@ -46,6 +46,31 @@ function outlineUrl(figure: Figure, grown: boolean): string | undefined {return sheet.toDataURL("image/png");}+/** Where the eyes sit across the flat symbol, and half their width and height, in symbol units. */+const EYE_X = [15.4, 24.6] as const;+const EYE_HALF = { lines: [1.35, 3.15], dots: [2.15, 2.3] } as const;++/**+ * The eyes of a figure as two plain elements at the place the picture's own+ * projection gives them: a wrapper that glances, and in it each eye, leaning+ * with the turned face, that blinks. Lengths are in `em` of one symbol+ * unit, so the motion scales with the face.+ */+function LivingEyes({ figure, size, eyes }: { figure: Figure; size: number; eyes: { kind: "dots" | "lines"; y: number; color: string } }) {+ const [a, b, c, d, e, f] = figure.face;+ const scale = size / figure.pixels;+ // One symbol unit across and down the turned face, CSS pixels.+ const across = Math.hypot(a, b) * scale, down = Math.hypot(c, d) * scale;+ const [halfX, halfY] = EYE_HALF[eyes.kind];+ const lean = Math.atan2(b, a) * 180 / Math.PI;+ return <span aria-hidden className="agent-figure-eyes" data-figure-eyes={eyes.kind} style={{ fontSize: down }}>+ {EYE_X.map(x => <i key={x} style={{+ left: (a * x + c * eyes.y + e) * scale - halfX * across, top: (b * x + d * eyes.y + f) * scale - halfY * down,+ width: halfX * across * 2, height: halfY * down * 2, transform: `skewY(${lean.toFixed(2)}deg)`,+ }}><b style={{ background: eyes.color }} /></i>)}+ </span>;+}+/*** An agent's shape as a 3D figure, `size` pixels wide. The picture is drawn* once by the figure worker and painted into a plain 2D canvas; until it is@@ -57,8 +82,13 @@ function outlineUrl(figure: Figure, grown: boolean): string | undefined {* What moves is laid over the still picture as compositor-only layers: the* colours of a flowing design (multiplied onto a white body), the shine of a* shimmering one, both cut to the body's outline, and the smoke of a cigar.+ *+ * The figure is alive at rest: it breathes, and with `eyes` it blinks and+ * glances about. Those eyes are plain elements moved by transforms only, so+ * 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 }: {+export function ShapeFigure({ look, size, shape, behind, children, overlay, fallback, flow, shine, inside, smoke, eyes }: {look: FigureLook; size: number;/** Shown when this look could not be drawn and no earlier picture is there. */fallback: ReactNode;@@ -74,6 +104,8 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fallshine?: boolean;/** Drawn on the body in the flat symbol's units and cut to its outline (twinkling stars). */inside?: 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 };/** Draws one plume of smoke, in symbol units around its source. */smoke?: (plume: FigureSmoke, index: number) => ReactNode;children?: ReactNode;@@ -110,8 +142,13 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fallconst cut = masked(current?.body);// A flowing body is white until its colours lie over it: show nothing rather than a white figure.const ready = !!shown && (!shown.body || !!cut);- return <span className="society-agent-figure" data-agent-figure={shape} data-ready={ready ? "true" : undefined} style={{ width: size, height: size }}>+ // Every figure keeps its own beat, so a roster never breathes or blinks as one.+ let 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 }}>{behind}+ <span className="agent-figure-body"><span className="agent-figure-picture" style={flow ? masked(current?.whole) : undefined}><canvas ref={canvas} aria-hidden />{cut && flow && <span aria-hidden className="agent-figure-flow" style={cut}>@@ -126,12 +163,14 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fall<g transform={`matrix(${shown.face.map(value => +value.toFixed(4)).join(" ")})`}>{inside}</g></svg></span>}+ {shown && eyes && <LivingEyes figure={shown} size={size} eyes={eyes} />}{shown && children && <svg aria-hidden focusable="false" viewBox={`0 0 ${shown.pixels} ${shown.pixels}`} className="society-agent-symbol" data-expressive="true"><g transform={`matrix(${shown.face.map(value => +value.toFixed(4)).join(" ")})`}>{children}</g></svg>}{shown && smoke && shown.smoke.length > 0 && <svg aria-hidden focusable="false" viewBox={`0 0 ${shown.pixels} ${shown.pixels}`} className="society-agent-symbol" data-figure-smoke>{shown.smoke.map((plume, index) => <g key={index} transform={`translate(${+plume.x.toFixed(2)} ${+plume.y.toFixed(2)}) scale(${+plume.scale.toFixed(4)})`}>{smoke(plume, index)}</g>)}</svg>}+ </span>{shown && overlay}</span>;}