Skip to content

Upgrade Python Playwright to 1.64 while preserving scroll and input behavior - #3772

Merged
leaf-agent merged 28 commits into
mainfrom
fix/playwright-164-behavior
Oct 28, 2026
Merged

leaf-agent merged 28 commits into
mainfrom
fix/playwright-164-behavior

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Upgrade Python Playwright to 1.64, which uses the same Chromium 156 as the Node Playwright main already runs (#4204), and keep Leaf's reading position and editor behavior under that browser.

Chromium 156 now sends scrollend after it anchors or clamps a box, as Firefox 157 and WebKit 27 already do. So scrolling.js no longer reads every scroll end as the reader's choice. A single move counts as layout's if the box's extent changed while it moved. A sequence of several scroll events still counts as someone's glide: all three engines end each anchoring or clamp move as a sequence of its own, even when the moves come in consecutive frames. Find-in-page that opens a hidden="until-found" fold fires beforematch first, so the scroll that follows counts as the reader's choice. An end that leaves the box where the last one did counts as no choice; Firefox sends one after layout moves. Chromium 156 can also scroll the page behind a fixed response editor while revealing its caret. The runtime restores the page's place in the editor's input task. Browser tests press visible fixed controls without Playwright's preparatory scroll.

The focused reading-place, pane, editor, touch, offscreen-frame and trace-import tests pass under 1.64. A new Firefox test finds words in a closed fold and then changes the window's width. It fails without the beforematch mark: the found words end up 1,300px away. pnpm run check passes. An earlier base/candidate startup probe of code-comparison showed 51 requests on each arm through presentation, and 3,322 more bytes delivered by the candidate for the runtime repair. The committed kernel is rebuilt on the merged tree.

Two failures don't come from this change:

  • tests/browser/threads/test_media.py::test_touch_capture_attaches_on_lift_and_a_tap_or_cancel_attaches_nothing also fails on main.
  • The nightly journey test_the_feature_gallery_exercises_its_core_journeys failed 3 of 5 local runs under 1.64 on a loaded host. It failed once as a shift-watch finding in a sample and twice as a pin-in-view assertion. It passed 2 of 2 runs under 1.63, and it fails the same way without this branch's scroll change.

Closes #3361

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

Chrome 156 emits scrollend for layout moves and can reveal the caret by scrolling the page behind a fixed response. Distinguish layout moves from user scrolls, restore the page place during floating response edits, and adapt browser gestures to avoid Playwright's preparatory scroll on visible fixed controls. Bump both Python and Node Playwright requirements and rebuild the kernel.

The existing reading-place, editor, touch, frame-watch, and feature-gallery journeys pass under 1.64. Main's concurrent swap-watch repair resolves the offscreen frame drain without a second workaround here.

Closes #3361
Format the runtime and browser tests as the CI hooks require. Schedule the floating editor's input cleanup through Leaf's next-frame queue so presentation settling counts it, then rebuild the committed kernel.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

The red CI run on 05d0ce49 came from pre-commit: Ruff and Prettier changed five source/test files, and ESLint rejected a raw requestAnimationFrame in the floating editor. I pushed 29bd3a7f3d930a488478f18a3c1158b524cf373c with the formatter output, a counted nextFrame callback, and the rebuilt kernel.

The affected pre-commit hooks, pnpm run check:browser, and pnpm run test:runtime pass locally (534 runtime tests). The focused browser test could not start in this sandbox because its Playwright 1.64 headless shell is absent; the PR's preceding CI run passed its Python tests. CI and review are now running on the new head.

# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay~index.js
#	dist/kernel/runtime/bundle-presence.js
#	pnpm-lock.yaml
leaf-agent added a commit that referenced this pull request Oct 24, 2026
Update the locked `websockets` dependency from 17.2 to 17.3. `uv lock
--check` passes. The Playwright 1.64 upgrade, with its browser behavior
changes, is covered by #3772.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: leaf-agent <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The new repeated branch treats two scroll events as a reader choice even when layoutMoved says that layout moved the box. If a streaming widget grows above the viewport in two steps before scrollend, anchoring can produce two scroll events without any reader input; this branch then calls chooseScroll. version.js uses that choice to rank a new reading place, so a later layout change can restore the position that layout produced instead of the reader's place. The same classifier also suppresses a single script or browser navigation scroll when the extent changes. The number of scroll events does not establish who moved the box; this needs a way to distinguish the gesture from the layout movement while preserving script and native navigation as choices. This is a code-path finding; I could not run its browser case locally because the Playwright 1.64 headless shell is absent.

leaf-agent added a commit that referenced this pull request Oct 24, 2026
Keep lit-html 3.3.0: 3.3.3 still leaves a marker for every removed repeat row, which a focused runtime test now catches. Keep Playwright 1.63.0 while PR #3772 carries its runtime changes. Update Pele and Pierre build seams and regenerate their shipped bundles for the other 24 updates.
leaf-agent added a commit that referenced this pull request Oct 24, 2026
Updates 24 JavaScript dependencies and rebuilds the browser assets
shipped with Leaf. The changed Pele and Pierre build adapters match
their new published modules. A frozen install, `pnpm run check`, and the
repeat-row regression test pass on the repaired head.

`lit-html` stays at 3.3.0 because 3.3.3 still accumulates markers when
`repeat` rows are removed; #3783 tracks its eventual upgrade. Playwright
stays at 1.63.0 because #3772 carries the 1.64 runtime fixes and should
own that version change.

A base/candidate `code-comparison` startup probe recorded 50 requests
through presentation on each arm. The candidate delivered 1,357 more
bytes through that phase, with no additional requests.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: leaf-agent <[email protected]>
# Conflicts:
#	pnpm-lock.yaml
# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	tests/browser/margin/test_pins.py
@max-sixty

Copy link
Copy Markdown
Owner

surely you need to install the correct version of playwright??

@leaf-agent

leaf-agent commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Yes. I installed the Playwright 1.64 headless shell pinned by this PR; my earlier local-test limitation was avoidable. With that browser, the focused reading-place tests for script scrolling during content growth and keyboard paging, plus the floating response editor test, pass locally (3 passed).

I also checked the separate scroll-classification finding in Chromium 156. In a direct browser probe, growing content above a scroller by 40px and scrolling it another 100px by script in the same task moved its offset from 450px to 590px, with one scroll/scrollend pair, but scrollChoices() did not advance. That confirms the missed-choice case from my review, so the PR remains open for a repair. Two layout-only growth steps each produced their own scrollend in this probe and recorded no choice; I have not reproduced the review's false-choice scenario.

# Conflicts:
#	tests/browser/threads/test_media.py
# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-reading-regions.js
# Conflicts:
#	dist/kernel/kernel.json
# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-reading-regions.js
# Conflicts:
#	tests/render_harness.py
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-annotation-overlay.js
leaf-agent added a commit that referenced this pull request Oct 26, 2026
)

