Repository navigation
Ask a margin card's end keeper whether its reader stands at the end before holding news - #5837
Merged
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.
…efore holding news 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 landed in the same task as the turn grew, as when a picture in it loaded. The card's held-news check (thread-card.js, `newsMoves`) asked the transcript's offset whether the reader followed the end (`followsEnd`). In that task the picture had already carried the end 97px past the reader, and the keeper had not yet read the growth, so the offset said no and the edit waited. On the next frame the keeper took the reader to the end, with the notice still standing for words they would have seen. The card's transcript already has one owner of that answer: its end keeper (scrolling.js, `followEnd`), whose `standsAtEnd` reads the reader against the end as the keeper last stood them. thread-preview.js now keeps the keeper rather than only its `stop`, and hands the card a `standsAtEnd` outlet, which `newsMoves` asks in place of the offset. With its last caller outside scrolling.js gone, `followsEnd` is no longer exported, and browser/AGENTS.md's question index names `followEnd` as the answer to whether a reader stands at a box's end. The new test, `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, so the reading is taken in that task. It fails on the old check (the edit isn't drawn and the notice shows) and passes with the keeper.
# Conflicts: # browser/AGENTS.md # browser/runtime/scrolling.js # tests/browser/widgets/test_workspaces_and_bounds.py
leaf-agent
approved these changes
Nov 11, 2026
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 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 instandsAtEnd.thread-preview.jsnow keeps the keeper itself rather than only itsstop, and gives the card astandsAtEndoutlet, whichnewsMovesasks in place of the offset. Nothing outsidescrolling.jscallsfollowsEndany more, so it is no longer exported, andbrowser/AGENTS.md's question index points atfollowEnd.What to weigh: since #5834,
standsAtEndreads 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_endholds the page's state reading until the picture'sloadevent 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, theu-press glide smoke test andpnpm run checkpass.