gui: a request's row on Routing keeps the model that answered readable beside its metrics, and the accounts column gives up its spare room (#1926, hibaliqya-yonma)

What changed:
- The request list's columns were time, asked, to (minmax(0, 1fr)) and
  the metrics (auto). Rows share their columns (subgrid), so the metrics
  column took the widest row's whole line for every row, and "to" got
  what was left. Now "to" keeps at least 14em (30% of a narrower list)
  and the metrics take at most 40%, wrapping inside it (they already
  wrap); asked is held to 32% (was 36%). The no-subgrid fallback gets
  the same columns.
- "to" said "<account> · <model>" in one box that gave way before the
  reasoning level, so it read "· hi…". It is now two boxes: the account
  gives way first (down to 2.5em), the model stays whole when it fits,
  and the said box keeps at least 9em before the level is cut. The
  text is the same, so tests and titles that read it see no change.
- Side by side (1150px and wider), the accounts column is clamp(260px,
  28%, 360px), was clamp(280px, 32%, 400px): in a page kept to 1200px
  (61a0a69b) it gave the requests ~47px more.

Why: since 61a0a69b kept Routing to 1200px, the requests' column beside
the accounts is ~800px, just over the 760 where rows stack, so each row
stayed on one line and the model that answered was squeezed to nothing
while the metrics kept their width. Reproduced with the reporter's
shape of row in Chromium and WebKit: at 1920 the served model's box was
0px of 226.

