Skip to content

Keep revision scroll offsets with their owner - #644

Merged
max-sixty merged 3 commits into
mainfrom
codex/ideas-page-full-height
Sep 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/ideas-page-full-height

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

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.

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@leaf-agent

Copy link
Copy Markdown
Collaborator

This is what closes the red ci on main. Run 34711087986 on 09437163 came back 1 failed, 2558 passed, 6 skipped, and the one failure is the case this branch names: tests/test_render_widgets.py::test_notification_configuration_becomes_a_commentable_local_artifact, at expect(configuration).to_have_attribute("open", ""). The playground's controls region is the active one once the reader presses Create notification, it reads no text, and its bare {y: 0} took the page scroller that the page's own landmark — the ask's Stress-test the deployment notification — would have restored, so the revision's <details> was never revealed and the reader's own configuration stayed collapsed.

The regression is view.activeRegion, introduced in 7ea46058 (#621): the case passes at its parent 4455ac0f and fails there and on every commit since. Before it, restoreView asked containingReadingRegionFor(focused()), which is null after replacement, so a textless active region could not reach the ranking at all.

Verified at this branch's head a6d32804: uv run pytest tests/test_render_widgets.py -q -n0 --run-nightly -k test_notification_configuration_becomes_a_commentable_local_artifact passes, and fails on main at da716dbe. test_render_* is nightly, so the everyday gate on this PR will not exercise it and main's complete suite stays red until this lands.

@max-sixty
max-sixty merged commit d2c2a29 into main Sep 12, 2026
7 checks passed
@max-sixty
max-sixty deleted the codex/ideas-page-full-height branch September 12, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants