Commit Graph
2 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 1c9747f611 usage: a Remote magpie provider's gateway keys each show their own limit, used and left, period and reset on the Usage page (#1547, PennyVibe)
A computer that uses another magpie through gateway keys that magpie gave
it saw the other magpie's subscription cards, but not what each key may
still spend there.

What changed:
- provider/remote_key_limits.go: each key of a remote-magpie provider
  gets a section on one card, "<remote>/~keys", read from the remote's
  existing GET /v1/magpie/limit asked with that key alone (the endpoint
  answers only the calling key, from access.Caller; nothing in the
  request picks another key, so a key never sees another's numbers).
  A window per cap (tokens, spend) named for its period (today / this
  week / this month / this cycle), used against the cap, with its
  reset; SubscriptionQuota.GatewayKey carries what is left, calls, the
  cycle's days, used up and unpriced calls. A key with no limit shows
  one "Limit: Unlimited" window. Kept for remoteCardsFor like the
  remote's cards; the card's refresh reads the named key again.
- A failed read keeps the last numbers, dated (AsOf); with nothing read
  the section says why, never zero and never "no limit". A remote from
  before /v1/magpie/limit (404) says it is too old to tell.
- GUI: the card is named "Gateway keys · <remote>" (main page and the
  tray panel), a line under each key says the cycle, calls and "used
  up", and the two new errors are said plainly; strings in zh, zh-TW,
  ja, de.
- magpie quota (CLI) shows the same cards; a window with no cap now
  reads "Limit unlimited" there, not "Limit 0%" (quotaCell).
- docs: providers-accounts (Allowance), gateway-routing (Remote magpie
  APIs, verification), reference (/v1/magpie/limit).

Run:
- New tests fail on the old code: TestRemoteMagpieKeyLimits (provider)
  and TestRemoteMagpieKeyLimitCards (gateway, a real Handler, real chat
  requests moving the numbers) with the key cards taken out of
  RemoteCards; usage-remote-key-limits.test.cjs on HEAD's app.js.
  TestKeyLimitTellsOnlyTheCaller guards what was already so (key A can't
  read key B by query, header or no key from the LAN), so it passes on
  both. TestQuotaCell's unlimited case reads "Limit 0%" on the old code.
- provider, gateway -count=3; go test -tags nogui ./... (full suite).
- GUI: the new test in chromium and webkit x en/zh/zh-TW/ja/de x
  900/400px (20 pass); the whole GUI suite.
- gofmt -l clean; go vet -tags nogui darwin, linux, windows.
- Real two-magpie run, both this build, sandbox HOMEs, 127.0.0.1:38461
  (remote) and :38471 (local); the upstream was a fake OpenAI server
  (fixed 175 tokens a reply). Remote keys laptop (1000 tokens/day), desk
  (5000/week), spare (no limit); local "office" Remote magpie with all
  three, routing rotate. After 17 chats through the local gateway,
  magpie quota on the local read laptop 1050/1000 (100%), desk
  1050/5000 (21%), spare unlimited (in --json; the text line read
  "Limit 0%", which the quotaCell change above fixes), matching the remote's own
  gateway-key list; laptop's spent key was passed over (every chat
  200). With the remote stopped each key said it couldn't be reached,
  never 0. Not run against a real vendor, nor a real magpie older than
  /v1/magpie/limit (unit-tested with a 404).
2026-10-11 09:10:44 +08:00