Update nine Node dependencies: Claude Agent SDK to 0.3.309, Workers
types to 5.20261023.1, pi-ai to 1.4.0, SnapDOM to 3.3.7, Pele to 1.9.0,
Playwright to 1.64.1, Vite to 8.3.5, Wrangler to 4.152.0, and Codex to
0.164.0.

Keep `lit-html` at 3.3.0; #3783 tracks the deferred upgrade. Refresh the
SnapDOM warning-suppression and Pele literal-label build adaptations,
and commit the rebuilt bundles and license notices. These preserve
capture behavior and literal unsupported tags in diagram labels.

Validation: `pnpm run build:browser`, `pnpm run check`, and the final
`pnpm run check:browser` passed. The capture drag test passed both
cases, and a direct check of the final Pele bundle preserved literal
`<img>` text and bold formatting. CI on the repaired head remains for
the queued review.

The Node Playwright update overlaps #3772, which also upgrades Python
Playwright and carries browser runtime repairs.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: leaf-agent <[email protected]>
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-reading-regions.js
#	package.json
#	pnpm-lock.yaml
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-annotation-overlay.js
# Conflicts:
#	browser/runtime/annotation-overlay/composing/floating-response.js
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-reading-regions.js
# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-reading-regions.js
# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-content-layout.js
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Resolved the generated-kernel conflict by merging main and rebuilding; pushed 225bcc41e8c4397f7175678b1da96bae5bb98dad. The pushed head test-merges cleanly, the browser build and all 690 runtime tests passed locally, and CI passed on that exact head.

