From 1b039a3c7247d0221fb0b8ed8ef89a35ffd8e9d6 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 25 Oct 2026 13:01:52 +0800 Subject: [PATCH] gui: a trackpad's coast after the lift is the reader's scroll, no longer put back (issenn on Discord) issenn (v0.1.1472, macOS app): a page with a scrollbar wouldn't scroll by trackpad. It shook fast and snapped back, and only dragging the bar worked. Seen on Agents. Cause: the scroll guard puts back any .view scroll that comes outside a window the reader's own events open. A wheel opened 250ms. When the fingers lift, WebKit on the Mac plays the coast itself, and the page hears those scrolls with no wheel for each. Once the last wheel's 250ms ran out, the guard put back every coast scroll. Each coast step moved the page and each put-back moved it back, so it shook and came to rest where the fingers lifted. Fix: the wheel now starts the same chain a touch fling does (flings, flingUntil). Each view scroll keeps the next one the reader's until the coast rests, and a click still ends it (purposeUntil = flingUntil = 0). A code scroll at rest is still put back. The code and the comment fit the old app.js size; no budget raised. Test: view-trackpad-coast.test.cjs, chromium and webkit, en and zh. It does five trusted wheels, then a 1s coast the page plays each frame with no wheel. The coast must reach its end, a code scroll at rest is put back, and a click mid-coast stops the row under the pointer. - On origin/main's app.js: red 6/6 ("lifted at 40, coast asked 166, left at 101/105"). - Broken by hand, flingUntil not reset by a click: red 6/6 ("the row was at 269 after the click, 140 once at rest"). - With the fix: 6/6. Real WKWebView probe (a Swift app loading the GUI with synthetic NSEvent scroll phases): with every momentum wheel delivered, old and new both end at 277. With the wheels after the first 32 kept from the page, standing in for the coast with no wheel, old ends at 249 and new at 277. Run: - click-scroll, view-scrollbar-drag, view-middle-autoscroll and view-trackpad-coast: 44/44. - Whole GUI suite (internal/gui/tests/*.test.cjs, chromium and webkit, every language) through suite-lock: still running at push, no red in its first 30 minutes; a red it finds gets a follow-up commit and an issue. - go test -tags nogui -run Budget ./internal/gui: ok, run again after the rebase. - No Go changed, so no gofmt or vet. Not tried: a real trackpad on the mac app. Synthetic NSEvents skip WebKit's MomentumEventDispatcher, which swallows the system's momentum and plays its own. That the page gets its coast with no wheel is the best fit for the report, not something seen on issenn's hardware. Also not tried: ProMotion 120Hz, and WebKitGTK and WebView2 with a real touchpad. --- docs/subsystems/gui-shell.md | 2 +- internal/gui/assets/app.js | 10 +- .../gui/tests/view-trackpad-coast.test.cjs | 138 ++++++++++++++++++ 3 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 internal/gui/tests/view-trackpad-coast.test.cjs diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 9fab1f9b9..24e9f2933 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -375,7 +375,7 @@ covers it in both engines, every language and a narrow window. - Settings' Search APIs add row has a base URL field under the key for every API (#1580): the vendor's own address is its placeholder, picking an API already added fills in its saved URL so a new key alone keeps it, and Add with no key changes only the URL. See [a search API's base URL](gateway-routing.md#a-search-apis-base-url), [`renderSearch`](../../internal/gui/assets/app.js) and `search-api.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 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). What was clicked is held where it was (`hold`); a view at its top when clicked stays at its top, and what comes in above the control moves it down instead (#2134, `update-auto.test.cjs`), as long as it moves less than half its own height and so stays under the pointer. Anything larger above it, as the stage a day picked on Routing brings in above the bar, is scrolled past, and the control stays where it was clicked (`routing-days-fit.test.cjs`, `routing-failed-open.test.cjs`). -- A scroll not the reader's is put back, so every way the reader scrolls has to count as theirs: the wheel, a touch and its fling, the keys, a drag, the scrollbar's own drag (`barDrag`, #1089) and the middle button's autoscroll (`panning`, 多喝热水 on Discord). Chromium and WebView2 give the autoscroll a press of button 1 and then no event of the reader's while it scrolls; from that press the view follows it till Chromium ends it, on the next press (which reaches the page only as a pointerup), a key (a keyup), or the lift after the mouse moved while held. A field the guard brings back into view after putting a scroll back is one focused since the reader last scrolled that view, not one they scrolled away from (`scrolledFrom`): the middle press focuses the button under it. See `view-middle-autoscroll.test.cjs`. +- A scroll not the reader's is put back, so every way the reader scrolls has to count as theirs: the wheel and a trackpad's coast after the lift (WebKit on the Mac plays the coast itself and the page hears its scrolls with no wheel for each, so the wheel starts the same chain a touch fling does, `flings`/`flingUntil`: each scroll keeps the next one the reader's till it rests, and a click ends it; issenn on Discord, `view-trackpad-coast.test.cjs`), a touch and its fling, the keys, a drag, the scrollbar's own drag (`barDrag`, #1089) and the middle button's autoscroll (`panning`, 多喝热水 on Discord). Chromium and WebView2 give the autoscroll a press of button 1 and then no event of the reader's while it scrolls; from that press the view follows it till Chromium ends it, on the next press (which reaches the page only as a pointerup), a key (a keyup), or the lift after the mouse moved while held. A field the guard brings back into view after putting a scroll back is one focused since the reader last scrolled that view, not one they scrolled away from (`scrolledFrom`): the middle press focuses the button under it. See `view-middle-autoscroll.test.cjs`. - Typing never moves the page either. A textarea that grows with its text (the Library's `autosize` in plugins/library/client.js: a set's text, an agent's own text, a skill's description, a subagent's fields) is measured at height auto with what holds it kept at its height, so the page never goes short for a moment: a page gone short has its view's scroll clamped by the browser at every input, an input method's every composing step included, and the guard's putting it back pulled a textarea taller than the view to one of its edges (#2636, `library-ime-scroll.test.cjs`). - There are no native `