Commit Graph
3 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 46aa7e6b89 providers: the Codex app's switch notice has a Restart (nb5p_hQ on X)
After an account switch, Codex's accounts say the Codex app is still on
the account before. A user asked for a button that does the restart for
them. The notice now has Restart: magpie's own dialog asks first, then
magpie ends the app's own app-server (POST /api/codex/daemon/restart-app,
provider.RestartSwitchedCodexApp), waits for it to be gone and for the
app to start another, which reads auth.json and the new account. The
window stays, as the owner chose on 10-27 (quit and reopen opened a new
window). It ends the app-server now even mid-turn, after the confirm says
a running turn stops.

The app-server is ended as a clean exit (proc.End), never killed: the app
shows a killed app-server as a crash, so there is no force fallback. Each
failure says so in the notice, in the reader's language: the app isn't
running, the app-server couldn't be ended, the app didn't start another
within 20s, or the listing failed ("couldn't tell", not success).

Only the Codex desktop app gets the button (macOS ChatGPT.app/Codex.app,
the Windows Codex app). CLI agents in a terminal get none: restarting
them would lose the user's session. The text stays as it was.

app.js is 457 bytes smaller than main (comments cut), no budget raise.
The button and the confirm and four notices are in zh, zh-TW, ja and de.

Run:
- mote (darwin): gofmt -l clean; go vet agent, provider, gui on darwin
  and GOOS=windows; GOOS=linux go vet agent and provider (gui needs
  WebKitGTK headers, which neither mote nor magpie-desktop has).
- mote: go test provider -run 'TestRestartSwitchedCodexApp|TestCodexApp|
  TestRestartCodexApp' ok; agent TestRestartSwitchedCodexAppSays,
  TestEveryNotice ok; gui TestCoreScriptBudget etc. ok.
- win-run: the same provider tests ok, with real helper processes ended
  by proc.End (TerminateProcess) and a new one started.
- mote GUI: codex-app-stale + i18n-keys, chromium and webkit, en zh
  zh-TW ja de, 900 and 480px: 54/54.
- Broken by hand: TestRestartSwitchedCodexApp and ...Real go red when
  the wait for a new app-server always holds ("none back: <nil>").
- Real app: on mote, the real ChatGPT.app 26.1021 opened under the
  test's sandbox HOME (not signed in), its app-server 5232 ended, the
  app started 5901 within 3s, no diagnostic report; the app was quit.
  (A throwaway test, not committed.)

Not tried: a signed-in Codex app switching between two real accounts
(whether its window shows the new account's limits after this); the real
Windows Codex app; the Restart clicked in the real magpie GUI.
2026-10-30 12:35:18 +08:00
yetone 4eb90b69f4 provider: after magpie switches Codex's account, Codex's accounts say the Codex app is still on the one before and to quit and reopen it (CavillZhang on X)
The Codex desktop app (ChatGPT.app 26.1007, bundled codex 0.162) reads
auth.json once, as its app-server starts. codex-rs AuthManager only
reloads it for the same account (reload_if_account_id_matches skips a
different one; a full reload is the app's own login/logout). So after
magpie's switch the running app keeps the spent account's token, its
webview reads /wham/usage with it (straight to chatgpt.com, which magpie
can't intercept), gets rate_limit.allowed=false, and hardBlocked stops
the composer in every thread with "You're out of Codex and Work usage".
Only quitting and reopening the app moves it.

magpie now notes, like the managed daemon, the app's own app-server
(…/CodexCLI.app/Contents/MacOS/codex … app-server, or the Windows Store
app's codex.exe) running at a switch and the account it holds, until that
process changes. Codex's accounts show "The Codex app is still signed in
as …; quit it and open it again" with Got it; `magpie accounts` and the
gateway log say the same.

Run: go test ./internal/provider ./internal/gui (TestCodexAppStale goes
red with the app not noted), the new GUI test in Chromium and WebKit, en
zh zh-TW ja de, 900 and 480px; findCodexApp against the owner's running
ChatGPT.app found its app-server; go vet darwin/linux(nogui)/windows,
go build.
2026-10-10 13:41:59 +08:00