"a wheel the page hears of after its scroll is still the reader's" failed
once in Chromium on a loaded machine.
Cause: the subtest delays the app's wheel listener by 60ms (the busy page
of the subtest), then waited a fixed 400ms before looking at the view,
and 100ms after a scroll by code. The listener opens a 250ms moment in
which scrolls are the reader's (readerScrolls(250)). That moment starts
when the page hears the wheel, not when the wheel happens. When the
machine ran the 60ms timer more than ~150ms late, the code's scroll that
followed fell inside that moment and stood ("code's scroll is put
back"). Later still, the view was looked at before the wheel was heard
("the late-heard wheel must scroll the view").
Fix: the wrapper counts the wheels the page has heard. Each wheel is
looked at once the page has heard it and performance.now() has passed
purposeUntil, the end of the reader's moment. The code's scroll is
looked at three frames on, since it is put back at the frame it is told
of. The wait of 100ms before the last wheel stays as a minimum gap: what
was put back from 50ms before a wheel counts as that wheel's own
(givesBack). The page is unchanged.
Run (injected: the late wheel's delay raised from 60ms, the test copied
to the scratchpad with only that number changed):
- Before, Chromium:
- 200ms: 4 of 22 cases red, "code's scroll is put back".
- 500ms: 4 of 22 red, "the late-heard wheel must scroll the view".
- 60ms: green.
- After:
- 200ms Chromium: 22 of 22.
- 500ms Chromium: 22 of 22.
- 500ms WebKit: 22 of 22.
- Broken by hand: with givesBack left out of the wheel listener, the
test is red on "the late-heard wheel must scroll the view".
- A first try with no gap before the last wheel went red: the code's
scroll was handed to the wheel. That is why the 100ms stays.
- click-scroll.test.cjs, both engines, 20 runs: 440 of 440 cases passed, with a load average of 12 to 17.
skill-install-agents-all.test.cjs was red on main in Chromium at 420px
(en, ja, de): the install picker's All chip, clicked, left the Library
view 5px down.
Cause: the browser tells the page of a scroll at the next frame. The test
clicks while the Library view is still sliding in (view-in, translateY
5px), and Playwright's click scrolls the chip into view first; with the
view 5px taller than it is high at 420px, that scroll takes the view to
its 5px foot. The click came in before that scroll's event, so the click
guard took its snapshot (held.chain, held.top) at 5px and every hold()
after kept it there, the scroll event included. A real click can do the
same: WebKit scrolls a field focused on the press, or code scrolls just
before the click, and the scroll was adopted as the reader's.
Fix (app.js, the click guard): before taking a click's snapshot, a view
not scrolled by the reader (no purposeUntil window, no scrollbar drag)
is put back where the reader left it (backToReader), as the scroll
listener would have done a frame later. A click in quick turn after
another still holds that one first, as before.
The guard is shared by every view, so every picker and button is covered;
the library picker needs no change of its own (the MCP editor's picker is
in #modal, outside any view).
Tests:
- click-scroll.test.cjs: new "a scroll the page hears of after the click
is still put back" (scrollTop += 40 and a click in one task). Red on the
old app.js in Chromium and WebKit (expected 2020, actual 2060), green
with the fix.
- sessions-manage-paging.test.cjs scrolled with Playwright's
scrollIntoViewIfNeeded and clicked Show more before the next frame, so
it passed in Chromium only through this bug (the guard puts that scroll
back a frame later; it was red in WebKit on main). It now scrolls with
the reader's wheel; green in both engines.
- docs/subsystems/gui-shell.md says a click is taken where the reader
left the view.
Run: skill-install-agents-all.test.cjs red before (en/ja/de 420px,
"view:5,0"), green after in Chromium and WebKit, every language;
click-scroll.test.cjs green in both engines; 306 GUI test files that
assert on scrolling or touch the library/skills/MCP, then the other 253,
both engines. Failures seen there were rerun alone: purpose-filter (WebKit,
1px, #1291) and search-api (WebKit zh, #1442) fail the same on the old
app.js; the rest pass alone. No Go changed.
WebKit scrolls off the main thread, and under load the view's scroll event
fires before the wheel that caused it (probe: scroll at 518ms, wheel
dispatched at 521ms with timeStamp 517ms). The scroll guard took the scroll
as no one's and put it back. Each put-back is now kept for a second, and a
trusted wheel or touchmove made before it was put back, going the same way,
gives it back. A scroll by code put back before the input was made stays put
back.
click-scroll.test.cjs "a wheel the page hears of after its scroll is still
the reader's" delays the app's own wheel listener by 60ms (the trusted
event kept), with nothing clicked and with a click held, and checks a
code scroll before the wheel stays put back. Without the fix it fails in
Chromium and WebKit: "the late-heard wheel must scroll the view".
Run: click-scroll, context-scroll-end, tray-cell-click, panel-arrange in
Chromium and WebKit, all green. panel-arrange 28 parallel WebKit runs
(load avg ~150-200): origin/main 20/28 runs failed (:89 wheel undone x4,
:147 Done x25); old app.js plus the test fix, 5/28 runs failed (:89 x6);
both fixes, 27/28 and 28/28 (the one failure a page.goto load timeout),
Chromium 28/28. Full GUI suite, both engines: the remaining failures are
login-import, routing-sessions and plugin-market, which fail or pass the
same way alone on origin/main. go test -tags nogui ./internal/gui ok.
5d871723 moved the Routing page's two columns from an 860px to a 1150px
Routing area. At the test's 1100px window the accounts now go below the
requests, so scrolling the view to its end takes the date bar out of sight
first, and "Live and a day, picked in turn, stay under the pointer" and
"the room kept for a click goes as the reader scrolls back" failed in
Chromium and WebKit on every run ("what's clicked must be in sight").
b2345078 and 76d82528 shipped saying they fail the same on origin/main.
Those two subtests open the page at 1440px, the layout they were written
for; the rest stay at 1100, one column, as before.
Verified: git bisect (69665a69 good) names 5d871723; the file fails 2 of 9
per engine on origin/main and passes 18 of 18 three runs in a row with
this change (Playwright 1.63, Chromium and WebKit).