Skip to content

Move a floating box from where it stood when a new line changes the edge holding it - #5054

Merged
max-sixty merged 13 commits into
mainfrom
send-newline-jerk
Nov 2, 2026
Merged

max-sixty merged 13 commits into
mainfrom
send-newline-jerk

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A margin card whose foot stood near the window's foot jerked as a new line came and went in its reply: the first frame drew the card part of a line lower, then it slid back up. The user reported it in Firefox on 31 October. The card now travels from where it stood, in Firefox and Chromium. The comment box beside a passage had a larger jerk of the same kind: after a scroll, its first new line drew it for one frame where it stood before the scroll, hundreds of pixels away. That is fixed too.

Cause

A new line that takes the card past the window's foot makes its placement hold it by that foot instead of beside its passage (floating.js, held). box-motion.js takes how far the page carried a box from the edge that holds it, so across that change the line's move read as the page carrying the card whole. The card also read its new size before the placement that size asks for had moved it, so its outline started toward the old spot and turned back a frame later.

What changes

  • One order for both boxes. The card and the comment box now stand the box through placed() before the motion reads a change of its size. The comment box already worked this way; the card's size observer now asks for its placement and reads in that placement's landing.
  • What travels and what is carried. A placement at the size last read is the page's move and is carried, as when a scroll re-solves a box held at the window's edge. A placement that answers a change of size travels from where the box was drawn, except for as far as its passage moved past it since the box was last read or placed, which is carried (planeShare).
  • Chromium's one-frame lag. Right after a box is taken into its anchor's plane, Chromium lays it out off its spot until the next frame, by up to a few hundred pixels. So the move is taken from the placement's own answer (stand() returns it, from clientBox), and how far the passage moved past the box is read from the anchor and the element its plane moves with (heldEdges now hands over by and plane), never from the box.
  • The comment box's motion root. It was the field's parent, a display: contents wrapper with no box, so it read no carry at all. It is now the composer.
  • A grip drag's end now stands inside the placement, so the placement's move includes the drop.

Tests

  • test_a_line_that_changes_the_edge_holding_a_card_moves_it_from_where_it_stood (browser, Chromium and Firefox) fails on main, where the card's top, head row and turn jump about 11 px to their rest in the first frame.
  • test_every_part_of_a_floating_box_moves_one_way_per_input (journeys) is a Hypothesis property over the card, the comment box and the panel's field. tests/page_scripts/motion_frames.js records where every painted part of the box is drawn after each frame: its outline, its controls and each run of words. The test fails any part that moves two ways on one axis within one input. It draws the draft, where the box stands against the window's foot, and the key timing. Both jerks above are its explicit examples. Hypothesis joins the dev dependencies.
  • 20 derandomized and 60 random cases per engine pass. The focused browser tests around cards, the comment box and the panel pass, but for test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection], which fails the same way with main's runtime. pnpm run test:runtime passes.

Still open

Found by the property test or by probes, and present on main too:

  • A card scrolled back about 200 px while it shrinks, letting go of the window's foot, travels about 60 px up from below that foot. Fixing it needs the placement to record the boundary that held the card.
  • In Firefox, a comment box held by the window's foot rides the page's smooth scroll into the reading band, then snaps back to the foot. The open comment box always stands in the page's plane, which causes it.
  • When an answer arrives in a card being read near the window's foot, Stand a card on a log row in the rail, and let a card rise as an answer arrives #4843 makes the card rise. On main the first frame drops the card about 90 px to the window's foot; here the outline grows from where the card stood. The question, head row and Reply field still vanish and reappear higher up, because news shows each part where it now stands. Whether such an answer should slide the card's contents up as a Send does is the maintainer's call.
  • A box held at the window's foot can vibrate by under a pixel after a new line, and Firefox rarely logs a ResizeObserver loop error.

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

…holding it

A margin card whose foot stood within a line of the window's foot jerked as a new
line came and went: the first frame drew the whole card part of a line lower, and
then it travelled back up. The user reported it on 31 October, toggling a new line
in a card's reply in Firefox. The card now travels from where it stood. The comment
box beside a passage had a larger jerk of the same family: after a scroll, its first
new line drew it where it stood before the scroll, hundreds of pixels away, for a
frame.

Cause. A new line that takes the card past the window's foot makes its placement
hold it by that foot rather than beside its passage (floating.js, `held`).
box-motion.js measures how far the box's plane carried it by the edge that holds it
when it reads (`rebase`), so across that change the move the line made read as the
page carrying the card whole. The comment box already stood each placement through
the motion's `placed()`; the card stood its placements on their own. The comment
box's motion was rooted on the field's parent, which since #4393 is a wrapper with
no box of its own (`display: contents`), so it read no carry at all.

