Skip to content

Credit a node that a native size animation's box carries, so the shift watch judges it at any frame rate - #6169

Merged
max-sixty merged 1 commit into
mainfrom
agent-afaef959fa2ec3718
Nov 16, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-afaef959fa2ec3718

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The shift watch now credits a node inside a box that a native size animation is growing or shrinking, so a press-begun transition that re-centres a button's label passes at every frame rate. Before, at 60 fps each frame moved the label less than the 3 px Chrome reports as a layout shift, so the watch never judged it. On a starved host one frame moved it 4 px, Chrome reported the shift, and the watch had no credit for it, because it credited a size animation's reflow only of boxes after the animated one.

innerReflow in tests/shift_watch.js credits the node's move when:

  • the move, beyond the node's other credits, lies between the moves of the box's two edges, beyond the box's own credits;
  • those edge moves grow or shrink the box, at one edge or both apart, rather than carrying it whole;
  • the node moves with the box: in its flow, or positioned against a box at or within it (unplacedBy, which sizeReaches now shares).

That covers a box growing at its foot, one standing on its foot and growing at its head, one centred in its parent, and a logical size in a vertical writing mode. The box's alignment isn't readable (a button centres its label by no CSS property), so a script move that stays within the box's growth in the same frame is credited too, as the sticky-inset credit already allows within its span.

For the reviewer: a script-started transition still depends on frame rate

The credit applies only to animations an input began, as the watch's translation and following-box credits do; the header's scope paragraph now says so. The swap-watch fixture as it was before #6166 started its transition from a script, with no input, so it still fails starved and passes unloaded. browser/AGENTS.md ("The page holds still under the user's aim") lets news grow a box but keeps reading content still, so the starved verdict is the one that rule asks for. The 60 fps pass comes from Chrome's paint signal, which every passive verdict starts from and which leaves out a frame's move under 3 px. Two ways to close that, both outside this PR:

  • A. Credit a passive size animation's inner reflow too. News could then re-centre a label by animating its box, though not by resizing it at once, which loosens the rule above.
  • B. Judge passive motion across frames, so a slow passive layout animation fails at 60 fps too. That changes how the watch admits a passive move, and would surface every such animation the suite's pages now hide.

A width animation that rewraps text, moving words to another line, is also still uncredited, as it was before.

Evidence

Scratch fixtures, the button row from the swap-watch test, 4 starved runs each (taskpolicy -b beside self-ending busy loops):

fixture base, starved head, starved unloaded, both
click starts the height transition 3 of 4 fail 0 of 4 fail pass
script starts it (fixture before #6166) 4 of 4 fail 4 of 4 fail pass
same growth, no transition (control) 4 of 4 fail 4 of 4 fail fail

test_a_size_animation_carries_what_its_box_lays_out seeks a press's paused height animation to its end in one frame, so every host sees the step a starved host does. Words re-centred in a box growing at its foot or at its head pass; words a script carries farther than the box grew, and words re-centred by a size change no animation of their box makes, fail. On the base watch the first two arms fail. Dropping the bound, the ownership checks or the box's head-edge term each turns the matching arm.

Focused checks pass, unloaded and the new test starved: the shift watch's size and animation credit tests, the swap-watch module, and four real-page fold and growth tests (97 in all). An independent Codex review found the vertical-writing-mode gap, unmemoised recursion through nested resizing boxes, a crash path for a box that turns display: contents, and the scope paragraph's overstatement; this PR fixes all four.

This was written by Claude Code on behalf of max-sixty

…t watch judges it at any frame rate

A box lays out its content as it grows: a button centres its label, a flex box
aligns its items. At 60 fps a short height transition moves the label less than
the 3 px Chrome reports as a layout shift in each frame, so the shift watch never
judged it. On a starved host a 110 ms frame moves it 4 px, Chrome reports the
shift, and the watch had no credit for it: it credited a size animation's reflow
only of boxes after the animated one in its flow.

`innerReflow` credits a node inside the animated box by its move beyond its other
credits, where that move lies between the moves of the box's two edges beyond the
box's own credits, the box grows or shrinks rather than being carried whole, and
the node moves with the box. That covers a box growing at its foot, one standing
on its foot and growing at its head, one centred in its parent, and a logical size
in a vertical writing mode. The box's alignment isn't readable (a button centres
its label by no property), so another move within that span is credited too, as
`sticky_inset` credits one within its span. The placement walk `sizeReaches` used
moves into `unplacedBy`, which both credits share.

The credit follows the watch's ownership rules, as translation and following-box
reflow do: only an animation an input began is credited. The header's scope now
says so. A transition a script starts with no input, as the swap-watch fixture
before #6166 did, moves the label without input, which browser/AGENTS.md ("The
page holds still under the user's aim") forbids. The watch still reports that
only when Chrome reports the shift, so on a starved host and not at 60 fps.

Starved runs (`taskpolicy -b` beside busy loops), base -> head, 4 runs each: a
click-started height transition on a centred button failed 3 -> 0; the
script-started one failed 4 -> 4; the same growth with no transition failed
4 -> 4. Unloaded, the first two pass and the third fails, on both.

`test_a_size_animation_carries_what_its_box_lays_out` seeks a press's paused
height animation to its end in one frame, so every host sees the step a starved
host does. Words re-centred in a box growing at its foot or at its head pass;
words a script carries farther than the box grew, and words re-centred by a size
change no animation of their box makes, fail. On the base watch the first two
arms fail; dropping the bound, the ownership checks or the box's head-edge term
each turns the matching arm.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit e5404ff into main Nov 16, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-afaef959fa2ec3718 branch November 16, 2026 12:56
max-sixty added a commit that referenced this pull request Nov 16, 2026
…ved Firefox (#6197)

Max's direction for tests whose result depends on CPU: design them so it
can't, confirm that in the nightly runs, and keep starved runs out of
the merge pipeline. This makes the macOS nightly that run: it now uses
four workers on the runner's three cores, which starves every test. A
trial at four workers ([run
43780587059](https://github.com/max-sixty/leaf/actions/runs/43780587059))
took 4h11m against 4h12m at two, with the CPU at 0% idle throughout and
memory peaking at 7.1 of 7.5 GB, no swap. `tests/AGENTS.md` now names
that job as the slow-machine rule's check.

In a starved Firefox, PageUp in a live log can do nothing: Firefox
applies the key's scroll 280–800 ms late, after the reader's 80 ms wait
for it, and no event says the browser won't scroll, so ending the loss
needs a deadline. Max accepted it as a corner case, so the Firefox cases
of `test_a_page_up_in_a_log_a_stream_feeds_leaves_its_end` whose scroll
the browser applies (PageUp, PageUp on a link, wheel, wheel across) are
now non-strict expected failures; this PR's first CI run lost a wheel
the same way. They pass at normal load, as they did locally here and on
main's last three push runs. `u`, which Leaf's own glide scrolls, stays
a plain case.

To weigh: the trial run at four workers had 30 failures against 21 at
two. #6154, #6155, #6166 and #6169 fixed the load-dependent ones found
then, but the first nightly after this may still turn up more; each is a
test whose result depends on speed.

> _This was written by Claude Code on behalf of max-sixty_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants