Skip to content

Fail a row that an occupant taking its seat stands taller - #3764

Merged
max-sixty merged 8 commits into
mainfrom
swap-watch
Oct 23, 2026
Merged

max-sixty merged 8 commits into
mainfrom
swap-watch

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

The browser fixture now fails a test when a flex row's height changes as one occupant gives way to another. That was the pattern of #3710, where page search stood the floating panel's row taller than the comment field it replaced, and of the margin card's Reopen growing its controls row. The shift watch passed both: a row standing on its foot rises at its top while every word and control in it stays put. On a sample of 1,086 browser tests the check fired 9 times in 8 tests, all on one real defect, which this PR fixes.

The watch

tests/swap_watch.js runs on every page the fixture opens, in every engine, beside the words watch.

  • A swap is a frame in which a box stays on the page while one child stops drawing a box and another starts: removed and inserted, moved in, hidden and shown. One ResizeObserver on every element supplies each element's last painted size; a MutationObserver supplies arrivals and departures.
  • What fails: a flex row whose height changes in a swap the way its tallest occupant's did, that occupant being the row's tallest child on its side of the swap, where the change reaches the box holding the row, and the taller occupant isn't taller for its content (words in a field that grows with them, or growth while it stood).
  • Before the frame: a test's next key or press often comes before the browser paints what the last one changed. A trusted keydown or pointerdown first judges what changed since the last frame, as the page then lays it out. Without this, page search opened and closed between two frames, and the Keep the floating panel's row one line tall whatever its field holds #3710 regression passed.
  • It skips the page before it presents, a hidden-tab return and a window resize, each until two frames after, as the shift watch does.

Measurements

The sample was two-thirds of the 1,629 tests in margin/, threads/, controls/, widgets/, drafts/, navigation/, projection/ and the floating panel, options, reactions and commands modules, run before merging #3738:

