Skip to content

Write a scroll only where it moves the box or stops one under way, and report one that does neither - #5806

Merged
max-sixty merged 6 commits into
mainfrom
scroll-write-watch
Nov 11, 2026
Merged

max-sixty merged 6 commits into
mainfrom
scroll-write-watch

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

The write watch now reports a page's instant scroll write that leaves its box where it stood (unmoved-scroll), as it reports a DOM write that changes nothing. A margin card's bounce in Firefox came from such writes: placing the card at every scroll's end put its transcript back at an end it already stood at, and each write cancelled the rubber band of the flick into it, which Firefox plays after the scroll has ended (#5763). Run over the card's tests on main, the check named seven writers that do the same (showReturnTurn, keepThreadLanding, #fitAnswer, restorePlace on a revision, the editor's caret reveal, keepFoot moving by zero, and the fit #5763 left), all through setScroll.

The guard. setScroll (browser/runtime/arrivals.js) never makes an instant write that would leave the box where it stands, so a writer may restate a position as often as it likes, as keeps lets one restate a DOM value. Stopping a scroll is its own write, stopWhereItStands, the one write meant to leave a box in place, which the watch allows by name: stopScroll calls it before a landing, and a glide taking over a wheel's motion calls it first. An earlier version of this PR let setScroll write in place while the browser or a glide moved the box, since that is how a stop is made, which left callers checking for a no-op themselves so their restatement wouldn't stop the user's scroll; moveScrollerBy's half-pixel check and the thread's New reply placement drop theirs. With the guard, the card's wheel test passes in Firefox on the card code from before #5763, and fails there without it.

Where a box stands. A write is judged against the box's range, since callers aim past both ends. A box scrolls from zero to the side where its content's flow starts: the negative side where that is the bottom or right edge (right-to-left, a reversed flex row or column, wrap-reverse, vertical writing modes). Off zero, the box's position says which side; at zero only style does, so scrollRange reads it (scrollsBack). The page scrolls from its principal flow, the root's or the body's by rules that turn on containment and on which the engines differ, so where the root and body agree that is the side, and where they don't a write from zero is judged against both sides, which never drops a move. No API reports a scroll range (Firefox's non-standard scrollTopMin aside). Judging a write at zero against both sides instead wrote every move past the top of a box at rest, which the watch then found in seven tests. localScrollBy in element-frame.js read the same range from direction alone, and now asks scrollRange.

What else the watch found. A landing asked overflow: clip boxes to scroll (innerMoves in landing-scroll.js now asks only scroll containers), and restoring a draft's editing wrote the field's offsets directly rather than through setScroll. CodeMirror's own measure restates its scroller's offset where the browser clamps it, which EXPECTED_SCROLLS allows as EXPECTED allows vendored DOM writes.

Tests. test_a_landing_that_moves_nothing_stops_a_scroll_still_under_way (a bounded log scrolling smoothly stops where a landing on a name already in place found it; a skip that ignored the scroll under way let it run to its end). tests/browser/test_scroll_writes.py moves fifteen boxes, one per style that decides the side, and the page under a root column-reverse and a vertical-rl body, from zero past each side; the boxes pass in Chromium and Firefox. tests/runtime/arrivals.test.mjs holds the end clamp, a restated position writing nothing while the browser scrolls, and the stop. A focused selection of about 960 browser tests over margin, navigation, drafts, boards, the watches, anchors and the floating panel passes, and again 605 of 611 over margin, navigation, drafts and the floating panel after the stop split; the failures fail the same way with main's runtime files.

test_align_current_item_from_the_menu_on_touch_reserves_z now presses its second tap through press_visible, which waits out the tap run the first began. Its raw locator.tap() landed on the same pixel within Chromium's ~400ms run, so the click carried detail 2 and the panel's runOfClicks pressed nothing; it passed only where the page ran slowly enough to space the taps, and fails on main on a quick host. CI never ran it here, since the PR job selects browser tests by edits to their own file.

Left as it was. In Firefox, stopScroll doesn't stop a smooth scroll already under way, on main too: a write of the position the page last saw leaves Firefox's scroll running, so the new landing test runs in Chromium only. A second check, a page's write to a box the browser was scrolling for the user, found no real case and missed the bounce itself, so it is not kept.

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

…d report one that does neither

The write watch now reports a page's instant scroll write that leaves its box where it stood (`unmoved-scroll`), as it reports a DOM write that changes nothing. A margin card's bounce in Firefox came from such writes: placing the card at every scroll's end put its transcript back at an end it already stood at, and each write cancelled the rubber band of the flick into it, which Firefox plays after the scroll has ended (#5763). Run over the card's tests on main, the check named the writers that do the same: `showReturnTurn`'s end before its step back, `keepThreadLanding` re-landing a transcript already at its end, `#fitAnswer`, `restorePlace` on a revision, the editor's caret reveal, `keepFoot` moving by zero, and the fit #5763 left. Every one wrote through `setScroll`.

So `setScroll` (arrivals.js) skips an instant write that would leave a still box where it stands. While the browser or a glide moves the box (`browserScrolls`, `holdScroll`), the same write has an effect: it is how `stopScroll` takes a landing's place from a wheel's scroll, and how a glide takes over one. So there it writes the box's own position (`stopWhereItStands`), the one write meant to leave a box in place, which the watch allows by name. A script's own instant write leaves nothing in motion. With that guard the card's wheel test passes in Firefox on the card code from before #5763, and fails there without it.

Where the box stands is read to the pixel, since a box's scroll size is whole pixels and an end read from it can stand a fraction short of the browser's own (Firefox's 314.25 against 314 at a 2x display), and against the box's range, which callers aim past at both ends. A box scrolls from zero to the side where its content's flow starts: the negative side where that start is the bottom or right edge, as in a right-to-left box, a reversed flex row or column, a wrap-reverse flex container, or a vertical writing mode. Off zero, the box's position says which side; at zero nothing does but the style that places the flow's start, so `scrollsBack` reads writing mode, direction, and a flex container's direction and wrap. The page itself scrolls from the start of its principal flow, which an HTML page takes from the body's writing mode and direction unless the root or the body is contained (as the default theme's body is), and which no flex flow on the root reverses. No API reports a box's scroll range (Firefox's non-standard `scrollTopMin` aside). `scrollRange` is that answer's one home: `localScrollBy` in element-frame.js read the same range from `direction` alone, and now asks it. Judging a write at zero against both sides instead would have written every move past the top of a box at rest, which the watch then found in seven tests (`returnTo`, `restorePlace`, a landing in a rotated port).

The watch judges every other write, and found two that could never move anything. A landing walked every box that clips its destination and asked each to scroll, `overflow: clip` boxes included, which no script can scroll (`innerMoves` in landing-scroll.js now asks only scroll containers). And restoring a draft's editing wrote the field's scroll offsets directly rather than through `setScroll`. CodeMirror's own measure restates its scroller's offset where the browser clamps it, which `EXPECTED_SCROLLS` allows as `EXPECTED` allows vendored DOM writes. The shift watch's passive gesture case scrolls by nothing on purpose, and consumes the finding.

Tests: `test_a_landing_that_moves_nothing_stops_a_scroll_still_under_way` holds the stop in Chromium: a bounded log scrolling smoothly when the reader lands on a name already in place stops where the landing found it, where a skip that ignored the scroll under way let it run to its end. In Firefox the log runs to its end on main too, since a write of the position the page last saw doesn't stop Firefox's smooth scroll; that is left as it was. `test_a_write_from_zero_moves_a_box_as_far_as_the_browser_lets_it` moves fifteen boxes, one per style that decides the side, from zero past each side, and `test_the_page_scrolls_from_the_start_of_its_body_s_flow` does the same for the page under four root and body styles; both pass in Chromium and Firefox. `tests/runtime/arrivals.test.mjs` holds the end clamp and the write while the browser scrolls.

A second check, a page's write to a box the browser was scrolling for the user, found no real case once a newer key was read as asking for its scroll, and missed the bounce itself, whose writes landed after the scroll's end or during a wheel pushing at an edge that scrolled nothing, so it is not kept.

@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 test job fails at its pre-commit step on this head. The formatter reverts the whitespace change this PR makes to the for header in tests/write_watch.js (it puts ShadowRoot; ) back to ShadowRoot;)), and the job stops before the suite runs. Every other hook passed, so reverting that line as suggested inline should be the only change the check needs.

