Skip to content

Agent: rework the motion layer on springs, with timing in one place - #1575

Merged
AnthonyRonning merged 6 commits into
masterfrom
codex-gpuibump-motion-core
Nov 14, 2026
Merged

AnthonyRonning merged 6 commits into
masterfrom
codex-gpuibump-motion-core

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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 b1ecb772 on 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_RATIO is 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.rs is one constant:

Token Entrance Curve Spring settles in
HOVER 120 ms smoothstep 180 ms
REVEAL 140 ms ease-out quint 210 ms
TOGGLE 150 ms ease-out cubic 230 ms
ENTER 180 ms ease-out quint 270 ms
PANEL 200 ms ease-out cubic 320 ms

Editing 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:

  • The sidebar and composer keep one Tween. They used to build a new one on every toggle, which would have thrown away the spring's speed.
  • MAPLE_MOTION=eased runs reversible values on their token's duration and curve, as in the PR below, to compare the two in one build.
  • Real fades for screen and Settings changes. swap_in painted 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, so swap_in now 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) replaces hover_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(..):

// before
.when(is_selected, |row| row.bg(gpui::rgb(theme::bg_sidebar_row_selected())))
.map(|element| {
    let rest: gpui::Hsla = if is_selected {
        gpui::rgb(theme::bg_sidebar_row_selected()).into()
    } else {
        gpui::transparent_black()
    };
    crate::ui::motion::hover_background(element, rest, gpui::rgb(theme::bg_sidebar_row_hover()))
})

// after
.when(is_selected, |row| row.bg(gpui::rgb(theme::bg_sidebar_row_selected())))
.hover_bg(gpui::rgb(theme::bg_sidebar_row_hover()))

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

  • The composer's expand transition and its layout read the same three constants (EXPANDED_SHARE, EXPAND_BUTTON_REMS, EMPTY_PANE_PADDING_REMS in chat/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_idle waited on real time with thread::sleep. It now advances the pinned clock like the others.
  • docs/motion.md and CLAUDE.md name the effort slider as the one deliberate exception to "animate only through ui/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.

  • The sent message's row never took over from its bubble. The hand-off was keyed by the id the event names; the transcript files a row under its view key (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.
  • Sending from a tall composer dropped the thread first. The composer emptied at once while the bubble's slot opened from nothing, so for a frame the thread fell into the gap. The slot now opens from the height the composer gave up, and the newest row only ever moves up.
  • The composer's move between a new task and a conversation is instant. This is the one change to what animates: it glided over 200 ms, which read as lag in the place the user types. The glide and its state are removed.

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.

  • 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 to .hover_bg(..) in commit 2 lost their highlight. The hover now brings its own hitbox when the control has none.
  • Sending while the waiting dots already showed (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. A slot that is already showing now takes the composer's height on the send frame and opens the rest from there.

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

  • On macOS, at this head: the app test suite with -D warnings (1,489 passed, 0 failed, 3 ignored), just ci-lint, and the repository pre-commit hook all passed.
  • Before the rebase, the build of 91416057 was 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.
  • At this head, on the macOS Dev build: a cold launch, opening Settings and returning from it were recorded again and stepped through, with no black or grey frame; the Apps catalog cards highlight under the pointer.
  • New tests: a spring leaving from rest, never overshooting, settling within its token's time and keeping its position and speed through a reversal; a row with a live identity taking over from the bubble; a five-line send never moving the newest row down, with and without the waiting dots showing; the composer at its new place on the first frame; a plain card taking its hover colour.

Not verified

  • Windows and Linux in a running app at this head. The Windows ARM64 VM has only run the build of the PR below.
  • Settings. Only a few of its transitions were tried, and the nine newly eased hovers have not been looked at one by one.
  • Frame cost under sustained use, beyond the readings above on one Mac.

Known, left for later

  • While a message sends, its bubble is capped at 180 px (as on master), so one longer than about seven lines is cut at the bottom until its row lands.
  • The real row has a timestamp and copy line under its bubble that the sending bubble lacks, so the thread eases up about 33 px when the row takes over.
  • Both would go away if the sending message were a real transcript row from the start. That is a larger change to the send code and is not attempted here.
  • One shared clip-and-measure element for the places that animate a height, and moving the transcript's and composer's animation state out of render.

🤖 Generated with Claude Code

@AnthonyRonning AnthonyRonning added the ci:package Build unsigned packages on this PR label Nov 11, 2026
@AnthonyRonning
AnthonyRonning removed this pull request from stack #1574 November 12, 2026 03:37
@AnthonyRonning AnthonyRonning changed the title Agent: move reversible motion onto springs, with timing in one place Agent: rework the motion layer on springs, with timing in one place Nov 12, 2026
@AnthonyRonning

Copy link
Copy Markdown
Contributor Author

VM QA pass on this build (91416057, which also contains #1571 and #1573)

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.

@AnthonyRonning
AnthonyRonning force-pushed the codex-gpuibump-motion-core branch from 9141605 to 9548200 Compare November 14, 2026 08:06
@AnthonyRonning
AnthonyRonning marked this pull request as ready for review November 14, 2026 16:18
@AnthonyRonning
AnthonyRonning force-pushed the codex-gpuibump-motion-core branch from cf27232 to 26e0997 Compare November 14, 2026 16:18
Base automatically changed from codex-gpuibump-motion-port to master November 14, 2026 16:19
AnthonyRonning and others added 6 commits November 14, 2026 08:19
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>
@AnthonyRonning
AnthonyRonning force-pushed the codex-gpuibump-motion-core branch from 26e0997 to 50b6ff5 Compare November 14, 2026 16:19
@AnthonyRonning
AnthonyRonning merged commit aec3a58 into master Nov 14, 2026
1 check passed
@AnthonyRonning
AnthonyRonning deleted the codex-gpuibump-motion-core branch November 14, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:package Build unsigned packages on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant