From f92db4cdd07ed1bc0b1692db9a51700fd7b41aae Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 27 Oct 2026 02:30:33 +0800 Subject: [PATCH] gui: a page wheeled right after a click that redraws scrolls on macOS 13's WebKit (issennknight on Discord) issennknight (macOS 13) tried v0.1.1621 (a6d7e02c7): the page still stood still and shook back under the wheel right after switching the Usage page's tabs (Overview/Requests/Sessions/Context), and after an agent's row on the Agents page was opened and then closed. Cause, the same class a6d7e02c7 left open: under a click's 4s hold, a scroll put back counts toward the reader's run only when the page was not redrawn since the hold last held it (redrawn(h), against h.lay). h.lay measured the first three held parts with NaN for one gone from the page, and NaN never equals NaN, so a click that draws what it clicked again (the Usage tabs are rebuilt by renderUsageTab, the agents' list by renderAgents) read as "redrawn" at every scroll for the whole hold. A held part stuck to the view's edge (Settings' tabs, sticky below SIDE_AT) read the same: its place in the page changes with every scroll. Every scroll in those 4s was put back, as the old gate did. Fix, at the one choke point (laid/redrawn): h.lay keeps the first three held parts still in the page that scroll with it (no sticky or fixed ancestor inside the view), with the nodes themselves. A part gone since is a redraw once; hold() then lays the page again and the next scroll counts as at rest. The view's height is checked as before. Every click on every page goes through the same hold, so this covers every tab bar, list or card drawn again under a click, not only the two reported. Tests: - New view-wheel-after-redraw.test.cjs, a wheel the page never hears (capture listener stopping it, as view-wheel-unheard): each Usage tab clicked in turn, an agent's row opened and then closed, and a Settings tab clicked with the page scrolled under the sticky tabs; after each click ten wheels down and ten up must move the page. en, zh, zh-TW, ja, de, 420 and 1000 wide (Settings at 420 only, where its tabs are sticky). On origin/main's assets (MAGPIE_AFTER_REDRAW_ASSETS): 25 of 25 red in Chromium and in WebKit, "ten wheels of 30px right after the click scroll the page: from 0 to 0". With the change: 25 of 25 green in both. - Same tree, both engines: click-scroll 11/11, i18n-keys 4/4, view-wheel-after-click 13/13, view-wheel-unheard 3/3, view-trackpad-coast 3/3, agent-expand-steady 2/2, held-animations 2/2, routing-days-fit 6/6, routing-failed-open 4/4, stays-strict 15/15, update-auto 5/5. Box at load 40-140. - go test -tags nogui -run 'Budget|Builtin' ./internal/gui ok (TestCoreScriptBudget; budget not raised). At the pushed head (rebased on 6e9820a3a..d56c14e95, 31da93ccd touched app.js): view-wheel-after-redraw 25/25, click-scroll 11/11, i18n-keys 4/4, view-wheel-after-click 13/13 in both engines; the Go budget tests ok (app.js 1,317,342 bytes, budget not raised). The other files above ran at the base e1709ab42. Broken by hand: origin/main's laid/redrawn (above, all red); the sticky check alone removed (scrolls() returning true): the five Settings subtests go red in Chromium, the Usage and agent ones stay green. Not tried: real macOS 13 / WebKit 16.6 and a real trackpad; the whole GUI suite and the Go suite were not run. --- docs/subsystems/gui-shell.md | 2 +- internal/gui/assets/app.js | 15 +- .../tests/view-wheel-after-redraw.test.cjs | 160 ++++++++++++++++++ 3 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 internal/gui/tests/view-wheel-after-redraw.test.cjs diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 7cf7e1467..eb4e07e23 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. When what the click does leaves the page shorter under it (a list emptied), the view keeps room at its foot for it to stay (`.view-room`), room that goes as the reader scrolls back. A control under what it unrolls (`data-unrolls`, "Show 7 more") goes down with what it opens: what's held is the part it is in, so the rows open downwards. 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 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 wheel or coast the page is never told of (macOS 13's WebKit, Safari 16.6's, scrolled a view under wheels it never dispatched, so every scroll was put back and only the bar's drag moved the page: three scrolls put back the same way within a second are taken as the reader's run and given back, and so is each one after it that goes on the same way within a second of the last, so a wheel turned slowly or on a loaded Mac loses no step; a scroll by code is one, not a run, and two at rest are still put back; issenn on Discord, `view-wheel-unheard.test.cjs`. Under a click's 4s hold the same holds: only a put-back that comes with the page redrawn since the hold last held (`redrawn`: the view's height or where the first held parts sit moved from `h.lay`) is the hold's and never counts toward a run, so a profile opened on the Agents page and wheeled through at once scrolls, issennknight on Discord, `view-wheel-after-click.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`. +- 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 wheel or coast the page is never told of (macOS 13's WebKit, Safari 16.6's, scrolled a view under wheels it never dispatched, so every scroll was put back and only the bar's drag moved the page: three scrolls put back the same way within a second are taken as the reader's run and given back, and so is each one after it that goes on the same way within a second of the last, so a wheel turned slowly or on a loaded Mac loses no step; a scroll by code is one, not a run, and two at rest are still put back; issenn on Discord, `view-wheel-unheard.test.cjs`. Under a click's 4s hold the same holds: only a put-back that comes with the page redrawn since the hold last held (`redrawn`: the view's height or where the first held parts sit moved from `h.lay`) is the hold's and never counts toward a run, so a profile opened on the Agents page and wheeled through at once scrolls, issennknight on Discord, `view-wheel-after-click.test.cjs`. The parts `h.lay` measures are those still in the page that scroll with it: a part drawn again since (the Usage page's tabs, the agents' list under an agent opened or closed) is a redraw once, not at every scroll, and a sticky one (Settings' tabs at a narrow width) is left out, as it sits still while the page scrolls; `view-wheel-after-redraw.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 `