Commit Graph
7 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 d4699c00a6 gui tests: usage-card-refresh reads the refresh button's own path, not the card's first
d3191a51c (v0.1.1594) put an account's eye on each Usage card, before
the refresh button, so the card's and the row's first <path> became the
eye's. usage-card-refresh took that first path for the refresh icon's
turn and waited on an animation the eye never has: red in chromium and
webkit at d3191a51c, green at 0f6615ffc, run alone. It now names
.quota-refresh path, as the page itself does (the refresh animates
b.querySelector("path") on the button). No other test reads a card's or
an account row's first path (grep of tests/*.cjs).

Run (macOS, playwright 1.62.0, at 84bc5fdad plus this):
- usage-card-refresh.test.cjs: 46/46 twice, both engines; red before
  this at d3191a51c (2 of 46, the waitForFunction at :239).

Found by the whole GUI suite at d3191a51c: 12,984 tests, 201 reds under
a shared machine (load ~120); the 58 red files rerun alone gave 27 red,
and each was rerun on 0f6615ffc, the main before the eye. Only this
file was red at d3191a51c and green at 0f6615ffc on a serial rerun;
context-map at 420px is red now and then on both (1 of 3 each).
go test ./internal/gui at d3191a51c: ok.
2026-10-27 03:47:05 +08:00
yetone f5b1d36ffa usage: a card's refresh opens after its "Refreshed just now", so the text never moves
The owner: on hovering a usage card, the refresh icon appearing pushed
"刚刚刷新" right each time. The icon opened from width 0 in front of the
text, so the text moved by the icon's width on every hover.

