Commit Graph
10 Commits
Author SHA1 Message Date
ggbdpq 0076fb0c9c gui tests: the lightweight click fails at once on an option out of sight (#3078)
The red reported on origin/main 75e769a9f ("posted []", 4 of 8, chromium
and webkit) was the row under the window's foot: rows added above
Settings › General had put the Off/On options past the 1000px viewport
(y about 1008 of 1000), where a mouse click lands on nothing. No save
ever came, and the failure read as an empty posted list. The product was
never broken: 28bec1507 raised this test's page to 1200 tall (with the
on-by-default change) and c627652e9 kept it, so the file has been green
on main since. The trap stayed, though: rows keep being added to
General, and one more row grown above puts the option under the foot
once more, where the same silent no-op click reads as "posted []"
again - the On option's middle sits at y 974 of 1200 now, about four
rows of room.

What changed: the click helper asserts, before the mouse click, that
the option is wholly inside #view-settings and nothing drawn over takes
the point pressed - the check segs-glide's reveal has had since #2683.
A row grown under the foot now fails at once with where the option is,
instead of "posted []" after the 2.5s poll.

Broken by hand: with this file's viewport at 900 (the option's middle
at y 974), main's file fails "posted []"; this file fails "the option
is out of sight at (851, 974) of 900" at once, in English and Chinese.

