routing: each account one calm cell in Accounts and keys (danzi002 on Discord)

danzi002 (v0.1.2945): Accounts and keys "显示的好乱啊,没有之前一目了然".
70a98dd85 (v0.1.2929) made the cards compact for ferock4669 and iyou00,
but left each card 3-5 lines of uneven height (tally, latest answer, a
Try now on its own line) in 168px columns: names cut, the status
wrapped, red twice on every resting account and on healthy ones with
old failures, Try now links scattered. Rendered with 9 Codex, 1
WorkBuddy and 3 WorkBuddy AI accounts, zh at 1100/1440, parent
c4245c4c2 against main.

Kept the compact change (still short, long lists still fold) and made
each account one uniform cell instead of reverting:
- a dot for its state: green in use (the provider's not-resting account
  that answered last), amber resting, grey otherwise, red to act on;
- name, plan and a muted Try now on one line, then one line of what is
  left and when it renews, or when it is back, wrapped in full, never cut;
- how it fared (the tally) and when it was read ("as of") on hover;
- red only where the reader must act: sign in again, a restriction or
  verification, a key failing with nothing else to say. Those rows keep
  their tally in sight;
- columns min(240px, 40vw), the usage bar back in the flow (Chromium
  misplaced the absolute bar inside a multicol .rt-lead).
routing-account-windows and routing-wallet-lapse now find "as of" last
in the tooltip instead of on the line.

