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: respect reduced motion in BrainGraph (#5225)
[._.]/ Adam Eivy028b91c304d6
diff --git a/client/src/components/brain/tabs/BrainGraph.jsx b/client/src/components/brain/tabs/BrainGraph.jsxindex 0390ab90ca..4957d9fefa 100644--- a/client/src/components/brain/tabs/BrainGraph.jsx+++ b/client/src/components/brain/tabs/BrainGraph.jsx@@ -54,6 +54,14 @@ const isCanvasGesture = (e) => e.target?.tagName === 'CANVAS';// constant the two silently drift apart.const TOOLTIP_WIDTH = 320;+// The force layout is settled before the scene renders, so reduced-motion+// users can see it immediately at rest. Keep the canvas on demand and turn+// off OrbitControls' inertia too, preventing movement after an interaction.+export const graphMotionSettings = (reducedMotion) => ({+ frameloop: reducedMotion ? 'demand' : 'always',+ enableDamping: !reducedMotion+});+// Per-type API getters for detail panelconst TYPE_GETTERS = {people: api.getBrainPerson,@@ -124,7 +132,7 @@ function GraphEdges({ simEdges, selectedId }) {// move over the canvas WHILE A NODE IS HOVERED (it tracks the tooltip position),// and every prop here is already identity-stable across that render — so without// memo each move reconciles a <mesh> per node for nothing.-const GraphScene = memo(function GraphScene({ graph, selectedId, adjacentIds, onSelect, onFocus, onHover, pickRef, touchGestureRef }) {+const GraphScene = memo(function GraphScene({ graph, selectedId, adjacentIds, onSelect, onFocus, onHover, pickRef, touchGestureRef, reducedMotion }) {const sphereGeo = useMemo(() => new THREE.SphereGeometry(1, 16, 12), []);const { camera, size } = useThree();@@ -205,7 +213,7 @@ const GraphScene = memo(function GraphScene({ graph, selectedId, adjacentIds, on</mesh>)}- <OrbitControls enableDamping dampingFactor={0.05} minDistance={10} maxDistance={200} />+ <OrbitControls enableDamping={!reducedMotion} dampingFactor={0.05} minDistance={10} maxDistance={200} /></>);});@@ -233,6 +241,10 @@ export default function BrainGraph() {const [typeFilters, setTypeFilters] = useState(() =>Object.fromEntries(BRAIN_TYPES.map(t => [t, true])));+ const [reducedMotion, setReducedMotion] = useState(() =>+ window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false+ );+ const motionSettings = graphMotionSettings(reducedMotion);const graphRef = useRef(null);const dragStartRef = useRef(null);@@ -242,6 +254,15 @@ export default function BrainGraph() {// and onPointerMissed can stand down for the threshold pick below.const touchGestureRef = useRef(false);+ useEffect(() => {+ const media = window.matchMedia?.('(prefers-reduced-motion: reduce)');+ if (!media) return undefined;+ const updatePreference = () => setReducedMotion(media.matches);+ updatePreference();+ media.addEventListener?.('change', updatePreference);+ return () => media.removeEventListener?.('change', updatePreference);+ }, []);+const focusId = currentFocusId(focusTrail);// Initial load: bounded overview + lightweight search index + embedding gaps.@@ -633,6 +654,7 @@ export default function BrainGraph() {{graph && (<Canvascamera={{ position: [0, 0, 80], fov: 50 }}+ frameloop={motionSettings.frameloop}dpr={[1, 1.5]}style={{ background: 'rgb(var(--port-bg))' }}gl={{ antialias: true }}@@ -647,6 +669,7 @@ export default function BrainGraph() {onHover={handleHover}pickRef={pickRef}touchGestureRef={touchGestureRef}+ reducedMotion={reducedMotion}/></Canvas>)}diff --git a/client/src/components/brain/tabs/BrainGraph.test.jsx b/client/src/components/brain/tabs/BrainGraph.test.jsxindex 28c688e0ad..556bcb8cf9 100644--- a/client/src/components/brain/tabs/BrainGraph.test.jsx+++ b/client/src/components/brain/tabs/BrainGraph.test.jsx@@ -1,4 +1,4 @@-import { describe, it, expect, vi, beforeEach } from 'vitest';+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';import { render, screen, act } from '@testing-library/react';import userEvent from '@testing-library/user-event';@@ -8,7 +8,7 @@ import userEvent from '@testing-library/user-event';// <bufferGeometry>/<mesh> as unknown DOM elements, and the r3f refs they hand// back are HTMLElements without the three.js geometry API.vi.mock('@react-three/fiber', () => ({- Canvas: () => <div data-testid="graph-canvas" />,+ Canvas: ({ frameloop }) => <div data-testid="graph-canvas" data-frameloop={frameloop} />,// GraphScene reads the live camera through this; it is never rendered here,// but the named import has to resolve.useThree: () => ({ camera: null, size: { width: 0, height: 0 } }),@@ -41,7 +41,7 @@ vi.mock('../../../services/api', () => ({import * as api from '../../../services/api';import { chipColors, parseColor } from '../../../lib/chipContrast';import { BRAIN_TYPE_HEX } from '../constants';-import BrainGraph, { recordBody } from './BrainGraph';+import BrainGraph, { graphMotionSettings, recordBody } from './BrainGraph';const GRAPH = {hasEmbeddings: true,@@ -58,6 +58,8 @@ const renderGraph = async () => {await act(async () => {});};+const originalMatchMedia = window.matchMedia;+beforeEach(() => {vi.clearAllMocks();api.getBrainGraph.mockResolvedValue(GRAPH);@@ -72,6 +74,33 @@ beforeEach(() => {]) getter.mockResolvedValue(null);});+afterEach(() => {+ window.matchMedia = originalMatchMedia;+});++describe('reduced motion', () => {+ it('reads the system preference and renders the canvas on demand', async () => {+ window.matchMedia = vi.fn(() => ({+ matches: true,+ addEventListener() {},+ removeEventListener() {}+ }));++ await renderGraph();++ expect(window.matchMedia).toHaveBeenCalledWith('(prefers-reduced-motion: reduce)');+ expect(screen.getByTestId('graph-canvas')).toHaveAttribute('data-frameloop', 'demand');+ });++ it('stops the canvas render loop and OrbitControls inertia when motion is reduced', () => {+ expect(graphMotionSettings(true)).toEqual({ frameloop: 'demand', enableDamping: false });+ });++ it('keeps animated rendering and controls for users without the preference', () => {+ expect(graphMotionSettings(false)).toEqual({ frameloop: 'always', enableDamping: true });+ });+});+// The legend is ten rows tall and sits over the canvas, which blankets a// phone-sized graph — so on mobile it hides behind a toggle. It must stay// reachable (the edge colours appear nowhere else) rather than be dropped.