Run:
- new routing-request-model.test.cjs: chromium and webkit, en zh zh-TW
  ja de, at 1920, 1320, 1240, 1100, 900 and 420: the model whole beside
  its account (its text's own unrounded width: WebKit cut a box a
  fraction narrower than its text, with an ellipsis scrollWidth doesn't
  show), no metric clipped or outside its row, no overlap, no sideways
  scroll. 10/10. Red with the old grid ("the model that answered is 0px
  of 30"), red without the split ("the model is cut (123px of 226)"),
  and red in WebKit with the model's box allowed to shrink.
- routing-columns.test.cjs: the accounts column's bound is now 260..360.
- routing-*.test.cjs (69 files), page-width and click-scroll, both
  engines, at load ~150: 835 passed, 1 failed. The one,
  routing-upstream's chromium en, passed 4/4 when run again. Two files,
  routing-group-fold and routing-mode-goes, ran out of the 240s per-file
  limit and passed 40/40 each when run again. After rebasing onto
  97751188e: routing-request-model 10/10, group-classifier-failed 20/20,
  routing-columns 4/4, routing-request-metrics 4/4, routing-upstream 4/4,
  routing-mode-goes 40/40, i18n-keys 1/1.
- Go, on this series at 04ff9a775: go test -tags nogui for usage,
  provider, cli and gateway (-timeout 45m), and go test ./internal/gui/,
  all ok. gofmt -l is clean. go vet passes on darwin and with -tags nogui
  on linux and windows. After rebasing onto 97751188e, the vets, usage,
  cli and gui were run again, all ok. Rebased again onto 15105161e, with
  the same results: gofmt is clean, all three vets pass, go test for
  usage, provider, cli, gateway and gui is ok, and routing-request-model
  10/10, group-classifier-failed 20/20, routing-columns 4/4 and i18n-keys
  1/1 pass. Rebased onto 54ba9042d (main had touched i18n.js,
  routing.js and the gateway): gofmt and all three vets are clean; go
  test passes for usage, for gateway and provider with -run
  Classif|Intent|Decide|MLX, and for gui; routing-request-model,
  group-classifier-failed, routing-columns, routing-request-metrics,
  routing-save-keeps-the-row and i18n-keys pass.
- Screenshots before and after at 1920/1320/1100/420 in both engines.

Not verified: a real WebView2 window on Windows; Chromium stands in for
it here.
This commit is contained in:
yetone
2026-10-13 16:39:29 +08:00
parent 08b1a60c03
commit 06ff45fed5
4 changed files with 119 additions and 7 deletions
+14 -5
View File
@@ -185,15 +185,21 @@
few accounts'. Only where the requests' column still keeps each request
on one line (wider than 760px, see below): narrower, one column of
one-line requests reads better than two with each request on three
(#860, huoranxuanyuan). Where the page is 1150px wide or more */
:where(.rt-more.min1150) .rt-cols { grid-template-columns: minmax(0, 1fr) clamp(280px, 32%, 400px); }
(#860, huoranxuanyuan). Where the page is 1150px wide or more. Kept to
28%, no more than 360px: in a page kept to 1200px the accounts had room
to spare while the requests' models were cut (#1926, hibaliqya-yonma) */
:where(.rt-more.min1150) .rt-cols { grid-template-columns: minmax(0, 1fr) clamp(260px, 28%, 360px); }
:where(.rt-more.min1150) .rt-cols:not(.solo) .rt-col:last-child { display: flex; flex-direction: column; }
:where(.rt-more.min1150) .rt-cols:not(.solo) .rt-acts { flex: 1 1 auto; height: 0; min-height: 216px; overflow-y: auto; overscroll-behavior: contain; }
/* each column sized by its own width: a request's row lays itself out by
the list's width, not the page's (#273: in two columns of ~470px the
rows kept to one line, and the reasoning was drawn over the numbers) */
.rt-col { min-width: 0; }
.rt-reqs { padding: 4px; max-height: 420px; overflow-y: auto; display: grid; grid-template-columns: auto fit-content(36%) minmax(0, 1fr) auto; }
/* the model that answered keeps room of its own (at least 14em, or 30%
of a narrower list) and the metrics wrap in theirs, up to 40%: an auto
column took the widest row's metrics for every row, and the model went
to "· hi…" (#1926, hibaliqya-yonma) */
.rt-reqs { padding: 4px; max-height: 420px; overflow-y: auto; display: grid; grid-template-columns: auto fit-content(32%) minmax(min(14em, 30%), 1fr) fit-content(40%); }
.rt-req { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; column-gap: 12px; padding: 6px 8px; font: inherit; font-size: 12px; text-align: left; color: var(--fg-2); background: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.rt-req:hover { background: var(--card-2); }
.rt-req[aria-pressed="true"] { background: var(--card-2); border-color: var(--line); color: var(--fg); }
@@ -203,7 +209,10 @@
.rt-req .asked .ic, .rt-req .asked .ic img, .rt-req .asked .ic svg { width: 14px; height: 14px; flex: none; }
.rt-req .m, .rt-req .to span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-req .to { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--fg); }
.rt-req .to .said { flex-shrink: 100000; }
.rt-req .to .said { flex-shrink: 100000; min-width: min(9em, 60%); }
.rt-req .to .said.split { display: flex; }
.rt-req .to .said .who { flex: 0 1000 auto; min-width: 2.5em; }
.rt-req .to .said .mdl { flex: none; max-width: calc(100% - 2.5em); white-space: pre; }
.rt-req .to i { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.rt-req.moved .to i { background: var(--accent); }
.rt-req.bad .to { color: var(--red); }
@@ -670,7 +679,7 @@ button.rt-session { cursor: pointer; }
.pr-req .meta { justify-self: end; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
@media (prefers-reduced-motion: reduce) { .pr-req.wait .pr-to > i, .ps-dst.wait > i, .ps-hub.busy, .ps-dot.wait { animation: none; } }
@supports not (grid-template-columns: subgrid) {
.rt-req { grid-template-columns: auto fit-content(36%) minmax(0, 1fr) auto; }
.rt-req { grid-template-columns: auto fit-content(32%) minmax(min(14em, 30%), 1fr) fit-content(40%); }
@media (max-width: 700px) {
.rt-reqs { grid-template-columns: auto minmax(0, 1fr); }
.rt-req { grid-template-columns: auto minmax(0, 1fr); row-gap: 2px; }
+7 -1
View File
@@ -2328,7 +2328,13 @@
// the one sent, each cut with an ellipsis in its own box (#435,
// azir12345: 文字重叠 — "medium → low" was drawn over the numbers)
const to = el("span", "to");
to.append(el("i"), el("span", "said", said));
// who answered, then its model: short of room the account gives way
// first, so the model that answered stays readable (#1926,
// hibaliqya-yonma: "ZCode …" was all the row had left of it)
const sd = el("span", "said"), cut = how === "ok" || how === "moved" ? said.lastIndexOf(" · ") : -1;
if (cut > 0) sd.classList.add("split"), sd.append(el("span", "who", said.slice(0, cut)), el("span", "mdl", said.slice(cut)));
else sd.textContent = said;
to.append(el("i"), sd);
if (tr?.effort) {
const ef = el("span", "ef" + (tr.picked ? " picked" : ""));
const was = r.effort && r.effort !== tr.effort;
+1 -1
View File
@@ -105,7 +105,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const requests = await box(".rt-col:first-child"), accounts = await box(".rt-col:last-child");
const rw = requests.right - requests.left, aw = accounts.right - accounts.left;
assert(rw > aw * 1.6, `${width}px: requests should have more room than accounts (${rw} / ${aw})`);
assert(aw >= 280 && aw <= 400.5, `${width}px: account column stays readable and capped (${aw})`);
assert(aw >= 260 && aw <= 360.5, `${width}px: account column stays readable and capped (${aw})`);
const rightList = await box(".rt-acts"), leftList = await box(".rt-reqs");
assert(Math.abs(rightList.bottom - leftList.bottom) <= 1, `${width}px: list bottoms stay aligned`);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false, `${width}px: no horizontal overflow`);
@@ -0,0 +1,97 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// #1926 (hibaliqya-yonma): with Routing kept to 1200px (61a0a69b) and the
// accounts beside the requests, a request's row gave the room to its
// metrics and the reasoning level, and the model that answered shrank to
// "· hi…": the metric column took the widest row's whole width for every
// row, and the model gave way before the level. The model that answered
// keeps a readable width now; the metrics wrap in their own column rather
// than take it. Both engines, every language, at the reporter's two-column
// width, at 1100 and at 420.
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 = new Date();
const seat = { id: "zcode", provider: "zcode", name: "ZCode", who: "someone@example.com", kind: "account", model: "glm-5.1-turbo" };
function req(id, extra = {}) {
const time = new Date(now.getTime() - (20 - id) * 60e3).toISOString();
return { id, seq: id, time, agent: "codex", session: "s" + (id % 3), model: id % 2 ? "group/auto-gpt-6-1-sol" : "group/group-sol-swe2", provider: "zcode",
effort: "high", order: [seat], tries: [{ id: seat.id, model: seat.model, effort: "high", start: time, done: true, status: 200, ms: 14000, ttft: 9600 }],
done: true, status: 200, ms: 14000, ttft: 9600, tokens: 396900, out: 670, usage: [{ provider: "zcode", model: seat.model, in: 1000, out: 670, cache_read: 395000, cache_write: 230 }],
priced: true, cost: 0.088, ...extra };
}
const fixtures = [req(12), req(11, { kind: "agent_created_title" }), req(10, { kind: "subagent" }), req(9), req(8, { cost: 0.075, ms: 4200, ttft: 4200 })];
function serve(lang) {
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"};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [{ id: "codex", name: "Codex", fields: [] }], profiles: [], settings: { lang, theme: "dark" } });
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.has("wait")) return new Promise(() => {}); // nothing more comes
return json({ mine: true, now: now.toISOString(), seq: 12, totals: { requests: fixtures.length, rerouted: 0, errors: 0 }, routes: fixtures });
}
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)];
return route.fulfill({ body: await fs.readFile(file), 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}: a request's row keeps the model that answered readable beside its metrics`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await browser.newPage({ viewport: { width: 1320, height: 900 }, reducedMotion: "reduce" });
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
const rows = page.locator(".rt-req");
await rows.nth(fixtures.length - 1).waitFor();
for (const width of [1920, 1320, 1240, 1100, 900, 420]) {
await page.setViewportSize({ width, height: 900 });
await page.waitForTimeout(150);
const seen = await rows.evaluateAll((rs) => rs.map((row) => {
const box = (e) => e.getBoundingClientRect();
// the text's own width, unrounded: WebKit cut a box a fraction
// narrower than its text with an ellipsis that scrollWidth hides
const inked = (e) => { const r = document.createRange(); r.selectNodeContents(e); return r.getBoundingClientRect().width; };
const said = row.querySelector(".to .said"), ef = row.querySelector(".to .ef"), mdl = said.querySelector(".mdl");
return { mdl: mdl && mdl.textContent, mdlCut: !mdl || mdl.scrollWidth > mdl.clientWidth + 1 || inked(mdl) > box(mdl).width + 0.01, said: said.clientWidth, full: said.scrollWidth, text: said.textContent, ef: ef ? ef.clientWidth : 0,
to: box(row.querySelector(".to")), meta: box(row.querySelector(".meta")), row: box(row),
metrics: [...row.querySelectorAll(".rt-metric")].map((e) => ({ clipped: e.scrollWidth > e.clientWidth + 1, l: box(e).left, r: box(e).right })) };
}));
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
await page.locator(".rt-reqs").screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}.png`) });
}
for (const [i, r] of seen.entries()) {
// its provider and the start of its model, at the least; whole when it fits
assert(r.said >= Math.min(r.full, 110), `${width}px row ${i}: the model that answered is ${r.said}px of ${r.full} ("${r.text}"), the level ${r.ef}px`);
// and the model itself whole, the account giving way first
assert.equal(r.text, "someone@example.com · glm-5.1-turbo");
assert(!r.mdlCut && r.mdl === " · glm-5.1-turbo", `${width}px row ${i}: the model is cut (${r.said}px of ${r.full})`);
for (const m of r.metrics) {
assert(!m.clipped, `${width}px row ${i}: a metric is clipped`);
assert(m.l >= r.row.left - 0.5 && m.r <= r.row.right + 0.5, `${width}px row ${i}: a metric is outside its row`);
}
assert(r.meta.width === 0 || r.meta.left >= r.to.right - 1 || r.meta.top >= r.to.bottom - 1, `${width}px row ${i}: the metrics overlap the model`);
}
const over = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
assert(over <= 0, `${width}px: sideways scroll ${over}`);
}
assert.deepEqual(errors, []);
});
}
}