Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
routing: the requests list lines up its rows without a subgrid, so Safari 16 stops crashing on it (#3731)
yetonea1f0a6109afe
diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.jsindex f77d151ee..6a45d206d 100644--- a/internal/gui/assets/plugins/routing/client.js+++ b/internal/gui/assets/plugins/routing/client.js@@ -291,11 +291,15 @@ function routingPage(part) {const kept = [], under = colA.classList.contains("meta-under");for (let p = reqs; p; p = p.parentElement) if (p.scrollTop) kept.push([p, p.scrollTop]);colA.classList.remove("meta-under");+ inMetaFit = true;+ fitCols(); // the rows' columns for the layout measured, not the one beforeconst wraps = [...reqs.querySelectorAll(".rt-req .meta:not([hidden])")].some((m) => {const k = m.children;return k.length > 1 && k[k.length - 1].getBoundingClientRect().top - k[0].getBoundingClientRect().top > 2;});colA.classList.toggle("meta-under", wraps);+ fitCols();+ inMetaFit = false;for (const [p, top] of kept) if (p.scrollTop !== top) p.scrollTop = top;if (colA.classList.contains("meta-under") !== under) redrawList(); // the rows' heights changed}); };@@ -3399,17 +3403,49 @@ function routingPage(part) {// taken as tall as the average drawn.//// The columns are as wide as the widest of all the requests, drawn or- // not, as before: a row unlike any drawn — another time's shape, model,- // kind or numbers — is in the list too, with no height and unseen (a- // probe), so the grid sizes its columns by it. Digits are as wide as- // each other there (tabular-nums), so a probe stands for every row of- // its shape.+ // not: one row of each shape — its time's, model's, kind's and numbers' —+ // is in a hidden grid at the list's foot (a probe in the sizer), which+ // sizes its columns by them, and every row takes the widths it found+ // (fitCols). Digits are as wide as each other there (tabular-nums), so a+ // probe stands for every row of its shape. The rows were a subgrid of+ // the list once, and Safari 16 crashed sizing them (#3731).const WIN_MIN = 300;let listItems = [], winKey = "", winAvg = 0, winSoon = 0, rowsMoved = false;const heights = new Map(); // a request's id, or a session's head → its heightconst gapAbove = el("div", "rt-gap"), gapBelow = el("div", "rt-gap");for (const g of [gapAbove, gapBelow]) g.setAttribute("aria-hidden", "true");const probes = new Map(), probeShapes = new WeakMap();+ const sizer = el("div", "rt-sizer");+ sizer.setAttribute("aria-hidden", "true");+ sizer.inert = true;+ // fitCols: the sizer's columns, measured, for the rows to take; each+ // fixed but the one taking what is left (the third of four, else the+ // last), which stays a share so a pixel rounded over never pushes a row+ // wider. Told whenever a probe's cell changes size, as a column moving+ // does: a new width, another layout, a font come in.+ let colsAt = "", inMetaFit = false;+ const fitCols = () => {+ if (!reqs.offsetWidth) return; // out of sight: left as it is, the list untouched+ const c = getComputedStyle(sizer).gridTemplateColumns;+ if (c === colsAt) return;+ colsAt = c;+ const w = c.split(" ");+ if (!w.every((x) => /^[\d.]+px$/.test(x))) reqs.style.removeProperty("--rt-cols"); // no probe: unsized+ else {+ // up to the layout's 1/64px: the width read back is rounded, and a+ // hair narrower than its numbers wraps them (meta-under)+ const px = w.map((x) => Math.ceil(parseFloat(x) * 64) / 64 + "px");+ px[w.length === 4 ? 2 : w.length - 1] = "minmax(0, 1fr)";+ reqs.style.setProperty("--rt-cols", px.join(" "));+ }+ redrawList(); // the rows' heights measured in the columns before are dropped (listKey)+ if (!inMetaFit) metaFit(); // new columns, not metaFit's own: whether the numbers fit asked again+ };+ // told a frame later: the rows taking their columns can move the list's+ // scrollbar and with it the probes, which within the observer's own turn+ // is a loop WebKit reports+ let colsSoon = 0;+ const colsSeen = new ResizeObserver(() => { if (!colsSoon) colsSoon = requestAnimationFrame(() => { colsSoon = 0; fitCols(); }); });const isHead = (x) => x instanceof Element;const itemKey = (x) => isHead(x) ? x : x.id;const itemEl = (x) => isHead(x) ? x : rowOf(x);@@ -3433,7 +3469,8 @@ function routingPage(part) {probeShapes.set(r, { key, s });return s;}- function probesFor(rs) {+ // fillSizer: a probe of each shape the rows have, in the sizer+ function fillSizer(rs) {const key = document.documentElement.lang + "|" + visibleMetrics.join(), seen = new Set(), want = new Map();for (const r of rs) {const s = shapes(r, key);@@ -3443,20 +3480,23 @@ function routingPage(part) {if (!want.has(id)) want.set(id, r);}for (const id of probes.keys()) if (!want.has(id)) probes.delete(id);- return [...want].map(([id, r]) => {- let b = probes.get(id);- if (!b) {+ const els = [...want].map(([id, r]) => {+ let p = probes.get(id);+ if (!p) {const [said, how, tr] = outcome(r), meta = r.tries.length > 1 ? [t("{n} tries", { n: r.tries.length })] : [];- b = reqRow(r, said, how, tr, agentOf(r.agent), meta, requestMetrics(r, how), "");- b.classList.add("probe");- b.removeAttribute("title");- b.tabIndex = -1;- b.inert = true;- b.setAttribute("aria-hidden", "true");- probes.set(id, b);+ const b = reqRow(r, said, how, tr, agentOf(r.agent), meta, requestMetrics(r, how), "");+ p = el("div", b.className.replace(/^rt-req /, "rt-probe ") + " probe"); // not a row to anything that asks for one+ p.append(...b.childNodes);+ probes.set(id, p);}- return b;+ return p;});+ // only the probes come and go: their order measures nothing, and the+ // rest are kept in place for a request going on (its numbers' shape+ // changing) not to put every probe in again on each update+ const keep = new Set(els);+ for (const k of [...sizer.children]) if (!keep.has(k)) { for (const c of k.children) colsSeen.unobserve(c); k.remove(); }+ for (const p of els) if (p.parentNode !== sizer) { sizer.append(p); for (const c of p.children) colsSeen.observe(c); }}// placeRows puts the list's children in order, moving only those out of// place: the list scrolls on its own, and WebKit, a row taken out for a@@ -3488,27 +3528,30 @@ function routingPage(part) {}function drawList() {const n = listItems.length;+ fillSizer(listItems.filter((x) => !isHead(x)));if (n < WIN_MIN) {reqs.classList.remove("win");- probes.clear();- return placeRows(listItems.map(itemEl));+ return placeRows([...listItems.map(itemEl), sizer]);}reqs.classList.add("win");// out of sight (another view, the window hidden) nothing has a height:// drawn as last measured, and measured once in sight againconst live = !!reqs.offsetParent;- const listKey = [colA.className, reqs.clientWidth, document.documentElement.lang, visibleMetrics.join()].join("|");- if (live && listKey !== winKey) { winKey = listKey; heights.clear(); winAvg = 0; }+ const listKey = [colA.className, reqs.clientWidth, reqs.style.getPropertyValue("--rt-cols"), document.documentElement.lang, visibleMetrics.join()].join("|");+ // other columns (a wider probe come in): the heights measured in the+ // old ones dropped, their average kept for the rows not drawn again+ if (live && listKey !== winKey) { if (winKey.split("|").filter((x, i) => i !== 2).join() !== listKey.split("|").filter((x, i) => i !== 2).join()) winAvg = 0; winKey = listKey; heights.clear(); }const pad = parseFloat(getComputedStyle(reqs).paddingTop) || 0;// the first row in sight, and where: it stays thereconst box = reqs.getBoundingClientRect();let anchor = null, anchorAt = 0;for (const e of reqs.children) {- if (e.classList.contains("rt-gap") || e.classList.contains("probe")) continue;+ if (e.classList.contains("rt-gap") || e === sizer) continue;const r = e.getBoundingClientRect();if (r.bottom > box.top) { anchor = e; anchorAt = r.top - box.top; break; }}- const est = winAvg || 31, off = new Float64Array(n + 1);+ let est = winAvg || 31;+ const off = new Float64Array(n + 1);const sum = () => { for (let i = 0; i < n; i++) off[i + 1] = off[i] + (heights.get(itemKey(listItems[i])) ?? est); };sum();const view = reqs.clientHeight, over = Math.max(view, 300), y = reqs.scrollTop - pad;@@ -3518,7 +3561,7 @@ function routingPage(part) {const drawn = listItems.slice(i0, i1).map(itemEl);gapAbove.style.height = off[i0] + "px";gapBelow.style.height = off[n] - off[i1] + "px";- placeRows([gapAbove, ...drawn, gapBelow, ...probesFor(listItems.filter((x) => !isHead(x)))]);+ placeRows([gapAbove, ...drawn, gapBelow, sizer]);if (!live) return;// measured as drawn: each one's slot in the grid, its margins with itdrawn.forEach((e, i) => {@@ -3528,6 +3571,7 @@ function routingPage(part) {let total = 0;for (const h of heights.values()) total += h;winAvg = heights.size ? total / heights.size : 0;+ est = winAvg || 31; // the rows not drawn as tall as those just measured, not as the average beforesum();const above = off[i0] + "px", below = off[n] - off[i1] + "px";if (gapAbove.style.height !== above) gapAbove.style.height = above;diff --git a/internal/gui/assets/plugins/routing/routing.css b/internal/gui/assets/plugins/routing/routing.cssindex 4923aad5b..c3418683f 100644--- a/internal/gui/assets/plugins/routing/routing.css+++ b/internal/gui/assets/plugins/routing/routing.css@@ -91,7 +91,7 @@.rt-accts b .ic { display: inline-flex; width: 16px; height: 16px; margin-right: 7px; vertical-align: -3px; }.rt-accts b .ic img, .rt-accts b .ic svg { width: 16px; height: 16px; }.rt-accts b .fb { margin-left: 6px; font-size: 10.5px; font-weight: 560; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }-.rt-accts b code.mdl, .rt-req code, .rt-act code.mdl { font: var(--code-style, normal) 500 11px/1.5 var(--code-font, var(--code)); font-stretch: var(--code-stretch, 100%); color: var(--fg-2); background: var(--card-2); border-radius: 5px; padding: 0 5px; }+.rt-accts b code.mdl, :is(.rt-req, .rt-probe) code, .rt-act code.mdl { font: var(--code-style, normal) 500 11px/1.5 var(--code-font, var(--code)); font-stretch: var(--code-stretch, 100%); color: var(--fg-2); background: var(--card-2); border-radius: 5px; padding: 0 5px; }.rt-accts b code.mdl { margin-left: 7px; font-weight: 450; }.rt-accts em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }.rt-accts .bar { grid-column: 2 / 4; height: 3px; border-radius: 2px; background: var(--card-2); overflow: hidden; }@@ -242,74 +242,92 @@of a narrower list) and the metrics wrap in theirs, up to 40%: an autocolumn took the widest row's metrics for every row, and the model wentto "· 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; }+/* Each row has columns of its own, as wide as the measuring grid's (a+ hidden .rt-sizer holding one probe of each row's shape) found its own+ (--rt-cols, set by the page); until it is measured, a row sizes its+ own. A row was a subgrid of the list: Safari 16 (macOS 13) recursed in+ sizing the list's fit-content() columns through it, and its WebContent+ process crashed and reloaded the page, up to 93 times a minute under+ traffic (#3731, gpboyer2). */+.rt-reqs { --rt-tpl: auto fit-content(32%) minmax(min(14em, 30%), 1fr) fit-content(40%); padding: 4px; max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; }+.rt-reqs > * { flex: none; }+.rt-req { display: grid; grid-template-columns: var(--rt-cols, var(--rt-tpl)); 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); }/* a long list draws only the rows near its sight, between gaps as tall asthe rest; a probe is a row unlike any drawn, there for the columns'widths only (#2524) */.rt-reqs.win { overflow-anchor: none; }-.rt-reqs .rt-gap { grid-column: 1 / -1; }-.rt-req.probe { height: 0; padding-block: 0; border-block-width: 0; overflow: hidden; visibility: hidden; pointer-events: none; }+/* the measuring grid: as wide as a row's content, with its gaps, and no+ height. Each probe's cells are in the columns a row's are (a layout's+ placing them wins over these), in whatever row: only the columns are+ measured */+.rt-sizer { display: grid; grid-template-columns: var(--rt-tpl); column-gap: 12px; padding-inline: 9px; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; font-size: 12px; }+.rt-sizer > .rt-probe { display: contents; }+/* a probe is measured, never seen: its dot doesn't pulse */+.rt-sizer *, .rt-sizer *::before, .rt-sizer *::after { animation: none !important; transition: none !important; }+:where(.rt-sizer) .at { grid-column: 1; }+:where(.rt-sizer) .asked { grid-column: 2; }+:where(.rt-sizer) .to { grid-column: 3; }+:where(.rt-sizer) .meta { grid-column: 4; }.rt-req[aria-pressed="true"] { background: var(--card-2); border-color: var(--line); color: var(--fg); }-.rt-req .at { font-variant-numeric: tabular-nums; color: var(--muted); }-.rt-req .asked { display: flex; align-items: center; gap: 6px; min-width: 0; }-.rt-req .asked i.ag { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--agent); }-.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; }+:is(.rt-req, .rt-probe) .at { font-variant-numeric: tabular-nums; color: var(--muted); }+:is(.rt-req, .rt-probe) .asked { display: flex; align-items: center; gap: 6px; min-width: 0; }+:is(.rt-req, .rt-probe) .asked i.ag { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--agent); }+:is(.rt-req, .rt-probe) .asked .ic, :is(.rt-req, .rt-probe) .asked .ic img, :is(.rt-req, .rt-probe) .asked .ic svg { width: 14px; height: 14px; flex: none; }+:is(.rt-req, .rt-probe) .m, :is(.rt-req, .rt-probe) .to span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }/* the waiting dot's 6px glow fits inside the clip: 6px on its left,1px more above and below, given back outside so nothing moves(#2553, dumplings) */-.rt-req .to { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--fg); padding: 1px 0 1px 6px; margin: -1px 0 -1px -6px; }-.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; }+:is(.rt-req, .rt-probe) .to { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--fg); padding: 1px 0 1px 6px; margin: -1px 0 -1px -6px; }+:is(.rt-req, .rt-probe) .to .said { flex-shrink: 100000; min-width: min(9em, 60%); }+:is(.rt-req, .rt-probe) .to .said.split { display: flex; }+:is(.rt-req, .rt-probe) .to .said .who { flex: 0 1000 auto; min-width: 2.5em; }+:is(.rt-req, .rt-probe) .to .said .mdl { flex: none; max-width: calc(100% - 2.5em); white-space: pre; }/* on a phone the account keeps a few letters, not a sliver of one (40px,where phone-rows.test.cjs calls a text cut to a sliver) */@media (max-width: 600px) {- .rt-req .to .said .who { min-width: 40px; }- .rt-req .to .said .mdl { max-width: calc(100% - 40px); }+ :is(.rt-req, .rt-probe) .to .said .who { min-width: 40px; }+ :is(.rt-req, .rt-probe) .to .said .mdl { max-width: calc(100% - 40px); }}-.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); }-.rt-req.bad .to i { background: var(--red); }-.rt-req.wait .to i { background: var(--muted); animation: rtlive 1.8s infinite; }+:is(.rt-req, .rt-probe) .to i { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }+:is(.rt-req, .rt-probe).moved .to i { background: var(--accent); }+:is(.rt-req, .rt-probe).bad .to { color: var(--red); }+:is(.rt-req, .rt-probe).bad .to i { background: var(--red); }+:is(.rt-req, .rt-probe).wait .to i { background: var(--muted); animation: rtlive 1.8s infinite; }/* the reasoning keeps to its own box: what it was asked at is cut first,then what it was sent at, never drawn over the numbers beside it (#435) */-.rt-req .to .ef { flex: 0 1 auto; display: flex; min-width: 0; margin-left: -2px; color: var(--muted); }-.rt-req .ef::before { content: "· "; flex: none; white-space: pre; }-.rt-req .to .ef span { min-width: 0; white-space: pre; }-.rt-req .to .ef .was { flex-shrink: 100000; }-.rt-req .to .ef.picked { color: var(--fg-2); }-.rt-req .ef .was { opacity: .75; }+:is(.rt-req, .rt-probe) .to .ef { flex: 0 1 auto; display: flex; min-width: 0; margin-left: -2px; color: var(--muted); }+:is(.rt-req, .rt-probe) .ef::before { content: "· "; flex: none; white-space: pre; }+:is(.rt-req, .rt-probe) .to .ef span { min-width: 0; white-space: pre; }+:is(.rt-req, .rt-probe) .to .ef .was { flex-shrink: 100000; }+:is(.rt-req, .rt-probe) .to .ef.picked { color: var(--fg-2); }+:is(.rt-req, .rt-probe) .ef .was { opacity: .75; }/* what a call was for (a Codex guardian review, a title…): a quiet grey tag by the model */-.rt-req .asked .kind, .rp-req .kind, .rt-steps li .kind { flex: none; font-size: 10.5px; line-height: 16px; padding: 0 5px; border-radius: 5px; color: var(--muted); background: var(--card-2); border: 1px solid var(--line); white-space: nowrap; }+:is(.rt-req, .rt-probe) .asked .kind, .rp-req .kind, .rt-steps li .kind { flex: none; font-size: 10.5px; line-height: 16px; padding: 0 5px; border-radius: 5px; color: var(--muted); background: var(--card-2); border: 1px solid var(--line); white-space: nowrap; }.rt-steps li .kind { display: inline-block; vertical-align: 1px; }.rt-steps li .rt-named { white-space: nowrap; }.rt-steps li .rt-named > .ic { width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }/* in a narrow row the model keeps its room first: the tag gives way, to an ellipsis */-.rt-req .asked .kind { flex: 0 100 auto; min-width: 3.2em; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }-.rt-req .asked.kinded .m { flex: none; max-width: calc(100% - 3.2em - 40px); }-.rt-req .to .swap, .rt-steps li .swap { font-size: 10.5px; line-height: 16px; padding: 0 5px; border-radius: 5px; color: var(--amber); background: var(--amber-soft); white-space: nowrap; }-.rt-req .to .swap { flex: none; max-width: 70%; }-.rt-req .to .routed, .pr-to .routed { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; line-height: 16px; color: var(--muted); white-space: nowrap; }+:is(.rt-req, .rt-probe) .asked .kind { flex: 0 100 auto; min-width: 3.2em; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }+:is(.rt-req, .rt-probe) .asked.kinded .m { flex: none; max-width: calc(100% - 3.2em - 40px); }+:is(.rt-req, .rt-probe) .to .swap, .rt-steps li .swap { font-size: 10.5px; line-height: 16px; padding: 0 5px; border-radius: 5px; color: var(--amber); background: var(--amber-soft); white-space: nowrap; }+:is(.rt-req, .rt-probe) .to .swap { flex: none; max-width: 70%; }+:is(.rt-req, .rt-probe) .to .routed, .pr-to .routed { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; line-height: 16px; color: var(--muted); white-space: nowrap; }.rt-steps li.swap::before { background: var(--amber); }/* short of room, where it went gives way down to the provider's name, then this does(.upstreamed, set with the tag: Safari before 15.4 has no :has()) */-.rt-req .to.upstreamed .said { min-width: min(10em, 45%); }-.rt-req .to .upstream, .pr-to .upstream { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; line-height: 16px; color: var(--muted); white-space: nowrap; }-.rt-req .meta { display: flex; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; gap: 2px 0; color: var(--muted); font-variant-numeric: tabular-nums; }+:is(.rt-req, .rt-probe) .to.upstreamed .said { min-width: min(10em, 45%); }+:is(.rt-req, .rt-probe) .to .upstream, .pr-to .upstream { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; line-height: 16px; color: var(--muted); white-space: nowrap; }+:is(.rt-req, .rt-probe) .meta { display: flex; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; gap: 2px 0; color: var(--muted); font-variant-numeric: tabular-nums; }.rt-metric { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; min-width: 0; }.rt-metric .k { color: var(--muted); }.rt-metric .v { font-variant-numeric: tabular-nums; }-.rt-req .tokens, .rt-session .rt-token-total { cursor: help; }-.rt-req .meta .retry-count { white-space: nowrap; }-.rt-req .meta > * + .rt-metric::before { content: "·"; margin: 0 2px; }-.rt-req .meta .cost-metric { margin-left: 10px; color: var(--fg-2); }-.rt-req .meta .cost-metric::before { display: none; }-.rt-req .meta[hidden] { display: none; }+:is(.rt-req, .rt-probe) .tokens, .rt-session .rt-token-total { cursor: help; }+:is(.rt-req, .rt-probe) .meta .retry-count { white-space: nowrap; }+:is(.rt-req, .rt-probe) .meta > * + .rt-metric::before { content: "·"; margin: 0 2px; }+:is(.rt-req, .rt-probe) .meta .cost-metric { margin-left: 10px; color: var(--fg-2); }+:is(.rt-req, .rt-probe) .meta .cost-metric::before { display: none; }+:is(.rt-req, .rt-probe) .meta[hidden] { display: none; }.rt-session { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; padding: 9px 8px; margin-top: 4px; font: inherit; font-size: 12px; text-align: left; color: var(--fg-2); background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; }button.rt-session { cursor: pointer; }.rt-session .arrow { flex: none; width: 10px; color: var(--muted); }@@ -350,14 +368,14 @@ button.rt-session { cursor: pointer; }/* Where a request's numbers don't fit their column on one line (set bymetaFit), they go on a line of their own under where it went, which keepsits room (#2288, xishuchkui-code). */-:where(.rt-col.meta-under:not(.max760)) .rt-reqs { grid-template-columns: auto fit-content(45%) minmax(0, 1fr); }+:where(.rt-col.meta-under:not(.max760)) .rt-reqs { --rt-tpl: auto fit-content(45%) minmax(0, 1fr); }:where(.rt-col.meta-under:not(.max760)) .rt-req { row-gap: 2px; }-:where(.rt-col.meta-under:not(.max760)) .rt-req .meta { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }-:where(.rt-col.max760) .rt-reqs { grid-template-columns: auto minmax(0, 1fr); }+:where(.rt-col.meta-under:not(.max760)) :is(.rt-req, .rt-probe) .meta { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }+:where(.rt-col.max760) .rt-reqs { --rt-tpl: auto minmax(0, 1fr); }:where(.rt-col.max760) .rt-req { row-gap: 2px; }-:where(.rt-col.max760) .rt-req .asked { grid-column: 2; grid-row: 1; }-:where(.rt-col.max760) .rt-req .to { grid-column: 2; grid-row: 2; }-:where(.rt-col.max760) .rt-req .meta { grid-column: 2; grid-row: 3; justify-content: flex-start; }+:where(.rt-col.max760) :is(.rt-req, .rt-probe) .asked { grid-column: 2; grid-row: 1; }+: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; }.rt-cols.solo { grid-template-columns: minmax(0, 1fr); }.rt-reqs.none { display: block; background: none; border-color: transparent; }@@ -566,9 +584,9 @@ button.rt-session { cursor: pointer; }body.web .rt-stats { flex-wrap: wrap; gap: 10px 16px; }/* the upstream a request went to takes a line of its own on a phone,so the reasoning beside the provider isn't cut to two letters */- body.web .rt-req .to.upstreamed { flex-wrap: wrap; row-gap: 0; }- body.web .rt-req .to.upstreamed .said { flex: 1 1 0; min-width: 0; }- body.web .rt-req .to .upstream { flex-basis: 100%; padding-left: 12px; }+ body.web :is(.rt-req, .rt-probe) .to.upstreamed { flex-wrap: wrap; row-gap: 0; }+ body.web :is(.rt-req, .rt-probe) .to.upstreamed .said { flex: 1 1 0; min-width: 0; }+ body.web :is(.rt-req, .rt-probe) .to .upstream { flex-basis: 100%; padding-left: 12px; }body.web #view-routing > .row-head .note { flex: 1 1 100%; order: 1; margin: 0; }}.rt-gsec .segs .opt { white-space: nowrap; }@@ -883,13 +901,12 @@ button.rt-session { cursor: pointer; }.pr-req .meta { flex: none; max-width: 100%; margin-left: auto; overflow: hidden; text-overflow: ellipsis; 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(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; }- .rt-req .asked { grid-column: 2; grid-row: 1; }- .rt-req .to { grid-column: 2; grid-row: 2; }- .rt-req .meta { grid-column: 2; grid-row: 3; justify-content: flex-start; }+ .rt-reqs { --rt-tpl: auto minmax(0, 1fr); }+ .rt-req { row-gap: 2px; }+ :is(.rt-req, .rt-probe) .asked { grid-column: 2; grid-row: 1; }+ :is(.rt-req, .rt-probe) .to { grid-column: 2; grid-row: 2; }+ :is(.rt-req, .rt-probe) .meta { grid-column: 2; grid-row: 3; justify-content: flex-start; }}}/* templates: groups for common needs made of the user's own models, eachdiff --git a/internal/gui/tests/routing-day-window.test.cjs b/internal/gui/tests/routing-day-window.test.cjsindex 8f14d1e04..30ce9a361 100644--- a/internal/gui/tests/routing-day-window.test.cjs+++ b/internal/gui/tests/routing-day-window.test.cjs@@ -85,7 +85,8 @@ const look = (page) => page.evaluate(() => {const seen = [...list.children].find((e) => (e.matches(".rt-req:not(.probe)") || e.matches(".rt-session")) && e.getBoundingClientRect().bottom > box.top + 1);return {rows: rows.length,- cols: getComputedStyle(list).gridTemplateColumns,+ // the rows' columns, which every drawn row has the same of+ cols: [...new Set(rows.map((r) => getComputedStyle(r).gridTemplateColumns))].join(" | "),models: rows.map((r) => r.querySelector(".m")?.textContent),first: seen && { text: seen.textContent, at: Math.round(seen.getBoundingClientRect().top - box.top) },top: list.scrollTop, height: list.scrollHeight, view: list.clientHeight,@@ -148,7 +149,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",if (at.models.includes(WIDE_MODEL)) break;await scrollTo(page, at.top + at.view);}- assert(at.models.includes(WIDE_MODEL), "the wide model's row was never drawn");+ assert(at.models.includes(WIDE_MODEL), `the wide model's row was never drawn (at ${at.top} of ${at.height}, last ${at.models.slice(-2)})`);assert.equal(at.cols, topCols, "the columns changed width as the list scrolled");if (width > 760) {const cut = await page.evaluate((model) => {diff --git a/internal/gui/tests/routing-live-calm.test.cjs b/internal/gui/tests/routing-live-calm.test.cjsindex e85d4eb2d..df22cb4db 100644--- a/internal/gui/tests/routing-live-calm.test.cjs+++ b/internal/gui/tests/routing-live-calm.test.cjs@@ -105,7 +105,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.equal(await row.evaluate((b) => b === window.__row), true, "the request's row was made again");assert.notEqual(await row.textContent(), said, "the row must say what the trace says now");assert.deepEqual(busy.anims.filter((a) => a === "rtlive"), [], "the row's pulse started over");- assert.deepEqual(busy.nodes.filter((n) => !/^rt-sky |\bpkt\b|rt-flier|#text/.test(n)), [], "nodes were put in afresh while the same request came (the packet in flight aside)");+ // (the sizer's probes aside too: unseen, a request's numbers taking+ // another shape is a probe of that shape, measured and never drawn)+ assert.deepEqual(busy.nodes.filter((n) => !/^rt-sky |^rt-sizer |\bpkt\b|rt-flier|#text/.test(n)), [], "nodes were put in afresh while the same request came (the packet in flight aside)");assert.deepEqual(errors, []);});}diff --git a/internal/gui/tests/routing-own-columns.test.cjs b/internal/gui/tests/routing-own-columns.test.cjsnew file mode 100644index 000000000..f829f1324--- /dev/null+++ b/internal/gui/tests/routing-own-columns.test.cjs@@ -0,0 +1,110 @@+// Run with Node's test runner and Playwright on the module path; see README.md.+// The requests' rows have columns of their own, not a subgrid of the list+// (#3731, gpboyer2: on macOS 13, Safari 16's WebKit recursed sizing the+// list's fit-content() columns through the rows' subgrid until its+// WebContent process was killed, and the page reloaded up to 93 times a+// minute under traffic). No rule of the list's rows says subgrid, and the+// rows still line up as they did: each column starts at one x down the+// list, as wide as its widest row's, in every layout the list takes.+// MAGPIE_ROUTING_ASSETS points the page at an older asset tree, to watch+// this go red there.+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 assetsDir = path.resolve(process.env.MAGPIE_ROUTING_ASSETS || path.join(__dirname, "../assets"));+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 W = {+ aihub: { id: "aihubmix", provider: "aihubmix", name: "AiHubMix", kind: "provider", model: "glm-5.3-flash", icon: "aihubmix-color", routing: "smart" },+ c1: { id: "codex:a", provider: "codex", name: "Codex", who: "[email protected]", plan: "plus", kind: "account", model: "gpt-5.6-terra", known: true, used: 9, renews: [renew], icon: "codex-color", routing: "smart" },+ c2: { id: "codex:b", provider: "codex", name: "Codex", who: "[email protected]", plan: "pro", kind: "account", model: "gpt-5.6-terra", known: true, used: 4, renews: [renew], icon: "codex-color", routing: "smart" },+ cop: { id: "copilot:a", provider: "copilot", name: "Copilot", who: "ann", kind: "account", model: "gpt-6-sol", known: true, used: 1, renews: [renew], icon: "githubcopilot", routing: "smart" },+ ds: { id: "deepseek", provider: "deepseek", name: "DeepSeek", kind: "provider", model: "deepseek-flash", icon: "deepseek-color", routing: "smart" },+ or: { id: "openrouter", provider: "openrouter", name: "OpenRouter", kind: "provider", model: "openai/gpt-6-sol", icon: "openrouter", routing: "smart" },+ wb: { id: "wb:a", provider: "workbuddy", name: "WorkBuddy", who: "ann", kind: "account", model: "glm", known: false, icon: "generic", routing: "smart" },+};+const mk = (i, w, model, extra = {}) => ({+ id: 200 - i, seq: 200 - i, time: at(i), agent: i % 2 ? "codex" : "curl", model, provider: w.provider,+ order: Object.values(W).filter((x) => x.provider === w.provider), done: true, status: 200, ms: 5000 + i * 900, tokens: 90000 + i * 700,+ tries: [{ id: w.id, model: w.model || model.split("/").pop(), start: at(i), done: true, status: 200, ms: 5000 }], ...extra,+});+const routes = [+ mk(0, W.ds, "deepseek/deepseek-flash"), mk(1, W.ds, "deepseek/deepseek-flash"),+ ...[2, 3, 4, 5].map((i) => ({ ...mk(i, W.c1, "codex/gpt-5.6-terra"), tries: [{ id: W.c1.id, model: "gpt-5.6-terra", start: at(i), done: true, status: 200, ms: 8000, effort: "medium" }] })),+ { ...mk(6, W.c1, "codex/gpt-6-luna"), tries: [{ id: W.c1.id, model: "gpt-6-luna", start: at(6), done: true, status: 200, ms: 8000 }] },+ { ...mk(7, W.c1, "codex/gpt-5.6-luna"), tries: [{ id: W.c1.id, model: "gpt-5.6-luna", start: at(7), done: true, status: 200, ms: 8000 }] },+ mk(8, W.cop, "copilot/gpt-6-sol-with-a-much-longer-model-name"), mk(9, W.aihub, "aihubmix/glm-5.3-flash"), mk(10, W.or, "openrouter/openai/gpt-6-sol"), mk(11, W.wb, "workbuddy/glm"),+];+function serve(lang) {+ const state = { agents: [{ id: "codex", name: "Codex", path: "/t", fields: [] }], profiles: [], settings: { lang, theme: "light" } };+ const assets = assetsDir;+ 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: 200, 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 });+ };+}+++test("no rule of the request rows says subgrid", async () => {+ const css = await fs.readFile(path.join(assetsDir, "plugins/routing/routing.css"), "utf8");+ const bad = [];+ for (const m of css.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]+)\{([^{}]*)\}/g)) {+ if (/\.rt-req\b/.test(m[1]) && /subgrid/.test(m[2])) bad.push(m[1].trim());+ }+ assert.deepEqual(bad, []);+});++// each drawn row's cells: where each starts+const rowsOf = (page) => page.evaluate(() => [...document.querySelectorAll(".rt-reqs > .rt-req")].map((r) => ({+ model: r.querySelector(".m").textContent,+ x: [".at", ".asked", ".to", ".meta"].map((s) => { const b = r.querySelector(s)?.getBoundingClientRect(); return b && b.width ? Math.round(b.left * 2) / 2 : null; }),+ under: document.querySelector(".rt-col").className,+})));++for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {+ for (const lang of ["en", "zh"]) {+ test(`${engine} ${lang}: the requests' columns line up without a subgrid`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ const page = await browser.newPage({ viewport: { width: 1440, height: 1400 } });+ page.setDefaultTimeout(5000);+ 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-reqs > .rt-req").first().waitFor();+ for (const width of [1440, 1100, 940, 700]) {+ await page.setViewportSize({ width, height: 1400 });+ // the columns are measured a frame or two after the width changes:+ // waited for until they line up, or two seconds+ const starts = (rows) => [0, 1, 2, 3].map((c) => [...new Set(rows.map((r) => r.x[c]).filter((x) => x !== null))]);+ let rows = await rowsOf(page);+ for (const until = Date.now() + 2000; Date.now() < until && starts(rows).some((xs) => xs.length > 1);) {+ await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => r())));+ rows = await rowsOf(page);+ }+ assert.equal(rows.length, routes.length, `${width}px: every request has its row`);+ starts(rows).forEach((xs, c) => assert(xs.length <= 1, `${width}px (${rows[0].under}): column ${c + 1} starts at ${xs.join(", ")}`));+ }+ assert.deepEqual(errors, []);+ });+ }+}diff --git a/internal/gui/tests/routing-scroll-end.test.cjs b/internal/gui/tests/routing-scroll-end.test.cjsindex 7c18b627f..595021d54 100644--- a/internal/gui/tests/routing-scroll-end.test.cjs+++ b/internal/gui/tests/routing-scroll-end.test.cjs@@ -72,7 +72,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",// a narrow list, the accounts beside the requests on a wide pageconst narrow = width <= 600;assert.equal(await tracks(page, ".rt-stage"), narrow ? 2 : 3, "the stage's columns");- assert.equal(await tracks(page, ".rt-reqs"), width < 800 ? 2 : 4, "the requests' columns");+ assert.equal(await tracks(page, ".rt-reqs > .rt-req"), width < 800 ? 2 : 4, "the requests' columns");// by the room the page has, the sidebar's aside (routing/client.js byWidth)const room = await page.locator(".rt-more").first().evaluate((e) => e.getBoundingClientRect().width);assert.equal(await tracks(page, ".rt-cols"), room >= 1150 ? 2 : 1, "the requests and the accounts, side by side or one under the other");