- `placed()` takes every placement: one answering a change of the box's size travels
  from where the box was drawn, and one at the size it last stood at, as a scroll
  re-solving a box held at the window's edge, counts as its plane carrying it. It no
  longer reads the box once it stands, since in Chromium a box just stood in the
  page's plane can read where its anchor stood before the last scroll.
- The card's placement stands through `placed()`.
- The comment box's motion is rooted on its composer.

Tests. New: `test_a_line_that_changes_the_edge_holding_a_card_moves_it_from_where_it_stood`,
in Chromium and Firefox; it fails on main in both, where the first frame drew the
card 10 px lower. New in journeys: `test_every_part_of_a_floating_box_moves_one_way_per_input`,
a Hypothesis property over the card, the comment box and the panel's field.
`motion_watch.js` records where every painted part of the box stands at each frame
(its outline as its surface cuts it, its controls, each run of words), and the test
fails a part that moves two ways on an axis within one input: drawn somewhere for a
frame and sent back, turning back, or vibrating. It draws the edit, where the box
stands against the window's foot, and whether the next key waits for the last
motion. Both jerks above are its explicit examples. Hypothesis joins the dev
dependencies.

Still found by the property: a card typing past a wrap near the window's foot can
jump by several lines and travel back, now occasionally, on main in every run; a box
held at the window's foot vibrates by under a pixel after a new line, on main too,
and the card does so indefinitely when its passage is below the window; and a rare
ResizeObserver loop error in Firefox.
A margin card that grew without a key, as when an answer arrives, while its foot stood
near the window's foot still turned back. Its motion read the new size first and started
the card's outline toward the old placement. The placement that held the card by the
window's foot landed a frame later and moved the layout under that outline: the outline
jumped about 4 px, and the motion's readings stayed off by that shift for the next
change. Key edits already came out placement-first, because each caret move asks for a
placement.

- The card's size observer now asks for its placement at once and reads the card in that
  placement's landing, before the frame paints, as the comment box already does. Both
  owners follow one order: a change of the box's size is read only after the placement it
  asks for has stood the box (box-motion.js, `placed`).
- `placed()` tells the box's own change from its plane's by comparing against the size
  its motion last read, instead of a size of its own. That drops `placedSize`.

Tests, after merging #4844, which shows a typed line at once:

- The card reproducer now holds the card by the window's foot with a typed line and
  checks the removed line's travel. It still fails on main in Chromium and Firefox, where
  the card's top, head row and turn jump about 11 px to their rest in the first frame.
- The property test's comment-box example now removes a line after the scroll, since a
  line added no longer travels.
- The frame recorder records two frames before the first input, so the judge can see a
  jump on that input. It moves to `tests/page_scripts/motion_frames.js`.
- The property test now uses frame and render signals instead of fixed delays, and the
  same draws on every run, without shrinking. Drafts can hold line breaks.

Still found by random draws, and failing on main too: a comment box held by the
window's foot rides the page's smooth scroll into the reading band, which Firefox
plays out over about 300 ms, and the next placement snaps it back to the foot.

> _This was written by Claude Code on behalf of max-sixty_
…resizes

The previous commit decided whether a placement's move travels by size alone: a
placement at a size the motion had not read yet travelled from where the box was drawn.
A scroll and a change of size can land in one placement, though. A card the window's foot
held, scrolled 200 px up while it grew, is stood back beside its passage, and it trailed
the scroll by about 150 px over the whole tween, in Chromium and Firefox. Main carried it
with the scroll.

`placed()` now also asks whether what the box stands by moved farther than the plane
carried the box since its last reading or placement, as a scroll moves a passage past a
box the window's edge holds. If it did, the placement follows the plane. The next
reading then carries the box by the edges holding it now, and only what changed within
the box travels. `rebase()` measures that, from the anchor floating.js now hands
box-motion with the held edges (`heldEdges`, `by`).

For the flip the reviewer probed, a card held at the foot scrolled 200 px and grown
14 px, the first frame now stands the card beside its passage, and only the growth
travels: 14 px at its top, where main shows it at its bottom. The reverse, scrolled
back 200 px while shrinking, travels about 60 px up from below the window's foot. Main
draws one frame there instead and jumps.

> _This was written by Claude Code on behalf of max-sixty_
…size

The previous commit made one yes-or-no choice for a placement's whole move: the move
travelled if the box had a new size and its passage hadn't moved past it, and was
carried otherwise. A scroll of only 2 px in the same turn as a shrink that let go of
the window's foot carried the whole move. The card's top was then drawn 18 px above
where it stood, and it travelled back down. On main the same case was 2 px off for a
frame. Trackpad momentum, the tail of a smooth scroll, or a reflow can each supply that
2 px.

