Commit Graph
4 Commits
Author SHA1 Message Date
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