Rule Firings Tests Real defects
Any place, any axis 678 336 mostly views, lists and cards growing with what they show
Flex lines across their line, with the occupant and container readings 19 — 8 were the defect; 8 were columns (cards, lists taking their words' width); 3 were drafts whose words sized the field
As landed 9 8 all 9: the defect below
  • Precision: 9 of 9 firings, on one defect (n = 9, so the rate is coarse).
  • Recall: the watch fails test_whatever_the_field_holds_the_row_keeps_its_line under a mouse and a finger when page search's WebAwesome box gets its vendor height back. That is Keep the floating panel's row one line tall whatever its field holds #3710's cause, re-created on the merged tree by dropping --wa-form-control-height. On main before Make every one-line control its place's line, and meet the touch floor with a reach #3738, Reopen and Resolve were both 28px, so the Reopen case had no height change to catch. A swap a renderer spreads over two frames is missed.
  • Cost: a median of 11ms of the watch's own script per test (p90 27ms, max 219ms), measured in-page on the second sample. Rerunning the sample's failures with the watch off gave the same failures, so none of them came from the watch.

The defect it found

Under a finger, the Threads list's filter tabs stood at the 44px floor. The panel's controls row was therefore 52px in the list and 42px in a thread (47px and 40px before #3738). The tabs now stand 26px tall, as under a mouse, and reach the floor through the panel's unpainted reach. The strip keeps the reach's room inside its scroll box, so nothing clips it, and takes none in the row. Both views now show a 42px controls row, and the aim sweep finds no short aim in the Threads list under a finger.

Known limits

  • A class on the root or the body, which the runtime sets as the pointer moves, is judged at the next frame rather than before a press, so a swap it drives and a test undoes before that frame is missed.
  • Observing every element has one side effect a page can see. A page's own ResizeObserver callback that resizes an element shallower than its target makes the browser report a loop error, which fails the test. Leaf's runtime defers such writes (rendering.js), and none of the roughly 1,400 test runs in this work hit one.
  • Reviewer suggestion, not built: since Make every one-line control its place's line, and meet the touch floor with a reach #3738, a one-line control's face should be its place's --lf-line. A sweep asserting that per control, in each mode, would catch control-height cases without a test having to swap them. It would not catch a composite occupant such as page search's surface, which this watch does.

Checks

  • tests/browser/test_render_swap_watch.py: a growing occupant fails when replaced, moved in, shown, swapped across two tasks in one frame, or swapped inside a declarative shadow tree. These pass: a filling occupant, one its own words grew, a swap the same press undoes before any frame, a row that loses its tallest item while a sibling moves within it, and a row a neighbouring field grows in the same press, in light DOM or a shadow tree. Each passing case was checked to fail with its mechanism removed.
  • An independent review found a throw on document.open(), missed moved-in occupants, a false firing on reorders and on a press's own mouse events, and a 22-36ms cost per press when the runtime set a body class; all are fixed and re-reviewed. The auto-reviewer's findings (a neighbour sizing the row, a shadow host's children, declarative shadow roots) are fixed too.
  • The floating panel and aim tests above, test_every_control_the_layer_offers_is_a_box_the_user_can_hit (both pointers), the shift watch's document-replacement test and tests/model pass.
  • Inherited failures, which the sample also showed with the watch off: test_composer_return_edits_or_sends_according_to_its_keyboard[android], test_align_current_item_from_the_menu_on_touch_reserves_z, test_shot_controls_have_disjoint_targets_and_labels_stay_passive[True].

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

max-sixty and others added 5 commits October 23, 2026 06:18
Twice a place changed size as one occupant gave way to another: page
search stood the floating panel's row taller than the comment field it
replaced (#3710), and a margin card's Reopen grew its controls row. The
shift watch passed both, because a row standing on its foot rises at its
top while every word and control in it stays put.

`tests/swap_watch.js` joins the browser fixture's watches and runs on
every test in every engine. A swap is a frame in which a box keeps its
place while one child stops drawing a box and another starts, by removal
and insertion or hiding and showing. The watch fails a flex row whose
height changes in a swap the way its tallest occupant's did, where the
change reaches the box holding the row and the taller occupant isn't
taller for its content (typed words, or growth while it stood). A
trusted key or press first judges what changed since the last painted
frame, so a swap a test opens and closes between two frames is still
judged.

Measured on 1,086 browser tests, every third and second-of-three test
across margin, threads, controls, widgets, drafts, navigation,
projection, the floating panel, options, reactions and commands:

- Judging every place in every axis fired 678 times in 336 tests,
  nearly all views, lists and cards growing with what they show.
- Flex lines in their cross axis, with the occupant and container
  readings, fired 19 times: 8 were columns, cards and lists taking the
  width of their words; 3 were drafts whose words sized the panel's
  field; 8 were the defect below.
- The rule as landed fires 9 times in 8 tests, all one defect: under a
  finger, the Threads list's filter tabs stood at the 44px floor, so the
  panel's controls row was 47px in the list and 40px in a thread.

Recall: with #3710's CSS reverted, it fails
`test_whatever_the_field_holds_the_row_keeps_its_line` under a mouse and
a finger, naming page search's field and its search surface. On main,
Reopen is as tall as Resolve, so the margin card's case only shows on
the control-line branch.

The filter tabs now stand 26px tall and reach the floor through the
panel's unpainted reach, with the strip keeping the reach's room inside
its scroll box, so the controls row is 40px in both views.

The watch costs a median 11ms of script per test (p90 27ms) in the
sampled pages.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… one task's events

- A document that `document.open()` empties holds no place; the watch threw on it
  and, with its reset skipped, on every frame after.
- A moved occupant keeps its last size, and an element read before a frame is
  watched again, unobserved first, since observing twice reports nothing.
- Only keydown and pointerdown judge before a frame: the mouse and touch events a
  press brings run in its task, so a swap one of them undoes was never painted.
- Judging before a frame reads everything inside an element whose attributes
  changed, as a panel's mode attribute swaps occupants several levels down, and
  reads an inline box as empty, as the observer does.
- Only a field that grows with its words exempts its occupant; a one-line input's
  words never size it.
- Resize, presentation and hidden-tab exemptions last until the second frame after
  their cause, as the shift watch counts them.
- The filter tabs' 26px face is one token.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A child a keyed renderer takes out and puts back in the same row took no one's
seat, so a row that lost its tallest item while one moved within it no longer
reads as a swap. Judging before a frame no longer reads the whole page when the
runtime sets a class on the root or the body as the pointer moves, which cost a
press 22-36ms on an 8,000-element page; it now costs about 1ms.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The row swap watch can fail a valid content-driven resize. The inline case reproduces a false finding from the browser fixture.

Comment thread tests/swap_watch.js Resolved
A row whose field took more lines in the same press as a short occupant gave way
to a taller one grew for the field, not the swap. The occupant that grows or
shrinks a row must now stand taller than every child that stood through the
swap, on its side of it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new sibling scan still attributes a shadow-root row's growth to the swapped occupant; see the inline reproduction.

Comment thread tests/swap_watch.js Resolved
…h a swap

A flex host lays out its shadow tree, and a slot its assigned elements, so a
field that grows beside the swap inside a shadow tree now vetoes the finding as
one in light DOM does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

laidOut reads a shadow tree only when attachShadow populated roots. A declarative <template shadowrootmode="open"> creates a root without calling that hook, and the watch also never observes its children. I reproduced a flex row with a declarative shadow root whose 24px button gives way to a 40px button: the row grew, but judge_watches() reported no place-resized finding. The repository uses declarative shadow roots in test_render_export.py, so this leaves a supported page shape outside the new check. Discover and observe roots already present when a host enters the document, and let laidOut read those roots too.

An open declarative shadow root never reaches the patched attachShadow, so its
host's arrival now adopts it: its children are observed and laid out as the
host's.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Declarative shadow roots: fixed in 3172c8e. A host's arrival now adopts an open shadow root the parser built, so its children are observed and laid out as the host's; test_an_occupant_that_grows_a_declarative_shadow_row_fails reproduces your case and fails without the change. A closed declarative root stays out of reach of page script, so the watch can't see into one.

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

@leaf-agent

Copy link
Copy Markdown
Collaborator

Confirmed: the declarative shadow root now participates in the swap watch, and the focused regression test passes at 3172c8ec (1 passed). My finding is resolved.

@max-sixty
max-sixty merged commit 022e073 into main Oct 23, 2026
3 checks passed
@max-sixty
max-sixty deleted the swap-watch branch October 23, 2026 15:08
leaf-agent added a commit that referenced this pull request Oct 23, 2026
)

The swap watch added in #3764 disturbed several browser fixtures on
main. It waited for animation frames in offscreen frames where Chrome
does not paint, observed unrelated descendants deeply enough to trigger
a ResizeObserver loop, and measured new nodes in a concealed tab before
a press. This change drains swaps after the existing shift-watch paint
checkpoint, observes only flex rows and the boxes needed to judge them,
and measures arrivals only when they belong to a tracked row. It also
treats an SVG drawing's intrinsic height as content growth, so replacing
a diagram's source with its drawing does not fail the row rule.

The failing cases from [main CI run
39975651411](https://github.com/max-sixty/leaf/actions/runs/39975651411)
for hidden and offscreen frames, revision layout, diagram rendering, and
hidden-tab log scrolling now pass. A focused selection of 19 browser
cases passed, including the swap watch's positive and negative examples;
Prettier and ESLint passed on the changed file. The run's press-handling
and quote failures were repaired on main by #3767 and #3766.

Co-authored-by: leaf-agent <[email protected]>
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