Repository navigation
Keep the reading place on what stands at the landing edge, in the reader's column - #2624
Merged
Merged
Conversation
…go of removed nodes A reading place was the first text block on screen in document order, quoted from its start, plus that start's offset. That held only while nothing between the block's start and what the reader saw changed: - A paragraph partly above the edge pinned its first line, so the line the reader was on drifted by however much the text above it rewrapped or was rewritten: +84px at 1200→600, -79px (under the banner) at 600→1200, and +81px for a revision lengthening words above it. - With the right column of two scrolled, stacking the columns at 800 restored the left column's block, 1255px away from the paragraph read. - With no text on screen (a tall figure), the place was a raw scrollTop that a width change re-applied over the browser's scroll anchoring: the figure's top landed 451px below the edge. capturePlace now names the first line whose middle stands at or below the landing edge, quoted from that line's first character with the context a comment's capture gives (anchorForPassage, split out of anchorForRange so a caller holding page segments skips the reading walk), and measures that line. Blocks are read in the column the reader's pointer, or failing that their focus, named; a heading is still read whole; words in a stuck box name no place. A raw offset is taken back only by the same scroller at the same width, so a width change with no line on screen leaves the browser's anchoring in charge (figure top stays put, as before #2562). Memory: a focused place and every intent (retainUserIntent's source) now hold their nodes weakly, so a place outliving a revision no longer keeps the removed section alive until the next scroll. Holds are keyed by scroller identity with a weak box. That also fixes their identity check: a bounded region's hold compared fresh region records and was dropped on its first reading, so a pane never re-applied its restored place while its layout settled. Tests: test_live_revision_keeps_the_visible_semantic_reading gains an `inside` case (revision rewriting words above the reader's line); the paging-down test now measures the word at the edge rather than its paragraph's top; the #2574 memory test focuses a link in the removed section; new test_a_width_change_keeps_what_stands_at_the_landing_edge (figure, right column) and test_a_bounded_box_holds_its_place_while_its_layout_settles. Each fails on main. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ep a figure's part across revisions Review of 1fb2e22 found two regressions against main and confirmed a pre-existing case: - A nav of short labels beside the text column became the place: "Part 36" first in document order, or under a pointer resting on the nav, put the paragraph read 2379px away once the columns stacked. A run shorter than 24 characters names no place again, as on main. - A pointer resting in the margin kept only a wide exhibit lower on screen that reached it, putting the reader's word under the banner at 600. The column now only chooses between blocks standing side by side at the line the document order found: blocks overlapping that line's row are asked, and one across the reader's column replaces it. - A same-width revision inserting paragraphs above a text-free screen restored the old scrollTop over the new paragraphs (figure top -864 to +473 with anchoring off). A raw offset now also has to be read in the current revision; and with no line on screen, a drawing the edge cuts (a replaced element, or a custom element) is the place, with how far through its height the edge cuts it, so a figure keeps the same part at the edge as it scales (0.40 at every width, not 0.52) and through a revision that keeps its node. Empty boxes draw nothing and are never landmarks, which is what sank the hit-tested landmark before. Tests: test_a_width_change_keeps_what_stands_at_the_landing_edge gains the nav (pointer on it, and no pointer) and margin-exhibit shapes and holds the figure to 0.01; test_live_revision_keeps_the_visible_semantic_reading gains a figure case. Each fails on 1fb2e22. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e below it Review of 8731174 confirmed two pre-existing cases: - A figure cut 40% through by the edge, with its caption 531px down: the caption became the place, so 1200→600 left the reader 22% into the figure and 600→1200 54%. What the edge cuts is now the place ahead of the first line below it; that line is still written down, and stands for the drawing where a revision replaces its node. - A div that scrolls on its own without being a reading region was read as page text: its lines move with its own scroll and rewrap, so 600→1200 took the edge from 47% to 34% into it. Lines inside a box that scrolls its words alone no longer name the page's place, and the edge cutting such a box takes it as a drawing is taken. A registered region's scroller is not the page's: the hit test stops at anything another scroller carries, so a pane never stands in for the page's place. A pointer resting outside the box's contents no longer aims the hit test. Run alongside: a drawing whose height changes after a revision. A revision that gives the figure a taller source keeps the reader 40% into it (main 26%). An image above it that loads after the restore moves it by the image's height where native anchoring is off, as on main: a revision's restore is not held while late layout settles, as a width change's is. Tests: test_a_width_change_keeps_what_stands_at_the_landing_edge gains the figure-above-caption and box-scrolling-alone shapes; both fail on 8731174. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…er-scrollable boxes as scrolling alone Review of 1212b2e found two bugs: - With no reader column and the content box at the window's left edge (a 600px window, nothing pointed at), `null >= 0` passed the column test, so the hit test ran at x = 0 and missed the figure: 600→1200 took the reader from 40% to 54% into it. A missing column now always probes the middle. - `overflow: hidden` counted as scrolling on its own, so a clearfix wrapper whose decoration hangs 12px past its foot hid its article's lines from the page's place: 1200→600 moved the line at the edge from -2.2px to -17.9px. Only overflows the reader can scroll (auto, scroll) count now. Tests: test_a_width_change_keeps_what_stands_at_the_landing_edge gains figure-above-caption-from-narrow and box-clipping-what-hangs-past-it; both fail on 1212b2e. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 13, 2026
… revision Since #2624, a raw scroll offset is taken back only in the revision that read it, on the reasoning that another revision draws other content there and the browser's scroll anchoring keeps the box better. Neither holds for Leaf's own interface across an executable revision: the Threads list and drawers draw the log, which the revision does not change, their words name no reading place (capturePlace reads only the document's blocks), and the reload leaves no box for the browser to anchor. So a reader who had scrolled the Threads list found it back at the top after every executable revision (`test_executable_revision_keeps_a_reader_who_scrolled_away_from_their_reply`, red in the journeys tier since #2624: 0 against a held 790). `rawOffsetFits` now also accepts an offset from another revision in a box of Leaf's interface when that box is not the one that read it. A reading holds the box that read it weakly, under a symbol, so a reading carried across a reload arrives without it. An in-place revision keeps its box, so there the browser's anchoring still keeps the list, as before. Co-Authored-By: Claude Opus 5.5 (1M context) <[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.
A reading place is now what stands at the landing edge, in the column the reader is using, rather than the first text block in document order plus a pixel offset from that block's start. That offset held only while nothing between the block's start and what the reader saw changed height, so a width change or a revision moved the reader whenever it did. A review of #2562 and #2574 as they sit together on main found the cases below; each became a test that fails on main.
What a place stands on, in order:
img,svg,canvas,video,picture,iframe,object,embed, or a custom element holding no text block), or a box that scrolls on its own and is no reading region of its own, kept as how far through its height the edge cuts it. The browser's hit test names it, at the reader's column or the middle of the content. The line below it is recorded too, and stands in when a revision replaces the drawing's node.anchorForPassage, split out ofanchorForRange), measured from that line. Lines above it in the same paragraph can rewrap or be rewritten without moving what the reader sees. Text in a stuck sticky box, and runs under 24 characters (a nav of labels), name no place.Memory: a place holds its focused node and body through WeakRefs, and
retainUserIntentholds its source weakly, so a revision that removes the section the reader focused or clicked in frees it (#2574's guarantee, which #2562'splacesbroke). Holds are keyed by scroller id with a WeakRef to the box;writingis a WeakMap.Also fixed: every bounded region's hold was dropped the first time it was read, because the hold compared region records with
===andreadingRegions()builds fresh records each call, so since #2562 a pane did not re-apply its restored place while its layout settled.Behavior changes (main → this, 1440×900 unless stated):
layout-columnsticky sidebar: main threw the reader 2353px → paragraph kept.Known limits, shared with main: with scroll anchoring off (Safari), an image that loads late after a revision still moves the reader (21% → 22%), because a revision's restore is applied once rather than held; holding it would reverse the rule that a revision ends every hold. focus.js
stood/publishedkeep a removed focused node until the next input, and history.js keeps a clicked#link's focus for its entry's life.Tests:
test_a_width_change_keeps_what_stands_at_the_landing_edge(new, nine shapes),test_a_bounded_box_holds_its_place_while_its_layout_settles(new);insideandfigurecases ontest_live_revision_keeps_the_visible_semantic_reading;test_paging_down_from_a_landed_section_keeps_the_paged_passagemeasures the word at the edge;test_a_revision_releases_the_served_markup_it_removesfocuses a link in the removed section.