gui: Usage's subscription cards in one row are as tall as each other, so their bottoms line up (ikunbots on X)
ikunbots ("magpie 的这个卡片可以对齐吗") and duanjl_china ("有的长有的短"):
Claude Code, Codex and Antigravity sat side by side in one row on the
Usage page, each as tall as what it held, so their bottoms were ragged.
What changed
- packUsage (app.js) still packs the cards into columns as #860 made it
(a short card stacks beside a tall one, never stretched to a row's
height). After placing them, the last card in each column gets a
min-height that takes it down to where the tallest column ends.
- Cards side by side in one row (one card per column) are as tall as
the tallest, bottoms on one line, content at each card's top.
- A stack stays a stack: the upper cards are as tall as themselves and
only the last one reaches down to end with the tall card beside it,
which is what #860 asked for (堆叠和 Codex 对齐).
- One column: each card is as tall as itself, nothing to line up.
- The min-heights are cleared before every measuring, so a re-pack
(resize, a fold opened, cards changed) measures each card as tall as
itself. A min-height rather than a stretch keeps a card that outgrows
it growing, so the ResizeObserver still re-packs.
- docs/subsystems/gui-shell.md says so.
Tests
- usage-pack.test.cjs:
- New: ikunbots' three cards (Claude Code 2 windows, Codex, Antigravity
6 families; content heights 107/169/217px) at 1400 and 1018px are one
row with bottoms within 0.5px; at 480px one column, each card as tall
as itself; widened again, one row lined up again.
- The reporter's #860 stack at 897/1018/1400px still stacks:
Antigravity as tall as itself, DeepSeek under it with the 7px gap,
ending where Codex does.
- sound(): a card is as tall as itself unless it is last in its column,
which ends with the tallest; no card is shorter than its content.
- The fold case: opening Codex's brief account grows what the card
holds; the card already reaching down to the stack's end stays that
tall rather than growing (was "the card grew").
- Broken by hand: no min-height applied -> "1400px: the cards' bottoms
line up" red in all 8 (chromium/webkit x en/zh/ja/de); min-height not
cleared before measuring -> "narrow: antigravity is as tall as itself"
red. Restored: 8/8 pass.
Run
- usage-pack.test.cjs in Chromium and WebKit, en/zh/ja/de: 8/8 pass.
- Every GUI test file touching the Usage page (75 files, those naming
#subscriptionUsage/.subscription-card/view=usage, plus click-scroll),
both engines, concurrency 6: 917/918 pass. panel-usage webkit en failed
once under that load ("asked: period=today&limit=1", a 2.4s poll in its
Requests-window step this change doesn't reach), passes 3/3 alone;
added to #1544 with its cause.
- Screenshots before/after with fixture data looked at: ragged row
before, one line after; 897px stack unchanged but for DeepSeek/Codex
ending together.
- No Go change; gofmt/vet/build not run. Full GUI suite not run.
This commit is contained in:
@@ -155,7 +155,7 @@ retry after a failed read. See `TestRecentCallBodiesOnDemand` and
|
||||
- There are no native `<select>` elements and no colored left-border stripes. State is shown with a dot or a swatch.
|
||||
- The Usage page's cards and the tray panel's Allowances tab share one order, `settings.UsageOrder` (`byUsageOrder`). In the panel a balance-only card stands where that order puts it, and balances next to each other share one *Balances* grid (`panelBalances`, #1510); none is gathered after the plans. The panel's *Arrange* (`panelArrange`) moves rows in it and hides subscriptions from that tab alone (`settings.PanelUsageHidden`); both save through `POST /api/usage/arrange`, which changes only the field it is sent, and the Settings save keeps both. Hiding is display only: a menu bar cell's card shows though hidden (`panelPeek`). See `TestUsageArrangePanelHidden`, `panel-arrange.test.cjs` and `panel-balance-order.test.cjs`.
|
||||
- Opening the allowances is asking to see them (#1588, `quotasOpened` in `app.js`): the Usage page from the nav or its Overview tab picked, the window brought back to the front on the Overview, the tray panel's Allowances tab picked or the panel brought up on it, and a menu bar cell clicked each load `usage/quotas?asked=1`, as Refresh now does. An asked read makes the backend read every account again (`AskClaudeUsage`), so an opening within 30s (`QUOTAS_OPEN_GAP`) of the last asked read sends an ordinary read instead, which joins one on its way; Refresh now always asks. A panel page loaded while it is put away (hidden, or without focus) doesn't ask. The timed refresh is unchanged and never asks. See `allowance-open-read.test.cjs`.
|
||||
- The Usage page's cards are packed into columns, never stretched to a row's height (`packUsage`, #860): each card in that order goes to the leftmost column that ends highest, on 1px grid rows, so short cards stack beside a tall one. The page's order (DOM, dragging, Alt+arrows) stays `UsageOrder`. The column count is the most 260px columns that fit, or one fewer when that leaves much less empty room; it is chosen again only when the cards change or the width fits another number of columns, so a card opened or folded stays where it is, even as the scrollbar comes in. See `usage-pack.test.cjs`.
|
||||
- The Usage page's cards are packed into columns, never all stretched to a row's height (`packUsage`, #860): each card in that order goes to the leftmost column that ends highest, on 1px grid rows, so short cards stack beside a tall one. The last card in each column then reaches down to where the tallest column ends (a `min-height`, cleared before the cards are measured again), so cards side by side in one row are as tall as each other and a stack ends with the tall card beside it (ikunbots on X); content stays at each card's top. The page's order (DOM, dragging, Alt+arrows) stays `UsageOrder`. The column count is the most 260px columns that fit, or one fewer when that leaves much less empty room; it is chosen again only when the cards change or the width fits another number of columns, so a card opened or folded stays where it is, even as the scrollbar comes in. See `usage-pack.test.cjs`.
|
||||
- The Providers page has a search box over its list (#1614, `findProviders` in [`app.js`](../../internal/gui/assets/app.js)): the words typed keep the rows, on and off, whose text or data say them all: name, id, preset, addresses, every model's id and name, the account's user and plan and each login's, account names and key names. The Turned off fold stays open while searching; Escape or clearing the box shows every row and the fold as it was. A row that is on reorders by dragging its logo, Alt+↑/↓, Alt+Shift+↑/↓ (top, bottom) or its right-click menu (`openProviderMenu`: Move to top, Move up, Move down, Move to bottom). While searching, a step or a drop moves it among the rows shown (it takes the place of the row it passes, `stepProvider`, `shownToOn`) and the hidden ones keep their order; Move to top and Move to bottom go to the ends of the whole list. Every move saves the whole order through `POST /api/providers/arrange`. See `provider-find.test.cjs` and `provider-order.test.cjs`.
|
||||
- The page must work in Chromium (Windows' WebView2) and WebKit (macOS, and WebKitGTK on Linux). GUI tests run in both engines.
|
||||
- On Linux the panel is frameless and the main window has a hidden title bar (`plainTitlebar`). GTK 3 asks KDE's Wayland session (KWin's decoration protocol) for a frame drawn by KWin on any window without client-side decorations, an undecorated one too, so `ownFrame` tells KWin the panel draws its own on each realize (#1283). GTK 4 builds ask for none themselves. With no KWin title bar, and with a Wayland window placed by the compositor rather than by the icon, the panel's header is its drag handle on Linux, as the window's is (`--wails-draggable` in `app.js`; `panel-drag-linux.test.cjs`); on the Mac and Windows the panel isn't dragged (#1430).
|
||||
|
||||
@@ -14575,7 +14575,11 @@ function keyCards(list) {
|
||||
// fold opened) only packs them again, so what was clicked stays where it
|
||||
// was, even as the view's scrollbar comes in and takes some of the width
|
||||
// (in WebKit a card turned to every model went to one column under its
|
||||
// neighbour, the page following it).
|
||||
// neighbour, the page following it). The last card in each column reaches
|
||||
// down to where the tallest column ends, so the bottoms line up: a row of
|
||||
// cards side by side is as tall as its tallest, and a short card stacked
|
||||
// under another ends with the tall one beside them (ikunbots on X: 卡片可以
|
||||
// 对齐吗). Each card is measured as tall as itself before that.
|
||||
const USAGE_MIN = 260, USAGE_GAP = 7;
|
||||
let usagePacked = null, usagePackFrame = 0;
|
||||
function packUsage() {
|
||||
@@ -14587,7 +14591,7 @@ function packUsage() {
|
||||
// out of sight: the grid as it is without packing, packed once it shows
|
||||
list.classList.remove("packed");
|
||||
list.style.gridTemplateColumns = "";
|
||||
for (const c of cards) c.style.gridArea = "";
|
||||
for (const c of cards) { c.style.gridArea = ""; c.style.minHeight = ""; }
|
||||
usagePacked = null;
|
||||
return;
|
||||
}
|
||||
@@ -14607,6 +14611,7 @@ function packUsage() {
|
||||
return { n, at, tall, empty };
|
||||
};
|
||||
const heights = () => {
|
||||
for (const c of cards) c.style.minHeight = "";
|
||||
for (const g of list.querySelectorAll(".quota-windows")) fitQuota(g);
|
||||
return cards.map((c) => c.getBoundingClientRect().height);
|
||||
};
|
||||
@@ -14630,9 +14635,14 @@ function packUsage() {
|
||||
}
|
||||
usagePacked = { most, keys, n: best.n };
|
||||
list.classList.add("packed");
|
||||
// the last card in each column, down to the end of the tallest
|
||||
const last = new Map(best.at.map(([c], i) => [c, i]));
|
||||
best.at.forEach(([c, top, h], i) => {
|
||||
if (last.get(c) === i) h = best.tall - top;
|
||||
const area = `${top + 1} / ${c + 1} / span ${Math.max(1, h)} / span 1`;
|
||||
if (cards[i].style.gridArea !== area) cards[i].style.gridArea = area;
|
||||
const min = last.get(c) === i ? `${h}px` : "";
|
||||
if (cards[i].style.minHeight !== min) cards[i].style.minHeight = min;
|
||||
});
|
||||
}
|
||||
// a card's height or the page's width moved: packed again on the next frame
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
// order on the page is still the user's (dragging and Alt+arrows are
|
||||
// usage-arrange's), no card overlaps another, and a card opened to its
|
||||
// accounts in full pushes the one under it down rather than over it.
|
||||
// The last card in each column reaches down to where the tallest ends
|
||||
// (ikunbots on X, "卡片可以对齐吗"): Claude Code, Codex and Antigravity side
|
||||
// by side end on one line, and DeepSeek under Antigravity ends with Codex.
|
||||
// Chromium and WebKit, English, Chinese, Japanese and German; no backend,
|
||||
// the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -42,6 +45,22 @@ function fixtures(now) {
|
||||
const history = [{ provider: "codex", user: "me@example.com", lines: [{ name: "7 days", points: week }] }];
|
||||
return { quotas, history };
|
||||
}
|
||||
// ikunbots on X: Claude Code, Codex and Antigravity side by side in one
|
||||
// row, each as tall as what it holds, their bottoms ragged
|
||||
const ikun = (now) => {
|
||||
const w = (name, used, h) => ({ name, used, resetsAt: iso(now + h * H) });
|
||||
const ag = (name, family, used, h) => ({ name, family, used, resetsAt: iso(now + h * H) });
|
||||
return [
|
||||
{ provider: "claude", name: "Claude Code", icon: "claude-color", user: "me@example.com", plan: "Max 5x", lastServedAt: iso(now),
|
||||
windows: [w("5 hours", 23, 3), w("7 days", 41, 90)] },
|
||||
{ provider: "codex", name: "Codex", icon: "codex-color", user: "me@example.com", plan: "Plus", windows: [w("5 hours", 8, 2)] },
|
||||
{ provider: "antigravity", name: "Antigravity", icon: "antigravity-color", user: "ag@example.com", plan: "Google AI Pro", windows: [
|
||||
ag("Gemini 3.1 Pro (High)", "Gemini", 100, 13), ag("Gemini 3 Flash", "Gemini", 20, 13),
|
||||
ag("Claude Sonnet 4.6", "Claude", 0, 5), ag("GPT-OSS 120B (Medium)", "GPT-OSS", 0, 5),
|
||||
ag("Gemini 2.5 Flash Image", "Image", 40, 5), ag("Tab completion", "Tab", 0, 5),
|
||||
] },
|
||||
];
|
||||
};
|
||||
// cards of one height: one row, in their order
|
||||
const even = (now) => ["kimi", "zai", "minimax", "moonshot"].map((p) => ({ provider: p, name: p, icon: p, windows: [{ name: "5 hours", used: 30, resetsAt: iso(now + 2 * H) }] }));
|
||||
// several accounts, the second in brief until opened
|
||||
@@ -83,9 +102,14 @@ const boxes = (page) => page.$$eval("#subscriptionUsage > .subscription-card", (
|
||||
const settle = (page) => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => requestAnimationFrame(r)))));
|
||||
|
||||
function sound(cards, what) {
|
||||
const end = Math.max(...cards.map((c) => c.bottom));
|
||||
for (const c of cards) {
|
||||
// as tall as what is in it, its padding and border: never stretched
|
||||
assert.ok(c.bottom - c.inner < 16, `${what}: ${c.key} is as tall as itself: ${JSON.stringify(c)}`);
|
||||
// as tall as what is in it, its padding and border, but for the last in
|
||||
// its column, which ends where the tallest column does (ikunbots on X)
|
||||
const last = !cards.some((d) => d !== c && d.x === c.x && d.y > c.y);
|
||||
assert.ok(c.inner <= c.bottom, `${what}: ${c.key} holds what is in it: ${JSON.stringify(c)}`);
|
||||
if (last) assert.ok(Math.abs(c.bottom - end) < 0.5, `${what}: ${c.key}, last in its column, ends with the others: ${JSON.stringify(cards)}`);
|
||||
if (!last || c.bottom < end - 0.5) assert.ok(c.bottom - c.inner < 16, `${what}: ${c.key} is as tall as itself: ${JSON.stringify(c)}`);
|
||||
}
|
||||
for (const a of cards) for (const b of cards) {
|
||||
if (a === b) continue;
|
||||
@@ -120,6 +144,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
};
|
||||
const now = Date.now();
|
||||
|
||||
// ikunbots' row of three of different heights: as tall as each other,
|
||||
// their bottoms lined up, each one's content at its top
|
||||
for (const width of [1400, 1018]) {
|
||||
const page = await open(`ikun-${width}`, { quotas: ikun(now) }, width);
|
||||
const cards = await boxes(page);
|
||||
assert.deepEqual(cards.map((c) => c.key), ["claude", "codex", "antigravity"], "the order on the page is the user's");
|
||||
assert.ok(cards.every((c) => c.y === cards[0].y), `${width}px: one row: ${JSON.stringify(cards)}`);
|
||||
assert.ok(cards.every((c) => Math.abs(c.bottom - cards[0].bottom) < 0.5), `${width}px: the cards' bottoms line up: ${JSON.stringify(cards)}`);
|
||||
assert.ok(Math.max(...cards.map((c) => c.inner)) - Math.min(...cards.map((c) => c.inner)) > 20, `${width}px: the fixture's cards hold different heights: ${JSON.stringify(cards)}`);
|
||||
sound(cards, `ikun ${width}px`);
|
||||
// a narrow window: one column, each card as tall as itself
|
||||
await page.setViewportSize({ width: 480, height: 900 });
|
||||
await settle(page);
|
||||
const narrow = await boxes(page);
|
||||
assert.ok(narrow.every((c) => c.x === narrow[0].x), `one column: ${JSON.stringify(narrow)}`);
|
||||
for (const c of narrow) assert.ok(c.bottom - c.inner < 16, `narrow: ${c.key} is as tall as itself: ${JSON.stringify(c)}`);
|
||||
// and wide again: lined up again
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await settle(page);
|
||||
const back = await boxes(page);
|
||||
assert.ok(back.every((c) => c.y === back[0].y && Math.abs(c.bottom - back[0].bottom) < 0.5), `${width}px again: one row, bottoms lined up: ${JSON.stringify(back)}`);
|
||||
}
|
||||
|
||||
// the reporter's three, at their window and wider
|
||||
for (const width of [897, 1018, 1400]) {
|
||||
const page = await open(`reporter-${width}`, fixtures(now), width);
|
||||
@@ -130,6 +177,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(ag.x, ds.x, `${width}px: DeepSeek under Antigravity: ${JSON.stringify(cards)}`);
|
||||
assert.ok(ag.x > codex.x && ag.y === codex.y, `${width}px: Antigravity beside Codex, at its top`);
|
||||
assert.ok(Math.abs(ds.y - (ag.y + ag.h) - 7) <= 1, `${width}px: the cards' own gap between them: ${JSON.stringify([ag, ds])}`);
|
||||
// still stacked, not stretched: Antigravity as tall as itself, and
|
||||
// DeepSeek, last in the column, ends where Codex does
|
||||
assert.ok(ag.bottom - ag.inner < 16, `${width}px: Antigravity as tall as itself: ${JSON.stringify(ag)}`);
|
||||
assert.ok(Math.abs(ds.bottom - codex.bottom) < 0.5, `${width}px: DeepSeek ends where Codex does: ${JSON.stringify(cards)}`);
|
||||
}
|
||||
|
||||
// cards of a height: one row, in their order; a narrow window one column
|
||||
@@ -158,7 +209,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await settle(fold);
|
||||
cards = await boxes(fold);
|
||||
const codex1 = cards.find((c) => c.key === "codex");
|
||||
assert.ok(codex1.h > codex0.h, "the card grew");
|
||||
// what it holds grew; the card with it, unless it already reached
|
||||
// down to the end of the stack beside it
|
||||
assert.ok(codex1.inner > codex0.inner && codex1.h >= codex0.h, `the card grew: ${JSON.stringify([codex0, codex1])}`);
|
||||
assert.equal(codex1.x, codex0.x, "the card clicked stays where it was");
|
||||
assert.equal(codex1.y, codex0.y, "the card clicked stays where it was");
|
||||
sound(cards, "opened");
|
||||
|
||||
Reference in New Issue
Block a user