Repository navigation
Move every Leaf scroll onto one glide, and end each scroll once for every reader - #5285
Merged
Merged
Conversation
…very reader Landings (`m`, `t`, a link, Back) now glide as the reading keys do, instead of riding the browser's smooth scroll, which takes 450–870 ms in Chromium and Firefox and has no way to set its pace. The handoff between the two mechanisms goes with it: the record of where a native landing was headed, the glide's takeover of a landing, and the `moving` map that told the two apart. Glides are per box, so a landing glides each nested scroller it moves at once. An `auto` landing in a box whose CSS asks for smooth scrolling glides too. A reading-page step pressed while the browser's own Space or PageDown scroll still moves the page waits for it to land and steps on from there, as the browser's paging keys chain; it used to be dropped. A step pressed during a wheel's or a touch's momentum takes the box at once, as the browser's own keys do. arrivals.js becomes the one owner of when a scroll ends. It hears `scroll` and `scrollend` in the document, every shadow stage and any tree a module enrolls, and ends each box's sequence once: at its `scrollend`, or after a quiet spell of 80 ms and two rendering updates. A script that writes a scroll frame by frame holds the sequence open (`holdScroll`), replacing the page-wide `scrollGlides` flag. The choice bookkeeping in scrolling.js, continuity's place recording in version.js and the margin's re-placement listen there instead of to raw `scrollend`, and a lint rule keeps runtime code from listening itself. A `d` glide no longer records the reading place on every frame: 254 ms of `recordPlaces` on main, 64 ms here, in Chromium on the probe page. Behavior changes: landings take 140 ms in every engine; `d` pressed during Space or PageDown adds to it in Chromium and Firefox.
# Conflicts: # browser/runtime/annotation-overlay/margin-layout.js # dist/kernel/kernel.json # dist/kernel/leaf.js # dist/kernel/runtime/bundle-comment-placement.js # dist/kernel/runtime/bundle-portable.js # dist/kernel/runtime/check-api.js
# Conflicts: # dist/kernel/kernel.json # dist/kernel/runtime/bundle-comment-placement.js
…de holds from its press `browserScrolls` called any open scroll sequence the browser's once no hold kept it open. A glide's or a landing's last write keeps its sequence open for a quiet spell after the release, so a step pressed in that spell read the finished motion as the browser's, took it over, and started from wherever the box stood at its first frame. A hand that moved the box between the press and that frame was ignored, and the glide pressed on to its goal: `test_the_reading_keys_accumulate_and_reverse` read 1447 where the user left the box at 400, under load. `setScroll` now records where a script last put each box until its sequence ends, and the browser moves a box only once it has left that place. The held-scroll unit test checks both sides.
leaf-agent
reviewed
Nov 4, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Pressing d twice while the browser's own PageDown is still scrolling loses both presses (inline), so the claim that steps pressed during PageDown add up holds only for a single press. I can push the reorder and a d d test phase if you'd like.
Pressing `d` twice while the browser's PageDown still scrolled lost both presses: the first `d` keydown counted as the latest input, so PageDown's next frame stopped counting as a key's scroll, the second `d` took the box over at once, and its glide dropped the first `d` waiting for PageDown to land (735 px where typing slowly ends at 1667, found by the PR review). Only the inputs that set the browser scrolling now decide whether its scroll is a key's: a pointer, a wheel or a touch, or one of its scroll keys. Any other key leaves that as it was. A step pressed while others wait on the box also joins them before anything else is asked, so waiting steps run in the order pressed. The typeahead test gains a `d d` phase, which fails without this change.
leaf-agent
approved these changes
Nov 4, 2026
This was referenced Nov 4, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 4, 2026
…y, since landings no longer smooth-scroll (#5311) #5285 replaced the browser's smooth scroll with Leaf's own glide for every landing, so nothing calls `scrollTo({behavior: 'smooth'})` on the page any more. Four tests created their "interrupt before the first frame" moment by wrapping that call, so since #5285 their hook never fires: - `test_primary_arrival_records_a_return_place_only_when_travelling[False-True-1000-False-True]` fails on `backRequestedAt is not defined`. - `test_a_thread_trip_takes_over_an_outgoing_trip_before_its_first_frame[walk|passage]`, `test_a_visible_datum_takes_over_pending_thread_motion` and `test_comment_follows_a_thread_current_location_instead_of_an_earlier_draft[-True]` time out waiting for the hook. Each test now uses one shared helper, `before_landing_frame` in `tests/render_harness.py`, which wraps the `pushState` that adds the trip's return stop. `arrive` commits that entry and starts the landing in the same synchronous handoff ([`anchor-travel.js`](https://github.com/max-sixty/leaf/blob/f93acc02c72769506f84e47ea7d7b08e248edfc2/browser/runtime/anchor-travel.js#L178-L187)), and the glide writes nothing until its first frame. So the interruption still lands before the page moves, and it no longer depends on which mechanism scrolls the page. Each test protects the same behavior as before. Verified locally on Linux: all five cases failed on `origin/main` and pass on this branch. Under `leaf-dev flake` (18 concurrent copies each) every case passed, and the primary-arrival test also passed every copy at `--cpu-throttle 4`. This leaves the failure #5188 reports open. That failure was a missing history entry on macOS, intermittent across all four primary-arrival cases in the nightly runs before #5285, alongside `scrollY` reading 0 instead of 200. It does not reproduce on Linux even throttled, and the next nightly is the first `test-macos` run on the glide. Refs #5188 — automated triage Co-authored-by: leaf-agent <[email protected]>
This was referenced Nov 5, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
…first frame (#5518) `test_a_thread_walk_starts_one_page_trip_and_reveals_its_nested_passage` has failed on main since #5285 because its threshold was built for the browser's smooth scroll, and #5285 replaced that on purpose. The test now checks the regression it was written for, a page jump in the press's own task, instead of how far the first animation frame goes. **Cause.** #5285 moved every landing onto Leaf's own glide: 140 ms of cubic ease-out (`glideTo` in `browser/runtime/scrolling.js`). Even when its first frame comes on time, that covers about a third of the trip, roughly 390 of the 1224 px here. Native smooth scroll started slowly, so `firstPage < 100` used to tell a jump from a smooth start, but against the glide it can't. On this runner the frame after `t` came 70–90 ms after the press, so the first page `scroll` event already read 1025–1146 px, and the frames after it eased monotonically to 1224. **Change.** The old bug was `scrollIntoView` moving the document to its nearest edge before the centred landing, and that move happens in the press's task. A `keydown` capture listener registered after the runtime's reads the page, the rail and the local scroller once the walk has handled `t`. At that point the nested scrollers have moved and the page has not. Once the passage is centred, the test also checks that the page's scroll positions only ever increase, so the page makes one trip. The interface and #5285's intent are unchanged; only the test moved. **Verification.** On current main the test fails as reported (`firstPage: 1025`). With this change it passes three runs in a row. Reintroducing the nearest-edge reveal on the page (dropping `if (box === targetScroller) inside = false;` in `innerMoves`) makes the new check fail with `page: 830`. <details><summary>Not changed here: the glide's clock and a late first frame</summary> `glideTo` starts its clock at the press. When the press's work holds the next frame back, as it did here by 70–90 ms, most of the ease runs out before anything is drawn, and the first frame that moves the page shows it about 90% of the way there. The first tick's rAF timestamp also came before the press (about 2845 ms against 3011 ms), so it was clamped to t = 0 and wrote no movement. Starting the clock at the first frame would change how long every landing and reading key takes, which is a product decision for #5285's line of work and not part of this test repair. Whether that delay also happens on a desktop, rather than this headless runner, hasn't been measured. </details> Closes #5476 — automated triage Co-authored-by: leaf-agent <[email protected]>
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.
Landings (
m,t, a link, Back) now glide as the reading keys do, instead of riding the browser's smooth scroll, and one module decides when a scroll ends for every reader. Follows #5227.One glide for every Leaf motion
A script's smooth scroll is slow by each engine's design and has no way to set its pace: Chromium lengthens it with the distance (about 450 ms for a page, 870 ms for three), and Firefox's spring settles in about 550 ms, both past the 300 ms that motion the user waits on may take (
browser/AGENTS.md). Leaf now drives every smooth vertical move itself, as Vimium does: 140 ms of easing out, written as instant scrolls. A landing measured on a tall page took about 870 / 630 / 245 ms in Chromium / Firefox / WebKit on main and takes 140–160 ms in each here.The handoff between the two mechanisms goes with it: the record of where a native landing was headed, the glide's takeover of a landing, and the
movingmap that told them apart. Glides are per box, so a landing glides each nested scroller it moves together. Anautomove in a box whose CSS asks forscroll-behavior: smoothglides too.Steps pressed while the page moves
afterBrowserScroll), and further steps wait behind it in the order pressed. They used to be dropped. Only the inputs that set the browser scrolling (its scroll keys, a pointer, a wheel or a touch) decide whether its scroll is a key's, so adin between doesn't change that.One owner for a scroll's end
arrivals.jshearsscrollandscrollendin the document, every shadow stage and any tree a module enrolls (hearScrollsIn), and ends each box's scroll once: at itsscrollend, or after 80 ms and two rendering updates with no movement. A glide holds the box (holdScroll), so its many frames end the scroll once.browserScrollssays whether the browser, rather than a script, is moving a box: a scroll under way that no hold keeps open, and that has taken the box from where a script last put it. The choice bookkeeping inscrolling.js, continuity's place recording inversion.jsand the margin's re-placement subscribe throughwatchScrollEnds, and a lint rule (architecture/scroll-ends) keeps runtime code from listening toscrollenditself. Adglide no longer records the reading place on every frame: 254 ms ofrecordPlaceson main, 64 ms here, in Chromium on the probe page.Behavior changes
dpressed during Space or PageDown adds to it in Chromium and Firefox. WebKit firesscrollendon each frame of a keyboard scroll, so there the step starts early and lands short (notes/browser-support.mdrecords it with a recheck).scrollendlistener hears one event per frame of a Leaf landing, as it already did for the reading keys.Testing
The typeahead test (
test_keys_pressed_while_the_page_moves_act_as_if_it_had_landed) gains PageDown-then-dand PageDown-then-d dphases, and the runtime unit test for held scrolls covers ending once and telling a script's settling scroll from the browser's. Firefox and WebKit were checked by probes: Space+d, PageDown+d, wheel+d,m uandd min each engine.