The confirmed scroll-classification finding recorded above remains unresolved, so this conflict repair does not land the PR.

# Conflicts:
#	dist/kernel/kernel.json
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Resolved the generated-kernel conflict by merging main and rebuilding; pushed 7b55432e0f7b9cc53c06a240ce6fef7f841ac372. The pushed head test-merges cleanly, the browser build and all 694 runtime tests passed locally, and CI passed on that exact head.

The scroll-classification finding recorded above remains unresolved, so this conflict repair does not land the PR.

max-sixty and others added 4 commits October 28, 2026 02:46
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-content-layout.js
Review found that the scroll-end classifier reads a script or browser
travel scroll as layout's when the scroll range changes in the same
frame, and questioned treating a sequence of several scroll events as a
choice.

Find-in-page that opens a `hidden="until-found"` fold now counts as the
reader's choice: the browser fires `beforematch` before it opens the
fold, and the next scroll end within two frames counts as a choice. In
Firefox, whose `window.find` opens folds as its find bar does, a width
change after such a find used to move the found words 1,300px away;
they now stay put. The new test fails without the mark.

The several-events rule stays. Chromium 156, Firefox 157 and WebKit 27
each end every anchoring or clamp move as a sequence of its own, even
when the moves come in consecutive frames, so layout alone never
produces a sequence of several scroll events.

Firefox also sends a second `scrollend` after a layout move without
scrolling. That end left the box where the last one did, so it now
counts as no choice. `ended` replaces `lastTop` and starts unset for a
box first watched mid-scroll.
@max-sixty max-sixty changed the title Upgrade Playwright to 1.64 while preserving scroll and input behavior Upgrade Python Playwright to 1.64 while preserving scroll and input behavior Oct 28, 2026
@max-sixty

Copy link
Copy Markdown
Owner

On the scroll-classification finding, now addressed in 32c473f. Every measurement below used Playwright's own builds, and the Playwright 1.64 headless shell is now installed locally.

  • Native navigation suppressed when the extent changes: confirmed. Firefox's window.find opens a hidden="until-found" fold as its find bar does. After that find, a width change moved the found words 1,300px away, because the find's end read as layout's. The browser fires beforematch before it opens the fold, so a scroll end in the next two frames now counts as a choice. test_words_found_in_a_closed_fold_become_the_readers_place fails without the mark.
  • Two layout steps before one scrollend: this doesn't happen in Chromium 156, Firefox 157 or WebKit 27. Each engine ends every anchoring or clamp move with its own scrollend, in the same frame (Chromium, Firefox) or the next (WebKit), even when the moves come in consecutive frames. So the several-events rule stays, and the module header now states why. A script's jump in the same frame as a layout change still reads as layout's. Input the reader aims at the box settles that case through version.js's inputSince.
  • Also fixed: Firefox sends a second scrollend after a layout move without scrolling. That end left the box where the last one did, so it now counts as no choice.

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

# Conflicts:
#	dist/kernel/runtime/bundle-annotation-overlay.js
@leaf-agent
leaf-agent merged commit 781de5e into main Oct 28, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/playwright-164-behavior branch October 28, 2026 11:30
leaf-agent added a commit that referenced this pull request Oct 29, 2026
The coordinate-based press helper introduced by #3772 sent input through
its document argument, but a Playwright `Frame` has no mouse or
touchscreen. The helper now uses the frame's owning page for input while
keeping the locator scoped to the child document. Bounding boxes already
use main-viewport coordinates, preserving the visible-control route that
avoids Chromium 156's preparatory scrolling.

Both affected inspection tests reproduce the `AttributeError` before the
change and pass after it, verifying child-document arrival and the
manual diagnostics-copy route. The selected top-level inspection and
small-screen map mouse/touch cases also pass: 5 cases total. Ruff and
Python compilation pass.

Closes #4669 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 29, 2026
…4694)

The margin test compared marker navigation with a scroll position
recorded before editing a reply. On current main it fails with 13px
versus 0px, but instrumenting the journey shows the page already at 13px
before Home or ArrowDown. Opening the card still passes its original
unchanged-scroll assertion.

Record the marker walk's baseline after entering the margin, then assert
that both Home and ArrowDown preserve it. The original card-opening
assertion and reply, draft, reopen, and focus checks remain intact;
product behavior is unchanged. This keeps the test aligned with the
separate opening and navigation guarantees while allowing the
intervening editor interactions to reveal their caret, behavior
discussed in #3772.

Verification: the reported test failed before the change and passed
after it at normal speed. It also passed with Chromium slowed sixfold;
Ruff lint and formatting checks pass.

Closes #4672 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 29, 2026
Hidden bounded logs now grow without forcing their skipped subtree to be
styled or measured. Scroll-layout tracking keeps observing hidden
children but defers their measurements until reveal; hidden scroll
events do not become reading choices, and reading-region classification
leaves concealed bodies alone. Reopening History still puts both logs at
their newest entries.

The existing hidden-log regression reproduced the CI run's 92 reads
before the fix. Temporary stack capture identified `scrolling.js`'s
child observer and scroll-end listener, `bounds.js`'s scroll listener,
and `reading-regions.js`'s scroll classification. The layout observer
added in #3772 remains responsible for distinguishing native layout
clamps from reader choices; its first visible reading refreshes the
baseline after a hidden interval.

Validation: seven focused browser tests passed, including hidden-log
growth/reopening, disclosure sampling, feed rebuilding, revision reading
restoration, concealed landmarks, and both wheel/clamp variants. `pnpm
run check` passed, including runtime tests and browser/Worker type
checks. The kernel is rebuilt. A base/candidate `code-comparison`
startup probe reached upgrade and server-state presentation with 40
requests on each arm, 247 additional code bytes, identical recorded
startup shifts, and no console errors. The visibility checks prevent
forced hidden layout and need to run before measurements.

Closes #1987 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 30, 2026
An instant landing on a saved trace element was missing the explicit
scroll-choice marker used by smooth landings. When opening the tree also
changed its layout, the scroll classifier introduced in #3772 treated
that jump as layout's, so continuity restored the tree's older reading
over the selected row. The shared landing function now marks both
motions before scrolling. With reduced motion, the Saved element Moment
keeps its row visible inside the tree and the page; ordinary motion and
checkpoint reopening retain their behavior.

The existing reduced-motion regression fails on the base with the row at
784–840px outside a 228–408px band, and passes after this change. Both
motion cases and checkpoint reopening pass, as do pane continuity in
Chromium/WebKit, Firefox's native hidden-fold search, all 712 runtime
tests, and `pnpm run check`. Base/candidate startup probes load 40
requests (36 code requests) through upgrade and server-state
presentation, with 28 fewer code bytes in the candidate.

This is a partial repair.
`test_trace_tree_opened_by_the_browser_keeps_its_match` still fails on
the base and candidate: it opens the disclosure and scrolls through a
script in the same task. The classifier deliberately treats a single
script jump coinciding with changed layout as layout's. That simulation
does not establish actual browser-find behavior; Chromium and Firefox
`window.find` attempts did not open this trace disclosure. The remaining
step is to reproduce through native find UI and establish the events it
delivers before changing that classification. A full Chromium launch
under Xvfb here fails before opening a page because its
process-singleton socket is unavailable (`Address family not supported
by protocol`); that check needs an environment supporting full
Chromium's native window path. #4747 stays open for that work.

Refs #4747 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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.

Reconcile Chrome 156 behavior before restoring Playwright 1.64

2 participants