Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: the tray panel's Usage cards have the same per-account eye as the window (yogurt36)

yetone66061fd4df33
diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md
index eb4e07e23..d44b7e98b 100644
--- a/docs/subsystems/gui-shell.md
+++ b/docs/subsystems/gui-shell.md
@@ -391,7 +391,7 @@ covers it in both engines, every language and a narrow window.
- In Usage → Allowances, Trends → Cycle offers each account's own recorded cycle menu beside its curve (`quotaCurve`, `quotaRecordedCycles` in [`app.js`](../../internal/gui/assets/app.js)). The longest window (usually weekly) owns the menu; shorter windows are drawn over the selected dates with their own reset breaks. `/api/usage/quotas/history?days=45` supplies all retained readings, including remote cards. Completed cycles come from observed boundaries, not seven-day arithmetic; an early reset ends the previous cycle at the vendor's new start if it fits between readings, otherwise at the first new reading. Each menu option gives its observed duration, so an early reset is not labelled as a full seven days. The selected meters, plot, legend, tooltip and dashed pace use that cycle's last readings, never today's percentages. A window without a reading in the selected interval says so instead of showing a current value. A local account's past cycle asks `/api/usage/quotas/history/holds?provider=&user=&from=&to=` once per selection (`quotaCycleHoldsOf`), which asks no vendor (#2009, NorethSea): `HistoricalWindowHolds` in [`window_holds_history.go`](../../internal/usage/window_holds_history.go) reckons each window's whole at its own last reading in that cycle, from the request log up to that reading, so the 5-hour figure is the cycle's last 5-hour window, never its short windows added up. Its tooltip names that window's start and the reading's time. It shows "Loading…" until the answer comes. A window it can't reckon says "not enough data" with the reason, as a current card does; a reply that comes after another cycle was picked is dropped, and a card's Refresh or an asked read reckons again. Historical meters show the cycle end and sampling time; current account actions, balances and policies are left out until returning to the current view. Accounts are independent, and a selection survives card refreshes in the same page. Trends → 2 days temporarily shows recent readings; Off removes the curves; the tray always shows its current cycle. See `quota-curve.test.cjs` and the [history limits and reset inference](providers-accounts.md#constraints-and-failure-behavior).
- 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`.
-- Hide accounts (`window.hideAccounts` at the end of [`app.js`](../../internal/gui/assets/app.js), stored in `magpie.maskEmails`, which the panel follows) masks every account name and address in the page's text and tooltips. While it is on, an account's name on the provider editor's row (`accountNameButton`, and the one-account line) and on its Usage card (`quotaWho`) has an eye (`hideAccounts.eye`), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (`kin`), everywhere the window draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory that `hits()` skips; nothing stores them. The panel keeps hiding them, and closing the window hides them again: the page stays loaded while the window is hidden, so `hideMain` runs `mainClosedJS` (`hideAccounts.closed`) first (`account-eye.test.cjs`, `TestClosingHidesShownAccounts`).
+- Hide accounts (`window.hideAccounts` at the end of [`app.js`](../../internal/gui/assets/app.js), stored in `magpie.maskEmails`, which the panel follows) masks every account name and address in the page's text and tooltips. While it is on, an account's name on the provider editor's row (`accountNameButton`, and the one-account line) and on its Usage card (`quotaWho`), and on the tray panel's Usage card (`panelQuotaCard`'s `.pq-who`, in sight while the card is hovered), has an eye (`hideAccounts.eye`), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (`kin`), everywhere that page draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory that `hits()` skips; nothing stores them. The window and the panel are pages of their own, each with its own set: one shown in the window stays hidden in the panel and the other way round, so a screenshot of either shows only what was shown there. Closing the window hides them again: the page stays loaded while the window is hidden, so `hideMain` runs `mainClosedJS` (`hideAccounts.closed`) first. Putting the panel away hides the panel's again, from its `visibilitychange` (the one that drops `panelPeek`) (`account-eye.test.cjs`, `TestClosingHidesShownAccounts`).
- A new user's Agents page (the window's first page and the panel's Agents tab) has a *Get started* card above the agents in the welcome's place (wangye1644294 on X, `guideCard` in [`app.js`](../../internal/gui/assets/app.js)). Its three steps are: add a model source; connect an agent, where the agents magpie found that can be connected are named and each is connected in one click (`agents/connect`); and, optional, a routing group, with the most harmless starter template that can be made from the user's models (`provider.Templates`, Never stuck first) added in one click through `POST /api/groups/template`. Every tick comes from the state: the models magpie serves (`served` in `/api/state`, groups left out), an agent wired, or a group that isn't automatic. None comes from the card having been seen. The card goes once the first two steps are done. Its close button saves `settings.GuideHidden` through `POST /api/settings/guide`, so the panel, the window and a reload agree, and the Settings save keeps it. See `getting-started.test.cjs`.
- Every page of the window keeps to one width, at most 1200px of content centred, with a 16px gutter in a narrow window (`padding: max(16px, calc(50% - 600px))` on each `#view-…`, #860). Routing, Usage and Sessions are in that rule too (面条 on Discord), so a large screen doesn't stretch them edge to edge while the others sit in the middle; their columns follow the room they get (`byWidth`). See `page-width.test.cjs`.
- The page must work in Chromium (Windows' WebView2) and WebKit (macOS, and WebKitGTK on Linux). GUI tests run in both engines.
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css
index 103ef1cb1..60946bf7f 100644
--- a/internal/gui/assets/app.css
+++ b/internal/gui/assets/app.css
@@ -1026,7 +1026,7 @@ body.window .field.solo { grid-column: auto; }
while it shows its account */
.acct-eye { display: none; flex: none; align-self: center; padding: 2px; border-radius: 4px; color: var(--muted); line-height: 0; opacity: 0; }
body.masked .acct-eye { display: inline-flex; }
-body.masked :hover > .acct-eye, body.masked :focus-within > .acct-eye, .acct-eye[aria-pressed="true"] { opacity: 1; }
+body.masked :hover > .acct-eye, body.masked .pq-card:hover .acct-eye, body.masked :focus-within > .acct-eye, .acct-eye[aria-pressed="true"] { opacity: 1; }
.acct-eye:hover { color: var(--fg); background: var(--pill-hover); }
.quota-balance b { margin-left: auto; font-size: 15px; color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
/* a balance field's several amounts (#420): a line each, the label quiet
@@ -1874,7 +1874,8 @@ body.panel .profiles #save { height: 25px; } /* the field's: the line keeps its
@keyframes pq-mode-flash { 0%, 30% { background: var(--accent-soft); color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .pq-mode.flash { animation: none; } }
.pq-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 12px; border-radius: 11px; background: var(--card); box-shadow: var(--card-edge); }
-.pq-user { font-size: 12.5px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.pq-who { display: flex; align-items: center; gap: 2px; min-width: 0; }
+.pq-user { flex: 0 1 auto; min-width: 0; font-size: 12.5px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-sub { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pq-sub.err { color: var(--muted); white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
/* a line with the card's refresh: the words shorten, the refresh keeps
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 08775fb27..648219877 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -16504,7 +16504,10 @@ function planSpan(q) {
// though the tab hides it, until the panel is put away or the tab left.
let panelArranging = false, panelPeek = "";
if (mode === "panel") document.addEventListener("visibilitychange", () => {
- if (document.hidden && (panelPeek || panelArranging)) { panelPeek = ""; panelArranging = false; renderPanelQuota(); }
+ if (!document.hidden) return;
+ // an account its eye showed is hidden again once the panel is put away
+ window.hideAccounts?.closed();
+ if (panelPeek || panelArranging) { panelPeek = ""; panelArranging = false; renderPanelQuota(); }
});
// The tray panel is four tabs over the one page: the agents, the allowances
@@ -17145,7 +17148,11 @@ function panelQuotaCard(q) {
if (q.balanceCard) card.dataset.balCard = q.balanceCard;
// by the name the user gave the account, or the key plan it stands
// in for (#1515), before the account itself
- card.append(el("span", "pq-user", q.alias || q.user || q.name));
+ // and its eye while Hide accounts is on, as on the Usage page (yogurt36)
+ const who = el("span", "pq-who");
+ who.append(el("span", "pq-user", q.alias || q.user || q.name));
+ if ((q.user || q.alias) && window.hideAccounts) who.append(hideAccounts.eye(q.user || q.alias));
+ card.append(who);
card.title = [q.name, q.alias, q.user, q.seat && q.seat !== q.alias && "≡ " + q.seat, q.plan, q.until ? planTerm(q) : "", q.balance && t("Balance") + " " + q.balance].filter(Boolean).join(" · ");
if (q.error) {
card.classList.add("err");
@@ -24508,7 +24515,9 @@ window.noteAccounts = noteAccounts;
// an address always is
const WORD = /[A-Za-z0-9_]/, JOIN = /[-.]/;
const joined = (s, i, step) => WORD.test(s[i] || "") || (JOIN.test(s[i] || "") && WORD.test(s[i + step] || ""));
- // accounts shown while the rest stay hidden, this window's only (yogurt36)
+ // accounts shown while the rest stay hidden (yogurt36), this page's
+ // only: the window and the tray panel are pages of their own, so one
+ // shown in either never shows in the other
const shown = new Set(), low = (x) => String(x).trim().toLowerCase();
function* hits(s, re) {
re.lastIndex = 0; // matchAll starts where the pattern's last test ended
@@ -24669,8 +24678,9 @@ window.noteAccounts = noteAccounts;
};
return b;
},
- // the window closed (hideMain): every account hidden again
- closed: () => { shown.clear(); redraw(); },
+ // the window closed (hideMain) or the panel put away: every account
+ // hidden again
+ closed: () => { if (shown.size) { shown.clear(); redraw(); } },
on: () => masked,
set: (on) => setMasked(on),
follow: (personal) => { if (chosen === null && personal !== masked) setMasked(personal, true); },
diff --git a/internal/gui/tests/account-eye.test.cjs b/internal/gui/tests/account-eye.test.cjs
index bb386ab1c..74bb0eb31 100644
--- a/internal/gui/tests/account-eye.test.cjs
+++ b/internal/gui/tests/account-eye.test.cjs
@@ -4,9 +4,10 @@
// on the provider editor's row and on its Usage card has a quiet eye, in
// sight on hover or keyboard focus. A click shows that account, by its
// address and the name the user gave it, wherever the window draws it,
-// tooltips too; the others stay hidden. It is the window's alone: the tray
-// panel keeps hiding it, and closing the window (hideMain's closed) hides
-// it again. With Hide accounts off there is no eye. A click moves nothing;
+// tooltips too; the others stay hidden. The tray panel's Usage cards have
+// the same eye. Each page's shown accounts are its own: one shown in the
+// window stays hidden in the panel and the other way round. Closing the
+// window (hideMain's closed) or putting the panel away hides them again. With Hide accounts off there is no eye. A click moves nothing;
// no native select, no border stripe; it fits at 360px. In every language.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -162,7 +163,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction((id) => document.querySelector(`.editor .acc[data-account-id="${id}"] .pii`), TEAM);
assert.ok(!(await seen(row(TEAM))).includes(TEAM), "pressed again, hidden again");
- // the tray panel follows the window's setting, not its eye
+ // the tray panel follows the window's setting, not its eye: one
+ // shown in the window stays hidden in a screenshot of the panel
+ assert.equal(await eye(ME).getAttribute("aria-pressed"), "true", "still shown in the window");
const panel = await open("http://magpie.test/?mode=panel");
await panel.evaluate(() => setPanelTab("usage"));
await panel.locator("#panelQuota .pq-user").first().waitFor();
@@ -191,6 +194,83 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
});
+ test(`${engine} ${lang}: the tray panel's eye shows one account there, until the panel is put away`, async (t) => {
+ const browser = await launch(t);
+ for (const width of [360, 440]) {
+ const context = await browser.newContext({ viewport: { width, height: 640 }, reducedMotion: "reduce" });
+ const errors = [];
+ const open = async (url) => {
+ const page = await context.newPage();
+ page.setDefaultTimeout(5000);
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", serve(lang, url.includes("mode=panel")));
+ await page.goto(url);
+ return page;
+ };
+ const panel = await open("http://magpie.test/?mode=panel");
+ await panel.evaluate(() => setPanelTab("usage"));
+ await panel.locator("#panelQuota .pq-user").first().waitFor();
+ // the group's second account is under its "more"
+ await panel.locator("#panelQuota .pq-group .pq-more:not(.pq-arrange)").first().click();
+ await panel.waitForFunction(() => document.querySelectorAll("#panelQuota .pq-card").length === 2);
+ const card = (u) => panel.locator(`#panelQuota .pq-card:has(.pq-user:text-is("${u}")), #panelQuota .pq-card:has(.pq-user .pii[data-raw="${u}"])`).first();
+ const eye = (u) => card(u).locator(".acct-eye");
+ assert.equal(await eye("Personal").count(), 1, "the panel's card has an eye");
+ assert.equal(await opacity(eye("Personal")), "none", "no eye while Hide accounts is off");
+
+ await panel.evaluate(() => hideAccounts.set(true));
+ await panel.waitForFunction(() => document.querySelectorAll("#panelQuota .pq-user .pii").length === 2);
+ await panel.mouse.move(0, 0);
+ assert.equal(await opacity(eye("Personal")), "0");
+ await card("Personal").hover();
+ assert.equal(await opacity(eye("Personal")), "1", "the eye shows on hover over its card");
+ assert.equal(await eye("Personal").getAttribute("aria-label"), await tr(panel, KEYS[0]));
+ assert.equal(await eye("Personal").getAttribute("title"), await tr(panel, KEYS[0]));
+
+ // a click shows that one, its card's tooltip too; the other stays hidden; nothing moves
+ const sc = await scrolled(panel);
+ await eye("Personal").click();
+ await panel.waitForFunction(() => document.querySelectorAll("#panelQuota .pq-user .pii").length === 1);
+ assert.equal(await scrolled(panel), sc, "a click scrolled");
+ assert.equal(await card("Personal").locator(".pq-user").textContent(), "Personal");
+ assert.ok((await card("Personal").getAttribute("title")).includes(ME), "its tooltip names it");
+ assert.equal(await eye("Personal").getAttribute("aria-pressed"), "true");
+ assert.equal(await eye("Personal").getAttribute("title"), await tr(panel, KEYS[1]));
+ assert.equal(await opacity(eye("Personal")), "1", "a shown account's eye stays in sight");
+ assert.ok(!(await seen(card(SEAT))).includes(TEAM) && !(await seen(card(SEAT))).includes(SEAT), "the other card stays hidden");
+ assert.equal(await eye(SEAT).getAttribute("aria-pressed"), "false");
+ // redrawn (a refresh, a tab), it stays shown
+ await panel.evaluate(() => renderPanelQuota());
+ assert.equal(await panel.locator("#panelQuota .pq-user .pii").count(), 1);
+ assert.equal(await eye("Personal").getAttribute("aria-pressed"), "true");
+
+ // the window has its own: the account shown in the panel stays hidden there
+ const win = await open("http://magpie.test/?view=usage");
+ await win.locator(".subscription-account .quota-alias").first().waitFor();
+ await win.waitForFunction(() => document.querySelectorAll(".subscription-account .quota-of .pii").length === 2);
+ const ws = await win.evaluate(() => [...document.querySelectorAll(".subscription-account")].map((c) => c.textContent).join(" "));
+ assert.ok(!ws.includes(ME) && !ws.includes("Personal"), "the window still hides it: " + ws);
+ await win.close();
+
+ // put away (the panel's page goes hidden): hidden again
+ await panel.evaluate(() => {
+ Object.defineProperty(document, "hidden", { configurable: true, get: () => true });
+ document.dispatchEvent(new Event("visibilitychange"));
+ });
+ await panel.waitForFunction(() => document.querySelectorAll("#panelQuota .pq-user .pii").length === 2);
+ assert.ok(!(await seen(card("Personal"))).includes(ME), "hidden once the panel is put away");
+ assert.equal(await eye("Personal").getAttribute("aria-pressed"), "false");
+
+ assert.equal(await panel.locator("select").count(), 0, "no native select");
+ assert.deepEqual(await stripes(panel, ".pq-card, .pq-card *"), [], "no border stripes");
+ assert.equal(await wide(panel), 0, `no sideways scroll at ${width}px`);
+ const fits = await panel.evaluate(() => [...document.querySelectorAll("#panelQuota .pq-card")].every((c) => { const r = c.getBoundingClientRect(), e = c.querySelector(".acct-eye").getBoundingClientRect(); return e.right <= r.right && e.width > 0; }));
+ assert.ok(fits, "each eye sits inside its card");
+ assert.deepEqual(errors, []);
+ await context.close();
+ }
+ });
+
test(`${engine} ${lang}: a Usage card's eye shows its account, on the card and its tooltips`, async (t) => {
const browser = await launch(t);
for (const width of [900, 360]) {