Skip to content

ui-react: framer-motion ignores reduced motion in five components and loads with the chat #2592

Open

Description

@schlessera

Context

framer-motion (packages/ui-react/package.json:58, locked at 12.43.0) is used in seven files. All but one use are simple fades or short slides:

Use Where Honours reduced motion
Message entry fade + 6px rise MessageBubble, packages/ui-react/src/components/chat/message-bubble.tsx:106-115 yes (useReducedMotion)
Tool detail expand/collapse to height: auto packages/ui-react/src/components/chat/tool-call-timeline.tsx:267-271 (guard), :370-380 yes
Subagent row fade packages/ui-react/src/components/chat/subagent-view.tsx:163 no
Gate status crossfade (AnimatePresence mode="wait") packages/ui-react/src/components/connectivity/connection-gate.tsx:211-218 no
Connection banner slide in/out connection-gate.tsx:289-297 no
Welcome fade packages/ui-react/src/components/chat/welcome-state.tsx:28-33 no
Command palette rise; its exit does nothing, with no AnimatePresence packages/ui-react/src/components/chat/command-palette.tsx:59-65 no
Login form fade packages/ui-react/src/components/connectivity/login-form.tsx:51-56 no

There is no MotionConfig, so five of the seven files animate under prefers-reduced-motion: reduce. That breaks the kit's non-negotiable rule (packages/ui-kit/src/tokens.css:1407-1435). MessageBubble imports the library eagerly, so it sits in the chat's first-load path: about 43 KB gzip (133 KB minified) as measured during the review. This package already animates an entry in plain CSS behind a no-preference guard (.answer-suggestions, packages/ui-react/src/theme.css:696-706).

D54 rules that overlay motion is entry-only and "Closing is instant" (docs/decisions/design-kit/overlays.md). This task applies the same entry-only rule to these non-overlay surfaces. It extends the rule's reach and does not amend D54.

Guides:

  • ui-behaviors/motion: "Start with no animations by default, and enable them using @media (prefers-reduced-motion: no-preference)".
  • ui-behaviors/animate-element-entry-exit: "MANDATORY: Use @starting-style for entry animations."
  • css/animate-to-intrinsic-sizes: "Apply interpolate-size: allow-keywords to a parent element".
  • performance/performance: "DON'T ship a single, enormous app.js bundle".

Scope

  • Replace every motion.* element with a plain element and CSS entry motion declared inside @media (prefers-reduced-motion: no-preference), following the .answer-suggestions pattern. Use either a keyframe or a transition from @starting-style.
  • Animate the tool detail's entry from block-size: 0 to auto with interpolate-size: allow-keywords scoped to that container. Keep today's rule that the details do not animate while a decision is pending (ui-react: restored phone approval clears its tracker without a recorded answer #1217).
  • Drop every exit animation, including AnimatePresence. Closing becomes instant.
  • Remove framer-motion from packages/ui-react/package.json and bun.lock, and from optimizeDeps.include in packages/ui-kit/vite.config.ts:16.
  • Remove the framer-motion mocks from the four tests that carry them:
    • packages/ui-react/tests/render/render-smoke.test.tsx:170
    • tests/render/desktop-panes-sixth.test.tsx:30
    • tests/render/handoff-entry.test.tsx:32
    • tests/render/answer-suggestions.test.tsx:45
  • Update the wait in packages/ui-react/tests/browser/brand-placements.layout.tsx:57 and its comment.

Out of scope

  • New motion, or changing durations and easings beyond carrying today's values (0.15 to 0.4 s, ease-out) over.
  • Kit components' own motion, and tokens.css.
  • Exit animations of any kind, including transition-behavior: allow-discrete exits.
  • The graph's own expansion transition (graph-canvas.tsx), which is canvas work.

Acceptance criteria

  • git grep framer-motion finds nothing outside changelogs, and the built @schlessera/brain-ui-react entry chunk no longer contains it. The PR records the entry-chunk size before and after.
  • Under prefers-reduced-motion: reduce, each of the seven surfaces renders at its final opacity and position on the first frame. A real-browser test with emulated reduced motion asserts computed opacity: 1 and no running animations (document.getAnimations() is empty) for at least the message bubble, the welcome state and the connection banner. It fails before the change for the welcome state and the banner.
  • Under no-preference, a newly mounted message bubble runs an entry animation (getAnimations() is non-empty on insertion).
  • Android support: @starting-style and interpolate-size exist in both Chromium targets (Chromium 129+). In Firefox for Android, interpolate-size is missing, so the tool detail opens instantly. That is the named fallback, and the content is never clipped or left at height 0. A layout test checks the detail's final height with interpolate-size unsupported, or the PR explains why only Chromium can run it.
  • The existing render and layout tests pass with the mocks removed.

Verification

bun install                      # refresh bun.lock after removing the dependency
bun run test packages/ui-react/tests
node scripts/visual.mjs --project=ui-react-layout --filter=brand-placements
node scripts/visual.mjs --project=ui-react-layout   # the new reduced-motion test lives here
bun run typecheck
bun run lint

Contract impact

  • This touches the integration contract, so it needs the contract label, a CONTRACT: commit prefix, and the doc updated in the same commit.
  • This changes a published package's behaviour, so it needs a changeset.

The changeset names the removed runtime dependency and the reduced-motion fix. No exported API changes.

Activity

  1. added
    type: fix
    area: ui-react
    priority: p2
    agent-ready
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-reactpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions