Repository navigation
Agent: rework the motion layer on springs, with timing in one place - #1575
Conversation
|
VM QA pass on this build ( Tested on Windows 11 ARM64 and Ubuntu 24.04: install, sign-in, sending short and multi-line messages, the hand-off to the real row, replies arriving, switching between New Task and a conversation, the sidebar and Settings shortcuts, Settings section changes, and a table with long file paths. Sends and task switches were screen-recorded and stepped through frame by frame. No regressions found: nothing jumps the wrong way, rendering is correct on both, and the logs are clean. On Windows' software renderer frames took 1–3 ms, 6.4 ms at worst during sends. The Ubuntu VM is emulated x86, so it shows correctness but not smoothness. Not covered: hover by pointer, x64 Windows, menus and dialogs, reduce motion. Good to go from this pass. |
9141605 to
9548200
Compare
cf27232 to
26e0997
Compare
Every reversible transition (hover, switches, chevrons, the composer, the sidebar, unfolding, text fields growing) now runs on a spring from gpui's integrator instead of restarting an easing curve. A spring keeps the speed it has when its target changes, so turning back mid-way has no corner in it. Springs are critically damped: they do not overshoot from rest. Timing lives in one place. Each token in ui/motion.rs (HOVER, REVEAL, TOGGLE, ENTER, PANEL) is one constant holding the duration and curve its one-shot entrances run and the time its spring takes to settle, and DAMPING_RATIO sets how every spring is damped. Editing a token retunes every animation of that kind. Call sites pass a token; none names a curve. - Tween keeps its interface and becomes a spring. The sidebar and the composer retarget the Tween they have instead of starting a new one, which is what lets them keep their speed. Tween::pixels stops a length within a quarter pixel. - MAPLE_MOTION=eased runs reversible values on their token's duration and curve, as before, to compare the two in one build. - swap_in fades its content instead of painting a cover over it. gpui now repaints a cached view when the opacity it inherits changes, so the cover and the rule against fading above a cached view are gone. - The two tests that asserted the old curve's exact shape now pin the eased style; new tests cover a spring leaving from rest, not overshooting, settling within its token, and keeping its position and speed through a reversal. Co-Authored-By: Claude <noreply@anthropic.com>
`.hover_bg(color)` replaces `hover_background(element, rest, hover)`. It reads the resting background from the control itself, so a call site no longer restates that colour beside the `.bg(..)` that set it, and the two cannot drift. The 36 call sites shrink from a five-to-nine-line `.map` block to one line each. The nine hover backgrounds that still changed in a single frame (the Settings catalog cards and tiles, the usage chart's bars and range pills, the theme pills, the ACP example tabs, the effort reset button and two transcript controls) now ease like the rest. `motion::reveal(element, visible)` fades a control in place; the sidebar's chevron used a hover with two transparent colours to get that. No colour or timing changes. The danger button sets its own fill now instead of relying on the hover to paint it. Co-Authored-By: Claude <noreply@anthropic.com>
The composer's expand transition works out its start and end heights from three numbers the layout also uses: the share of the column the expanded composer takes, the expand button's size, and the empty state's padding. Each was written twice, once in the layout and once in the arithmetic, so changing the layout would have left the transition landing a few pixels off with nothing to catch it. They are now named constants in chat/composer.rs that both sides read. Also: - The last motion test that slept on real time (cached_child_hover_animates_reverses_and_goes_idle) now advances the pinned clock, and the per-element test clock it needed is gone. - docs/motion.md and CLAUDE.md name the effort slider as the one control with physics of its own, tuned beside it and deliberately outside the tokens. Co-Authored-By: Claude <noreply@anthropic.com>
Recording a multi-line send against a real backend and stepping through the frames showed two jumps, and the composer's move between a new task and a conversation read as lag. - The sent message's row never took over from its bubble. The hand-off was keyed by the id the event names, but the transcript files a row under its view key, and a real host's rows have one. The row entered as a new row, faint and growing from nothing, on the frame its bubble vanished, so the thread dropped and climbed back. The hand-off now uses the view key. The tests passed because their rows carry no identity; a new test sends one that does. - Sending from a composer several rows tall dropped the thread first. The composer emptied at once while the bubble's slot opened from nothing. The slot now opens from the height the composer gave up, so the newest row holds still on the send frame and then only moves up. Clearing the field now also resets its eased height on purpose. - The composer changes place at once between a new task and a conversation. Where the user types is not something to animate. Co-Authored-By: Claude <noreply@anthropic.com>
Two defects a read of the whole stack turned up, each with a test that fails without its fix. - An eased hover on a plain card did nothing. gpui gives a div a hitbox only when something else on it is hit-tested (a click, a cursor, a tooltip, a native hover style), and the hover read that hitbox. The Settings catalog cards have none of those, so converting them from `.hover(bg)` to `.hover_bg(..)` lost their highlight. The hover now brings its own hitbox when the control has none, so no caller has to remember. - Sending while the waiting dots already showed under the thread (a second message before the first reply) dropped the thread and then popped the slot open in one frame. The slot was already on screen, so it did not take the height the composer gave up, and its opening was timed from when the dots appeared, seconds earlier. A slot that is already showing now takes the composer's height on the send frame and opens the rest from there, and only a slot that is opening keeps a start time. Co-Authored-By: Claude <noreply@anthropic.com>
Opening Settings, returning from it, and the first screen at launch flashed dark: one black frame, then grey while the new screen faded in. The screen fade used to paint a cover in the app's background colour. When it became a real opacity fade, nothing painted behind the fading screen at the window's root, so the fade started from the window's own backdrop, which is black. The root now paints the app background, so a screen fades in over that, as the cover version looked. The Settings section fade already sat on a painted background and was not affected. Found by recording a cold launch and Settings opening on macOS and stepping through the frames. Co-Authored-By: Claude <noreply@anthropic.com>
26e0997 to
50b6ff5
Compare
Third of three PRs in the stack, on top of Matt's motion as he designed it (#1573). This is our engineering pass over it: how reversible transitions move, where their timing lives, how a hover is written, and the fixes that came out of using it against a real backend. What animates, and when, is his, with one exception noted below.
Six commits, each readable on its own. Rebased onto master
b1ecb772on Nov 13 with no conflicts in this layer.1. Springs, and timing in one place
Hover plates, switches, chevrons, icon swaps, the composer expanding, the sidebar collapsing, content unfolding and text fields growing now run on a spring from gpui's integrator. Before, each reversal restarted an easing curve from the value on screen, at rest. A spring also keeps its speed, so turning back mid-way has no corner in it, and it leaves from a standstill instead of at full speed. Springs are critically damped (
DAMPING_RATIOis 1), so nothing overshoots from rest or bounces.One-shot entrances (rows arriving, menus and dialogs opening) keep their duration and curve. Nothing interrupts them, so a spring would add nothing.
Each token in
ui/motion.rsis one constant:HOVERREVEALTOGGLEENTERPANELEditing a token retunes every animation of that kind. Call sites pass a token and no longer name a curve. The entrance values are Matt's; the settle times are the ones tried side by side in the Motion Bench page.
Also in this commit:
Tween. They used to build a new one on every toggle, which would have thrown away the spring's speed.MAPLE_MOTION=easedruns reversible values on their token's duration and curve, as in the PR below, to compare the two in one build.swap_inpainted a cover in the background colour because gpui replayed cached views at their old opacity. This gpui repaints a cached view when the opacity it inherits changes, soswap_innow fades its content and the rule against fading above a cached view is removed from the docs.2. One call for a hover
.hover_bg(color)replaceshover_background(element, rest, hover). It reads the resting background from the control itself, so a call site no longer restates the colour it just set with.bg(..):All 36 call sites are converted. Nine hover backgrounds that still changed in a single frame now ease like the rest, most of them in Settings code that merged after the motion branch was cut: the catalog cards and tiles, the usage chart's bars and range pills, the theme pills, the ACP example tabs, the effort reset button and two transcript controls.
motion::reveal(element, visible)fades a control in place, which the sidebar's section chevron was faking with a hover between two transparent colours.No colour or timing changes. Two details: the danger button now sets its own fill (before, only the hover painted it), and the Settings catalog card gained an element id, which the eased hover needs to keep its state.
3. Shared composer numbers, no sleeps in the motion tests
EXPANDED_SHARE,EXPAND_BUTTON_REMS,EMPTY_PANE_PADDING_REMSinchat/composer.rs). Each number was written twice, so a layout change would have left the transition landing a few pixels off with nothing to catch it.cached_child_hover_animates_reverses_and_goes_idlewaited on real time withthread::sleep. It now advances the pinned clock like the others.docs/motion.mdandCLAUDE.mdname the effort slider as the one deliberate exception to "animate only throughui/motion.rs": it is dragged by hand and its springs, overshoot included, are tuned for that.4. Fixes from using it against a real backend
A multi-line send was screen-recorded and stepped through frame by frame. Two jumps stood out, each a few frames long.
timeline_view_key), which a real host's rows have, so the two never matched. The row entered as a new one, faint and growing from nothing, on the frame its bubble vanished. The hand-off now uses the view key. The existing tests passed because their rows carry no identity; a new test sends a row with a live identity and failed before the fix.5. Fixes from the final review
A read of the whole stack after the rebase turned up two defects, each fixed with a test that fails without it.
.hover_bg(..)in commit 2 lost their highlight. The hover now brings its own hitbox when the control has none.6. A dark flash on every screen change
Commit 1 turned the screen fade from a cover in the app's background colour into a real opacity fade. Nothing painted behind the fading screen at the window's root, so the fade started from the window's own backdrop, which is black: opening Settings showed one black frame and then grey, and the first screen at launch dipped to grey. The window root now paints the app background, so a screen fades in over that, as the cover version looked. The Settings section fade already sat on a painted background and was not affected.
Found by recording a cold launch and Settings opening on macOS and stepping through the frames; the VM pass had recorded section changes inside Settings but not opening Settings itself.
Validation
-D warnings(1,489 passed, 0 failed, 3 ignored),just ci-lint, and the repository pre-commit hook all passed.91416057was used by hand on macOS and tested on a Windows 11 ARM64 VM and an Ubuntu 24.04 VM (see the QA comment below): sends, the hand-off, replies, the composer's place, shortcuts, Settings and tables. A multi-line send and the switch between New Task and a conversation were recorded and stepped through frame by frame.Not verified
Known, left for later
render.🤖 Generated with Claude Code