You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f35826c
Browse filesBrowse the repository at this point in the historyBrowse files
perf: lazy-load Motion and fix React Doctor findings (CHAT-46) (#91)
Motion's animation engine shipped in every route's first load. The app now
uses `m.*` from motion/react-m inside one strict LazyMotion provider that
loads domMax on demand from lib/motion-features.ts, cutting ~24 kB gzipped
from the playground and docs first-load JS. Strict mode makes a stray
`motion.*` throw instead of quietly pulling the engine back in, and
MotionConfig reducedMotion="user" snaps the remaining height reveals.
Fixes from a React Doctor review (23 errors / 66 warnings -> 18 / 57; the
rest are triaged as intentional or false positives):
- Refs are no longer written during render where React may discard it.
AskUser mirrors its latest highlight and register callback in insertion
effects, which run before the options' own layout effects that seed the
highlight. Composer.Command's closing flag and the playground's ask-user
panel cache are state that changes only when they flip.
- AskUser, the shared collapsible (Reasoning, Steps), the anchored Tabs
surface and SidebarViews memoize their context values.
- The playground builds its seen-messages set once instead of per stream
chunk, the steps chevron transitions only opacity and rotate, and the
docs search input gets an accessible name.
- The playground mints its chat id with a lazy useState initializer:
useMemo may recompute, which would swap the chat out from under the user.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Render-safety and re-render fixes from a React Doctor review.
6
+
7
+
**No ref writes during render.**`AskUser.Options` and `AskUser.Option` mirror their latest values into refs in an insertion effect instead of during render, which React may discard. It runs before every layout effect, so options still seed the initial highlight from their own. `Composer.Command`'s "this prefix is the one closing" flag is now state that flips only at open and close.
8
+
9
+
**Stable context values.**`AskUser.Root`, `AskUser.Options`, `AskUser.Option`, the shared collapsible behind `Reasoning` and `Steps`, and the anchored `Tabs` surface memoize their context values, so memoized consumers no longer redraw on every parent render.
0 commit comments