Commit Graph
6 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
yetone c627652e9a settings: lightweight mode is off for a user who never chose
The owner, 10-21: "要默认关闭「轻量模式」,不然太卡了". With it on, the window
is made again and its page loaded again on every opening, which is slow.
28bec1507 had made it on for a user who never chose, against a hidden
webview growing ~20 MB a minute on Windows (#2515); that user now gets
the kept window again. A user who turned it on or off keeps their choice:
only an unset value changes meaning (LightweightOn, Settings › General's
row).

Run on origin/main b855cfee9 + this commit, macOS, playwright 1.62.0:
- go test ./internal/settings/ -run Lightweight ok; red with the old
  LightweightOn.
- lightweight.test.cjs, segs-glide, segs-press-redraw, settings-general:
  89/90 in chromium and webkit, every language; the red was
  segs-press-redraw chromium en 440px while a full GUI suite ran beside
  it, and the file passes 42/42 alone. lightweight.test.cjs goes 4 of 8
  red with app.js's old `!== false`.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of internal/settings and internal/gui.

Shipped at the owner's word (10-21, "赶紧上线") before the full GUI suite
finished: it was stopped at ~2,040 passing tests (about a quarter of the
files, on b855cfee9 + the dialog change), with two reds,
desktop-longest chromium zh 640px and gateway-key-groups chromium en,
both under load at ~100. On origin/main c79400556 + both commits (rebased after onto
e68a0b1db, which adds only internal/sessions):
desktop-longest, gateway-key-groups, modal-morph, lightweight,
segs-glide, segs-press-redraw and settings-general 108/108 in chromium
and webkit; go test ./internal/settings/ ok; go test ./internal/gui/
-run 'Budget|Lightweight' ok; gofmt -l clean; GOOS=linux go vet -tags
nogui and GOOS=windows go vet of internal/settings and internal/gui.
Not run: the rest of the GUI suite.
2026-10-21 18:45:23 +08:00
yetone 28bec1507c settings: lightweight mode is on for a user who never chose it, and off for one who turned it off
The owner: 改成默认开,只对没设过的用户. A webview kept for good holds what
its page drew while hidden, which grew ~20 MB a minute on Windows under
steady requests (#2515); lightweight mode lets it go.

- settings.Lightweight is a *bool: nil (never chosen) is on, false is
  off, true is on. LightweightOn() says which; gui/lightweight.go reads
  it. KeepOwn still keeps this computer's value on a sync or a restore.
- app.js shows On unless lightweight is false, and the prefs save sends
  s.lightweight as it is: unchosen stays out of the JSON, so saving
  another setting doesn't choose it.

Caveat: until now Off was a bool with omitempty, so it was never stored.
A user who chose Off before this can't be told from one who never chose,
and gets On. Only choices made from this release on are kept.

Tests:
- settings TestLightweightKeptAndOwn: on when unset, Off saved reads back
  off, another save keeps it off, KeepOwn keeps this computer's Off over
  the other's On, and an empty one stays unset. Broken by hand
  (`!= nil && *`) it fails "off for a user who never chose".
- lightweight.test.cjs: On shown for a user who never chose; another
  setting's save posts no lightweight; Off posts false and shows Off;
  another save keeps false; On posts true; nothing scrolls. Its viewport
  is 1200 tall: rows added above had put Off under the window's foot
  (y≈1008 of 1000), where the mouse click did nothing.
- segs-glide and segs-press-redraw start from a user who turned it off,
  so On is still a pick away; README's lightweight line says the new
  default.

Run at this commit's parent (the #2683 test fix on origin/main
f73378365), chromium 1234 and webkit 2336, playwright 1.62.0:
- lightweight, segs-glide, segs-press-redraw, settings-general
  (--test-concurrency=1): 90 of 90. These are every GUI file that reads
  lightweight (grep); no others reach it.
- go test -timeout 45m ./internal/settings ./internal/gui: ok (gui 554s).
- gofmt -l internal/: nothing. GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: clean.

Not tried: the real app's webview being let go after this change on
Windows or Linux; the release path is the same as with On chosen before.
2026-10-20 20:23:50 +08:00
yetone 031715d5e4 gui tests: segs-glide names each control by the nearest id above it and brings an option wholly into view (#2683)
segs-glide was red 20 of 20 on origin/main. Two causes, both in the test:

- It named a control by its parent's id, or else its options' kind.
  Full window's and Codex async's controls both sit in a .compact-at
  with no id, so both were "off|on", and Codex async's 38px thumb was
  compared with Full window's 118px one: "off|on's thumb moved
  (2.0/38.0 → 2.0/118.0)". A control is now named by the nearest id
  above it, and oneWay fails when two controls share a name.
- Behind that, en 440px failed "a click never moves the page" (160 vs
  150): reveal stopped once the option's middle was on screen, with its
  foot cut by the view's (button bottom ~979, view bottom 972), and
  Playwright's click scrolled it in by itself. Pressed by hand (mouse
  down/up, no locator.click) nothing scrolled. reveal now waits until
  the whole option is inside #view-settings.

Run at origin/main f73378365 (chromium 1234 and webkit 2336, playwright
1.62.0): segs-glide.test.cjs 20 of 20 (both engines, en/zh/zh-TW/ja/de,
900px and 440px), --test-concurrency=1. Before: chromium en 900/440 red
the same way as the issue, and en 440 red 3 of 3 on the scroll check
once the name was fixed. Broken by hand: with the old naming the new
guard fails "answer mid-glide: two controls under one name".
2026-10-20 20:23:49 +08:00
yetone 8f9bc3fccf gui tests: the 37 other Settings tests act on rows once the page has drawn its last read of the settings, as the masking-rules tests do since #1653 (#1659)
Opening Settings reads the settings twice: the page's own read
(showView), then the window's load() once the state is in. Each read
redraws every row. A test that found a row after the first draw, and
then called scrollIntoViewIfNeeded or boundingBox on it, failed when the
second read landed in between. The errors were "Element is not
attached", or a null box. #1653 fixed the three masking-rules tests and
listed these 37 in #1659.

Each of the 37 now calls watchSettingsReads(page) before every
page.goto, and settingsDrawn(page) right after it. Right after goto is
exact for ?view=settings: at boot, show(view) asks for showView's read
before load() runs. load() sets load.done in the same run that then asks
for its own read, so settingsDrawn's "load.done and every read asked
for drawn" holds only once the second read is drawn. For a test opened
on another page that clicks into Settings later, load is done by then,
the click makes the only read, and the wait passes at once.
watchSettingsReads now watches a page once, however many times it is
opened, since some of these tests open one page several times. The
page is unchanged.

Reproduced with a generic injection (scratchpad inject1659.cjs, loaded
with NODE_OPTIONS=--require). A route added at each goto holds the
page's second GET /api/settings. It lets the read go just as the test
calls scrollIntoViewIfNeeded or boundingBox, or waits on the page with
waitForFunction (which settingsDrawn is), with a 4s timer as a backstop.
This is #1653's injection, made generic.

Before, injected, both engines, all languages:
- 5 files red with the issue's error:
  - github-token: null box.
  - member-model-setting, searcher-pick, search-first and update-wait:
    "Element is not attached to the DOM".
- 4 files red on a check of a row drawn from the first read:
  model-suffix-own, otel, readable-focus and warm-at-times.
- 28 green.

After, injected: 36 of the 37 files green, every held read let go by
settingsDrawn's wait. otel stays red in WebKit at 360px. It is red the
same way with no injection, on origin/main's own copy of the test. That
cause is separate (the narrow nav laid out after setViewportSize
returns) and has its own commit next.

Plain (no injection), both engines, all 37 files: 460 cases passed and
2 failed, both otel's WebKit 360px check above.

The 8 files red under injection before, injected again after,
5 rounds: 390 of 390 cases passed.
2026-10-12 03:25:47 +08:00
yetone b0e25696eb gui: a segmented control's thumb glides once, one way, and no other thumb moves when a save redraws the page
Settings' Off/On (Lightweight mode in the report) shook back and forth when
clicked, and the first click on the page replayed every thumb's animation.

Why, in the old slide():
- Every save's answer runs renderSettings(), which draws a new control and
  a new thumb for each one. The new thumb took its place from what was
  remembered: within 300ms of the click it started from the position
  before the click, so a redraw mid-glide sent the thumb back to Off and
  slid it again.
- Settings is drawn while hidden (at start, or from another tab), so every
  control was remembered 0 wide. thumbsUnderPicks put the DOM right when
  the tab was shown but never the memory, so the first save's redraw grew
  every thumb on the page in from the left.

#1211 (700315dff) only kept a press made across a redraw (pointerdown on
one button, pointerup on its replacement); it never touched how the thumb
moves across a redraw, which is why the shake stayed.

