Repository navigation
Leave a box to the reader's scroll in every writer that would cancel it - #5863
Merged
Merged
Conversation
…nswer arrives A reader at the end of a margin card's transcript, or of the floating panel's thread view, who wheeled up as the agent's answer to their turn arrived was put back: the answer's placement (thread-card.js, `#fitAnswer`) read the box at its old end before the browser applied the wheel's scroll, and in the next frame moved the user's turn into sight above New reply, which cancelled the wheel. Firefox applies a wheel's scroll a frame or more after the input; with the answer released just after the wheel, Chromium lost it too. Since #5834 the reader's input opens the box's scroll sequence at the input (arrivals.js, `startReaderScroll`). `readerScrolls(box)` now says whether that sequence runs, and the placement treats a reader whose input has the box scrolling as standing where the scroll takes them: at the read, and again before its delayed write. A sequence layout starts, as a clamp does, isn't the reader's, which is why this reads the reader's sequence rather than `browserScrolls`. Behavior change: 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 above it. Probes (Firefox): card 1110 -> wheel -> write 1148, wheel lost; now 1110 -> 810, no write. Panel 699 -> write 729, wheel lost; now 699 -> 399 with New reply. Chromium likewise. The new test, `test_a_wheel_up_a_card_as_its_answer_arrives_goes_where_it_takes_the_reader`, fails in both engines with thread-card.js reverted (771 vs 733, 763 vs 725) and passes with it.
leaf-agent
previously approved these changes
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.
leaf-agent
previously approved these changes
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.
leaf-agent
previously approved these changes
Nov 12, 2026
This was referenced Nov 12, 2026
# Conflicts: # browser/runtime/user-place.js # tests/runtime/arrivals.test.mjs
…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.
leaf-agent
approved these changes
Nov 14, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
Some tests ran real work under a deadline the product sets, so their result depended on how fast the machine runs, against tests/AGENTS.md's "Results do not depend on execution speed". The suite's check, `test_a_wait_takes_the_suites_deadline`, reads only deadlines written in test source, so it missed every one. The prompt hook gives a resumed session's page server 5 s to start (`reconnect.SERVE_WITHIN`) and hands the turn its input inline only within 10 s of its own start (`hook_transport.CONFIRM_WITHIN`). A start takes about 1 s on an idle Mac and about 3 s on CI, over 5 s at the tail. On 14 Nov two CI runs ([#5863's](https://github.com/max-sixty/leaf/actions/runs/43627224592/job/132545728761) and [another a minute later](https://github.com/max-sixty/leaf/actions/runs/43627326086)) failed four `test_session_lifecycle.py` tests with "did not become ready". Across 324 CI runs since the tests landed in #5555, their call time shows no drift: every day's slowest run sits within half a second of the bound. An autouse fixture in `tests/interact_support.py` now gives both bounds `STATED_TIMEOUT` in every in-process test, replacing the one test that patched `CONFIRM_WITHIN` to 600 s for the same reason. The `port held` arm keeps 0.5 s, which holds at any speed because the held port means its start never becomes ready. An audit of every other product deadline a test runs work under, or shortens with `monkeypatch`, found three more: - Two presence tests count neighbor scans while the presence cache's 2 s age runs out; they now give it `STATED_TIMEOUT`. - The render gate's stopped-server journey cut `SERVED_TIMEOUT_MS` to 1.5 s for every probe and read in four renders; now only the stalled read is cut. - Three arms of the Codex desktop start test cut `START_TIMEOUT` to 0.2 s, so a late answer read as lost, the outcome those arms expect; now only the lost-answer arm cuts it. tests/AGENTS.md now says to give such a deadline `STATED_TIMEOUT` and shorten it only to 0 or where the work it bounds can never finish. Still exposed: `tests/journeys/test_session_lifecycle.py` runs the hook as a subprocess, which a fixture can't reach. Tests: under twelve busy loops on the Mac's efficiency cores, all six reconnect tests fail on `main` and pass here (one start took 40 s); with only `SERVE_WITHIN` raised, the resumed-session test fails on `CONFIRM_WITHIN` instead. The presence tests passed 6 of 6 under the same load. The edited journey, the hook, lifecycle, Codex adapter and suite-source tests, and the other hook-reaching model tests pass. Asked for by Max, reviewing a CI failure his session flagged. > _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.
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 insetScroll: 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 (asg gwould) 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, asg gdoes.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;scrollIntoViewtakeskeptfor a reveal that returns the reader to a place they had, whichrestorePlacepasses.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/ownEndin 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_withoutis new;test_a_wheel_up_a_card_as_its_answer_arrives_goes_where_it_takes_the_readercovers 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 coverscrollsFor,readerScrolland 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 excepttest_an_open_view_covers_the_page_beneath_it, which fails intermittently on main too (#5744). CI'stestat 54a6771 failed two server-lifecycle tests intests/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.