routing: a row's model chip is whole; its status is what is cut short (yi_time)

yi_time on Discord (#feedback): on the Routing page, a group member's
row that was answering showed its model chip cut to "gpt-6.1-te…".
The status after it ("回答中… · 按意图"任务主要依靠视觉或界面…")
took up to 60% of the row (fit-content(60%)), and the head, with the
account, plan and model as one inline run, was cut at its end, which
is the model. So which model answered didn't show. The same happened
in a fold of keys, whose status column was auto, and at narrow widths,
where a long account name pushed the chip off.

The head's column is now as wide as its content (minmax(0,
max-content)). The status takes the rest and keeps at least
min(14em, 40%), cut short with an ellipsis. Inside the head, the
account name, then the plan, give up room. The chip and its
fast/fallback tags never shrink. Folds get the same columns, and their
status still wraps. A status beside the name is right-aligned, as
before. Under the name (max460/max560) it starts at the left. A status
cut short is read whole on hover: its em gets a title when the pointer
finds it overflowing. Measured on pointerenter, not each render
(#3164). Resting rows keep their rest tooltip; the intent and session
titles are as before. Sibling of 889767b7b (the failure tag cut).

Run:
- routing-model-chip-whole.test.cjs (new). Rows: answering with the
  reporter's intent text (the prefix their screenshot shows, then
  more), one gone on from (429), one failed to the agent (504), one
  resting, a plain provider row, and a fold of three keys. Models
  gpt-6.1-terra, gpt-6.1-sol:medium, gpt-6-astra:high and gpt-6-luna:low,
  plan prolite. en, zh, zh-TW, ja, de; Chromium and WebKit; 1600 and
  1280 wide (status beside the name, as the reporter had it) and 420
  (under it). Checks: every chip inside its head, at least 40px left
  for the status beside it, the intent row's status cut and titled
  whole, every cut status titled on hover, no sideways scroll.
  - On mote: 90 of 90 ok.
  - On WSL at 4a2bf73a0 (this change on bc10a6198): 90 of 90 ok.
  - Old code (origin/main with only the test added): 85 of 90 red at "the
    model's chip is whole" (gpt-6.1-terra in 53, the fold's chip in
    30), the reporter's case at 1600 among them.
- The 257 GUI files that reach the Routing page, plus i18n-keys, both
  engines, on mote at the pre-rebase head (load ~300). The run was
  stopped at ~680 results, with 12 reds in 9 files: codex-subagent-model,
  group-editor-selected, group-first-token, group-found-skip,
  group-from-model-add, group-member-weight, last-page, menu-input-scroll
  and mobile-web. None of them reads .rt-accts rows. Those 9 files on
  WSL, at this change and at origin/main bc10a6198:
  - At the change: 3 reds, group-editor-selected webkit and mobile-web
    in both engines.
  - At main: the same 3, plus codex-subagent-model chromium zh 560 and
    group-member-weight webkit en 420.
  Filed: #3952 (mobile-web), #2387 (group-member-weight), #5049
  (group-editor-selected), #5050 (codex-subagent-model).

