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 ad2424ade4 usage: a card's account button names the accounts it opens and folds back the ones it opened
WuSix on Discord (#help): three accounts on WorkBuddy, one deleted. The
button read 展开其余 2 个账号 with two accounts left; it opened both, and
收起其余账号 then folded only the second, leaving 展开其余 1 个账号 and the
first one open until its own arrow was clicked.

Cause:
- "其余 2" ("2 more"): each account's full/brief is remembered by
  provider and account (magpie.usageAccounts). An earlier 收起其余账号
  stored the one in sight (the deleted account) as in full and the other
  two as in brief. With it gone, neither left is in full, so every
  account is "the other" and the count was all of them.
- The fold: usageMore's fold was "every one but the one in sight back in
  brief" (usageShown: last answered, else the first). It kept alpha open
  however the accounts stood before the click.

Now:
- The window's button names what it opens: "Show all {n} accounts in
  full" (展开全部 {n} 个账号) when none is in full, as before otherwise.
- The accounts the button opens are remembered (magpie.usageAcctsOpened,
  followed across the window and the tray panel through the storage
  event). Its fold puts those back in brief, and only those; with every
  account opened by it, it reads "Show every account in brief" (收起全部
  账号). With none recorded (all opened by their own arrows, or a
  provider opened before this), it folds every one but the one in sight
  as before.
- An account's own arrow, and a menu bar cell opening an account, take
  that account off the record, so the button leaves what the user opened
  by hand alone. The panel's wording is unchanged.
- zh, zh-TW, ja and de for the two new strings. No layout change.

Test: usage-fold.test.cjs "an account deleted, the button opens and
folds the ones it names", at 420px wide, chromium and webkit, en and zh:
three accounts, open and fold (back to the one in sight), delete one,
reload: both in brief with "all 2"; open both, fold both; an account's
own arrow, then the button opening and folding the other alone.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- usage-fold's new "an account deleted" test passes in both engines, en
  and zh. Its chromium "several accounts" test is red alone at the stack
  and on main alike ("the view didn't scroll", 184 !== 180): #2163.
- internal/gui ok, the core script budget with it.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Broken by hand:
- app.js and i18n.js at ea6be1592: the new test is red in all four
  (chromium/webkit x en/zh), first at the "all 2" label (got "Show 2
  more accounts in full" / 展开其余 2 个账号 with none in full).
- Only the old fold put back (setUsageAccts(subs, q => q === pick)):
  red in chromium en and zh at line 241, waiting for "all 2" after the
  fold, since alpha stayed open.

Not tried: the real app; the GUI is faked in the tests.
2026-10-23 01:58:01 +08:00
yetone 472b36cec5 gui: the Usage page's short cards stack beside a tall one, packed into columns in the user's order (#860, huoranxuanyuan)
huoranxuanyuan's screenshots (1569px window at 175%, about 897px CSS):
a tall Codex card shared a grid row with Antigravity and a DeepSeek
balance, and both short cards stretched to Codex's height, mostly empty.
They asked for Antigravity and DeepSeek to stack beside Codex.

What changed
- packUsage (app.js) packs #subscriptionUsage into columns on 1px grid
  rows. Each card takes the leftmost column that ends highest and is as
  tall as itself; the cards' 7px gap stays.
  - The DOM order is unchanged and is still settings.usageOrder, so
    dragging, Alt+arrows and screen readers work as before.
  - Column count: the most 260px columns that fit, or one fewer when
    that leaves much less empty room (<0.6x) for a page at most 1.3x
    taller. It is chosen again only when the cards change or the width
    fits another number of columns. A card that grows or shrinks (a fold,
    "Every model") is only re-packed, so the card clicked stays where it
    was, even when the view's scrollbar appears and takes 10px of width.
    Keying the choice on the pixel width moved a card turned to every
    model in WebKit, which quota-families caught.
  - A ResizeObserver on the list and each card re-packs on the next
    frame. A hidden view falls back to the plain grid.
- fitQuotas is split into fitQuota(g), so heights are measured with each
  meter box laid out for the width being tried.
- The tray panel's Allowances list is a single column with no row
  stretching, so it needs no change.
- docs/subsystems/gui-shell.md describes the packing.

Tests
- New usage-pack.test.cjs, with fixtures of the reporter's cards:
  - Codex with a 7-day window, credit resets and a curve; Antigravity by
    family; a DeepSeek balance with its trend.
  - At 897, 1018 and 1400px: Antigravity beside Codex at its top,
    DeepSeek under it with the 7px gap, order kept, no overlap, no card
    taller than its content.
  - Equal cards: one row in order at 1300px, one column at 480px.
  - Opening a brief Codex account grows that card in place, with no
    scroll.
  - Runs in Chromium and WebKit, in en/zh/ja/de. It goes red when
    packUsage returns early (checked by hand).
- usage-accounts-fold: "Show fewer" now holds the card's head where it
  was, as usage-keys-fold already does for keys. Its old assertions
  expected the page to shrink to its end, which packing no longer does.
- usage-fold: scrolls to each fold button before clicking it, since
  Codex is now packed under ZCode, past the 300px-tall window.

Run
- usage-*.test.cjs, quota-families and click-scroll in both engines:
  all pass except usage-heatmap, which fails the same way alone on
  origin/main 497656174.
- Full GUI suite at concurrency 6, under machine load ~170: 5125 pass,
  56 subtests fail.
  - Run alone, these pass in this tree and on origin/main:
    account-arrange, agent-models-redraw, agent-stale-copies,
    agent-update-all, factory-key, group-from-model-add,
    library-servers-bulk, proto-menu-overflow, routing-mode-goes,
    routing-served, sessions-overview, tray-cell-click, update-wait,
    usage-ledger, usage-refresh.
  - These fail the same alone on origin/main: mobile-web, old-webkit,
    plugin-moved-signin, routing-context-fold, routing-group-fold,
    usage-heatmap.
  - quota-families was red only in this tree. That was the width-keyed
    choice above, now fixed and green in both engines.
- No Go change.
2026-10-11 00:30:14 +08:00
yetone 655f96ede4 gui tests: usage-fold and account-mask no longer reload the Usage page the moment it opens, so WebKit has no first reads to cancel and report as page errors (#1350)
Both tests opened the page in a new browser context, cleared their
localStorage keys and reloaded at once. A new context's storage is already
empty, and the reload lands while the page's first reads (agents/cli,
agents/install, usage, upstream, update, whatsnew) are on their way. WebKit
logs each fetch it cancels as "Fetch API cannot load … due to access
control checks." with source "javascript", which Playwright's WebKit turns
into a pageerror, and the tests' final assert.deepEqual(errors, []) failed.
The app catches every one of those reads; nothing is wrong in the page.

Instrumented runs show it: requestfailed "cancelled" for whatsnew/update
and the two page errors within 70ms after the first reload, none after.

Verified (Playwright 1.62.1, macOS arm64), WebKit "several accounts"
(en+zh), 8 copies at once, 5 rounds:
- before: 3 of 80 cases red, each with "Fetch API cannot load … due to
  access control checks" right after the first reload
- after: 80 of 80 pass, no page error
- usage-fold.test.cjs + account-mask.test.cjs, Chromium and WebKit,
  10 runs: 100/100 pass (10 cases each run)
2026-10-09 19:24:16 +08:00
yetone 2d5f9c748e gui: the Usage page shows every account again, each as compact as before the trend lines, and remembers which ones are open (ARNO on Discord: 以前每个账号所占的空间很小,基本能一页看到所有账号的情况,现在要一个个手动展开账号,展开后占的空间又特别大,余额走势的线条也分散在各个地方很乱。而且关了magpie后又得一个个展开)
With 17 subscriptions and 29 accounts, a card with several accounts showed one of them and hid the rest behind "Show N more accounts". Opening one showed every account at full size, with resets, credit days and its own trend line, so a page that once fit most accounts filled several screens. The open state was kept per subscription, and ARNO had to open the cards again after quitting.

Now every account of a card is on the page. The one in sight (the last served, else the first) is shown in full. The others are shown in brief: the account row and its windows' names, figures and bars, with the reset times only in the bar's tooltip, and no trend line, credit days, "read" line or resets row (the balance stays). A chevron at the end of each account row opens or folds that account alone. The card's button, now in its head beside the name, opens the rest in full or puts them back in brief. Each account's choice is kept in localStorage magpie.usageAccounts (provider + account), so it survives a restart and syncs with the tray panel. A subscription opened under the old magpie.usageOpen starts with all its accounts in full. A brief account's separator sits where a full one's does, so folding doesn't move the account clicked, and the page doesn't scroll (backToReader). The tray panel shows the accounts open in full (or the one in sight) with the same button. A jump to an account from the tray opens that account.

Tested: usage-fold.test.cjs checks the full/brief split, the per-account chevron (no scroll, the account stays put), the head button, that the choice survives a reload, Hide accounts, and the panel following the window. A new case with 17 subscriptions and 29 accounts at 1280x800 with Trends off has all 29 accounts' bars on the page and at least 15 fully on the first screen (16 now; 15 before the curves at 9ccabdfb^; 12 on v0.1.752, with 12 more only behind buttons). It fails on the old code. tray-cell-click now expects the opened account in magpie.usageAccounts. quota-curve, click-scroll, panel-usage, account-mask, mobile-web, tray-cell-click, quota-families and quota-pools pass in WebKit. Screenshots at 1280x800 in zh: Trends off, 19 of 29 accounts' bars fully on screen (scroll height 1360 vs 2005 with Cycle). go vet ./internal/... and go test -tags nogui -count=1 ./internal/gui/ under a temp HOME pass. Not tried in the built app with real accounts.
2026-10-03 19:45:33 +08:00
yetone ae6b4c9335 gui: a subscription with several accounts shows one of them on Usage and in the tray panel, the others behind "Show N more accounts" (whqtian on Discord: 我这个workbuddy只有4个账号,其实大多数情况下,我不需要显示全部的账号信息,你只要显示一个账号信息即可,其他的可以点击展开再看) — every provider's card listed each account's meters, credits and curve one under another, so four WorkBuddy accounts took the page. Now a card with several accounts shows the one that answered through the gateway last (lastServedAt), else the first, with "Show 3 more accounts" / 展开其余 3 个账号 under it; opened, all are shown in their order with "Show fewer accounts" / 收起其余账号. Opened is remembered by provider (localStorage magpie.usageOpen), for the window and the tray panel alike, each following the other as it is turned; a provider with one account has no button. The folded accounts stay in the page, hidden, so Hide accounts masks them as before; the line between accounts is drawn only after one in sight. The click keeps the page where it is (backToReader). usage-fold.test.cjs (WebKit, en and zh: 4 accounts show the last-served one and the button, opening shows all without moving the page, remembered after a reload, one account has no button, masking covers them, the panel folds the same and the window follows it) fails on the old code and passes; quota-families and quota-pools open the panel's second Antigravity account first. account-mask, quota-curve, click-scroll, mask-emails, credit-days, balance-parts, usage-arrange, panel-usage, tray-usages and usage-accounts pass; the GUI tests failing here fail the same on origin/main. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-03 16:50:31 +08:00