Repository navigation
Description
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-stylefor entry animations." - css/animate-to-intrinsic-sizes: "Apply
interpolate-size: allow-keywordsto a parent element". - performance/performance: "DON'T ship a single, enormous
app.jsbundle".
Scope
- Replace every
motion.*element with a plain element and CSS entry motion declared inside@media (prefers-reduced-motion: no-preference), following the.answer-suggestionspattern. Use either a keyframe or a transition from@starting-style. - Animate the tool detail's entry from
block-size: 0toautowithinterpolate-size: allow-keywordsscoped 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-motionfrompackages/ui-react/package.jsonandbun.lock, and fromoptimizeDeps.includeinpackages/ui-kit/vite.config.ts:16. - Remove the
framer-motionmocks from the four tests that carry them:packages/ui-react/tests/render/render-smoke.test.tsx:170tests/render/desktop-panes-sixth.test.tsx:30tests/render/handoff-entry.test.tsx:32tests/render/answer-suggestions.test.tsx:45
- Update the wait in
packages/ui-react/tests/browser/brand-placements.layout.tsx:57and 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-discreteexits. - The graph's own expansion transition (
graph-canvas.tsx), which is canvas work.
Acceptance criteria
-
git grep framer-motionfinds nothing outside changelogs, and the built@schlessera/brain-ui-reactentry 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 computedopacity: 1and 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-styleandinterpolate-sizeexist in both Chromium targets (Chromium 129+). In Firefox for Android,interpolate-sizeis 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 withinterpolate-sizeunsupported, 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 lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT: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