At the pushed head (rebased on b967b1620, which touches no Routing
file):
- The new test and i18n-keys on WSL: 94 of 94 ok.
- go test ./internal/gui on mote: red only in TestMainWindowCorners,
  which is red the same way on origin/main b967b1620 (#3949, macOS 27).

Not tried: the rest of the 257 files after the stop; the real app's
WebKitGTK and WebView2; the reporter's own account and window width.
Screenshots were looked at by eye in Chromium only (zh 1600 and 420,
live and fold).
This commit is contained in:
yetone
2026-11-03 16:37:33 +08:00
parent 1dead5dc7b
commit f0e0385a0e
3 changed files with 184 additions and 4 deletions
+10 -1
View File
@@ -2306,6 +2306,15 @@ function routingPage(part) {
if (w.fallback) b.append(el("small", "fb", t("fallback")));
const st = el("em"), bar = el("div", "bar"), bi = el("i"), tg = el("span", "tag");
bar.append(bi);
// what the row says, cut short beside the model (routing.css), is read
// whole over it (yi_time on Discord). Measured as the pointer comes,
// not on each render: hundreds of rows (#3164)
st.onpointerenter = () => {
const cut = st.scrollWidth > st.clientWidth + 1;
if (cut) st.dataset.cut = "1"; else delete st.dataset.cut;
if (cut && !st.title) st.title = st.textContent;
};
st.onpointerleave = () => delete st.dataset.cut;
li.append(el("i", "dot"), b, st, bar, tg);
li.title = w.id;
return { li, wire: path(), st, bi, tg, w };
@@ -2711,7 +2720,7 @@ function routingPage(part) {
}
// the intent and a session's title are the user's own words, of any
// length: cut short on the row (routing.css), read whole over it
const full = said && s.includes(said) || named ? line + named : resting && !w.unlisted ? restTip(rest) : "";
const full = said && s.includes(said) || named ? line + named : resting && !w.unlisted ? restTip(rest) : row.st.dataset.cut ? s : "";
if (row.st.title !== full) { if (full) row.st.title = full; else row.st.removeAttribute("title"); } // an empty title would hide the row's own
// an account's windows each, with when they reset, in its tooltip
// (#1835): the row says the fullest one while idle and what it is
@@ -64,7 +64,12 @@
"No request yet" held the page as wide as a wider window had it, a
scrollbar under it (young02036 on Discord) */
.rt-accts { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; min-width: 0; }
.rt-accts li { position: relative; display: grid; grid-template-columns: 10px minmax(0, 1fr) fit-content(60%); align-items: center; column-gap: 10px; row-gap: 6px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; transition: opacity .3s, border-color .3s, transform .5s cubic-bezier(.2, .8, .2, 1); }
/* a row's name, plan and model as wide as they are, and what it says the
rest: a long status (an intent smart routing picked it for) is what is
cut short, never the model, which says what answered (yi_time on
Discord). It keeps at least min(14em, 40%) of the row, where the name
and plan are cut first (b below) */
.rt-accts li { position: relative; display: grid; grid-template-columns: 10px minmax(0, max-content) minmax(min(14em, 40%), 1fr); align-items: center; column-gap: 10px; row-gap: 6px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; transition: opacity .3s, border-color .3s, transform .5s cubic-bezier(.2, .8, .2, 1); }
.rt-accts li { margin-left: calc(var(--depth, 0) * 18px); }
/* a key off screen is not laid out or painted (#3164): with hundreds of
keys open, WebKit painted every row again on each frame a magpie flew.
@@ -97,6 +102,14 @@
.rt-accts li.rt-sub:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.rt-accts li.idle { display: block; color: var(--muted); border-style: dashed; text-align: center; }
.rt-accts b { font-weight: 560; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* a row's and a fold's head: the name and the plan give up their room
before the model's chip and its tags do, each cut short on its own */
.rt-accts li:not(.rt-sub) > b { display: flex; align-items: baseline; min-width: 0; }
.rt-accts li:not(.rt-sub) > b > * { flex: none; }
.rt-accts li:not(.rt-sub) > b > span:not(.ic) { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rt-accts li:not(.rt-sub) > b > span.who { flex-shrink: 100; } /* the name first, the plan after it */
.rt-accts li:not(.rt-sub) > b > span:not(.ic):not(.who):not(:empty) { margin-left: .3em; }
.rt-accts li:not(.rt-sub) > b > .ic { align-self: center; }
.rt-accts b > span:not(.ic) { font-weight: 450; color: var(--muted); }
.rt-accts b > span.who { color: var(--fg); font-weight: 560; }
.rt-accts b .ic { display: inline-flex; width: 16px; height: 16px; margin-right: 7px; vertical-align: -3px; }
@@ -108,7 +121,7 @@
/* what a row says has at most its column: a long one (an intent smart
routing picked it for) is cut short, its name kept, never run off the
row's edge (penershu on X) */
.rt-accts li > em { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rt-accts li > em { min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; }
/* the session an account answers (connor_yang on Discord): one line cut
short, also where a narrow stage lets the status wrap */
.rt-accts em .ses { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@@ -135,7 +148,7 @@
.rt-accts li.tagged .tag { opacity: 1; transform: none; }
/* a provider's keys for one model, folded into one row (#1319): it opens
to head them, as a group in the group heads its models */
.rt-accts li.rt-fold { grid-template-columns: 10px minmax(0, 1fr) auto auto; cursor: pointer; user-select: none; }
.rt-accts li.rt-fold { grid-template-columns: 10px minmax(0, max-content) minmax(min(14em, 40%), 1fr) auto; cursor: pointer; user-select: none; }
.rt-accts li.rt-fold em { white-space: normal; text-align: right; }
.rt-accts li.rt-fold .chev { display: inline-flex; color: var(--muted); transition: transform .2s; }
.rt-accts li.rt-fold:hover .chev { color: var(--fg); }
@@ -223,6 +236,8 @@
.rt-accts:where(.max560) li { grid-template-columns: 10px minmax(0, 1fr); }
.rt-accts:where(.max560) em { grid-column: 2; white-space: normal; }
.rt-accts:where(.max560) .bar { grid-column: 2; }
/* under the name, what a row says starts where the name does */
.rt-accts:where(.max460, .max560) li > em { text-align: left; }
:where(.rt.max560) .rt-stats { gap: 14px; }
/* the Routing view */
#view-routing .row-head { margin: 14px 0 6px; padding: 0 2px; gap: 0; }
@@ -0,0 +1,156 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// A row on the Routing page's stage names its account, its plan and the
// model in a chip, then says what it is doing. The row answering a request
// smart routing picked by intent says "answering… · picked for “…”", and
// the intent is the decision model's own words, of any length: the status
// took the room and the chip was cut to "gpt-6.1-te…", so which model
// answered didn't show (yi_time on Discord: one Codex account, plan
// prolite, a group of its models). The chip is whole on every row kind
// (answering, gone on from, failed to the agent, resting, a plain
// provider's row, a fold of keys), and what is cut short is the status,
// read whole over it, or the name. Every language, 1600 and 1280 wide (the
// status beside the name, as the reporter had it) and 420 (under it);
// 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 iso = (ms) => new Date(ms).toISOString();
// the reporter's intent, as far as their screenshot shows it, and on
const intent = "任务主要依靠视觉或界面判断,需要先读懂截图、设计稿和页面布局再动手修改样式与交互";
const who = "someone.with.a.long.address@example-company.test";
const acct = (model, fixed, extra) => ({ id: "codex-1", provider: "codex", name: "Codex", who, plan: "prolite", kind: "account", icon: "generic", model, ...(fixed ? { fixed } : {}), known: true, used: 30, ...extra });
const members = ["codex/gpt-6.1-terra", "codex/gpt-6.1-sol:medium", "codex/gpt-6-astra:high", "codex/gpt-6-luna:low", "openrouter/vendor/a-model-with-a-long-name-v2"];
// how: "live" (answering, one gone on from, one resting), "failed" (the
// last try failed to the agent), "fold" (three keys of one model, one answering)
function routeOf(how) {
const t0 = Date.now() - 1500;
const rule = { n: 1, use: "codex/gpt-6.1-terra", when: [`intent "${intent}"`], turn: 3, tokens: 9000,
classified: { by: "c/cls", intents: [intent], intent, ms: 300 } };
const group = { id: "main", name: "Main", members };
const base = { id: 7, seq: 7, time: iso(t0), agent: "codex", model: "main", provider: "codex", tokens: 9000, group, rule };
if (how === "fold") {
const key = (n) => ({ id: "relay-" + n, provider: "relay", name: "Relay", who: "key-" + n, kind: "key", icon: "generic", model: "gpt-6.1-terra-preview-long-0611" });
return { ...base, provider: "relay", group: { id: "main", name: "Main", members: ["relay/gpt-6.1-terra-preview-long-0611"] },
rule: { ...rule, use: "relay/gpt-6.1-terra-preview-long-0611" },
order: [key(1), key(2), key(3)], tries: [{ id: "relay-1", model: "gpt-6.1-terra-preview-long-0611", start: iso(t0 + 100) }], done: false };
}
const order = [acct("gpt-6.1-terra"), acct("gpt-6.1-sol", "medium"),
acct("gpt-6-astra", "high", { rest: { why: "rate", status: 429, model: "gpt-6-astra", until: iso(Date.now() + 3600e3) } }),
acct("gpt-6-luna", "low"),
{ id: "openrouter", provider: "openrouter", name: "OpenRouter", kind: "provider", icon: "generic", model: "vendor/a-model-with-a-long-name-v2" }];
if (how === "failed") {
return { ...base, order, done: true, status: 504, error: "no first token", ms: 1200,
tries: [{ id: "codex-1", model: "gpt-6.1-sol", fixed: "medium", start: iso(t0), done: true, status: 429, fail: "rate", ms: 200 },
{ id: "codex-1", model: "gpt-6.1-terra", start: iso(t0 + 300), done: true, status: 504, fail: "slow", ms: 1200, error: "no first token" }] };
}
return { ...base, order, done: false,
tries: [{ id: "codex-1", model: "gpt-6.1-sol", fixed: "medium", start: iso(t0), done: true, status: 429, fail: "rate", ms: 200 },
{ id: "codex-1", model: "gpt-6.1-terra", start: iso(t0 + 300) }] };
}
function serve(lang, route) {
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light" } };
let first = true;
return async (r) => {
const url = new URL(r.request().url());
const json = (data) => r.fulfill({ json: data }).catch(() => {});
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/plugins") return json({ plugins: [] });
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
const routes = first ? [route] : [];
first = false;
return json({ mine: true, now: new Date().toISOString(), seq: 7, totals: { requests: 1, rerouted: 1, errors: 0 }, routes });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
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 });
};
}
// every row's head and status, as laid out: where the chip is against the
// head that clips it, and whether the status is cut short
const rowsOf = (page) => page.evaluate(() => [...document.querySelectorAll(".rt-accts li:not(.rt-gap):not(.rt-sub)")].map((li) => {
const b = li.querySelector(":scope > b"), chip = b?.querySelector("code.mdl"), em = li.querySelector(":scope > em");
const r = (e) => e.getBoundingClientRect();
return {
fold: li.classList.contains("rt-fold"), chip: chip?.textContent || "",
chipIn: chip ? r(chip).left >= r(b).left - 0.5 && r(chip).right <= r(b).right + 0.5 : false,
chipW: chip ? r(chip).width : 0, chipText: chip ? chip.scrollWidth - chip.clientWidth : 0,
em: em?.textContent || "", emW: em ? r(em).width : 0, emCut: em ? em.scrollWidth > em.clientWidth + 1 : false, tip: em?.title || "",
};
}));
const words = (page, lang) => page.evaluate(([lang, intent]) => {
const t = (k) => (lang !== "en" && I18N[lang]?.[k]) || k;
return { answering: t("answering…"), picked: t("picked for “{intent}”").replace("{intent}", intent) };
}, [lang, intent]);
const engines = process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"];
const langs = ["en", "zh", "zh-TW", "ja", "de"];
for (const engine of engines) for (const lang of langs) for (const width of [1600, 1280, 420]) for (const how of ["live", "failed", "fold"]) {
test(`${engine} ${lang} ${width}px ${how}: a row's model chip is whole; its status is what is cut short`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width, height: 1000 } })).newPage();
page.setDefaultTimeout(8000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, routeOf(how)));
await page.goto("http://magpie.test/?view=routing");
const w = await words(page, lang);
const want = `${w.answering} · ${w.picked}`;
if (how === "fold") await page.waitForFunction((want) => [...document.querySelectorAll(".rt-accts li.rt-fold > em")].some((e) => e.textContent.includes(want)), want);
else if (how === "live") await page.waitForFunction((want) => [...document.querySelectorAll(".rt-accts li > em")].some((e) => e.textContent === want), want);
else await page.waitForFunction(() => document.querySelector(".rt-accts li.rest") && document.querySelectorAll(".rt-accts li > b code.mdl").length >= 5);
await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
const rows = await rowsOf(page);
// the list is laid out wide, the status beside the name, as the
// reporter's was; narrow, the status goes under the name
const beside = await page.evaluate(() => !document.querySelector(".rt-accts").classList.contains("max560"));
assert.equal(beside, width > 560, `the list's layout at ${width}px`);
assert(rows.length >= (how === "fold" ? 1 : 5), `rows: ${JSON.stringify(rows)}`);
for (const r of rows) {
assert(r.chip, `every row names its model: ${JSON.stringify(r)}`);
assert(r.chipIn && r.chipText <= 0, `the model's chip is whole: ${JSON.stringify(r)}`);
// a status beside the head keeps room enough to be read
if (beside) assert(r.emW >= 40, `the status keeps some room: ${JSON.stringify(r)}`);
}
if (how !== "failed") {
const lit = rows.find((r) => r.em.includes(want));
assert(lit, `the answering row says the intent: ${JSON.stringify(rows)}`);
assert(lit.chip.startsWith(how === "fold" ? "gpt-6.1-terra-preview" : "gpt-6.1-terra"), JSON.stringify(lit));
// the status cut short beside the name is read whole over it
if (beside && how !== "fold") assert(lit.emCut && lit.tip.includes(intent), `the long status is the one cut, read whole on hover: ${JSON.stringify(lit)}`);
}
// every status cut short says itself whole when pointed at
const cut = await page.evaluate(() => [...document.querySelectorAll(".rt-accts li:not(.rt-gap):not(.rt-sub) > em")]
.map((em, i) => [i, em.scrollWidth > em.clientWidth + 1]).filter(([, c]) => c).map(([i]) => i));
for (const i of cut) {
const em = page.locator(".rt-accts li:not(.rt-gap):not(.rt-sub) > em").nth(i);
await em.hover();
const [text, tip, rest] = await em.evaluate((e) => [e.textContent, e.title, e.parentElement.classList.contains("rest") && !e.parentElement.classList.contains("on")]);
assert(rest ? tip : tip === text, `a status cut short is read whole over it: ${JSON.stringify({ text, tip })}`);
}
if (beside && how === "live" && lang === "en" && width === 1600) assert(cut.length >= 2, `this fixture cuts the intent's and the 429's status: ${cut}`);
const wide = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
assert(wide <= 0, `no sideways scroll: ${wide}px`);
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
await page.locator(".rt-accts").screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-${how}.png`) });
}
assert.deepEqual(errors, []);
});
}