Comment thread tests/write_watch.js Resolved
The page scrolls from its principal flow, the root's writing mode and direction or the body's. Which one applies turns on containment, content visibility, a hidden body or a frameset, and Chromium and Firefox differ on a hidden body, so modelling the choice kept missing cases. Both candidates are known, so where the root and the body agree, that is the side; where they don't, a write from zero is judged against both sides, which never drops a move and at most writes one that moves nothing. No flex flow on the root reverses the page.
leaf-agent
leaf-agent previously approved these changes Nov 10, 2026
…hat moves nothing

setScroll skipped an instant write that would leave a still box where it stands, but
while the browser or a glide moved the box it made the write anyway, since writing
where the box stands is how a landing stops a scroll and a glide takes over a wheel's.
One call meant both place and stop, so a writer restating a position mid-scroll would
stop the user's scroll, and callers kept their own checks for a write that moves
nothing: moveScrollerBy's half-pixel guard and the thread's New reply placement.

The stop is now its own write, stopWhereItStands, which stopScroll and a glide taking
over the browser's motion call by name and the write watch already knows. setScroll
never writes a move of under a pixel, and the two callers' checks go. A skipped write
no longer claims the box's position for the script, since it wrote nothing; the
runtime test of a held scroll now gives its box a range its writes can move in.

