Repository navigation
Keep revision scroll offsets with their owner - #644
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
restoreRegion still reaches its raw fallback — box.scrollTo({ top: view.y }) — for any reading that cleared the new guard on hasLandmark. So a revision that removes the recorded landmark and changes the owner in the same step puts one scrollport's offset into another, which is the case this PR sets out to close. The guard sits at the three call sites that choose a restore, not at the one place the raw offset is consumed.
Reproduced against this head, on the shape of test_revision_does_not_move_an_offset_between_bounded_region_owners with a quotable paragraph added to the active region and dropped by the revision: the left parent is scrolled to 150, the active region moves to the right parent, and the right parent's body ends at 150 instead of 0. hasLandmark is true from the captured quote, rawOffsetFits is never consulted, and resolveAnchor finds nothing to land on.
Guarding where the offset is consumed closes it and keeps the ownership rule in one place:
// skills/leaf/assets/runtime/version.js, in restoreRegion
} else if (rawOffsetFits(view, box))
box.scrollTo({ top: view.y, behavior: "instant" });captureRegion(null) records "$page", so the page path still restores through it. With that line, my probe passes and tests/test_render_projection.py, tests/test_render_widgets.py, and tests/test_render_navigation.py stay green. Happy to push it if you'd like.
The four new cases each fail at the merge base and pass here, so they pin what they name. The one red case in the projection file, test_revision_changes_follow_authored_text_into_declared_shadow_trees, reproduces at the merge base and is not this branch's.
Probe case
Added to tests/test_render_projection.py, reusing the lf-owned-scroll registry entry and module from the new nested-ownership test:
def active(landmark):
return f"""
<div style="height: 250px"></div>
<lf-owned-scroll id="active-region" posture="flow">
<div data-scroll-body>
{'<p id="active-landmark">The active reading carries a landmark long enough to be quotable.</p>' if landmark else ''}
<button id="standing-control">Change setting</button>
</div>
</lf-owned-scroll>
"""
first = leaf_page("Probe", parent("left", active(True)) + parent("right"))
# ... left.scrollTop = 150, focus #standing-control ...
revised = leaf_page("Probe", parent("left") + parent("right", active(False)))
stamp_page(serve.page_dir, revised, "move the active region and drop its landmark")
wait_for_revision(page, 2)
assert right.evaluate("s => s.scrollTop") == 0 # observed 150|
This is what closes the red The regression is Verified at this branch's head |
The full nightly exposed a pre-existing revision-continuity regression: a textless active region could suppress the containing page landmark, and its raw scroll offset could later be applied to a different scrollport after the layout changed.
Record the exact semantic owner of each captured scrollport, reveal a surviving active region before restoring geometry, and reuse raw offsets only when that owner survives. Everyday browser regressions cover disclosure without a region landmark, semantic page-position restoration, flow-to-bounded transitions, and moving a nested flow region between bounded parents.
Validated with six focused revision-continuity browser cases and all 159 nightly widget tests.