`placed()` now splits the move. When a placement answers a change of the box's size,
the plane carries the move only as far as the box's passage moved past it since the last
reading or placement, and only in that direction (`planeShare`). The rest travels from
where the box was drawn. A placement at the size last read is still all the plane's.

The split takes the move from the placement's own answer. `floating.js`'s `stand()` now
returns how far it moved the box, from `clientBox`, because Chromium lays out a box it
has just taken into its anchor's plane hundreds of pixels off its spot until the next
frame. Read off the box, a shrink that let go of the window's foot drew the card 342 px
low and slid it back. Each owner now ends the grip's drag inside its stand, so that
move includes the drop.

`rebase()` returns how far the passage moved past the box. It now compares the
passage's box only with an earlier box of the same element.

Probed in Chromium and Firefox:
- the reviewer's 2 px case now carries 2 px and travels the rest one way;
- a 200 px scroll that lets go of the foot while the card grows still carries the card
  with the scroll;
- the reported case still travels from where the card stood.

The reverse flip, scrolling back 200 px while shrinking, still travels about 60 px up
from below the window's foot. Fixing that needs the boundary the placement was held
against.

> _This was written by Claude Code on behalf of max-sixty_
… the box

`placed()` lets the plane carry a resized placement's move only as far as the box's
passage moved past it. It measured that as the passage's move less the box's. In
Chromium, a box a placement has just taken into its anchor's plane lays out off its spot
until the next frame, so the reading after that landing took the box there. The next
reading then saw the box move back while its passage stood still, and a resized
placement in that frame carried its whole move instead of travelling. Review reproduced
it: a card held at the window's foot that shrank and grew back two frames later drew its
top 3 px above both its old and new rest, then slid back. Firefox, which lays the box out
at once, stayed smooth.

`rebase()` now reads where the passage stands in the box's plane from the elements the
plane is made of: from the anchor in the page's plane, where it can't move past the box,
from the region's body in a region's, and from the window in the window's. Nothing reads
the anchored box for it. `heldEdges` hands box-motion the plane's element (`plane`), and
`placed()` takes that reading again after the placement, in the plane it now stands
the box in.

Probed in Chromium and Firefox: the shrink-then-grow case now travels from where the card
was drawn in both, and the flip, jitter and reported cases read as before.

> _This was written by Claude Code on behalf of max-sixty_
Conflicts came from #4873's strict type check meeting this branch's placement and
motion changes. The resolution keeps the branch's code and gives it the types the
strict check asks for:

- The comment box's motion stays rooted on the composer, now reached as the
  composition frame's parent. Main's `response.composition().frame` is the same
  `display: contents` wrapper this branch moved off.
- The anchor a box stands by can be the start of what a scroller holds
  (css-anchors.js, `ContentStart`), which has no `isConnected`. `beside()` now
  checks that scroller instead, so a box anchored that way also measures how far
  its passage moved past it, rather than reading 0.
- `rebase()` returns the root's box with `past`, so `placed()` needs no null
  frame.
- The card's size observer passes its session to `placedThreadPreview`, which
  now takes one.

The kernel is rebuilt.

> _This was written by Claude Code on behalf of max-sixty_
…ebase's

> _This was written by Claude Code on behalf of max-sixty_
Only the generated kernel conflicted; it is rebuilt.
Only the generated kernel conflicted; it is rebuilt.
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
Only the generated kernel conflicted; it is rebuilt.
@max-sixty
max-sixty merged commit 3e1d2b9 into main Nov 2, 2026
4 checks passed
@max-sixty
max-sixty deleted the send-newline-jerk branch November 2, 2026 05:09
leaf-agent added a commit that referenced this pull request Nov 3, 2026
…pages (#5216)

The nightly guard
`test_the_resources_a_fixture_owns_are_taken_from_that_fixture` failed
because two tests closed a page they took from the `browser` fixture:
the floating-box journey (added in #5054), and
`test_a_frame_of_another_live_leaf_page_is_checked_on_its_own` in
`tests/browser/test_render_gate.py` (added in #5035; it fails the guard
on current main too). The fixture closes every context it lent at
teardown, after `judge_watches` reads each page that is still open.
Closing early skipped that reading for every Hypothesis example of the
journey. Both tests now leave their pages for the fixture to close, and
neither test's assertions change.

Verified locally: the guard failed on main naming both files and passes
now. The gate test passes. `tests/journeys/test_floating_box_motion.py`
passes on Chromium and Firefox with every example's page left open until
teardown (22 per engine, about 100 s, peak resident memory of the
largest single process 1.9 GB).

Closes #5172 — automated triage

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