gui: an account row holds its readings when they wrap (the owner, after a quota refresh)
The owner, with a screenshot of Claude Code's 账号: "有时候这个页面的排版会崩掉", then "每次点击手动刷新额度的小按钮之后,账号列表的排版就会崩掉". An account's 5-hour and 7-day meters ran under the next account's name. .accts was a one-column grid (b19f3dbab). When a row's .aq readings went from one line to two (they wrap by language and width, and a refresh redraws them), WebKit kept the grid row at its old height, so the second line overflowed into the next row. Hiding and showing the row put it right; Chromium never did it. Changing the row's own display (grid, column, block) didn't help; changing the list's did. .accts is now a flex column, which lays out the same. account-rows-fit.test.cjs serves five Claude accounts with both windows, opens the editor, and checks that no row's last line reaches past the row, then clicks two rows' refresh and checks again. Chromium and WebKit, en zh zh-TW ja de, 900 and 720px. A last test asserts that every engine and language hit a case where the readings wrapped, so the check is never made on one line only. Run at this tree once2e81da1(the 90-file runs on d577c184b; between them main changed no .acc CSS), on mote through mote-run: - account-rows-fit.test.cjs: 21/21 ok, again once2e81da1. - the 90 GUI files that select .acc or .accts, at load 80 to 170 from other sessions' suites: 1625 tests, 1582 ok, 43 red in 11 files. The same 11 files run on unchanged origin/maind577c184b: 25 red there, 22 at this head, with the cases moving between runs. Their issues: account-eye #4244, key-replace #4126, key-rest-date #4691, login-import #1307, provider-typed #4673, proxy-login-fields #3382, rest-try-now #4127, signin-again #4643, and providers-reset-use #4873 (filed now; 2 of 2 ok alone on both trees). - gateway-key-models (#4081) and gateway-key-groups (#1974) are red on unchanged origin/main4fc34828etoo (models 3 of 3 runs, at line 79 right after setViewportSize; groups' left border once), so they are not this change. Broken by hand: with the old grid .accts, account-rows-fit is red in webkit zh 900, zh-TW 900 and ja 720 ("ferronatoousseni@example.com's readings reach 10.7px past its row"), green with the column. Not tried: the real macOS app's WKWebView with real accounts; the whole GUI suite (mote was at load ~85 with other sessions' suites).
This commit is contained in:
@@ -2688,7 +2688,8 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
.acct .n { font-weight: 500; }
|
||||
.acct .plan { color: var(--muted); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--pill-hover); }
|
||||
/* a subscription's accounts: the one in use first, a way to add another */
|
||||
.accts { display: grid; grid-template-columns: minmax(0, 1fr); border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
|
||||
/* a column, not a grid: WebKit kept a grid row at its height from before its readings wrapped, so they ran under the next account (the owner, after a refresh) */
|
||||
.accts { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
|
||||
.acc { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 5px 8px 5px 11px; font-size: 12.5px; text-align: left; }
|
||||
.acc + .acc, .accts .signing { border-top: 1px solid var(--line-2); }
|
||||
/* every row of the box ruled off from the one above it, a setting's too
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// An account row holds its readings when they take two lines (the owner,
|
||||
// with a screenshot of Claude Code's 账号: "有时候这个页面的排版会崩掉",
|
||||
// then "每次点击手动刷新额度的小按钮之后"). The list was a grid, and
|
||||
// WebKit kept a row at the height it had before its 5-hour and 7-day
|
||||
// meters wrapped, so the second meter ran under the next account's name.
|
||||
// Each row is checked as the editor opens and again after a row's refresh.
|
||||
// Chromium and WebKit, every language, a wide and a narrow window; no
|
||||
// backend, the API is faked here.
|
||||
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 users = ["ferronatoousseni@example.com", "sales@example.ai", "shiro@example.com", "worktrial@example.ai", "yetoneful@example.ai"];
|
||||
const at = (ms) => new Date(Date.now() + ms).toISOString();
|
||||
const quotas = users.map((user, i) => ({ provider: "claude", name: "Claude", user, windows: [
|
||||
{ name: "5 hours", used: [100, 0, 100, 0, 0][i], resetsAt: at(36e5 * (i + 1)) },
|
||||
{ name: "7 days", used: [89, 97, 50, 96, 98][i], resetsAt: at(864e5 * (i + 1)) },
|
||||
] }));
|
||||
|
||||
function serve(lang, reads) {
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"dark",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "dark" } });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [{
|
||||
id: "claude", name: "Claude", icon: "claudecode-color", models: [], agents: [], fallback: [], headers: {}, keyList: [],
|
||||
account: { agent: "claude", agentName: "Claude Code", user: users[0], plan: "max",
|
||||
logins: users.map((user, i) => ({ user, plan: "max", active: i === 0, on: true })) },
|
||||
}], presets: [], excluded: [], gateway: { running: true, window: true } });
|
||||
if (url.pathname === "/api/login/usage") { reads.n++; return json(Object.fromEntries(quotas.map((q) => [q.user, q]))); }
|
||||
if (url.pathname === "/api/usage/quotas") return json(quotas);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
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)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
// how far each row's last line reaches past the row, and whether its
|
||||
// readings took more than one line
|
||||
const rows = (page) => page.evaluate(() => [...document.querySelectorAll(".editor .acc.with-aq")].map((r) => {
|
||||
const aq = r.querySelector(".aq"), w = [...aq.querySelectorAll(".aq-w")];
|
||||
return {
|
||||
user: r.querySelector(".n")?.textContent || "",
|
||||
past: Math.max(...[...r.children].map((c) => c.getBoundingClientRect().bottom)) - r.getBoundingClientRect().bottom,
|
||||
wraps: w.length > 1 && w.at(-1).offsetTop > w[0].offsetTop,
|
||||
};
|
||||
}));
|
||||
const frames = (page) => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
||||
|
||||
// where the readings wrap depends on the language and the width; every
|
||||
// language wraps at one of them at least, so each is tested holding two lines
|
||||
const wrapped = new Set();
|
||||
const engines = process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"];
|
||||
for (const engine of engines) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [900, 720]) {
|
||||
test(`${engine} ${lang} ${width}px: an account row holds its two lines of readings`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await browser.newPage({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
const reads = { n: 0 };
|
||||
await page.route("**/*", serve(lang, reads));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider", { hasText: "Claude" }).first().click();
|
||||
await page.waitForFunction(() => document.querySelectorAll(".editor .acc.with-aq .aq-w").length === 10);
|
||||
await frames(page);
|
||||
const check = async (when) => {
|
||||
const rs = await rows(page);
|
||||
assert.equal(rs.length, users.length);
|
||||
if (rs.some((r) => r.wraps)) wrapped.add(`${engine} ${lang} ${width} ${when}`);
|
||||
for (const r of rs) assert(r.past <= 0.5, `${when}: ${r.user}'s readings reach ${r.past.toFixed(1)}px past its row: ${JSON.stringify(rs)}`);
|
||||
};
|
||||
await check("opened");
|
||||
for (const i of [1, 3]) {
|
||||
const n = reads.n;
|
||||
await page.locator(".editor .acc.with-aq").nth(i).locator(".quota-refresh").click();
|
||||
for (let k = 0; k < 500 && reads.n === n; k++) await page.waitForTimeout(10);
|
||||
assert(reads.n > n, "the refresh read the usage again");
|
||||
await page.waitForFunction(() => !document.querySelector(".editor .quota-refresh.busy"));
|
||||
await frames(page);
|
||||
await check(`after row ${i}'s refresh`);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
test("the readings wrapped where a row is tested holding two lines", () => {
|
||||
for (const engine of engines) for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
assert([...wrapped].some((w) => w.startsWith(`${engine} ${lang} `)), `${engine} ${lang} never wrapped: ${[...wrapped].join("; ")}`);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user