Repository navigation
Keep a log's end with the card's keeper, and treat the reader's scroll as theirs from the input - #5834
Merged
Conversation
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 ignored any reading in which a turn changed size. The placement's fit followed the growth a reading of the thread drew, through `buildThreadCard`'s `follow` (an agent turn that changed, its foot near the reply box) and the reading's `end` and `limit`. Growth after a reading reached neither, since it changes no room and takes no reading.
`followEnd` (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 that has yet to move it, stays where it was sent. Layout may carry it toward the end in the change itself, as Chromium's scroll anchoring did by 58px when a shorter window shrank a card's transcript, and that reader still follows. A change that leaves the end where it stood, or the reader at it, writes nothing, 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, with how the box stood before the change. The card answers that it does while it arrives on its opening turn (`showArrival`), and asks the thread (`ThreadView.placesEnd`). The thread owns the end while an answer to the user's turn is its to place (`answering`), as before. It 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. The keeper asks before it checks whether the reader is already at the new end, since Chromium's scroll anchoring carries a reader there in the same layout when the node it anchors stands below the picture. Where the answer still fits, its placement then writes the end the reader already stands at, which `setScroll` skips while nothing moves the box (the change this branch stands on).
The fit no longer follows the end, and `buildThreadCard` no longer computes `follow` or keeps the latest turn for it. `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` each hold a picture's request until the reader stands at the end, then let it load; both fail without the change.
…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.
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.
…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.
… of nothing followEnd checked that the reader wasn't already at the new end before it wrote, its own copy of setScroll's rule, kept while setScroll still wrote in place for a box the browser was scrolling and so would have stopped the user's scroll. With the stop its own write (scroll-write-watch), a restated end writes nothing, and the copy goes.
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, already lets a box a glide heads back from go, and judges a reader's scroll against the end as the box stood at its last size reading. 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`), as its own follower did: 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 also: - takes its first reading as it starts, rather than at the first scroll event, which absorbed a change made in between and left the reader short of the end; - reads nothing while its box isn't drawn, as in a hidden tab or a shut disclosure; - says whether its reader stands at the end (`standsAtEnd`), which a revision asks of a bounded log to record its place, by the test it follows by or at the end as the box now stands: a reader scrolled back before that scroll's event arrives, or headed back by a glide, isn't at the end. bounds.js's own answer missed the glide. Behavior changed: a page-up or other glide away from the end of a following log while entries arrive now moves the log, where it was sometimes undone; and a revision captured just after a glide up a following log starts records the reader's line rather than the end. `test_a_page_up_in_a_log_a_stream_feeds_leaves_its_end` presses u six times mid-stream in Chromium and Firefox; it failed in 3 of 4 runs with the old follower. `test_a_log_follows_text_it_gains_and_opens_at_its_end_once_drawn` holds two cases a first version of this change missed.
leaf-agent
previously approved these changes
Nov 11, 2026
…r scroll with a write both engines honour 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; Firefox applies a wheel's or key's scroll that late too. Anything that asked in between heard that nobody was scrolling: - The end keeper (`followEnd`) 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. - `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 (scroll-containers.js, `inputScroller`, moved there from version.js with `scrollChainOf` from reading-regions.js; arrivals.js, `startReaderScroll`), 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: read as the reader's scroll, either made a keep holding the user's place stand down. 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 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`, which a revision records a log's place by) until that scroll ends, and 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 instead, and layout moving the box meanwhile, a clamp or an anchoring adjustment, read as the reader leaving; Codex's review found that and the cases above. `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 wheel, PageUp or arrow key up a following log in Firefox moves it while entries arrive; `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 until its scroll's quiet spell ends, about 80 ms.
leaf-agent
approved these changes
Nov 11, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 11, 2026
…efore holding news (#5837) A reader at the end of a margin card's transcript saw an agent's edit to the last turn wait behind the card's "1 new" notice when the edit arrived in the same task as that turn grew, for example as a picture in it loaded. The card's held-news check (`thread-card.js`, `newsMoves`) asked the transcript's scroll offset whether the reader followed the end. In that task the picture had already pushed the end 97px past the reader, and the end keeper hadn't yet read the growth. So the check said no and the edit waited. One frame later the keeper took the reader to the end, and the notice still stood for words they would have seen. The transcript's end keeper (`scrolling.js`, `followEnd`, from #5811 and #5834) already owns that answer in `standsAtEnd`. `thread-preview.js` now keeps the keeper itself rather than only its `stop`, and gives the card a `standsAtEnd` outlet, which `newsMoves` asks in place of the offset. Nothing outside `scrolling.js` calls `followsEnd` any more, so it is no longer exported, and `browser/AGENTS.md`'s question index points at `followEnd`. What to weigh: since #5834, `standsAtEnd` reads false from the moment a wheel or key heading up arrives, before the box moves. News to the last turn in that frame now waits, as it would a frame later once the box has moved. The keeper doesn't follow that reader either, so the check and the keeper agree. `test_an_edit_landing_as_a_card_s_last_turn_grows_shows_at_its_end` holds the page's state reading until the picture's `load` event fires, so the reading is taken in that task. It fails on the old check and passes with this change. The card's other held-news tests, the `u`-press glide smoke test and `pnpm run check` pass. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 12, 2026
A scroll write cancels the scroll the browser is about to apply for the reader's wheel or key, which Firefox applies a frame or more after the input. #5834 made the input open the box's scroll sequence (arrivals.js, `startReaderScroll`) and taught the end keeper to let go of an input heading up. A review of #10, "one owner for who controls a box's scroll", ran the remaining writers against that and found more still cancelling the reader's scroll or taking their place. Each now asks the facts the sequence record already holds, rather than a second owner: - The end keeper (`followEnd`) let go only of an input heading up, so in Firefox its writes cancelled a wheel across a log's long lines while entries streamed in (scrollLeft stayed 0; Chromium reached 176). `leavesEnd(box)` (scrolling.js) says whether the reader's input heads the box up or across and its scroll hasn't ended; a wheel heads down where it moves down more than across, so a trackpad's drift doesn't hold the end. While it holds, the keeper writes nothing but keeps reading. A size reading is layout's, a clamp's or an appended entry's, and takes that move in before the move's own scroll event; so a scroll event that finds the box moved is the reader's, or Leaf's, as `g g` pressed meanwhile. At the first reading of the drawn box after the scroll ends, a reader who stood at the end and whom no scroll took from it, as an input a handler prevented leaves them, is put at the end. This replaces the keeper's snapshot of the input and the callback map `aimScroll` called. Two rejected versions: one that stopped reading took a log emptied and refilled during a wheel across for the reader's move, and one that judged each reading by the box's distance from its end read a log that lost its oldest entries and gained new ones in one change as the reader's. - The panel thread view's foot keeper (`keepFoot`) moved the view as it gave up room during a wheel, cancelling the wheel in Firefox: from 400, a wheel of 200 up with 100px of room taken ended at 500, not 300. It now owes the move while the reader's scroll runs (arrivals.js, `readerScrolls`) and makes it from wherever that scroll left the view, unless the scroll ended at an edge, as Home's does, or Leaf started a move meanwhile, as `g g` does. - `scrollsFor` read every control as taking every scroll key, so PageUp on a link, a radio or a button, or ArrowUp on a button, in a log entries stream into opened no reader scroll, and the keeper cancelled it in Firefox, 3 trials of 3. A link takes Enter alone, a plain press Enter and Space, a radio its arrows (control-selectors.js, `LINKS`, `PLAIN_PRESSES`, `RADIOS`); the browser scrolls for the rest. The glide stop's `aimsScroll`, which disagreed with it on controls, is now a touch or `scrollsFor`. - The place keep (`holdUserPlace`) gave up for a scroll chosen in any box; it now yields only to a choice in a box scrolling the place it keeps (`chosenSince`), so a landing in another pane no longer leaves a focused control to move 100px. - A restore's reveal of the control the reader was on (reading-place.js, `restorePlace`) counted as the reader's choice, through the landing it makes (landing-scroll.js, `scrollIntoView`), so a place keep open meanwhile gave up: a window resized while a diff's new source drew left the focused control 262px down. `scrollIntoView` takes `kept` for a reveal that returns the reader to a place they had, which records where it left each box (`placeKept`) instead. Behavior changes: Space or an arrow on a radio, select or range no longer stops a Leaf glide, since the control takes the key; a scroll key on a link or button now does. The end keeper reads its box again at every scroll end. Not changed, on the review's evidence: one rule in `setScroll` refusing writes while the browser scrolls (served as a scratch copy, it dropped the foot keeper's correction and left a log's tail 1,407px below the window after a wheel across); the answer placement's own policy, which keeps #11's `readerScrolls` checks; and continuity's correction for the end of a restore's scroll that layout moved on (`writing`/`ownEnd` in version.js), which no case showed failing for another consumer. Tests: the streamed-log test gains "PageUp on a link" and "wheel across", which fail in Firefox on the previous runtime and pass now, with Chromium and PageUp on the log as controls. The log test's refill case gains a wheel across, which fails on a keeper that stops reading during it. `test_a_wheel_as_the_thread_gives_up_room_moves_it_as_far_as_without` fails in Firefox on the previous runtime (moved -100 for an expected 100) and passes in both engines. Unit tests cover `scrollsFor` on links, buttons and radios, `leavesEnd`, and the per-box keep. The navigation, diagonal-wheel, hidden-log, Home and resize cases ran as probes in both engines.
max-sixty
added a commit
that referenced
this pull request
Nov 12, 2026
…ents CI's Chromium found the keeper's last attribution wrong: PageUp up a log entries stream into was pulled back to the end in every trial. The keeper took a scroll event that found the box moved for the reader's move, and a size reading for layout's; but a reading taken between two frames can find the box already moved by the reader's scroll before that scroll's own event fires, and then the event finds nothing. No reading tells the reader's moves from layout's, so the input says. `readerScroll(box)` (scrolling.js) now gives which way the reader's input heads the box, down, across or up, where its first input found it, from its top and from its end, and how many moves Leaf had started in the box then. When the scroll ends, the keeper puts a reader who stood at the end back there only where Leaf started no move meanwhile (as `g g` would) and the scroll moved nowhere up or down: across, a scroll moves the box up or down by nothing, so every such move is layout's; up, the box stands where the input found it, from its top or from its end, which is #5834's rule. A wheel that moves up but more across, as (100, -80) does, now counts as across, and the keeper puts the reader back at the end after it. The question index row naming two modules read as one module's exports (`test_each_owner_in_the_question_index_is_exported_by_its_module`); it is two rows now.
This was referenced Nov 13, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 13, 2026
…efore the wheel event (#5931) Chromium can apply a wheel's scroll before it dispatches the wheel event. #5834's `startReaderScroll` therefore recorded the box already at the scroll's goal. When the scroll's own `scrollend` arrived, the box still stood where the input had "found" it, so `awaitsReader` took that event for the end of some other scroll. The reader's sequence then stayed open for the 80 ms quiet spell after the scroll had actually ended. If a reply was drawn above the reader during that spell, the keep that holds their place (`holdUserPlace` in `user-place.js`) saw `browserScrolls` as true and yielded. The reply then took back 195px of the reader's 300px wheel. A trace of the failing case shows the order: the wheel event fires with `scrollTop` already at 2679, then `scrollend` is heard with `awaitsReader` true, the keep runs 50 ms later with `browserScrolls` true, and the sequence ends 40 ms after that. On #5834's parent, the keep wrote the place back at that point. With this change, a reader's input starts from where the page last heard the box stand (its last scroll event, a Leaf `setScroll` or a stop) whenever the box has moved since without the page hearing about it. That keeps #5834's intent in both of its cases: - **Firefox**, which applies the input's scroll after the input: the box hasn't moved unheard, so the behavior is unchanged. - **A layout clamp as a log loses entries:** the clamp keeps the box's end where the page last heard it, so its `scrollend` still ends nothing of the reader's. **Behavior changed:** after a wheel in Chromium, a reply drawn above the reader just after the scroll ends is held in place again, as before #5834. **Verification:** - `test_the_page_holds_still_under_the_user[wheel-reply-above-chromium]` fails on main `5606fc2c9` (`moved -105.0px`) and passes with this change. All `wheel`/`smooth` cases of that journey pass in both engines; the two Firefox `smooth` cases stay xfailed as before. - A new case in `tests/runtime/arrivals.test.mjs` fails before the change and passes after. The full runtime suite passes (965 tests). - I also ran the browser tests #5834 added or changed: 108 of 109 pass. `test_obligations_sharing_context_keep_their_source_identity` failed, but it fails 2 of 4 runs on main without this change too. Closes #5926 — automated triage Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
…it (#5863) A scroll write cancels the scroll the browser is about to apply for the reader's wheel or key, and Firefox applies that scroll a frame or more after the input. #5834 made the input open the box's scroll sequence (arrivals.js, `startReaderScroll`), so a writer can know the reader has the box before it moves. This PR has every writer that was still cancelling the reader's scroll, or taking their place, ask that record. It began as the fix for the answer placement below, and grew with a review of "one owner for who controls a box's scroll", which ran the other writers and found more. The review's verdict was to share the facts the sequence record already holds, not to build a second owner or one rule in `setScroll`: served as a scratch copy, that rule dropped corrections other writers owe and left a log's tail 1,407px below the window. **Answer placement** (thread-card.js, `#fitAnswer`): a reader at the end of a card's transcript, or of the panel's thread view, who wheeled up as the answer to their turn arrived was put back, since the placement read the box at its old end and then moved their turn into sight. `readerScrolls(box)` says whether the reader's input has the box scrolling; the placement treats that reader as standing where the scroll takes them, at the read and again before its delayed write. A reader at the end whose wheel or key down moves nothing, as the answer arrives within that scroll's quiet spell, now gets New reply without their turn being moved into sight. Probes (Firefox): card 1110 → write 1148, wheel lost; now 1110 → 810. Panel 699 → 729; now 699 → 399. **End keeper** (scrolling.js, `followEnd`): it let go only of an input heading up, so its writes cancelled a wheel across a log's long lines while entries streamed in (Firefox: scrollLeft stayed 0). `readerScroll(box)` says which way the reader's input heads the box, down, across or up, and where its first input found it, as the reader's sequence records it (arrivals.js, `startReaderScroll`, which since #5931 takes where the page last heard the box, as Chromium can apply a wheel before dispatching it); a wheel counts by the axis it moves most along, so a trackpad's drift down doesn't hold the end. While a scroll across or up runs, the keeper writes nothing. When it ends, at the first reading of the drawn box, a reader who stood at the end is put back there only where Leaf started no move meanwhile (as `g g` would) and the scroll moved the box nowhere up or down: across, every such move is layout's; up, the box stands where the input found it, from its top or from its end (#5834's rule). No reading during the scroll tells the reader's moves from layout's: an attribution by scroll events, tried here, passed locally and failed on CI's Chromium, where a reading between frames found the box already moved by PageUp before PageUp's own scroll event. **Foot keeper** (scrolling.js, `keepFoot`): the panel's thread view moved as it gave up room during a wheel, cancelling the wheel in Firefox (from 400, a wheel of 200 up with 100px of room taken ended at 500, not 300). It now owes the move until the reader's scroll ends, and drops it where that scroll ended at an edge, as Home's does, or where Leaf started a move meanwhile, as `g g` does. **Keys on controls** (scrolling.js, `scrollsFor`; control-selectors.js): every control was read as taking every scroll key, so PageUp on a link, radio or button, or ArrowUp on a button, in a streaming log opened no reader scroll and the keeper cancelled it in Firefox. A link takes Enter alone, a plain press Enter and Space, a radio its arrows; the browser scrolls for the rest. The glide stop now uses the same predicate, so Space or an arrow on a radio, select or range no longer stops a Leaf glide, and a scroll key on a link or button does. **Place keep** (user-place.js, `holdUserPlace`; landing-scroll.js, `scrollIntoView`): the keep gave up for a scroll chosen in any box; it now yields only to a choice in a box scrolling the place it keeps. And a restore's reveal of the control the reader was on counted as their choice, so a window resized while a diff's new source drew left that control 262px down; `scrollIntoView` takes `kept` for a reveal that returns the reader to a place they had, which `restorePlace` passes. Left as they were: touch drags, which no engine here can drive in Firefox; ArrowLeft and ArrowRight, which Leaf doesn't count as scroll keys; a wheel moving up but more across, which counts as across, so the keeper puts the reader back at the end after it; a reader at a capped log's end whose input up moved nothing while the log lost its oldest entries and gained new ones in one change, whom the keeper stops following, as on main; and continuity's correction for the end of a restore's scroll that layout moved on (`writing`/`ownEnd` in version.js), which no case showed failing for another consumer. Tests: the streamed-log test gains "PageUp on a link" and "wheel across"; the log test's refill case gains a wheel across; `test_a_wheel_as_the_thread_gives_up_room_moves_it_as_far_as_without` is new; `test_a_wheel_up_a_card_as_its_answer_arrives_goes_where_it_takes_the_reader` covers the answer placement. Each fails on the runtime without its fix, in Firefox (the answer placement's in Chromium too), and passes with it. Unit tests cover `scrollsFor`, `readerScroll` and the per-box keep. The navigation, hidden-log, refill, trim-and-append, Home and resize cases ran as probes in both engines, with the reviewer's reproducers from all three rounds. Locally, the focused browser selection (bounded logs, card and panel threads, keys, glides, reading places and place keeps) passes except `test_an_open_view_covers_the_page_beneath_it`, which fails intermittently on main too (#5744). CI's `test` at 54a6771 failed two server-lifecycle tests in `tests/model/test_session_lifecycle.py` (`test_a_prompt_says_why_a_page_did_not_start_and_tries_again[port held]`, `test_a_prompt_serves_only_a_page_its_session_still_means_to_serve`), where a prompt's server start did not become ready in time; this PR changes no Python, both pass locally on this branch, and another PR's run in the same quarter-hour failed other tests of that module the same way, so they are inherited. > _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.
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 inbounds.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.jsnow 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.jskeeps 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:
afterBrowserScrolldidn't wait for PageDown whendcame before PageDown's first scroll event, soPageDown dtyped 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 toscroll-containers.jsfrom version.js, withscrollChainOffrom reading-regions.js) names the box, andstartReaderScroll(arrivals.js) opens its sequence, sobrowserScrollsholds from the input andkeyScrolledsays 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. Ascrollendheard 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.stopWhereItStandsstopped 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, andmpressed 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;
dtyped right after PageDown steps on from where PageDown lands;mpressed 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_endaims 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_landednow pressesPageDown dback to back andmduring PageDown; both failed before this change.test_a_landing_that_moves_nothing_stops_a_scroll_still_under_waynow also runs in Firefox, where it failed.test_a_log_follows_text_it_gains_and_opens_at_its_end_once_drawnholds 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.mjsholds which inputs the browser scrolls for, andarrivals.test.mjsthe 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 (
#fitAnswerin 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.