Repository navigation
Stop a margin card writing its transcript back to its end when nothing moved it - #5763
Merged
Merged
Conversation
…g moved it
Scrolling a long thread in a margin card in Firefox on macOS, with a
Magic Mouse, made the transcript's rubber band snap flat instead of
easing back. The card was fighting the browser for the transcript's
end. At every scroll's end, `user-place.js` repaints the page, which
places the card again, and the placement's fit (`measureThreadCard`)
called `scrollToEnd` on any transcript within 2px of its end, whether
or not anything had moved that end. `scrollToEnd` writes the
whole-pixel `scrollHeight - clientHeight`, which at a 2x display stands
a fraction short of where Firefox ends (314 against 314.25), so each
write moved the box, the running flick moved it back, and 90ms later
the card wrote again. A script's scroll write cancels the overscroll
animation Firefox runs for momentum into an edge, and that cancellation
clears the overscroll, so each write flattened the band.
The fit now follows the end only where `scrollLimit` moved since the
reading: each reading records where the end stood (`limit`), and the
reading taken before a render keeps the end from before an answer grew
it, so a streaming answer still carries a reader at the end along, as
does a fit that rewraps or re-caps the card. A placement that moves
nothing writes nothing.
Behavior changed: a card scrolled to its end by the user takes no scroll
write from its placement. The native rubber band at the transcript's
edge stays. `test_a_card_wheeled_to_its_end_stays_where_the_browser_put_it`
fails without the change (one `scrollTo` in Chromium).
## Evidence
The reported session's observation log on `red-suite-owners` (Firefox
159, pixel wheel deltas that decay, so a Magic Mouse) shows the
transcript at 314.25 and then 314, 89-92ms later, 20 times in the minute
before the report, with no wheel event pointing back.
Reproduced in Firefox 159, headless at a 2x pixel ratio, with native
touchpad pans through Firefox's async scrolling: before, a flick that
reaches the end (298.25) gets `scrollTo({top: 298})` 93ms later and every
~95ms after, each answered by Firefox putting 298.25 back; after, no
write. In Chromium the same wheel journey made 31 writes before (one a
frame while the wheel pushed at the end) and none after. The panel's
thread view (Open in panel) wrote none in either version.
That a write clears the band is read from Gecko's source:
`AsyncPanZoomController::CancelAnimation` clears overscroll, a scroll
update cancels any animation that can't absorb it, and
`OverscrollAnimation` absorbs none.
leaf-agent
approved these changes
Nov 9, 2026
This was referenced Nov 10, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 11, 2026
…d report one that does neither (#5806) 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_
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 11, 2026
…l as theirs from the input (#5834) Two changes to how Leaf keeps a box's end and who owns a scroll under way. Both came up on the thread card's Firefox bounce (#5763), and both are on the path a reader of a streaming log takes. ## One keeper for a log's end A block bounded at its end (`data-bound="end"`) followed its newest entry with a follower of its own in `bounds.js`, which judged a reader at the end from the box's offset alone. A press of u inside such a log starts a glide whose first frame can leave the box where it stands, so when an entry arrived before the glide moved, the follower took the reader for one still at the end, put the log back there and stopped the glide: the press did nothing, in 1 of 8 presses in Chromium and 4 of 8 in Firefox while entries streamed in every 4 ms. `followEnd` (`scrolling.js`), written for a margin card's transcript in #5811, already lets a box a glide heads back from go. `bounds.js` now opens a following block at its end once it is drawn and hands it to that keeper, so Leaf keeps a reader at a box's end one way. `bounds.js` keeps its watch on what a log holds and asks the keeper to read the log at each change (`check`): text grows a `<pre>` log without resizing any element a size observer reports, and a log emptied and refilled in two steps is clamped to its top in between. The keeper takes its first reading as it starts, reads nothing while its box isn't drawn, and says whether its reader stands at the end (`standsAtEnd`), which a revision asks of a bounded log to record its place. ## The reader's scroll is theirs from the input Leaf learned that the reader had set a box scrolling only from the box's first scroll event, which comes a frame or more after the wheel or key, and Firefox applies a wheel's or key's scroll that late too. Anything that asked in between heard that nobody was scrolling: - The keeper wrote a streaming log's end at each new entry, and Firefox cancels its pending scroll for a script write that moves the box, so a wheel, PageUp or ArrowUp up a log fed every 4 ms was pulled back to the end every time, on main too. - `afterBrowserScroll` didn't wait for PageDown when `d` came before PageDown's first scroll event, so `PageDown d` typed as a pair didn't add up, in Chromium and Firefox. An input the browser scrolls for (`scrollsFor`: a wheel, or a scroll key pressed where focus rests on no control) now starts the scroll sequence of the one box it moves: `inputScroller` (moved to `scroll-containers.js` from version.js, with `scrollChainOf` from reading-regions.js) names the box, and `startReaderScroll` (`arrivals.js`) opens its sequence, so `browserScrolls` holds from the input and `keyScrolled` says whether a key set it going. A touch may be a tap and a control takes keys of its own, as Space presses a button, so neither counts. A `scrollend` heard while the box still stands where the input found it, from its top or from its end, ends some other scroll, as Firefox ends a write it applied before the input and layout a clamp as a log loses its oldest entries, so it ends nothing of the reader's; an input that moves nothing ends after the 80 ms quiet spell. An input heading up a box tells its end keeper, which writes no end and says its reader isn't at the end (`standsAtEnd`) until that scroll ends, then reads the box again; where the input moved nothing, as one a handler prevented, it catches up with what it held back. A first version deferred the keeper's writes for any input, and layout moving the box meanwhile read as the reader leaving. `stopWhereItStands` stopped too little: Firefox ignores an instant write of the position the page last saw, and in Chromium 158 and Firefox 159 no instant write, even one that moves the box, stops the smooth scroll a key such as PageDown sets off. So a landing that moved nothing let a smooth scroll run on in Firefox, and `m` pressed as PageDown moved the page lost its landing to PageDown in both engines. A smooth write to where the box stands, then an instant one, stops each. **Behavior changed:** a page-up, wheel or arrow key away from the end of a following log while entries arrive now moves it, in both engines; `d` typed right after PageDown steps on from where PageDown lands; `m` pressed during PageDown lands; a landing that moves nothing stops a smooth scroll in Firefox too. A wheel or key up a following box that moves nothing pauses its following for about 80 ms. **Left as it was:** a key pressed on a control (a link or a button in a log) and a touch drag are still read from their first scroll event, as on main, since the input alone doesn't say a scroll follows. ## Tests - `test_a_page_up_in_a_log_a_stream_feeds_leaves_its_end` aims u, PageUp and a wheel up a streaming log in Chromium and Firefox; PageUp and the wheel fail 6 of 6 in Firefox on main. - `test_keys_pressed_while_the_page_moves_act_as_if_it_had_landed` now presses `PageDown d` back to back and `m` during PageDown; both failed before this change. - `test_a_landing_that_moves_nothing_stops_a_scroll_still_under_way` now also runs in Firefox, where it failed. - `test_a_log_follows_text_it_gains_and_opens_at_its_end_once_drawn` holds the `<pre>` log, a log first drawn late, and a log refilled just after End at its end; each failed on an earlier version of this change. - `tests/runtime/scrolling.test.mjs` holds which inputs the browser scrolls for, and `arrivals.test.mjs` the reader's sequence and the two-write stop. An independent Codex review ran three rounds. It found five regressions in earlier versions of the second change (a deferral that lost a clamp or an anchoring move, Space on a button and a tap standing down a place hold, control keys no longer stopping a glide); each reproducer passes on this head in Chromium and Firefox. Its last round also named cases left as on main: the thread card's answer placement (`#fitAnswer` in thread-card.js) decides from the offset before a wheel up and writes after it, and keys on controls (above). Locally the 915 runtime unit tests pass, and so do 227 of 228 browser tests over bounded blocks and card ends and 625 of 628 scroll-heavy browser tests. The failures also fail on main: `test_sending_flashes_only_the_new_message[card]`, `test_a_resolve_s_notice_stands_for_that_resolve_alone`, `test_a_transfer_keeps_its_persisted_source_when_the_destination_write_fails[reply]`, and the attached-image test's teardown. > _This was written by Claude Code on behalf of max-sixty_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scrolling a long thread in a margin card in Firefox on macOS, with a Magic Mouse, made the transcript's rubber band snap flat instead of easing back. The card was fighting the browser for the transcript's end. At every scroll's end,
user-place.jsrepaints the page, which places the card again, and the placement's fit (measureThreadCard) calledscrollToEndon any transcript within 2px of its end, whether or not anything had moved that end.scrollToEndwrites the whole-pixelscrollHeight - clientHeight, which at a 2x display stands a fraction short of where Firefox ends (314 against 314.25), so each write moved the box, the running flick moved it back, and 90ms later the card wrote again. A script's scroll write cancels the overscroll animation Firefox runs for momentum into an edge, and that cancellation clears the overscroll, so each write flattened the band.The fit now follows the end only where
scrollLimitmoved since the reading: each reading records where the end stood (limit), and the reading taken before a render keeps the end from before an answer grew it, so a streaming answer still carries a reader at the end along, as does a fit that rewraps or re-caps the card. A placement that moves nothing writes nothing.Behavior changed: a card scrolled to its end by the user takes no scroll write from its placement. The native rubber band at the transcript's edge stays.
test_a_card_wheeled_to_its_end_stays_where_the_browser_put_itfails without the change (onescrollToin Chromium).Evidence
The reported session's observation log on
red-suite-owners(Firefox 159, pixel wheel deltas that decay, so a Magic Mouse) shows the transcript at 314.25 and then 314, 89-92ms later, 20 times in the minute before the report, with no wheel event pointing back.Reproduced in Firefox 159, headless at a 2x pixel ratio, with native touchpad pans through Firefox's async scrolling: before, a flick that reaches the end (298.25) gets
scrollTo({top: 298})93ms later and every ~95ms after, each answered by Firefox putting 298.25 back; after, no write. In Chromium the same wheel journey made 31 writes before (one a frame while the wheel pushed at the end) and none after. The panel's thread view (Open in panel) wrote none in either version.That a write clears the band is read from Gecko's source:
AsyncPanZoomController::CancelAnimationclears overscroll, a scroll update cancels any animation that can't absorb it, andOverscrollAnimationabsorbs none.