The refresh button now comes after the text in every place quotaRefresh
is put (the read-when line, a panel row's name, the panel's error line,
both panel sub lines, and a failed window's line after its fix button),
and opens rightward into the card's padding: open, it is 14px with a
-2px right margin, so the text before it stays where it was. A panel
row's name ellipsizes rather than being pushed.

Run (darwin, chromium and webkit, logs kept whole):
- usage-card-refresh, panel-quota-refresh, quota-curve,
  quota-balance-error, usage-remote-key-limits, usage-remote-cards:
  144/144 ok
- quota-refresh-order, usage-refresh, i18n-keys: 17/17 ok
usage-card-refresh's hover check now asserts the text's rects don't
move when the icon opens and that the icon sits after the last of them;
on the old code it fails at the text moving.
Not tried: the real Wails app; the Windows and Linux webviews.
2026-10-24 19:19:24 +08:00
yetoneandchiperman 85eef5d87a gui: quota refreshes stay centered and finish each turn without jumping (#2397)
chiperman's patch (df288db, #2397), landed here since external PRs are
collaborators only. The card redraw replaced its refresh button on a
background reading and again when the click finished, restarting its
rotation and hover reveal and moving the Updated text; a fast reply also
stopped the spin partway through a turn. Each account's control and its
animation are kept through redraws, the reply is shown at once and the
current 800ms turn finishes (at least one), Reduce Motion skips it, and the
glyph sits on the text baseline in an inline grid instead of a pixel offset.

Changed in landing: main had since given the tray panel's Allowances the
same quotaRefresh (#panelQuota, #840). A kept button is reused only when its
redraw took it out of the page, so a refresh started on the Usage page is
never moved out of the panel (or back); the other place's copy of a turning
control gets busy+spun and turns by itself until done() clears it. The
panel's hover rule (.pq-card:hover) reveals it as the Usage card's does.
quota-refresh-order's vm harness gets a document stub for that.

app.js's budget goes from 1,250,000 to 1,269,000: with four comments
shortened it is 1,250,904 here, the core's own code since the tray panel
draws the same control, plus 1.5% as the budget's comment asks. Every core
script together is still under coreScriptBudget, which is unchanged.

Run, sandbox HOME, pinned GOMODCACHE/GOCACHE, load ~110-360 from other
sessions' suites:
- Full suite on 81313b912 + this change: set -o pipefail; go test
  -timeout 45m ./...: 64 packages ok; gateway and gui red
  in 3 tests:
  - TestCoreScriptBudget (app.js 47 bytes over; this change, fixed above)
  - TestPluginModelServiceTiersListed: ENOSPC, disk full; -count=3 ok
  - TestMainWindowCorners: killed at its deadline, red alone on main too
    (#1936)
- At this head:
  - go test ./internal/gui/: only TestMainWindowCorners red (#1936)
  - TestCoreScriptBudget: ok
  - gofmt -l: clean
  - go vet -tags nogui for darwin, linux and windows: ok (./... on
    81313b912 + this change; ./internal/gui/... at the rebase)
  - node --check app.js: clean
- GUI, Chromium and WebKit, at e085d6e92 + this change: usage-card-refresh,
  quota-refresh-order, panel-quota-refresh, gui-zh-tw, gui-ja, gui-de:
  84 pass, 0 fail. At this head usage-card-refresh, quota-refresh-order
  and panel-quota-refresh: 75 pass, 0 fail.
- Broken by hand: the new tests against the old app.js/app.css fail 26 of
  46 in usage-card-refresh ("a background reading replaced the spinning
  control", "the refresh icon and the first text line must share a
  vertical center": 253.875 vs 252.375).
- Whole GUI suite (789 files) on 81313b912 + this change, per file, 3 at a
  time. Every red file was rerun alone and checked against plain main
  where it stayed red. None is from this change:
  - Red on main as well, already filed: codex-predictions (#2624),
    lightweight (#2638), segs-glide (#2683), sidebar (#2684),
    login-import, routing-keys-fold, routing-bodies (#2658),
    usage-agents-hide (#2276), quota-count-wrap, quota-name-translated
    (#2228, #2399), routing-model-rest (#2115), rest-try-now (#2564),
    routing-request-metrics (#2571), s3-sync (#2448), usage-checkin
    (#2549), usage-refresh (#2184), quota-curve (load).
  - Load reds filed now, red on main too: tray-cell-click (#2686),
    usage-ledger-abort (#2700), sessions-paging (#2703).
  - The rest were launch or goto timeouts in the parallel run and pass
    alone (about 30 files, among them provider-max-output and
    plugin-agent).

Co-authored-by: chiperman <chipermanju@gmail.com>
2026-10-17 17:26:58 +08:00
hhh2210 2a99e7a429 gui: keep refreshed cards when their account identity changes (#1630)
The ce5d9f9d4 review correctly restored replies whose account was first
named by a refresh. Its full-list fallback bypassed the ordering guard:
an older GET could restore the unnamed card, or the fallback could undo
another card's completed refresh.

Apply the fallback to its provider's cards (a remote summary's namespaced
children included), keep other providers, and preserve card refreshes that
completed since the request began. Mark the replaced keys as well as the
new cards, so an old response cannot resurrect the unnamed summary. Only
a serialized whole-page read retires the markers it no longer needs.
No changes to account reading, authentication, throttling or auto-refresh.

Verification on macOS arm64, Go 1.27.2, Bun 1.4.3, isolated homes/APIs:
- On ce5d9f9d4, four new ordering cases fail: renamed account vs old GET,
  crossed card replies, a pending GET after another provider's completed
  refresh, and a remote summary becoming child cards. All nine now pass.
- The real browser page on ce5d9f9d4 reverts 61% to 28% after the late
  response. Named and unnamed cards now pass in both engines/all five
  languages. 21 related frontend files pass 184/184; the whole GUI suite
  was not run. The remote-card suite caught a missing namespace case in
  the first draft; corrected and the 21-file run repeated successfully.
- Three-platform vet and darwin/linux-nogui/windows builds pass. Final
  internal/gui Go tests pass after the namespace correction. Diff clean.
- Full go test -tags nogui ./... completed. The first isolation wrapper
  made TMPDIR too long for the omarchy Unix sockets; shortening TMPDIR
  makes that package pass. The unresolved failure is the already recorded
  TestPluginSOCKSProxy HTTPS/dead-SOCKS response-vs-error mismatch. No Go
  source or proxy paths changed; no full-suite-green claim.

Not tried: the native app or real account identity changes. These are
controlled response-order regressions, not the cause of the user's clicks
on the noninteractive reset-date glyph.

Review record (magpie maintainer session, on origin/main 429698f96, then
rebased onto fad96ea0f; sandbox HOME, private GOCACHE):
- gofmt -l clean; go vet darwin/linux/windows and the three builds pass.
- go test -tags nogui ./...: 52 packages ok at once. agent and gateway hit
  the 10m default under load ~190, middleware's TestFailOpen was slow and
  omarchy's sockets hit a long TMPDIR; rerun with a short TMPDIR and
  -timeout 40m all four are ok. internal/gui ok again after the rebase.
- quota-refresh-order: on main's app.js cases 6-9 fail; patched 9/9.
  Broken by hand, each red: no marker on replaced keys (6,8,9); an older
  reply may restore a removed key (6,8,9); fallback skipping
  keepRefreshedQuotas (7); remote children not matched (9); markers
  retired inside keepRefreshedQuotas (8); belongs() always true (8).
- Full GUI suite in chromium and webkit, 5 languages, 1100/420. Reds also
  red on main alone: usage-agents-hide and usage-fold (#2211, #2163),
  usage-sum-whole ja/de 780px (#1864: main 1/3, patched 2/3; that test
  serves no quotas). quota-name-translated and quota-pace goto timeouts
  under load passed rerun. After the rebase quota-refresh-order and
  usage-card-refresh pass 21/21 in both engines.
- Not tried: the native app or a real account whose identity changes.
2026-10-15 00:44:51 +08:00
hhh2210 86cc7ac56d usage, gui: keep refreshed cards and distinguish deferred readings (#1630)
A card refresh and a whole-page quota read could replace each other's
entire snapshots. An older GET arriving after a successful refresh put
the old number back on screen; two card refreshes could undo each other.
Apply each POST's requested card alone and retain completed card readings
against whole-page requests that began before them. Later reads can still
update or remove cards. Failed refreshes do not block background results.

A saved Claude account not asked for, or allowances held by When I ask,
could also show "couldn't be read just now" without making a request.
Carry readDeferred through the cached card and CLI/gateway report, and
give that state a separate translated notice. Keep original read times,
network-failure notices and authentication errors. Automatic saved-account
reads and the existing 30-second floor are unchanged.

Verification (macOS arm64, Go 1.27.2, Bun 1.4.3; isolated homes/API fixtures):
- On base 2c5db1c6, quota-refresh-order.test.cjs fails three cases:
  old whole-page replies restore 0 over 32; crossed card replies restore
  0 over the other card's 61. With the fix, 4/4 pass.
- TestQuotaDeferredReadIsNotFailure fails the three deliberate-skip cases
  on the base, passes here; checks real read failures and auth refusals too.
- Original assets fail the new browser case with "a request not made was
  described as failed". Related frontend checks pass 71/71, including the
  real card button in Chromium and WebKit across en/zh/zh-TW/ja/de. The
  extra locale/i18n checks pass 12/12. The full GUI suite was not run.
- Provider tests for deferred/kept/saved readings pass -race -count=20.
- gofmt and git diff --check clean. Full vet on darwin, linux nogui and
  windows; darwin build, linux nogui build and windows build pass.
- go test -tags nogui ./... completed: every tested package passed except
  internal/plugin's TestPluginSOCKSProxy. HTTPS through a dead SOCKS proxy
  produces "proxyconnect tcp: 502 Bad Gateway: socks connect ... refused",
  while the test expects an HTTP 502 response. Reproduced unchanged on
  freshly fetched upstream 68552188 in an independent worktree; already
  reported in #1630. The full suite is not green; no proxy change here.

Not tried: the patched native app with a real Claude account. The response
ordering is injected in tests, not captured from the reported incident;
this does not establish that every intermittent refresh failure is fixed.
2026-10-14 21:54:12 +08:00
yetone 37f2a2851f gui: a Usage card has a refresh of its own, left of its "Updated" time, that reads that card alone (Hu9956, #840: 在更新时间左侧加一个刷新按钮,鼠标悬停在套餐卡片上时显示,可以单独刷新某个套餐的用量,不用刷新全部) — only the page's Refresh read the allowances again, every card at once. Each card now has a ↻ that opens left of "Updated 3 min ago" (or of a failed reading's reason, or under a balance) as the card is hovered; at rest the line starts where the card's others do. A click POSTs /api/usage/quotas/refresh?provider=&user=: provider.RefreshUsage reads that subscription account, plan key or balance key again (a Claude account by running Claude Code's own /usage, as the page's Refresh does) and puts it in place in the caches, the other cards not asked and kept as they were read; the button turns while it reads. zh, ja, de strings. TestRefreshOneCard (two keys of one relay and another provider: a refresh asks that key alone, the others keep their figures) and the plugin case in TestPluginUsage (one account of three read) fail on the old code; usage-card-refresh.test.cjs (WebKit, en and zh: aligned at rest, left of the time when hovered, a click reads that card alone, turns meanwhile, doesn't scroll; a failed card's own button) fails on the old code. usage-quota-head, usage-checkin, click-scroll, quota-read-at, balance-parts, claude-usage-asked, gui-ja and gui-de pass on WebKit. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-05 08:59:47 +08:00