Skip to content

Hear a native scrollIntoView as the script's write it is - #6951

Merged
max-sixty merged 12 commits into
mainfrom
agent-ae22ff701aadc9f97
Nov 24, 2026
Merged

max-sixty merged 12 commits into
mainfrom
agent-ae22ff701aadc9f97

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

One step of the package-interface redesign, after #6942: Leaf hears a native scrollIntoView too. arrivals.js wraps it, and Chromium's scrollIntoViewIfNeeded, and records each box the call moved at once, as it records a scrollTo. A smooth reveal is still heard by its events. Before, a reveal's boxes read as the browser's own motion from their scroll events to scrollend.

To weigh:

  • A fix to Hear every script's scroll write, and take setScroll out of the package API #6942. Chromium's scroll calls return a promise, which the wrap on main drops; a heard call now returns what the browser's returns.
  • Cost: a reveal that moves its pane goes from 4 to 11 µs four boxes deep and 4 to 33 µs thirty-four deep in Chromium; 4 to 12 and 2 to 14 in Firefox.
  • Limits: a target slotted into a closed shadow tree, and a focus's or a fragment's reveal, are heard by events only.
  • The package API keeps its 164 names.

Max approved the redesign and asked for small steps; he hasn't read this diff. A fresh agent reviewed it.

Tests: pre-commit, pnpm run check, 146 browser tests by node id, 18 holds-still cases, leaf-dev probe --base in both engines.

This was written by Claude Code on behalf of max-sixty

@max-sixty
max-sixty merged commit fb8b0cc into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-ae22ff701aadc9f97 branch November 24, 2026 05:22
max-sixty added a commit that referenced this pull request Nov 24, 2026
…t by its source text (#6987)

`test_sample_browser_boundary_contains_focus_scroll_and_parent_access`
has failed on main since #6951 (`fb8b0cc1e7`): it passes at that
commit's parent and fails from it on. #6951 made
`Element.prototype.scrollIntoView` Leaf's wrap around the browser's
method in every Leaf document, a live sample's included, and the test
asserted that the method's source text reads `[native code]`.

What that assertion stood for still holds: a reveal a sample's script
makes itself does what the browser's does. The test now makes that call
and checks what it moves, which is the sample's own page and, through
the sample's frame, the page around it. Leaf's own `scrollIntoView`
leaves the page around the sample still, as the test already checked.
`focus` keeps its source-text check, since nothing wraps it. No runtime
code changes.

To weigh: the new check relies on the browser scrolling the host page
for a reveal made inside a sandboxed frame, as Chromium and Firefox both
do today. `module-scroll-and-motion.md` already says that Leaf's
`scrollIntoView`, unlike the native one, stays inside a live sample.

The session running the package-interface redesign asked for this, after
an agent found six browser tests failing on main. This is the only one
of the six that a pull request of the redesign caused; the others trace
to #6796, #6947 and #6009 and are left alone. Max hasn't read the diff.

Tests: the test by node id in Chromium, also under `--cpu-throttle 8`,
and its body in Firefox with the fixture swapped by hand. It fails when
the wrap drops the browser's call, and when the script's call is swapped
for Leaf's contained one.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 24, 2026
…current API

Main's follower is still the resting one #6008 landed; it moved its imports to
the library and landing-scroll.js gained a glide's aim (#6904). Three files
conflicted, each resolved to main's text with this branch's change made again:

- packages/default/widgets/lf-code.js: main's imports, with `alreadyShown` and
  `scrollIntoView` dropped. `setScroll` left the package API (#6951), so the
  follower writes the pane's scroll with the browser's own `scrollTo`, asking
  `scrollMoves` (lib/scroll-range.js) first, as module-scroll-and-motion.md
  asks of a writer that may name the position its box holds. A line out of the
  band at an end of the pane is such a write.
- browser/runtime/landing-scroll.js: `innerMoves` loses its `block` again and a
  `within` box lands at once, nearest. The glide's aim (`landingAim`) and the
  boxes a landing steers ask `innerMoves` without it.
- browser/runtime/widget-api.js: main's exports, plus `alreadyShown`, which
  portable-api.js no longer exports and lf-trace reads.

skills/leaf/references/module-scroll-and-motion.md merged clean and named
`setScroll`; it names `scrollTo` now.
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