Commit Graph
2 Commits
Author SHA1 Message Date
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
wizzy-yangandwizzy-yang 6dd8c9aaf0 gui: a page's own scrollbar is dragged by the mouse (#1213)
Dragging a scrollbar did nothing on any page with content taller than the
window: the thumb would not move, and letting go left it where it started
(emo172, #1089). The wheel worked, so only the drag was broken, and a
scrollbar dragged in a container the app does not listen to scrolled
normally.

"Where the reader is" holds a view still unless the reader asked for the
scroll: the wheel, a touch, the keys, or a drag of the content, each of
which says so through an event. A scrollbar dragged by the mouse has no
such event — Chromium and WebView2 give it no pointermove — so every
scroll it produced was put back as it came, the thumb sliding back under
the pointer. The wheel works because wheel is one of the events.

The press on a scrollbar does reach the view, with the pointer past its
content in the scrollbar's band, and the lift ends the drag. Held from
that press to the lift, the drag's scrolls count as the reader's.

Two more things hold the page still that a wheel already lets go of, and
the drag lets go of the same two:

- what the last click was holding in place, which keeps what was clicked
  on the screen frame by frame for a few seconds after it;
- the reader's window itself, which WebKit needs held open past the lift:
  it sends the drag's last scrolls once the gesture is over, after the
  pointerup, so closing the window on the lift put those back.

A scroll nothing asked for — code setting scrollTop — is still put back:
only the bar's own drag counts as the reader's, not every scroll.

view-scrollbar-drag.test.cjs is new. It drags a page's own scrollbar in
both engines in English and Chinese, straight away and after a click in
the page that holds what was clicked; it checks the page follows the bar
and stays where it was left, that the wheel still scrolls, that a scroll
code set is still put back, and that a scroll arriving after the lift is
still the reader's. It uses the pages' own scrollbar CSS rather than one
of its own: a scrollbar-width set on the view makes Chromium drop every
::-webkit-scrollbar rule (app.css) and draw Windows' classic bar. The
Routing page is dragged at a narrow window, where it has room to scroll:
at a wide one it lays its stage beside the list and has ~35px left, not
enough to tell a drag from a nudge. The scroll arriving after the lift is
checked on the list page only. It was left off Routing while #1249 was
open — WebKit clamped Routing's last stretch there, so a scroll sent
after the lift measured that bug rather than the window held open past
it. #1249 is fixed in main now, so the check could be widened to Routing;
it is not, because that clamp was only ever checked on Windows headless
WebKit here and not on the macOS WKWebView, and widening a check is
beyond what review asked for.

Three of the checks were reworked after they were run four test files at
a time and each was found to pass for the wrong reason, or to race:

- the click in the page lands on a part that leaves the page as it is.
  The Routing page's own header opens the group editor in English,
  growing the page and scrolling it on its own, so where the drag left
  the page passed without the drag having moved it. The page is measured
  again where it is now and the drag is judged by how far it moves it.
- the scroll arriving after the lift is written from the pointerup
  itself, installed in the page before the lift. A round trip between the
  lift and that scroll measured 6-180ms alone and 314ms four files at a
  time — past the 250ms window the app holds open for it.
- the wheel's scroll is waited for to come to rest, not for a fixed
  time, which under load was not always long enough.

The scroll code sets a value the page is not already at, and runs before
any click: a click holds what was clicked on the screen for a few
seconds, and that hold moves the page on its own, which would answer for
the app.

It fails on main (the drag leaves the page at 0) and passes with this.

Verified at this head, rebased onto main 0d8f85e4 — which brought
#1249's fix, a change to the same scroll handler (its early return and
puttingBack), and #1236's scrollbar CSS. The merge kept main's structure
and folded barDrag === v into its first branch, so a dragged bar is
treated as the reader's and never recorded as a put-back.
node --check; go vet ./...; go build (windows); GOOS=linux build -tags
nogui. view-scrollbar-drag 5/5 in Chromium and WebKit, en and zh, three
solo runs each with no flake, and 5/5 again four test files at a time,
three rounds each on both engines. The nineteen scroll-related GUI files
(click-scroll, menu-scroll, strip-scrollbar, view-scrollbar,
view-no-sideways, sessions-toolbar, sess-agent-strip, agent-grip,
group-member-drag, usage-arrange, provider-order, purpose-filter,
proto-menu-overflow, routing-scroll-end, routing-purpose-state,
routing-steady, routing-served, fold-show-grip) 94/94 in both engines,
main's new view-no-sideways included since the base changed the
scrollbar CSS this test measures against; gui-ja / gui-de / gui-zh-tw /
i18n-keys 10/10 in both. Two mutations at this head: main's app.js fails
all five (the drag leaves the page at 0), and removing only the merged
barDrag === v condition — leaving the rest of the feature — fails WebKit
5/5 and Chromium 2/5 ("a scroll arriving after the lift is still the
reader's"), so the line the rebase folded in is guarded and the new
scrollbar CSS has not let the page pass without it. The other four
per-guard mutations (the whole barDrag rule, the hold let go on the
press, the window held open past the lift, the reader-position
put-back) were each run red without their guard at the pre-rebase head;
the rebase only folded barDrag into main's first branch and left those
four paths as they were.

Not verified here: only on Windows, in Chromium and WebKit through
Playwright. Not tried on macOS or Linux.

Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
2026-10-09 22:24:07 +08:00