From 472b36cec5d0975c0e67a088c7d894f26ea3b8fd Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 11 Oct 2026 00:22:05 +0800 Subject: [PATCH] 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. --- docs/subsystems/gui-shell.md | 1 + internal/gui/assets/app.css | 5 +- internal/gui/assets/app.js | 103 ++++++++++- .../gui/tests/usage-accounts-fold.test.cjs | 11 +- internal/gui/tests/usage-fold.test.cjs | 14 ++ internal/gui/tests/usage-pack.test.cjs | 168 ++++++++++++++++++ 6 files changed, 286 insertions(+), 16 deletions(-) create mode 100644 internal/gui/tests/usage-pack.test.cjs diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index da22c06d2..22c6dde3b 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -133,6 +133,7 @@ axis controls. - A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. - There are no native `