gui: a scroll down to a view's end with a wheel the page never hears stands

On macOS 13's WebKit the page never hears the wheel, so a scroll at rest
waits for a second one the same way before it counts as the reader's,
and is put back after 120ms if none comes. A view with less room than
one wheel step reaches its end on the first step, and no second scroll
can follow, so the reader's step was put back. A scroll down that stops
at the end, with the content still the same height, is now the
reader's. Code's put-backs this guards against come from a redraw: up,
or with the height changed.

Found by view-open-wheel at 420px in zh and zh-TW, Chromium: the phone
head left Usage's skeleton 23px of room, less than the test's 30px
step, and it was red 3 of 3 on this branch.

Broken by hand: without this change the case is red 3 of 3 alone
(MAGPIE_OPEN_WHEEL_HEARD=unheard, Chromium); with it, green in the run
below, and main at 8ac1c7a56 is green 3 of 3 alone. The comment above it
was shortened so the core scripts stay under their budget, not raised.

Run (mote, at this branch's head after the rebase onto 8ac1c7a56, beside
8ac1c7a56 itself): go test ./internal/gui/, and 116 GUI files (every
usage-*, view-*, *scroll*, phone-* and thumb file, Routing's rules and
the sign-in files) in both engines, concurrency 4. 1903 tests, 64 red on
the head; 1891, 64 red on main. The branch's own tests pass:
usage-phone-head in all 5 languages and both engines, usage-range,
credit-days, routing-held-dot, routing-rule-columns, segs-glide.
Red on both, each with an issue: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestMainWindowCorners/macOS_26_SDK (#3949), provider-typed
(#4673, filed now), tencent-cloud (#4321), usage-agents-hide (#3414),
usage-ledger Requests (#3104), mobile-web (#3952), phone-connect-menu
(#3524), menu-input-scroll (#3402), provider-levels-scroll (#4395),
view-open-wheel in WebKit under load (#4132); alone, its WebKit
unheard case passes 2 of 2 on both. signin-closes-sheet (#2628) is red
alone 3 of 3 on main and 1 of 3 here. signin-paste-import's paste
subtests were red once each (en here, zh on main), on the click #4035
names.
Before the last three commits and the rebase, the whole GUI suite ran on
this branch: 17076 tests; the reds it alone had were routing-held-dot and
routing-rule-columns (fixed by the thumb commit), credit-days and
usage-range (the two test commits).
At the pushed head, rebased onto 90c02326b (which left the core scripts
1 byte of room; this branch's app.js lines were cut by 179 bytes to
24 under main's, no raise): go test ./internal/gui/ on both. Head:
TestCoreScriptBudget passes; red are TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners/macOS_26_SDK (#3949), as on main, which
also has TestColdTurnsTaken red (#4510). And 110 GUI files at the head
(every file naming thumb or segs, usage-phone-head, usage-range,
credit-days, view-open-wheel, gateway-skew, i18n-keys), both engines:
2080 tests, 28 red, all in omarchy (#4624), s3-sync (#2448),
segs-press-redraw (#4566, #3922) and tencent-cloud (#4321); those four
files are 28 of 72 red on 90c02326b too.
Then rebased onto 8f5f2a294 (Library, Plugins and search pages, none of
this branch's files): the core scripts are 1,533,079 against 1,533,105,
and go test ./internal/gui/ at the pushed head has only the two reds
above.
Not tried: a real phone; Playwright at 390 and 420px stands in for one.
This commit is contained in:
yetone
2026-11-01 12:55:38 +08:00
parent febef9741f
commit ef8bd98fba
+6 -8
View File
@@ -22744,13 +22744,10 @@ function puttingBack(v, from, h) {
for (const p of mine) v.scrollTop += p.by;
if (!deaf) { deaf = true; try { localStorage.setItem("magpie.unheardWheels", "1"); } catch {} }
}
// Seen once (a run given back, kept for the next start), a scroll at rest
// waits a moment before it is put back, and one more the same way within
// 80ms (a frame or few: code's two scrolls come further apart), nothing laid
// out anew between them, is the reader's: a gesture
// starts without three put back first. What it puts back is kept, as at
// once, for a wheel heard late to give back (issennknight, macOS 13: Routing and
// Usage shook as they were opened and wheeled)
// Seen once (kept), a scroll at rest waits before it is put back; a second
// the same way within 80ms, nothing laid out anew, or one down to the end is
// the reader's. A wheel heard late gives back what was put back (issennknight,
// macOS 13)
let deaf = false;
try { deaf = localStorage.getItem("magpie.unheardWheels") === "1"; } catch {}
const waits = new WeakMap();
@@ -22759,7 +22756,8 @@ function waitsBack(v) {
if (!d) return false;
clearTimeout(w?.t); waits.delete(v);
if (w?.d === d && w.h === v.scrollHeight && performance.now() - w.at < 80) { readerWay.set(v, d); readerLeaves(v); flings(); return true; }
waits.set(v, { d, h: v.scrollHeight, at: performance.now(), t: setTimeout(() => { waits.delete(v); if (performance.now() >= purposeUntil && held?.v !== v) { const from = v.scrollTop; backToReader(v); puttingBack(v, from, false); } }, 120) });
const h = v.scrollHeight;
waits.set(v, { d, h, at: performance.now(), t: setTimeout(() => { waits.delete(v); if (d > 0 && h === v.scrollHeight && v.scrollTop + v.clientHeight >= h - 1) { readerWay.set(v, d); readerLeaves(v); } else if (performance.now() >= purposeUntil && held?.v !== v) { const from = v.scrollTop; backToReader(v); puttingBack(v, from, false); } }, 120) });
return true;
}
// Given back is what was put back after the reader's input was made (its