Run on mote (Chromium + WebKit, en/zh/zh-TW/ja/de, 1100/420 and the
files' own widths):
- new routing-acts-calm.test.cjs: green both engines, all 5 languages.
- every Routing file that renders .rt-act plus i18n-keys and
  panel-routing*: 679 tests, 610 pass; the reds besides mine were
  rest-try-now WebKit, rules-line, rule-drag/remove, row-swap, steady,
  steps-cap, story-shrinks, order-unknown and many-keys webkit zh, the
  same set as main f44fa2ef6 run alone (41 reds there), filed as #5035,
  #5088, #4585, #3593, #4082, #4628, #3789, #3799, #3412, #4629, #3954.
  After fixing my own reds, acts-calm, account-windows, wallet-lapse,
  many-keys, rules-line and key-windows: 135 pass, 1 red (rules-line
  webkit en 1100, #3593/#5035).
- At the pushed head (rebased on 34116ec01): acts-calm,
  account-windows, wallet-lapse and i18n-keys 70/70 pass, the Go size
  budgets pass.
- go test ./internal/gui/...: TestMainWindowCorners/macOS_26_SDK red
  only (#3949, AppKit on macOS 27); the size budgets pass.

Broken by hand, each red in routing-acts-calm (Chromium):
- the resting line red everywhere (.st.rest red): red outside ivy;
- the tally shown on calm rows: "main: its name and what it says";
- columns back to 168px: a one-line status fails;
- no rest class: expected 'rest'.

Not tried: dark mode by eye, the real app on WebKitGTK (Linux) and on
Windows, real accounts (the fixture is synthetic), and the 8-row fold
with more than 8 Codex accounts by eye.
This commit is contained in:
yetone
2026-11-04 22:04:17 +08:00
parent 34116ec012
commit 11d9d0a3a5
6 changed files with 258 additions and 29 deletions
+14 -5
View File
@@ -246,11 +246,20 @@ fullest window while idle, what it is doing while it answers. See
### Routing account cards
Each row under Accounts and keys keeps its name, one line of what is left
(or its rest), and how it fares (tried, answered, failed, last answered),
with Try now or Sign in again when it needs one (ferock4669 and iyou00 on
Discord: many keys ran the list on and on). The models it answered are in
its tooltip, under its id; a folded row of keys or accounts names none.
Each row under Accounts and keys is one cell like the others: a dot, its
name, plan and Try now on one line, and under it what is left (or its
rest) in full (ferock4669 and iyou00 on Discord: many keys ran the list
on and on). The dot is green for the one in use (of a provider's rows not
resting, the one that answered last), amber resting, red for what the
reader has to do (`.act`: sign in again, a restriction or verification, a
key failing with no answer), grey otherwise. Red is only on `.act` rows:
a quota rest or old failures are muted (danzi002 on Discord, "显示的好
乱"). How it fares (tried, answered, failed, last answered) is a line of
its own only on a row with nothing else to say or one to act on; on the
others (`.said`) it is in the tooltip with the models it answered, under
its id. A folded row of keys or accounts names no models. Columns are
`min(240px, 40vw)` wide, so a name and its Try now share a line
(`routing-acts-calm.test.cjs`).
`renderActs` in
[`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js)
shows the first `ACTS_SHOWN` (8) rows of a longer list and puts the rest
+33 -5
View File
@@ -4440,6 +4440,15 @@ function routingPage(part) {
// of keys looked through the whole list for its own (#3164)
const kin = new Map(), kinOf = (w) => w.provider + "\u0000" + w.kind;
for (const a of list) { const k = kinOf(a.w); kin.has(k) ? kin.get(k).push(a) : kin.set(k, [a]); }
// the one in use, a dot of its own: of each provider's not resting,
// the one that answered last (danzi002 on Discord: which account is
// in use, which are out and when each is back, at a glance)
const inUse = new Map();
for (const a of list) {
if (!a.last || (a.rest && at(a.rest.until) > n)) continue;
const u = inUse.get(a.w.provider);
if (!u || a.last > u.last) inUse.set(a.w.provider, a);
}
for (const a of list) {
const w = a.w;
let opened = false;
@@ -4477,7 +4486,7 @@ function routingPage(part) {
// a provider's own row: its model, the provider's name is the heading
if (w.kind === "provider") name.append(el("b", "", w.model || w.name));
else name.append(el("b", "", who(w)), el("span", "", w.plan || (w.kind === "key" ? t("API key") : "")));
let st, cls = "";
let st, cls = "", asOf = "";
const resting = a.rest && at(a.rest.until) > n;
// its models resting alone, while the account answers its others:
// a line of their own, naming them, under what the account has left
@@ -4489,7 +4498,10 @@ function routingPage(part) {
else if (w.known) {
const soon = usedRenews(w);
st = soon && soon <= n ? quota(w, "{n} used at {time}; it has renewed since", "{n} left at {time}; it has renewed since", { time: clock(a.at) })
: (soon ? quota(w, "{n} used · renews in {d}", "{n} left · renews in {d}", { d: dur(soon - n) }) : quota(w, "{n} used", "{n} left")) + " · " + t("as of {time}", { time: clock(a.at) });
: (soon ? quota(w, "{n} used · renews in {d}", "{n} left · renews in {d}", { d: dur(soon - n) }) : quota(w, "{n} used", "{n} left"));
// when it was read is on hover: the line says what is left and
// when it renews, on one line in every language (danzi002)
if (!(soon && soon <= n)) asOf = t("as of {time}", { time: clock(a.at) });
} else if (w.kind === "account") st = t("what's left not known yet");
else st = "";
const tally = el("div", "tally");
@@ -4512,7 +4524,7 @@ function routingPage(part) {
const ws = day ? [] : [...winsOf(w).map((text) => ({ text })), ...remoteWinsOf(w)];
const figure = !!st && (resting || w.known || w.unlisted || w.noURL);
if (resting && restTip(a.rest)) stEl.title = restTip(a.rest);
else if (figure && ws.length) stEl.title = ws.map((x) => x.text).join("\n");
else if (figure && (ws.length || asOf)) stEl.title = [...ws.map((x) => x.text), asOf].filter(Boolean).join("\n");
row.append(name, stEl);
if (parts.length) {
const r0 = parts[0][1].rest;
@@ -4570,7 +4582,20 @@ function routingPage(part) {
bar.append(bi);
row.append(bar);
}
row.title = w.id + (mdls.length ? "\n" + mdls.join(", ") : "");
// one cell each, alike (danzi002 on Discord: "显示的好乱"): its
// name and a dot for how it is, then one line, what is left or when
// it is back, in a quiet colour. Red is for what the reader has to
// do: sign in again, a vendor's restriction or verification, a key
// failing with no answer. How it fares is that line where it has no
// other, and on hover, unless it is the reader's to fix.
const act = signIn || (!a.ok && fails.length > 0) || (resting && (a.rest.why === "restricted" || a.rest.why === "verify"));
const said = !!st || (ws.length > 0 && !figure);
row.classList.toggle("act", act);
row.classList.toggle("rest", !act && !!resting);
row.classList.toggle("on", !act && inUse.get(w.provider) === a);
row.classList.toggle("said", said && !act);
name.prepend(el("i", "dot"));
row.title = w.id + (mdls.length ? "\n" + mdls.join(", ") : "") + (said && !act ? "\n" + [...tally.children].map((e) => e.textContent).join(" · ") : "");
put(row, false, opened || signIn || resting || parts.length > 0 || remoteBad || (!a.ok && Object.keys(a.fails).length > 0));
}
// a long list shows its first ACTS_SHOWN rows and every one kept in
@@ -4650,7 +4675,10 @@ function routingPage(part) {
el("span", "ok", t("answered {n}", { n: sum((a) => a.ok) })),
...(bad.length ? [el("span", "bad", bad.join(", "))] : []),
...(last ? [el("span", "", t("last answered {time}", { time: clock(last) }))] : []));
// the models they answered are each one's, opened
// the models they answered are each one's, opened. A cell like each
// account's: its name, then how many are available and resting; how
// they fared together is each one's, on hover
row.classList.toggle("said", true);
const kids = [name, el("div", "st" + (resting === ks.length ? " rest" : ""), st.join(" · ")), tally];
// drawn again only when what it says changes
if (kids.length !== row.children.length || kids.some((k, i) => !k.isEqualNode(row.children[i]))) row.replaceChildren(...kids);
+44 -11
View File
@@ -432,8 +432,10 @@ button.rt-session { cursor: pointer; }
in columns, each provider's heading over its own (in one block with
its first row, .rt-lead): one to a line, or a heading across each
line, a page of many providers ran on far below the requests (Jiabubu
on Discord, twice). Beside the requests (min1150) the column holds one */
:where(.rt-more:not(.min1150)) .rt-acts, .rt-cols.solo .rt-acts { columns: 168px; column-gap: 0; }
on Discord, twice). Beside the requests (min1150) the column holds one.
A column is wide enough for an account's name, plan and Try now on one
line (danzi002 on Discord), two of them still on a phone */
:where(.rt-more:not(.min1150)) .rt-acts, .rt-cols.solo .rt-acts { columns: min(240px, 40vw); column-gap: 0; }
:where(.rt-more:not(.min1150)) .rt-acts > *, .rt-cols.solo .rt-acts > * { break-inside: avoid; }
.rt-cols.solo { grid-template-columns: minmax(0, 1fr); }
.rt-reqs.none { display: block; background: none; border-color: transparent; }
@@ -456,14 +458,33 @@ button.rt-session { cursor: pointer; }
.rt-found { animation: rtfound 1.4s ease-out; }
@keyframes rtfound { 0%, 40% { box-shadow: inset 0 0 0 2px var(--fg); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
@media (prefers-reduced-motion: reduce) { .rt-found { animation: none; } }
.rt-act { display: grid; gap: 3px; padding: 6px 12px 6px 33px; font-size: 12px; }
.rt-act .nm { display: flex; gap: 6px; min-width: 0; }
/* an account or key: one cell each, alike (danzi002 on Discord: "显示的好
乱"). Its name, plan and Try now on one line, a dot before it for how it
is; under it what is left or when it is back, how it fared on hover.
Red only for what the reader has to do (.act) */
.rt-act { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; padding: 6px 12px 9px 33px; font-size: 12px; line-height: 18px; }
.rt-act > * { grid-column: 1 / -1; min-width: 0; }
.rt-act > .nm { grid-column: 1; grid-row: 1; }
.rt-act > .fix { grid-column: 2; grid-row: 1; }
/* Try now no taller than the name beside it (WebKit's button is): the
cell keeps its height when the rest is lifted */
.rt-act:not(.act) > .fix { height: 18px; align-items: center; }
/* what the reader has to do has a line of its own, its words in full */
.rt-act.act > .fix { grid-column: 1 / -1; grid-row: auto; flex-wrap: wrap; white-space: normal; }
.rt-act .nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rt-act .nm b { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-act .nm span { color: var(--muted); white-space: nowrap; }
.rt-act .st { color: var(--fg-2); }
/* narrow, the plan gives way before the name does */
.rt-act:not(.rt-keys) .nm span { flex: 0 1000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rt-act .nm .dot { position: absolute; left: 19px; top: 12px; width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.rt-act.on .nm .dot { background: var(--green); }
.rt-act.rest .nm .dot { background: var(--amber); }
.rt-act.act .nm .dot { background: var(--red); }
/* in full, a second line if it must: when it is back is what it says (#1016) */
.rt-act .st { color: var(--fg-2); overflow-wrap: anywhere; }
.rt-act .st:empty { display: none; }
.rt-act .st.rest { color: var(--red); }
.rt-act .st.left { color: var(--muted); }
.rt-act .st.rest, .rt-act .st.left { color: var(--muted); }
.rt-act.act .st.rest { color: var(--red); }
/* the accounts' allowances read again by hand (#1834), beside the heading */
.rt-read { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; margin: -3px 0 -3px 6px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; transition: background .12s, color .12s; }
.rt-read[hidden] { display: none; }
@@ -477,10 +498,22 @@ button.rt-session { cursor: pointer; }
figure of its own, the rest of it on hover */
.rt-act .wins { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.rt-act .wins span + span { margin-left: 12px; }
.rt-act .tally { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.rt-act .tally .bad { color: var(--red); }
.rt-act .fix { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 11px; }
.rt-act .bar { height: 3px; border-radius: 2px; background: var(--card-2); overflow: hidden; }
.rt-act .tally { display: flex; gap: 0 10px; overflow: hidden; white-space: nowrap; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.rt-act .tally > span { flex: none; }
.rt-act .tally > span:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* with a line of its own, how it fares is on hover; one to fix says it */
.rt-act.said > .tally { display: none; }
.rt-act.act .tally .bad { color: var(--red); }
.rt-act .fix { display: flex; gap: 10px; font-size: 11px; white-space: nowrap; }
.rt-act .fix button.link { color: var(--muted); }
.rt-act .fix button.link:hover { color: var(--fg); }
.rt-act .fix button.link:focus-visible { color: var(--fg); }
.rt-act .fix button.rt-signin, .rt-act.act .fix button.link { color: var(--red); }
/* under the cell, in its bottom padding: every cell keeps its height. In
the flow, not absolute: Chromium put an absolute bar of a row in a
column's unbroken block (.rt-lead) over the row above it */
.rt-act .bar { height: 2px; margin: 2px 0 -4px; border-radius: 2px; background: var(--card-2); overflow: hidden; }
.rt-act:has(> .bar) { padding-bottom: 8px; }
.rt-act .bar i { display: block; height: 100%; border-radius: 2px; background: var(--muted); }
/* a provider's keys summed up in one row (#1319), opened to each */
.rt-act.rt-keys { cursor: pointer; user-select: none; }
@@ -83,8 +83,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.goto("http://magpie.test/?view=routing");
const act = page.locator(".rt-act", { hasText: "work@example.com" }).first();
// the one figure routing went by, the windows each on hover over
// it: a card keeps one line of what is left (ferock4669 on Discord)
await page.waitForFunction((want) => [...document.querySelectorAll(".rt-act")].some((e) => e.textContent.includes("work@example.com") && e.querySelector(".st")?.title === want), words[lang].join("\n"));
// it: a card keeps one line of what is left (ferock4669 on
// Discord), and when it was read comes last on hover (danzi002)
await page.waitForFunction((want) => [...document.querySelectorAll(".rt-act")].some((e) => e.textContent.includes("work@example.com") && (e.querySelector(".st")?.title || "").split("\n").slice(0, 2).join("\n") === want), words[lang].join("\n"));
assert.ok(await act.locator(".st").isVisible());
assert.equal(await act.locator(".wins").count(), 0);
const spare = page.locator(".rt-act", { hasText: "spare@example.com" }).first();
@@ -0,0 +1,157 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// danzi002 on Discord: after Accounts and keys got compact, "路由里面的的账号
// 与秘钥显示的好乱啊,没有之前一目了然". Cards of three to five lines, each its
// own height, ragged columns, names cut to "bob.work@gm…", and red on every
// resting account (twice: its line and its tally), on a healthy one with
// old failures too. Now each account is one cell like every other: a dot
// for how it is (green in use, amber resting, red to act on), its name,
// plan and Try now on one line, what it says under it; how it fared on
// hover.
// Red only where the reader has to do something. Every language, at a
// window's width and at 420px, in both engines.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const now = Date.now();
const H = 3600e3, M = 60e3;
const iso = (ms) => new Date(ms).toISOString();
const rest = (why, until, status) => ({ key: "r-" + why + until, why, until: iso(until), status, error: why === "quota" ? "You've hit your usage limit." : "" });
const cx = (u, plan, extra, tally) => ({ seat: { id: "codex@" + u, provider: "codex", name: "Codex", who: u + "@example.com", kind: "account", agent: "codex", model: "gpt-5.5", plan, ...extra }, tally });
const fine = (n, ago) => ({ tried: n, ok: n, fails: {}, last: now - ago });
const seats = [
cx("main", "Pro", { known: true, used: 34, renews: [iso(now + 3 * H)], usedRenews: iso(now + 3 * H) }, fine(120, 20e3)),
cx("alice", "Plus", { rest: rest("quota", now + 2 * H, 429) }, { tried: 30, ok: 26, fails: { quota: 4 }, last: now - 50 * M }),
cx("bob", "Plus", { rest: rest("quota", now + 28 * H, 429) }, { tried: 22, ok: 20, fails: { quota: 2 }, last: now - 3 * H }),
cx("carol", "Plus", { rest: rest("quota", now + 72 * H, 429) }, { tried: 18, ok: 15, fails: { quota: 3 }, last: now - 5 * H }),
cx("dave", "Team", { rest: rest("rate", now + 90e3, 429) }, { tried: 41, ok: 38, fails: { rate: 3 }, last: now - 4 * M }),
cx("erin", "Plus", { known: true, used: 82, renews: [iso(now + 50 * M)], usedRenews: iso(now + 50 * M) }, fine(16, 9 * M)),
// answering again after two refusals: nothing to do, so no red
cx("frank", "Plus", { known: true, used: 12, renews: [iso(now + 4 * H)], usedRenews: iso(now + 4 * H) }, { tried: 9, ok: 7, fails: { quota: 2 }, last: now - 12 * M }),
cx("henry", "Plus", {}, { tried: 0, ok: 0, fails: {}, last: 0 }),
// refused for its sign-in since it last answered: the reader signs in again
cx("ivy", "Plus", {}, { tried: 2, ok: 1, fails: { auth: 1 }, last: now - 10 * M, authAt: now - 5 * M }),
];
const tallies = {};
for (const { seat, tally } of seats) tallies[JSON.stringify([seat.provider, seat.who])] = { ...seat, ...tally, models: tally.ok ? [seat.model] : [] };
const order = seats.map((s) => s.seat);
const routes = [{ id: 1, seq: 1, time: iso(now - 20e3), agent: "codex", model: "gpt-5.5", provider: "codex", done: true, status: 200, ms: 4200, order,
tries: [{ id: "codex@main", model: "gpt-5.5", start: iso(now - 20e3), done: true, ms: 4100, status: 200 }] }];
const langs = ["en", "zh", "zh-TW", "ja", "de"];
function serve(lang) {
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light", quotaLeft: false } };
return async (r) => {
const url = new URL(r.request().url());
const json = (data) => r.fulfill({ json: data });
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json(state);
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 290, rerouted: 12, errors: 21 }, routes });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [{ day: new Date(now).toISOString().slice(0, 10), requests: 290 }], routes: [], tallies });
if (url.pathname === "/api/usage/quotas" || url.pathname === "/api/usage/quotas/history") return json([]);
if (url.pathname === "/api/groups") return json({ models: [], groups: [], pools: [] });
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
await r.fulfill({ body: await fs.readFile(file), contentType });
};
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(`${engine}: each account in Accounts and keys is one calm cell like the others`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
for (const width of [1100, 420]) for (const lang of langs) {
await t.test(`${lang} at ${width}px`, async () => {
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
try {
const page = await ctx.newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
// the reader opened Codex's accounts
await page.addInitScript(() => { try { localStorage.setItem("magpie.routingKeysOpen", JSON.stringify(["codex/@"])); } catch {} });
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-acts .rt-act", { hasText: "ivy@example.com" }).waitFor();
const rows = await page.evaluate(() => {
const probe = document.createElement("i");
probe.style.color = "var(--red)";
document.body.append(probe);
const red = getComputedStyle(probe).color;
probe.remove();
return [...document.querySelectorAll(".rt-acts .rt-act:not(.rt-keys)")].map((r) => {
const st = r.querySelector(".st"), box = r.getBoundingClientRect(), nm = r.querySelector(".nm").getBoundingClientRect(), fix = r.querySelector(".fix");
const seen = (e) => e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden";
return {
who: r.querySelector(".nm b").textContent,
cls: [...r.classList].filter((c) => ["on", "rest", "act"].includes(c)).sort().join(" "),
dot: getComputedStyle(r.querySelector(".nm .dot")).backgroundColor,
h: box.height, stLines: st && seen(st) ? Math.round(st.getBoundingClientRect().height / 18) : 0,
stCut: !!st && st.scrollWidth > st.clientWidth + 1, x: Math.round(box.x), w: box.width,
cut: r.querySelector(".nm b").scrollWidth > r.querySelector(".nm b").clientWidth + 1,
fixTop: fix && seen(fix) ? Math.round(fix.getBoundingClientRect().top - nm.top) : null,
tally: seen(r.querySelector(".tally")),
lines: [...r.children].filter((e) => seen(e) && !e.classList.contains("bar") && !e.classList.contains("fix")).length,
reds: [...r.querySelectorAll("*")].filter((e) => seen(e) && e.children.length === 0 && e.textContent.trim() && getComputedStyle(e).color === red).map((e) => e.textContent),
redDot: getComputedStyle(r.querySelector(".nm .dot")).backgroundColor === red,
};
});
});
const by = Object.fromEntries(rows.map((r) => [r.who.replace("@example.com", ""), r]));
assert.deepEqual(Object.keys(by).sort(), ["alice", "bob", "carol", "dave", "erin", "frank", "henry", "ivy", "main"]);
// how each is, by its dot: in use, resting, to act on, or neither
assert.equal(by.main.cls, "on");
for (const u of ["alice", "bob", "carol", "dave"]) assert.equal(by[u].cls, "rest", u);
for (const u of ["erin", "frank", "henry"]) assert.equal(by[u].cls, "", u);
assert.equal(by.ivy.cls, "act");
assert.equal(new Set([by.main.dot, by.alice.dot, by.erin.dot, by.ivy.dot]).size, 4, "four dots apart");
// red only on the one to sign in again: not on a rest, nor on old refusals
for (const [u, r] of Object.entries(by)) {
if (u === "ivy") continue;
assert.deepEqual(r.reds, [], u + " has no red");
assert.equal(r.redDot, false, u);
}
assert.ok(by.ivy.reds.length > 0 && by.ivy.redDot, "ivy says what to do, in red");
// one cell each, alike: a name line and one line under it, the
// same height; how it fared on hover, unless there is something to do
const calm = rows.filter((r) => r.cls !== "act");
for (const r of calm) {
assert.equal(r.lines, 2, r.who + ": its name and what it says");
assert.equal(r.tally, false, r.who + ": its tally on hover");
if (r.fixTop !== null) assert.ok(Math.abs(r.fixTop) <= 2, r.who + ": Try now beside its name, " + r.fixTop);
}
assert.equal(by.ivy.tally, true, "the one to act on says how it fared");
// its line in full, when it is back above all: a second line
// when the column is too narrow, never cut
assert.deepEqual(rows.filter((r) => r.stCut).map((r) => r.who), [], "a line cut short");
const one = calm.filter((r) => r.stLines === 1).map((r) => r.h);
// what is left and when it renews on one line in every language;
// a rest (when it is back, at and in) may take a second
for (const u of ["main", "erin", "frank", "henry"]) if (width > 1000) assert.equal(by[u].stLines, 1, u + " in one line");
assert.ok(one.length > 0 && Math.max(...one) - Math.min(...one) <= 1, "cells of one height: " + one);
// in columns of one width, each starting where the others do
const ws = rows.map((r) => r.w);
assert.ok(Math.max(...ws) - Math.min(...ws) <= 1, "cells of one width: " + ws);
const xs = [...new Set(rows.map((r) => r.x))];
assert.ok(xs.length <= (width > 1000 ? 3 : 2), "columns: " + xs);
// at a window's width, every name in full
if (width > 1000) assert.deepEqual(rows.filter((r) => r.cut).map((r) => r.who), []);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - innerWidth <= 1), true, "nothing past the window");
assert.deepEqual(errors, []);
} finally {
await ctx.close();
}
});
}
});
}
@@ -120,17 +120,18 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// the tooltip names the four rows the Usage card shows
const tip = await row("magicrew#big@example.com").getAttribute("title");
for (const s of ["185 / 200 积分 · 今日 23:59 到期", "1,106 积分 · 最早 2026-11-03 到期", "5,000 积分"]) assert.ok(tip.includes(s), tip);
// the accounts listed below: the figure and its lapse, then when it
// was read, each window on hover over it
// the accounts listed below: the figure and its lapse; each window
// and when it was read on hover over it (danzi002 on Discord)
const acts = page.locator(".rt-act");
await acts.filter({ hasText: "6,291" }).first().waitFor();
const list = await acts.evaluateAll((as) => as.map((a) => ({ st: a.querySelector(".st")?.textContent || "", wins: a.querySelector(".st")?.title || "" })));
const b = list.find((a) => a.st.startsWith(big + " · "));
const b = list.find((a) => a.st === big);
assert.ok(b, `${big}: ${JSON.stringify(list)}`);
assert.ok(b.wins.includes("185 / 200 积分 · 今日 23:59 到期") && b.wins.includes("5,000 积分"), b.wins);
assert.ok(list.some((a) => a.st.startsWith(small + " · ")), JSON.stringify(list));
// no lapse told: its figure, then when it was read, and nothing between
assert.ok(list.some((a) => a.st.startsWith(none + " · ") && a.st.split(" · ").length === 2), JSON.stringify(list));
assert.ok(/\n.*\d\d:\d\d/.test(b.wins), "when it was read, last on hover: " + b.wins);
assert.ok(list.some((a) => a.st === small), JSON.stringify(list));
// no lapse told: its figure, and nothing after it
assert.ok(list.some((a) => a.st === none), JSON.stringify(list));
const over = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
assert.ok(over <= 1, `${over}px past`);
assert.deepEqual(errors, []);