Run at origin/main f24829636 + this commit, macOS, playwright 1.62.0:
- lightweight.test.cjs 10 rounds (chromium and webkit): 9 all-green;
  the one red round was settingsDrawn's 5s wait timing out on a box at
  load about 8, in a subtest that makes no click at all (the wait bar
  #4470 leaves at the click's 5s on purpose), green again on a rerun.
- settings-general, segs-glide, segs-press-redraw: green, two rounds
  each.

Generated-by: GLM-5.3-Flash (ZCode)

Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady,
sidebar and lightweight together, Chromium and WebKit, 30/30 ok. The
change makes the failure say what is wrong at once instead of waiting out
the click's timeout; it does not change what passes.
2026-11-06 05:53:50 +08:00
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 845b5c4ddd gui: Settings › General's Codex model rows and Open at login say what they do in their tooltip, and Lightweight mode that the gateway keeps running (#2120)
Anoninz asked on #2120 what the Codex model rows do, why Open at login
shows under App Background Activity on macOS, and what Lightweight mode
gives up. These rows were made to say their name alone in f36e744c3
(1ooogle's mockup, approved by the owner), so this adds no line under
them. The explanation goes into the row's tooltip, the way the text size
keys went in that same commit.
- Codex thread titles, descriptions, composer predictions, auto-review
  and memories model rows: what Codex uses the model for and when, and
  what "Codex's own" means. The facts are from settings.go and
  codexcat.go.
- Open at login: opens in the menu bar (tray) with no window. On a Mac
  it is a launch agent, which System Settings › General › Login Items
  lists under App Background Activity, not Open at Login. The section
  names are from macOS 26's LoginItems loctables.
- Lightweight mode keeps its one line. It now says the gateway and tasks
  keep running and only the page reloads (lightweight_rule.go: only a
  closed window's webview is let go). It still fits on one line at 1000px
  in every language. In de, "only the page reloads" didn't fit, so de
  says that the gateway and tasks keep running.
All five languages are covered: en, zh, zh-TW, ja and de.

Run: NODE_PATH playwright 1.62.0, chromium and webkit, all green:
- i18n-keys, bare-ids, gui-de, gui-ja, gui-zh-tw, search-keys
- lightweight, settings-general, settings-groups, settings-sections,
  settings-search, keep-login
- codex-titles, codex-descriptions, codex-predictions,
  codex-auto-review, codex-auto-reset-settings, codex-memories,
  codex-memories-settings, codex-subagent-model
A scratch check (not committed) loaded Settings › General in both
engines, at 1100 and 420, in all five languages, with Mac and non-Mac
platforms. It found each tooltip set and translated, the Mac/other
login text picked right, no sideways scroll, no row overflow and no
page errors (40/40).

Not tried: the tooltips weren't hovered in the real Wails window. No
Go code changed, so no go vet or go test was run.
2026-10-14 18:36:42 +08:00
yetone f36e744c30 gui: Settings › General says each setting's name alone where it says enough, and Language is one menu (1ooogle on X)
1ooogle's mockup on X redrew Settings › General the way macOS System
Settings reads it. The owner approved, and this follows it.

Rows that now show only their name:
- Appearance, Text size, Interface and Code font, the tray click,
  Provider in model names, the Codex titles, auto-review and memories
  model rows, Open at login and Show in Dock.
- A font row's line shows only while its fonts are loading or have
  failed.
- The text size keys (⌘0 / Ctrl+0) move into the choices' tooltip.

Rows that keep one short line, because the name alone doesn't explain
the setting or what it costs:
- Codex subagents, Long conversations, Lightweight mode, Prevent sleep
  and Session terminal.

Renames:
- "Tray icon" becomes "Click the tray icon to", with the choices "Open
  the quick panel" and "Open the main window" (点击托盘图标: 打开快捷面板 /
  打开主窗口).
- "Keep awake while agents work" becomes "Prevent sleep" (防止休眠: 在
  magpie 运行任务时,让电脑保持唤醒状态).
- "Dock" becomes "Show in Dock" (显示程序坞).

Language is one button showing the language picked (renderLangPick).
It opens in the app's own menu (openProtoMenu, styled like Session
terminal's sess-pick), not a native <select> and not six segments.

Every language gets the same text: en, zh, zh-TW, ja and de. The 25
strings no longer used are removed from all four translations.

Tests:
- New: settings-general.test.cjs. In Chromium and WebKit, en, zh,
  zh-TW, ja and de, at 1000 and 440 px, on a Mac, it checks that:
  - the rows that should show only their name have no line;
  - the kept lines are one line each, and none is cut short at 1000px;
  - Language is a button showing the language, and its menu lists all
    six;
  - a pick saves lang and redraws the page in that language, with the
    button staying under the pointer;
  - nothing has a left stripe and nothing scrolls sideways.
  I broke it by hand twice and saw it fail both times: once by giving
  the Dock row a line back, once by making the pick save nothing.
- Updated to the new text and controls: codex-titles,
  codex-auto-review, codex-memories-settings, model-suffix-own,
  plain-names, lightweight, keep-awake, text-size, gateway-mode,
  omarchy, settings-search, gui-zh-tw (Language's button and menu fit
  at 1000/440px), header-relang (picks through the menu) and
  readable-focus (the first shown line).
- German's long-conversations line was shortened to fit on one line at
  1000px.

What was run:
- go test -tags nogui ./internal/gui passes; gofmt -l is clean; go vet
  passes on darwin, linux and windows.
- The whole GUI suite (601 files, --test-concurrency=4): 6584 passed,
  33 failed. Every failing file was then run alone:
  - mobile-web fails on purpose. It compares desktop screenshots with
    origin/main, and only the Settings page differs.
  - routing-group-fold, text-size, routing-sessions and pick-skills
    are #1672; searcher-pick is #1745. Each also fails alone on
    origin/main 260ded9af.
  - routing-provider-off, routing-steady and usage-sum-whole pass when
    run alone, both here and on main.
- Screenshots before and after (zh, en and de light at 1000px, zh at
  440px, zh dark) were looked at.

Not tried in the real Wails window.
2026-10-12 22:51:53 +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
forever 62bee03287 gui tests: a Settings option is measured after the last save's answer has redrawn the page, so lightweight's Off is still attached when it is clicked ("Cannot read properties of null (reading 'x')", webkit zh, about 1 run in 4 under load) (#1177)
lightweight.test.cjs clicked Dock, waited only for its POST to reach the
fake API, then called boundingBox() on Lightweight's Off. The answer to that
POST runs renderSettings(), which replaces every segs control. When the
redraw landed between Playwright resolving the button and measuring it,
boundingBox() got a detached node and returned null. Diagnostics at the
failure: two POSTs, #lightweightSegs swapped twice.

The click helper now waits for prefsBusy === 0 before it measures. That
condition holds only after renderSettings has run, and fonts.test.cjs waits
on it the same way. Three sibling tests that act on a control their own
earlier save redraws get the same wait:
- keep-awake: drops its retry on a null box.
- search-first: before reading and measuring the redrawn row.
- skill-how: waits for the row the library's answer draws.

Run under a loaded machine (load average 120-170):
- lightweight, webkit zh: 8/32 failed before, 0/30 after.
- whole files in Chromium and WebKit: lightweight 20 rounds, 160/160;
  keep-awake 4 rounds, 128/128; skill-how 10 rounds, 60/60.
- search-first, webkit: still fails about 3 runs in 15, unchanged from
  upstream/main (3/15). The failure is at line 64, before this change:
  opening ?view=settings loads and draws Settings twice (show() and
  load()), and the row found by waitFor() is replaced. That is a separate
  cause in the page's startup, left for its own change.
2026-10-08 06:48:35 +08:00
yetone 7ca9419bcf gui tests: lightweight and provider-levels-scroll find their rows where the pages put them now — settings rows were added above Lightweight mode, so in a 700px window its segs sat under the footer (the test's window is 1000px tall); and a model row carries its price under its name, so the fixed scrollTop 260 left model-5 out of sight and Playwright's own scroll moved the list. provider-levels-scroll scrolls each row's levels to mid-list by hand (and throws if it can't), then checks a click moves nothing, as before. Pass in Chromium and WebKit, en and zh; failed on 6e623d16. 2026-10-06 05:07:13 +08:00
yetone 4a2f538c61 gui: lightweight mode, off by default, lets a closed panel's or window's webview go and makes it again when it is opened (somls on #580: GUI版可否增加轻量模式,关闭面板退出webview,减少资源占用) — closing the tray panel or the main window only hid it, so each kept its page and, on a Mac, its WebKit WebContent process (about 65 MB each at start, 95–100 MB after use) for as long as magpie ran. Settings → General now has Lightweight mode (轻量模式), shown in the app only (not on a browser's page) and kept as this computer's own through a sync or a restored backup (KeepOwn): with it on, a window found closed on two looks in a row 30 s apart (lightStep) is let go 30–60 s after it was closed, so a panel opened again soon after is still the same one at once. Letting go happens on the main thread under a new h.winMu: the window field is set to nil, the panel is unhooked from the tray icon (AttachWindow(nil); left click goes through magpie's own OnClick), and the main window is marked gone so its closing hook, which otherwise cancels a close and hides, lets it close; on the Mac the WKWebView is taken out of the window first (stopLoading, delegates and script handlers cleared, removed from its superview), since Wails' NSWindow close alone left the WebContent process alive for minutes. Opening it again (the tray icon, ShowMain, an import link, the Dock) makes the window anew with the options it was started with (makeMain/makePanel, moved out of Run with their hooks), its text size and title bar or Hyprland name (madeAgain), on Windows shown only once its page has loaded; every other path that reached h.main or h.panel (fit, tint, zoom, hide, glide, the Windows title-bar tint, the Hyprland click watch, the folder picker) now goes through the main thread and does nothing to a window let go; Linux keeps running with no window left (DisableQuitOnLastWindowClosed). Measured in a sandbox build under a temp HOME on other ports: started in the tray with the setting on, two WebContent processes of ~65 MB each; about a minute later both windows were let go and both processes ended (GPU and Networking, ~56 MB, are shared and stay; magpie's own process is unchanged), so the saving is ~130 MB idle and up to ~200 MB after use; the main window and the panel were then opened again with their pages, tinted and at the tray icon, closed, let go a second time, and magpie quit cleanly, with fit/tint/zoom calls every 0.2 s through a release crashing nothing. Windows and Linux build but were not run. TestLightStep and TestLightweightKeptAndOwn are new; lightweight.test.cjs (WebKit, en and zh: the row, off by default, On/Off posted as lightweight true/false, another setting's save keeping it, no scroll, no left-border accent, no row on a browser's page) is new and passes, as do click-scroll, settings-sections and searcher-pick. go vet ./internal/..., go build (darwin GUI), go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-03 00:24:49 +08:00