From 9bb68615b03cc6cf3bb4454fb7896b62cd0db047 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 11 Oct 2026 12:14:30 +0800 Subject: [PATCH] gui: a scroll not the reader's made just before a click is put back, not kept as where the reader was (#1554) 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. --- docs/subsystems/gui-shell.md | 2 +- internal/gui/assets/app.js | 10 ++++++++- internal/gui/tests/click-scroll.test.cjs | 21 +++++++++++++++++++ .../gui/tests/sessions-manage-paging.test.cjs | 9 +++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 1cb052411..6cf558272 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -148,7 +148,7 @@ retry after a failed read. See `TestRecentCallBodiesOnDemand` and - Settings' search-provider picker offers **Off**, saved as `searcher: "off"`. Its help explains API-only search and suppresses provider fallback/own-search hints while off; the search priority row is hidden because no provider competes with the APIs. See [gateway search behavior](gateway-routing.md#turning-provider-search-off), [`renderSearcher`](../../internal/gui/assets/app.js), `TestSettingsSearchProviderOff` and `searcher-pick.test.cjs`. - Every user-visible string has zh, zh-TW, ja and de translations with the same placeholders. `gui-zh-tw.test.cjs`, `gui-ja.test.cjs` and `gui-de.test.cjs` fail on a missing one; `gui-zh-tw.test.cjs` also fails on a zh-TW string with a Simplified character left in it. -- A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. +- A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. A click is taken where the reader left the view: a scroll not theirs made just before it, whose scroll event the browser sends only at the next frame, after the click, is put back first (`backToReader` in the click guard, #1554). - There are no native `