Repository navigation
fix: end a reader's wheel sequence when Chromium applied the scroll before the wheel event - #5931
Merged
Merged
Conversation
…efore the wheel event Chromium can apply a wheel's scroll before it dispatches the wheel event, so `startReaderScroll` recorded the box already at the scroll's goal. The scroll's own `scrollend` then arrived with the box still where the input "found" it, so `awaitsReader` took it for some other scroll's end and the reader's sequence ran on for the 80 ms quiet spell after the scroll had ended. A keep holding the reader's place across a reply drawn above them in that spell (user-place.js, `holdUserPlace`) saw `browserScrolls` and yielded, so the reply took back 195px of a 300px wheel. The input now starts from where the page last heard the box stand (its last scroll event, Leaf write or stop) when the box has moved since unheard. A layout clamp keeps the box's end where it was last heard, so its scrollend still ends nothing of the reader's; where the browser applies the input's scroll after the input, as Firefox does, nothing changes. Behavior changed: after a wheel in Chromium, a reply or revision drawn above the reader within ~80 ms of the scroll ending is held in place again, as before #5834. Closes #5926
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
…cond reading #5931 made the reader's sequence record where the input found the box as where the page last heard it stand, since Chromium can apply a wheel's scroll before it dispatches the wheel. `aimScroll` still read `box.scrollTop` at the input for `readerScroll`'s `top` and `fromEnd`, a second copy of that fact which disagreed with the corrected one: a wheel up a log entries stream into, applied before its event, would have stood "where the input found it" at its end, and the end keeper would have put the reader back at the end. `startReaderScroll` now returns where the input found the box, and `aimScroll` takes its `top` from that. A runtime case holds it: a box heard at 150 and moved to 100 unheard is found at 150.
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.
Chromium can apply a wheel's scroll before it dispatches the wheel event. #5834's
startReaderScrolltherefore recorded the box already at the scroll's goal. When the scroll's ownscrollendarrived, the box still stood where the input had "found" it, soawaitsReadertook 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 (holdUserPlaceinuser-place.js) sawbrowserScrollsas 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
scrollTopalready at 2679, thenscrollendis heard withawaitsReadertrue, the keep runs 50 ms later withbrowserScrollstrue, 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
setScrollor a stop) whenever the box has moved since without the page hearing about it. That keeps #5834's intent in both of its cases:scrollendstill 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 main5606fc2c9(moved -105.0px) and passes with this change. Allwheel/smoothcases of that journey pass in both engines; the two Firefoxsmoothcases stay xfailed as before.tests/runtime/arrivals.test.mjsfails before the change and passes after. The full runtime suite passes (965 tests).test_obligations_sharing_context_keep_their_source_identityfailed, but it fails 2 of 4 runs on main without this change too.Closes #5926 — automated triage