Now:
- A redrawn control takes over the old thumb element itself, with its
  running animation, so a glide in flight just goes on. No clock math.
- slide() glides only when the target changes, from where the thumb is
  drawn now (computed transform), with a WAAPI animation; the CSS
  transform/width transition is gone so nothing else starts one.
- One shared ResizeObserver puts a thumb under its option, without motion,
  when its control is shown or resized. A control drawn hidden is never
  measured. thumbsUnderPicks and the two per-bar ResizeObservers go.

Run:
- segs-glide.test.cjs (new): records every thumb on General per frame and
  between frames, for an answer mid-glide, an answer at once with two more
  redraws on the way, and a refused save; Chromium and WebKit, en zh zh-TW
  ja de, 900 and 440px. 80/80 over two runs; on the old code 20/20 fail
  (thumb jumps back to 0).
- Full GUI suite, concurrency 6: 6157 tests, 10 fail. Each fails the same
  alone on origin/main 96de5cac2 (library-mcp-tool-switch #1609,
  privacy-hides-accounts and usage-stale-answer #1632) or passes alone on
  both (purpose-filter, routing-signin, filed in #1632). tencent-cloud's
  WebKit flake also happens on the old code (#1620).
- Checked by hand against a sandbox magpie web (real server, sandbox
  HOME): the clicked thumb moves one way, no other thumb moves, including
  Settings opened from Usage first.
- gofmt, go vet (darwin, linux nogui, windows), go test ./internal/gui.

Not tried: the Wails app itself, Windows and Linux webviews.
2026-10-11 23:04:12 +08:00