Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: honor prefers-reduced-motion on six WebGL CoS avatars (#8119)
[._.]/ Adam Eivy4ac6b1894fb3
diff --git a/client/src/components/cos/CyberCoSAvatar.jsx b/client/src/components/cos/CyberCoSAvatar.jsxindex 98ef1f4eac..44b1b5a262 100644--- a/client/src/components/cos/CyberCoSAvatar.jsx+++ b/client/src/components/cos/CyberCoSAvatar.jsx@@ -1,11 +1,13 @@-import { useRef, useMemo } from 'react';-import { Canvas, useFrame } from '@react-three/fiber';+import { useRef, useMemo, useEffect } from 'react';+import { Canvas, useFrame, useThree } from '@react-three/fiber';import { Float, MeshDistortMaterial, Sparkles } from '@react-three/drei';import * as THREE from 'three';import { AGENT_STATES } from './constants';import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';import CoSCanvasGuard from './CoSCanvasGuard';import CoSBackgroundCamera from './CoSBackgroundCamera';+import { graphMotionSettings } from '../graph3d/GraphScene';+import usePrefersReducedMotion from '../../hooks/usePrefersReducedMotion';// Holographic wireframe skull/head geometryfunction CyberHead({ color, state, speaking }) {@@ -383,6 +385,16 @@ function StateEffects({ color, state }) {);}+// Under frameloop='demand', state/speaking changes that only affect+// useFrame-driven properties need to invalidate the frame so one renders.+function InvalidateOnStateChange({ state, speaking }) {+ const { invalidate } = useThree();+ useEffect(() => {+ invalidate();+ }, [state, speaking, invalidate]);+ return null;+}+// Ground glow planefunction GroundGlow({ color }) {return (@@ -407,6 +419,9 @@ function Scene({ state, speaking, background }) {<><CoSBackgroundCamera enabled={background} z={3.5} />+ {/* Invalidate the frame when state changes so emissive colors update */}+ <InvalidateOnStateChange state={state} speaking={speaking} />+{/* Lighting */}<ambientLight intensity={0.1} /><pointLight position={[2, 3, 4]} intensity={0.5} color={color} />@@ -437,12 +452,14 @@ function Scene({ state, speaking, background }) {}export default function CyberCoSAvatar({ state, speaking, background = false }) {+ const reduceMotion = usePrefersReducedMotion();return (<CoSCanvasGuard label="Cyber 3D avatar. Drag to rotate." background={background}><Canvascamera={{ position: [0, 0, 3.5], fov: 45 }}style={{ width: '100%', height: '100%', background: 'transparent' }}gl={{ alpha: true, antialias: true }}+ {...graphMotionSettings(reduceMotion)}><Scene state={state} speaking={speaking} background={background} /></Canvas>diff --git a/client/src/components/cos/EsotericCoSAvatar.jsx b/client/src/components/cos/EsotericCoSAvatar.jsxindex 7649c43cef..108ef082e9 100644--- a/client/src/components/cos/EsotericCoSAvatar.jsx+++ b/client/src/components/cos/EsotericCoSAvatar.jsx@@ -1,11 +1,13 @@-import { useRef, useMemo } from 'react';-import { Canvas, useFrame } from '@react-three/fiber';+import { useRef, useMemo, useEffect } from 'react';+import { Canvas, useFrame, useThree } from '@react-three/fiber';import { Float, MeshDistortMaterial, Sparkles, Stars } from '@react-three/drei';import * as THREE from 'three';import { AGENT_STATES } from './constants';import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';import CoSBackgroundCamera from './CoSBackgroundCamera';import CoSCanvasGuard from './CoSCanvasGuard';+import { graphMotionSettings } from '../graph3d/GraphScene';+import usePrefersReducedMotion from '../../hooks/usePrefersReducedMotion';// Central mystical core - an artifact of unknown originfunction EsotericCore({ color, state, speaking }) {@@ -178,6 +180,16 @@ function FloatingRunes({ color }) {}+// Under frameloop='demand', state/speaking changes that only affect+// useFrame-driven properties need to invalidate the frame so one renders.+function InvalidateOnStateChange({ state, speaking }) {+ const { invalidate } = useThree();+ useEffect(() => {+ invalidate();+ }, [state, speaking, invalidate]);+ return null;+}+function Scene({ state, speaking, background }) {const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;const color = stateConfig.color;@@ -186,6 +198,8 @@ function Scene({ state, speaking, background }) {<><CoSBackgroundCamera enabled={background} z={5} />+ <InvalidateOnStateChange state={state} speaking={speaking} />+<ambientLight intensity={0.2} /><pointLight position={[10, 10, 10]} intensity={1} color={color} /><pointLight position={[-10, -10, -10]} intensity={0.5} color="#4c1d95" />@@ -204,12 +218,14 @@ function Scene({ state, speaking, background }) {}export default function EsotericCoSAvatar({ state, speaking, background = false }) {+ const reduceMotion = usePrefersReducedMotion();return (<CoSCanvasGuard label="Esoteric 3D avatar. Drag to rotate." background={background}><Canvascamera={{ position: [0, 0, 5], fov: 45 }}style={{ width: '100%', height: '100%', background: 'transparent' }}gl={{ alpha: true, antialias: true }}+ {...graphMotionSettings(reduceMotion)}><Scene state={state} speaking={speaking} background={background} /></Canvas>diff --git a/client/src/components/cos/MiniCharacterCoSAvatar.jsx b/client/src/components/cos/MiniCharacterCoSAvatar.jsxindex ea0bb3668f..9ec5dbc6c2 100644--- a/client/src/components/cos/MiniCharacterCoSAvatar.jsx+++ b/client/src/components/cos/MiniCharacterCoSAvatar.jsx@@ -1,5 +1,5 @@import { useRef, useMemo, useEffect, useState, Suspense } from 'react';-import { Canvas, useFrame } from '@react-three/fiber';+import { Canvas, useFrame, useThree } from '@react-three/fiber';import { AGENT_STATES } from './constants';import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';import CoSBackgroundCamera from './CoSBackgroundCamera';@@ -7,6 +7,8 @@ import CoSCanvasGuard from './CoSCanvasGuard';import useClonedGltf, { GltfPrimitive } from '../../hooks/useClonedGltf';import { resolvePlaybackClip } from '../../hooks/useAvatarCapabilities';import { fitModelToHeight } from '../../utils/modelFit';+import { graphMotionSettings } from '../graph3d/GraphScene';+import usePrefersReducedMotion from '../../hooks/usePrefersReducedMotion';// Kenney Mini Characters (CC0) ship 32 named clips. We map the CoS agent// states onto the most evocative ones. Each entry has a clip name plus a@@ -109,12 +111,23 @@ function StageLighting({ color }) {);}+// Under frameloop='demand', state/speaking changes that only affect+// useFrame-driven properties need to invalidate the frame so one renders.+function InvalidateOnStateChange({ state, speaking }) {+ const { invalidate } = useThree();+ useEffect(() => {+ invalidate();+ }, [state, speaking, invalidate]);+ return null;+}+function Scene({ state, speaking, background, variant, coverage = null }) {const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;const color = stateConfig.color;return (<><CoSBackgroundCamera enabled={background} z={3.6} />+ <InvalidateOnStateChange state={state} speaking={speaking} /><StageLighting color={color} /><MiniCharacter state={state} speaking={speaking} variant={variant} coverage={coverage} /><CoSAvatarOrbitControls />@@ -156,6 +169,7 @@ function LoadingPlaceholder({ background = false }) {export default function MiniCharacterCoSAvatar({ state, speaking, background = false, variant = 'mini-male-c', coverage = null }) {const [modelPresent, setModelPresent] = useState(null);const url = useMemo(() => buildModelUrl(variant), [variant]);+ const reduceMotion = usePrefersReducedMotion();useEffect(() => {let cancelled = false;@@ -179,6 +193,7 @@ export default function MiniCharacterCoSAvatar({ state, speaking, background = fcamera={{ position: [0, 0.2, 3.0], fov: 40 }}style={{ width: '100%', height: '100%', background: 'transparent' }}gl={{ alpha: true, antialias: true }}+ {...graphMotionSettings(reduceMotion)}><Suspense fallback={null}><Scene state={state} speaking={speaking} background={background} variant={variant} coverage={coverage} />diff --git a/client/src/components/cos/MiniCharacterCoSAvatar.test.jsx b/client/src/components/cos/MiniCharacterCoSAvatar.test.jsxindex f3e3623d98..e81a407aae 100644--- a/client/src/components/cos/MiniCharacterCoSAvatar.test.jsx+++ b/client/src/components/cos/MiniCharacterCoSAvatar.test.jsx@@ -14,11 +14,21 @@ vi.mock('./CoSCanvasGuard', () => ({}));// jsdom has no WebGL context and none of the scene is under test here, so the// Canvas is stubbed CHILDLESS — rendering the subtree would run three.js object-// code against r3f's HTMLElement stand-ins. Only which props reach the guard-// matters, and the guard sits OUTSIDE the canvas.+// code against r3f's HTMLElement stand-ins. Capture frameloop prop to verify+// reduced-motion behavior. The guard sits OUTSIDE the canvas.+const canvasProps = vi.hoisted(() => []);vi.mock('@react-three/fiber', () => ({- Canvas: () => <div data-testid="mini-canvas" />,+ Canvas: (props) => {+ canvasProps.push(props);+ return <div data-testid="mini-canvas" data-frameloop={props.frameloop} />;+ },useFrame: vi.fn(),+ useThree: vi.fn(() => ({ invalidate: vi.fn() })),+}));++let reduceMotionPreference = false;+vi.mock('../../hooks/usePrefersReducedMotion', () => ({+ default: () => reduceMotionPreference,}));import MiniCharacterCoSAvatar from './MiniCharacterCoSAvatar';@@ -26,6 +36,8 @@ import MiniCharacterCoSAvatar from './MiniCharacterCoSAvatar';describe('MiniCharacterCoSAvatar', () => {beforeEach(() => {guardProps.length = 0;+ canvasProps.length = 0;+ reduceMotionPreference = false;// The component HEAD-probes the model before mounting the canvas.vi.stubGlobal('fetch', vi.fn(() => Promise.resolve({ ok: true })));});@@ -59,4 +71,16 @@ describe('MiniCharacterCoSAvatar', () => {'/api/avatar/model.glb?variant=rigged-image3d-1',));});++ it('passes frameloop="demand" to Canvas when reduced motion is preferred', async () => {+ reduceMotionPreference = true;+ render(<MiniCharacterCoSAvatar variant="mini-male-c" />);+ await waitFor(() => expect(screen.getByTestId('mini-canvas')).toHaveAttribute('data-frameloop', 'demand'));+ });++ it('passes frameloop="always" to Canvas when reduced motion is not preferred', async () => {+ reduceMotionPreference = false;+ render(<MiniCharacterCoSAvatar variant="mini-male-c" />);+ await waitFor(() => expect(screen.getByTestId('mini-canvas')).toHaveAttribute('data-frameloop', 'always'));+ });});diff --git a/client/src/components/cos/MuseCoSAvatar.jsx b/client/src/components/cos/MuseCoSAvatar.jsxindex 10b8abac8f..c71da7e5cc 100644--- a/client/src/components/cos/MuseCoSAvatar.jsx+++ b/client/src/components/cos/MuseCoSAvatar.jsx@@ -1,5 +1,5 @@import { useRef, useMemo, useEffect, useState, useCallback, Suspense } from 'react';-import { Canvas, useFrame } from '@react-three/fiber';+import { Canvas, useFrame, useThree } from '@react-three/fiber';import { useGLTF, Sparkles } from '@react-three/drei';import * as THREE from 'three';import {@@ -15,6 +15,8 @@ import CoSCanvasGuard from './CoSCanvasGuard';import { withInPlaceClips } from '../../utils/animationClips';import { fitModelToHeight } from '../../utils/modelFit';import useClonedGltf, { GltfPrimitive } from '../../hooks/useClonedGltf';+import { graphMotionSettings } from '../graph3d/GraphScene';+import usePrefersReducedMotion from '../../hooks/usePrefersReducedMotion';const MODEL_URL = '/api/avatar/model.glb';const TARGET_HEIGHT = 1.9; // world units — fills the fixed portrait frame@@ -235,6 +237,16 @@ function StateEffects({ color, state }) {return <Sparkles count={15} scale={3} size={1.5} speed={0.3} color={color} />;}+// Under frameloop='demand', state/speaking changes that only affect+// useFrame-driven properties need to invalidate the frame so one renders.+function InvalidateOnStateChange({ state, speaking }) {+ const { invalidate } = useThree();+ useEffect(() => {+ invalidate();+ }, [state, speaking, invalidate]);+ return null;+}+function Scene({ state, speaking, background }) {const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;const color = stateConfig.color;@@ -243,6 +255,8 @@ function Scene({ state, speaking, background }) {<><CoSBackgroundCamera enabled={background} z={3.3} />+ <InvalidateOnStateChange state={state} speaking={speaking} />+{/* Neutral, even lighting so the model renders in its own full textureand color. The per-state hue lives in the accent point light + halo /ground glow / sparkles below rather than being painted onto the model. */}@@ -285,6 +299,7 @@ function LoadingPlaceholder({ background = false }) {export default function MuseCoSAvatar({ state, speaking, background = false }) {// null = checking, true = GLB present, false = missingconst [modelPresent, setModelPresent] = useState(null);+ const reduceMotion = usePrefersReducedMotion();useEffect(() => {let cancelled = false;@@ -310,6 +325,7 @@ export default function MuseCoSAvatar({ state, speaking, background = false }) {camera={{ position: [0, 0, 3.3], fov: 45 }}style={{ width: '100%', height: '100%', background: 'transparent' }}gl={{ alpha: true, antialias: true }}+ {...graphMotionSettings(reduceMotion)}><Suspense fallback={null}><Scene state={state} speaking={speaking} background={background} />diff --git a/client/src/components/cos/NexusCoSAvatar.jsx b/client/src/components/cos/NexusCoSAvatar.jsxindex b99d1c03af..6a682e7710 100644--- a/client/src/components/cos/NexusCoSAvatar.jsx+++ b/client/src/components/cos/NexusCoSAvatar.jsx@@ -1,11 +1,13 @@-import { useRef, useMemo } from 'react';-import { Canvas, useFrame } from '@react-three/fiber';+import { useRef, useMemo, useEffect } from 'react';+import { Canvas, useFrame, useThree } from '@react-three/fiber';import { Float, MeshDistortMaterial, Sparkles } from '@react-three/drei';import * as THREE from 'three';import { AGENT_STATES } from './constants';import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';import CoSCanvasGuard from './CoSCanvasGuard';import CoSBackgroundCamera from './CoSBackgroundCamera';+import { graphMotionSettings } from '../graph3d/GraphScene';+import usePrefersReducedMotion from '../../hooks/usePrefersReducedMotion';// Central brain-like neural corefunction NeuralCore({ color, state, speaking }) {@@ -333,6 +335,16 @@ function StatusRing({ color, state }) {);}+// Under frameloop='demand', state/speaking changes that only affect+// useFrame-driven properties need to invalidate the frame so one renders.+function InvalidateOnStateChange({ state, speaking }) {+ const { invalidate } = useThree();+ useEffect(() => {+ invalidate();+ }, [state, speaking, invalidate]);+ return null;+}+function Scene({ state, speaking, background }) {const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;const color = stateConfig.color;@@ -344,6 +356,8 @@ function Scene({ state, speaking, background }) {<><CoSBackgroundCamera enabled={background} y={0.2} z={3.5} />+ <InvalidateOnStateChange state={state} speaking={speaking} />+<ambientLight intensity={0.1} /><pointLight position={[3, 2, 3]} intensity={0.6} color={color} /><pointLight position={[-2, -2, 2]} intensity={0.3} color="#6366f1" />@@ -370,12 +384,14 @@ function Scene({ state, speaking, background }) {}export default function NexusCoSAvatar({ state, speaking, background = false }) {+ const reduceMotion = usePrefersReducedMotion();return (<CoSCanvasGuard label="Nexus 3D avatar. Drag to rotate." background={background}><Canvascamera={{ position: [0, 0.2, 3.5], fov: 45 }}style={{ width: '100%', height: '100%', background: 'transparent' }}gl={{ alpha: true, antialias: true }}+ {...graphMotionSettings(reduceMotion)}><Scene state={state} speaking={speaking} background={background} /></Canvas>diff --git a/client/src/components/cos/SigilCoSAvatar.jsx b/client/src/components/cos/SigilCoSAvatar.jsxindex 1c704b7497..c02642c89b 100644--- a/client/src/components/cos/SigilCoSAvatar.jsx+++ b/client/src/components/cos/SigilCoSAvatar.jsx@@ -1,11 +1,13 @@-import { useMemo, useRef } from 'react';-import { Canvas, useFrame } from '@react-three/fiber';+import { useMemo, useRef, useEffect } from 'react';+import { Canvas, useFrame, useThree } from '@react-three/fiber';import { Float, MeshDistortMaterial, Sparkles } from '@react-three/drei';import * as THREE from 'three';import { AGENT_STATES } from './constants';import CoSAvatarOrbitControls from './CoSAvatarOrbitControls';import CoSCanvasGuard from './CoSCanvasGuard';import CoSBackgroundCamera from './CoSBackgroundCamera';+import { graphMotionSettings } from '../graph3d/GraphScene';+import usePrefersReducedMotion from '../../hooks/usePrefersReducedMotion';function SigilCore({ color, state, speaking }) {const coreRef = useRef();@@ -249,6 +251,16 @@ function ScanBeam({ color, state }) {);}+// Under frameloop='demand', state/speaking changes that only affect+// useFrame-driven properties need to invalidate the frame so one renders.+function InvalidateOnStateChange({ state, speaking }) {+ const { invalidate } = useThree();+ useEffect(() => {+ invalidate();+ }, [state, speaking, invalidate]);+ return null;+}+function Scene({ state, speaking, background }) {const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;const color = stateConfig.color;@@ -261,6 +273,8 @@ function Scene({ state, speaking, background }) {<><CoSBackgroundCamera enabled={background} y={0.1} z={3.7} />+ <InvalidateOnStateChange state={state} speaking={speaking} />+<ambientLight intensity={0.08} /><pointLight position={[2.2, 2.8, 3.2]} intensity={0.6} color={color} /><pointLight position={[-2.5, -1.5, 3]} intensity={0.35} color="#8b5cf6" />@@ -285,12 +299,14 @@ function Scene({ state, speaking, background }) {}export default function SigilCoSAvatar({ state, speaking, background = false }) {+ const reduceMotion = usePrefersReducedMotion();return (<CoSCanvasGuard label="Sigil 3D avatar. Drag to rotate." background={background}><Canvascamera={{ position: [0, 0.1, 3.7], fov: 45 }}style={{ width: '100%', height: '100%', background: 'transparent' }}gl={{ alpha: true, antialias: true }}+ {...graphMotionSettings(reduceMotion)}><Scene state={state} speaking={speaking} background={background} /></Canvas>