routing: in a narrow window the accounts and keys sit several to a line (Jiabubu)
Jiabubu on Discord (Windows, 0.1.2738): with the window narrow, Requests and Accounts and keys go one under the other, and every account or key then took a whole line, so a page of many accounts ran far down. The cause is routing.css: under 1150px .rt-acts stays a one-column block list. Now, when the columns stack (not .min1150, or .solo), .rt-acts is a grid of auto-fill columns of at least 168px. Each provider's heading and an open "N accounts" summary row span the whole line. Beside the requests (1150px and wider) the column holds one to a line, as before. No collapse arrows and no other change to the page: once the list is compact the page is no longer long. Test: routing-accounts-narrow.test.cjs. At 700, 560 and 420px, four accounts with two of them sharing a line, side by side; headings and the summary row across the list; no sideways scroll; names inside their box; one to a line at 1440. Chromium and WebKit, en zh zh-TW ja de. Run at the pushed head on mote: that file 10/10. Also routing-columns, routing-keys-fold, routing-group-fold, routing-compact and the rest of the head run in the next commit's body; TestCoreScriptBudget and other Budget tests ok (no script grew). Earlier, atdcc84dbc0, every routing-*, panel-routing*, usage-ledger*, session-identity, i18n-keys and phone-rows file: 1051 ok, 5 red. Four were load (a browser launch timing out at 180s) and passed when run again alone. The fifth, routing-many-keys, is red on origin/main173b7e274too (#4082, numbers added). Broken by hand: routing.css at its base makes all 10 red (700px, one account per line). Not tried: the whole GUI suite (mote had two other sessions' whole suites running at load ~200); the real Windows app at a narrow width.
This commit is contained in:
@@ -397,6 +397,12 @@ button.rt-session { cursor: pointer; }
|
||||
:where(.rt-col.max760) :is(.rt-req, .rt-probe) .to { grid-column: 2; grid-row: 2; }
|
||||
:where(.rt-col.max760) :is(.rt-req, .rt-probe) .meta { grid-column: 2; grid-row: 3; justify-content: flex-start; }
|
||||
.rt-acts { padding: 4px 0; }
|
||||
/* under the requests, as wide as the page, the accounts and keys sit
|
||||
several to a line, each provider's heading across them: one to a line,
|
||||
a page of many accounts ran on far below the requests (Jiabubu on
|
||||
Discord). Beside the requests (min1150) the column holds one */
|
||||
:where(.rt-more:not(.min1150)) .rt-acts, .rt-cols.solo .rt-acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); align-content: start; }
|
||||
:where(.rt-more:not(.min1150)) .rt-acts > :is(.rt-prov, .rt-keys.open), .rt-cols.solo .rt-acts > :is(.rt-prov, .rt-keys.open) { grid-column: 1 / -1; }
|
||||
.rt-cols.solo { grid-template-columns: minmax(0, 1fr); }
|
||||
.rt-reqs.none { display: block; background: none; border-color: transparent; }
|
||||
.rt-reqs.none .empty-state { padding: 14px 12px 18px; font-size: 12px; line-height: 1.6; }
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The Routing page in a narrow window (Jiabubu on Discord): the Requests and
|
||||
// the Accounts and keys go one under the other, and each account or key then
|
||||
// took a whole line, so a page of many accounts ran on far down. Under the
|
||||
// requests the accounts sit several to a line, each provider's heading across
|
||||
// them; beside the requests (1150px and wider) the column still holds one.
|
||||
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 now = new Date();
|
||||
const at = (i) => new Date(now.getTime() - (i + 1) * 60e3).toISOString();
|
||||
const renew = new Date(now.getTime() + 3 * 864e5).toISOString();
|
||||
const acct = (n, who, plan) => ({ id: "codex:" + n, provider: "codex", name: "Codex", who, plan, kind: "account", model: "gpt-5.6-terra", known: true, used: 10 + n, renews: [renew], icon: "codex-color", routing: "order" });
|
||||
const codex = [acct(1, "ann@example.com", "plus"), acct(2, "bob@example.com", "pro"), acct(3, "cat@example.com", "plus"), acct(4, "dan@example.com", "team")];
|
||||
const ds = { id: "deepseek", provider: "deepseek", name: "DeepSeek", kind: "provider", model: "deepseek-flash", icon: "deepseek-color", routing: "order" };
|
||||
const mk = (i, w, model) => ({
|
||||
id: 100 - i, seq: 100 - i, time: at(i), agent: "codex", model, provider: w.provider,
|
||||
order: w.provider === "codex" ? codex : [w], done: true, status: 200, ms: 4000, tokens: 9000,
|
||||
tries: [{ id: w.id, model: w.model, start: at(i), done: true, status: 200, ms: 4000 }],
|
||||
});
|
||||
const routes = [...codex.map((w, i) => mk(i, w, "gpt-5.6-terra")), mk(4, ds, "deepseek-flash")];
|
||||
|
||||
function serve(lang) {
|
||||
const state = { agents: [{ id: "codex", name: "Codex", path: "/t", fields: [] }], profiles: [], settings: { lang, theme: "light" } };
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
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:"light",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(state);
|
||||
if (url.pathname === "/api/gateway/trace") {
|
||||
if (url.searchParams.get("wait")) await new Promise((r) => setTimeout(r, 20e3));
|
||||
return json({ mine: true, now: now.toISOString(), seq: 100, totals: { requests: routes.length, rerouted: 0, errors: 0 }, routes });
|
||||
}
|
||||
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
|
||||
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 route.fulfill({ body: await fs.readFile(file).catch(() => ""), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
test(`${engine} ${lang}: narrow, the accounts sit several to a line`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await browser.newPage({ viewport: { width: 700, height: 1200 } });
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang));
|
||||
t.after(() => browser.close());
|
||||
await page.goto("http://magpie.test/?view=routing");
|
||||
await page.locator(".rt-act", { hasText: "dan@example.com" }).waitFor();
|
||||
|
||||
// the account rows' boxes: how many share the first one's line
|
||||
const rows = () => page.locator(".rt-acts > .rt-act:not(.rt-keys)").evaluateAll((es) => es.map((e) => {
|
||||
const b = e.getBoundingClientRect();
|
||||
return { top: Math.round(b.top), left: b.left, right: b.right, text: e.textContent };
|
||||
}));
|
||||
const settle = () => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(r, 100)))));
|
||||
for (const width of [700, 560, 420]) {
|
||||
await page.setViewportSize({ width, height: 1200 });
|
||||
await settle();
|
||||
const reqs = await page.locator(".rt-reqs").boundingBox(), acts = await page.locator(".rt-acts").boundingBox();
|
||||
assert(acts.y >= reqs.y + reqs.height - 1, `${width}px: the accounts under the requests`);
|
||||
const rs = (await rows()).filter((r) => r.text.includes("@example.com"));
|
||||
assert.equal(rs.length, 4, `${width}px: each Codex account drawn`);
|
||||
const shared = rs.filter((r) => Math.abs(r.top - rs[0].top) <= 1);
|
||||
assert(shared.length >= 2, `${width}px: two accounts share a line, not one each: ${JSON.stringify(rs.map((r) => [r.top, Math.round(r.left)]))}`);
|
||||
assert(shared[1].left >= shared[0].right - 1, `${width}px: side by side`);
|
||||
// the open "4 accounts" row heads them, across its line, as a provider's heading does
|
||||
const sum = await page.locator(".rt-acts > .rt-keys.open").evaluate((e) => e.getBoundingClientRect().width / e.parentElement.clientWidth);
|
||||
assert(sum > 0.95, `${width}px: the accounts' summary row across the list: ${sum}`);
|
||||
// each provider's heading still across its own line
|
||||
const heads = await page.locator(".rt-acts > .rt-prov").evaluateAll((es) => es.map((e) => e.getBoundingClientRect().width / e.parentElement.clientWidth));
|
||||
assert(heads.length >= 2 && heads.every((f) => f > 0.95), `${width}px: headings across the list: ${heads}`);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false, `${width}px: no horizontal overflow`);
|
||||
const out = await page.locator(".rt-act .nm b").evaluateAll((es) => es.some((e) => e.getBoundingClientRect().right > e.closest(".rt-act").getBoundingClientRect().right + 1));
|
||||
assert.equal(out, false, `${width}px: names stay inside their account`);
|
||||
}
|
||||
// beside the requests the column holds one to a line, as before
|
||||
await page.setViewportSize({ width: 1440, height: 1200 });
|
||||
await settle();
|
||||
const wide = (await rows()).filter((r) => r.text.includes("@example.com"));
|
||||
assert.equal(new Set(wide.map((r) => r.top)).size, 4, "wide: one account to a line");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user