The touch Align test's second tap now goes through press_visible, which waits out the
tap run the first began. Its raw locator.tap() landed on the same pixel within
Chromium's ~400ms run, so the click carried detail 2 and the panel's runOfClicks
pressed nothing for it; the test passed only where the page ran slow enough to space
the taps, and failed on main as on this branch on a quick host.
@max-sixty
max-sixty merged commit c170a33 into main Nov 11, 2026
5 checks passed
@max-sixty
max-sixty deleted the scroll-write-watch branch November 11, 2026 17:55
max-sixty added a commit that referenced this pull request Nov 11, 2026
…5811)

Builds on #5806, which stopped `setScroll` making a scroll write that
moves nothing.

A reader at the end of a margin card's transcript fell behind when its
last turn grew after the card drew it, as when a picture in an answer
loaded: the reader was left 97px short of the end. The card kept the end
with two partial keepers: `keepFoot(transcript, {atEnd: true})` kept it
through a change of the transcript's room only, and the placement's fit
followed growth a reading of the thread drew (`buildThreadCard`'s
`follow`, the reading's `end` and `limit`). Growth after a reading
reached neither, since it changes no room and takes no reading.

`followEnd` (`browser/runtime/scrolling.js`) replaces both. It watches
the transcript and each turn in it, and puts a reader who stood at the
end back there whenever the end moves, whatever moved it: the reply box
taking room or giving it back, a fit, a turn drawn, a turn growing.
Whether the reader stood at the end is read at each scroll, against the
end as the box stood at its last size reading, so a scroll whose event
arrives between a change and its size reading counts against the end the
reader saw. A box moved back since that reading, or headed back by a
glide, stays where it was sent. A change that leaves the end where it
stood asks nothing, and a write to an end the reader already stands at
moves nothing, which `setScroll` skips (#5806), so the rubber band of a
flick into the end stays the browser's (#5763).

Before following, the keeper asks whether another placer owns the end.
The card answers that it does while it arrives on its opening turn, and
asks the thread (`ThreadView.placesEnd`). The thread owns the end while
an answer to the user's turn is its to place, as before, and now also
takes back an answer its end followed into sight once that answer grows:
`#fitAnswer` decides again, with the box as it stood before the growth,
whether the end follows or New reply stands for the rest, so a picture
loading in an answer can't carry the user's turn out of sight. Where the
answer still fits after scroll anchoring already carried the reader to
the new end, its write to the end moves nothing, which `setScroll` skips
(#5806).

The fit no longer follows the end, and `buildThreadCard` no longer
computes `follow`. `keepFoot` loses its `atEnd` mode; the floating
panel's thread view still uses it, and both keepers share the
observation of a box and its children (`watchHeld`).

Behavior changed: a reader at a card's end now follows any growth at
that end, a turn's late layout and a turn from anyone included, where
the card followed only a new or changed agent turn whose foot stood near
the reply box; and an answer that outgrows the card after the card
followed it says New reply, keeping the user's turn in sight.
`test_a_card_at_its_end_follows_its_last_turn_as_it_grows` and
`test_an_answer_a_card_followed_says_new_reply_once_its_picture_outgrows_it`
(plain and after progress) hold a picture's request until the reader
stands at the end, then let it load; both fail without the change. They
and the card's end, wheel, New reply and ride tests pass in Firefox too.
Three card tests fail on this branch and identically with main's runtime
files, so they come from main:
`test_a_thread_card_reply_stays_in_the_visible_viewport[tablet]`, and
the Firefox cases of
`test_a_press_that_changes_the_edge_holding_a_card_moves_it_from_where_it_stood`
and
`test_a_card_a_scroll_moves_onto_or_off_the_windows_foot_as_it_resizes_only_resizes`;
so does
`test_a_transfer_keeps_its_persisted_source_when_the_destination_write_fails[reply]`.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 12, 2026
…5839)

Every tap the suite sends through Playwright now waits until half a
second has passed since the page's previous tap, so Chromium never
counts it as the next press in a run. Chromium counts a touch tap within
about 25 px and 400 ms of the previous one as a double tap (click
`detail` 2 and a `dblclick`), and the floating panel presses nothing for
such a press on a control it drew since (`runOfClicks`). A test that
tapped faster than a person therefore passed only on a slow host. #5806
spaced `press_visible`'s taps, and about 30 raw `locator.tap()` calls
stayed unspaced. Instead of routing them through a helper guarded by a
source check, `fresh_taps` (`tests/render_harness.py`) wraps
Playwright's `Locator.tap` and `Touchscreen.tap`, the suite's only tap
routes. No call site changes, and `press_visible` loses its own copy.

On the 60 `tests/browser` tests that tap, Chromium counted 26 touch runs
on main and 2 with this change, both from finger holds sent as raw CDP
events. The waits add 64 s of sleep, which uses no CPU, across those
tests. The worst is 11 s in the playground focus test, spread over its
22 subtests. Waiting only when a tap's target box lay near the previous
one cut that to 33 s. A review then reproduced two double taps that
passed that check, from a target that moves after its tap and from one
that slides in, because Playwright doesn't report where a locator's tap
lands. So the wait ignores distance.

Spaced taps exposed a `shift_watch.js` gap that back-to-back taps had
hidden: a control that a tap shows under the finger takes `:active` and
lets go on Chromium's timer, and the watch didn't notice. The watch now
also checks the element at the release point, and
`test_a_tap_s_press_letting_go_is_heard` gains that case, which fails on
the old watch.

Requested by max-sixty after #5806. Tests: the 60 tap tests in
`tests/browser` and the tapping tests in `tests/journeys`, the
shift-watch press, tap and verdict tests, and `test_suite_source`. Two
failures are inherited and also fail with spacing off:
`test_a_root_summary_keeps_thread_actions_outside_its_fold[1400-True-10]`
and `test_a_finger_reaches_the_page_commands_its_keys_reach`.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 16, 2026
…eals a focused row (#6149)

`@pierre/trees` measures its viewport with `getBoundingClientRect`, so a
reveal target can be fractional. In the file-tree example the tree is
791.84px tall, and the target for a focused row at the bottom edge comes
out at 138.16 while Chrome holds `scrollTop` at 138. The library's
"already there" check compares exactly, so every focus change wrote
`scrollTop = 138.16`, which moved nothing and stopped any scroll under
way. #5806's unmoved-scroll watch reports that write, and
`test_presses_and_fills_leave_no_element_naming_stale_keys[file-tree]`
has failed on Linux in the Nov 12, 14 and 15 scheduled runs, most
recently
[43706054091](https://github.com/max-sixty/leaf/actions/runs/43706054091).

The trees bundle's `adapt` seams in `build/vendor.mjs` now also make the
library's four scroll-target comparisons treat a target within a pixel
of the current `scrollTop` as reached. The rebuilt bundle changes only
those comparisons. `@pierre/trees` 1.0.0 still compares exactly, so
upgrading wouldn't fix this. A row at the edge can now stay clipped by
less than a pixel instead of getting a write that moves nothing.

Verification: the journey failed 3 of 3 runs locally on main with `uo
(vendor/pierre-trees.esm.js…)` as the writer and passed 2 of 2 with the
change. The file-tree cases in
`tests/browser/test_render_diff_controls.py` (4) and
`tests/journeys/test_render_diff_controls.py` (3) pass, and so does
`build/browser/build.test.mjs`.

#5657's original 18 cases all pass in the Nov 15 scheduled run except
three that now fail with different messages and have their own owners:
card placement `[workspace-1000]` (#6047), the focus-ring sweep (#5832)
and macOS `thread-panel-gallery` (#6048). The `[file-tree]` case is the
one later diagnoses on #4225 filed under #5657.

Closes #5657 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 18, 2026
…the top (#6364)

`glideTo` aimed at fractional positions, and since #5806 `setScroll`
skips any write that lands within a pixel of where the box already
stands. So a glide could end a pixel off its goal: when a page of the
threads view measures about 159.7px, a late frame of `d`'s glide leaves
the box at 160, and the final write to 159.7 is skipped. `u`, pressed
once that glide has landed, then aims for 0.3. A late frame leaves the
box at 1, and the final write is skipped again. The view stops at
`scrollTop` 1, and `test_keys_in_threads_act_on_threads` times out
waiting for `scrollTop === 0`. #5806 landed the day before that test's
first failure.

The glide now rounds its goal and each frame's write to whole pixels, so
its last write always moves the box onto the goal. A goal at the box's
end stays exactly `scrollLimit`, because `scrollToEnd` and the glide's
`end` flag compare against it
([`scrolling.js`](https://github.com/max-sixty/leaf/blob/096f8a7737de4f76c7206fec7f1d014f4a35e7b2/browser/runtime/scrolling.js#L648-L666)).
Behavior change: `d`, `u` and every other glide end on a whole pixel.

Verification:
- The new runtime test in `tests/runtime/scrolling.test.mjs` drives a
glide's frames over a box that snaps to whole pixels. It fails before
the change (the box ends at 1) and passes after it. `pnpm run
test:runtime` passes.
- The CI picture of the failure matches a locally rendered threads view
at `scrollTop` 1 far better than one at 0 (1,499 differing pixels
against 11,477).
- In a 1440×503 window, `d` → wait → `u` left the view at 1 in 2 of 4
tries before the change and in 0 of 4 after it.
- 78 focused browser tests that exercise glides, paging and scroll
landings pass.

This fixes only `test_keys_in_threads_act_on_threads`. #5883's other
intermittent tests, the diff sideways reader and the visual action's
`Locator.focus` timeout, have different mechanisms and stay open there.

Refs #5883 — 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