Skip to content

feat(memory-graph): respect prefers-reduced-motion - #1576

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:feat/graph-reduced-motion
Open

feat(memory-graph): respect prefers-reduced-motion#1576
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:feat/graph-reduced-motion

Conversation

@abhay-codes07

@abhay-codes07 abhay-codes07 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Proposal

The issue: the memory graph is the most animation-heavy surface in the product and it ignores the OS reduce motion preference. On load the force simulation animates every node flying into place and keeps settling for a while; panning has fling momentum; zoom and centering (auto-fit, node focus, slideshow) ease in via a spring. For someone with a vestibular disorder or motion sensitivity that is exactly the kind of continuous, non-essential motion WCAG 2.3.3 (Animation from Interactions) is about.

It's also inconsistent with the rest of the app, which already honors the setting — superloader, onboarding-confetti, orbit-memory, and review-memories-modal all check prefers-reduced-motion. The graph was the gap.

The proposal: honor prefers-reduced-motion in the two engines that produce the motion, with zero loss of functionality — a calm, static graph that's still fully pan/zoom/click/drag-able.

Changes

  • ForceSimulation — still runs the pre-settle ticks, then stays static instead of kicking off the perpetual settle (the same path dense graphs already use). reheat() (fired on node drag) becomes a no-op. Dragging still moves the grabbed node directly via the input handler, so it works exactly as before, just without neighbours jiggling.
  • ViewportStatereleaseWithVelocity drops fling momentum, and tick() snaps zoom and pan/centering straight to their targets in one frame instead of easing.
  • canvas/reduced-motion.ts — small SSR-safe matchMedia helper; the viewport caches the MediaQueryList so the per-frame check stays cheap while .matches still reflects a live OS change.

When reduce-motion is off, behavior is byte-for-byte unchanged (the new branches are gated on the flag).

Testing

  • reduced-motion.test.ts9 tests: the helper (missing matchMedia → false, reflects the query), the simulation staying static + ignoring reheat under reduced motion (and running normally otherwise), and the viewport dropping momentum / snapping zoom + pan (vs. easing normally).
  • Full @supermemory/memory-graph suite: 205 passing. tsc and vite build clean.

Touches only canvas/* engine files, so it composes cleanly with the graph work in my other open PRs.

The graph is in near-constant motion — the force simulation animates nodes into
place on load and keeps settling, panning has fling momentum, and zoom/centering
ease via a spring. There was no path for users who set "reduce motion", even
though the rest of the app honors it (loaders, confetti, the review modal).

Honor prefers-reduced-motion in the two engines that drive that motion, with no
loss of functionality:

- ForceSimulation: pre-settle as usual, then stay static instead of running the
  perpetual settle; reheat() (fired on drag) is a no-op. Dragging still moves the
  grabbed node directly, so interaction is unchanged — just no neighbour jiggle.
- ViewportState: drop fling momentum, and snap zoom / centering to their targets
  in a single tick instead of easing.

Detection lives in canvas/reduced-motion.ts (SSR-safe matchMedia). Behavior is
unchanged when reduce-motion is off. Added reduced-motion.test.ts (9 tests); full
package suite 205 passing, build and type-check clean.
Copilot AI lite review requested due to automatic review settings August 21, 2026 23:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants