Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
routing: a skipped member's story line leads with its own logo (#3953)
yetone0a7633136df6
diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.jsindex 58ef04ff1..f77d151ee 100644--- a/internal/gui/assets/plugins/routing/client.js+++ b/internal/gui/assets/plugins/routing/client.js@@ -796,6 +796,21 @@ function routingPage(part) {return null;}+ // leftWhy is why a member was skipped before it was tried (r.left)+ const leftWhy = (x) => x.held+ ? t("{who} is left out: the gateway key asking may not use its account.", { who: who(x) })+ : x.window+ ? t("{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.", { who: who(x), n: ctxShort(x.window) })+ : x.noCredits+ ? t("{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.", { who: who(x) })+ : x.capped+ ? t("{who} is left out: a usage window is at {n}, past the {cap}% cap set on the account, so it counts as used up until that window renews.", { who: who(x), n: pct(x.used), cap: x.capped })+ : x.barred+ ? t("{who} is left out: it is set to serve other models, not {model}.", { who: who(x), model: x.model })+ : x.kind === "key"+ ? t("{who} is left out: {name} lists {model} to its other keys, not this one.", { who: who(x), name: x.name, model: x.model })+ : t("{who} is left out: its plan doesn't list {model}.", { who: who(x), model: x.model });+// asides: the others' places, where they say somethingfunction asides(r) {const out = [];@@ -848,19 +863,7 @@ function routingPage(part) {}const pooled = r.order.find((x) => !x.aside && x.kind === "key");for (const x of r.order.filter((x) => x.aside)) out.push(t("{who} is made for {api}, not {other} as the keys routed over are, so it isn't one of them: it's tried after them.", { who: who(x), api: API[x.speaks] || x.speaks || t("any API"), other: API[pooled?.speaks] || pooled?.speaks || t("any API") }));- for (const x of r.left || []) out.push(x.held- ? t("{who} is left out: the gateway key asking may not use its account.", { who: who(x) })- : x.window- ? t("{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.", { who: who(x), n: ctxShort(x.window) })- : x.noCredits- ? t("{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.", { who: who(x) })- : x.capped- ? t("{who} is left out: a usage window is at {n}, past the {cap}% cap set on the account, so it counts as used up until that window renews.", { who: who(x), n: pct(x.used), cap: x.capped })- : x.barred- ? t("{who} is left out: it is set to serve other models, not {model}.", { who: who(x), model: x.model })- : x.kind === "key"- ? t("{who} is left out: {name} lists {model} to its other keys, not this one.", { who: who(x), name: x.name, model: x.model })- : t("{who} is left out: its plan doesn't list {model}.", { who: who(x), model: x.model }));+ for (const x of r.left || []) out.push(leftWhy(x));return out;}@@ -2702,10 +2705,15 @@ function routingPage(part) {// provider a line of the story names, so who it is about reads at a// glance (the owner: 这里在前面显示对应的 provider 图标会不会更直观一点)const logoOf = (w) => w.icon || w.preset || "generic";- function logoed(s, r) {+ // A line names an order member, one skipped before it was tried (r.left,+ // #3953: a skipped OpenCode Zen Free's line had no logo, or another+ // member's), or both. Where two share the name at the same place (a key+ // called "API key" on two providers), the member the line is about wins,+ // then an order member over a skipped one.+ function logoed(s, r, about) {const word = /[A-Za-z0-9_]/;let hit = null;- for (const w of r.order) {+ for (const w of new Set([about, ...r.order, ...(r.left || [])].filter(Boolean))) {for (const n of new Set([who(w), w.name].filter(Boolean))) {for (let i = s.indexOf(n); i >= 0; i = s.indexOf(n, i + 1)) {if (word.test(s[i - 1] || "") || word.test(s[i + n.length] || "")) continue;@@ -2736,9 +2744,11 @@ function routingPage(part) {: "This subagent task is encrypted. Only ChatGPT accounts can read it."), "aside"]);items.push([affWhy(r, true) || ruleWhy(r, true) || firstWhy(r), "why"]);for (const s of nestedWhy(r)) items.push([s, "why"]);- for (const a of asides(r)) items.push([a, "aside"]);+ // the member a line is about, where it is one: a skipped one's line, a try's+ const skipped = new Map((r.left || []).map((x) => [leftWhy(x), x]));+ for (const a of asides(r)) items.push([a, "aside", undefined, skipped.get(a)]);r.tries.forEach((tr, i) => {- items.push([tryWhy(r, i), tr.done ? (tryOk(tr) ? "ok" : "bad") : "wait"]);+ items.push([tryWhy(r, i), tr.done ? (tryOk(tr) ? "ok" : "bad") : "wait", undefined, tried(r, tr)]);// where its time went, once it is done: the first try's has the// request's masking before itconst timed = i === 0 && r.masking > 0 ? { ...tr, masking: r.masking } : tr;@@ -2768,7 +2778,9 @@ function routingPage(part) {if (tr.done && tryOk(tr) && tr.upstream) items.push([upstreamWhy(tr), "aside upstream-said", tr]);});if (r.done && !r.tries.length) items.push([t("Nothing was tried: {error}", { error: r.error || r.status }), "bad"]);- const key = JSON.stringify([tagKind(r), items.map(([s, c, tr]) => [s, c, tr?.model, tr?.served]), r.order.map(logoOf)]);+ const aboutKey = (w) => w ? seat(w) : "";+ const logos = [...r.order, ...(r.left || [])].map(logoOf);+ const key = JSON.stringify([tagKind(r), items.map(([s, c, tr, w]) => [s, c, tr?.model, tr?.served, aboutKey(w)]), logos]);// a different request starts its steps at the top, even when they say// what the last one's said (the box is routing.css's, #3764); the same// request keeps its scroll while its steps grow@@ -2780,21 +2792,20 @@ function routingPage(part) {// again and, in WebKit, blinks out for a frame, and the story is drawn// again on every request that comes in and at each of its steps, so// with an agent at work every logo in it blinked on and off- const logos = r.order.map(logoOf);const was = new Map([...steps.children].map((li) => [li.dataset.k, li]));- const lis = items.map(([s, c, tr]) => {- const k = JSON.stringify([tagKind(r), s, c, tr?.model, tr?.served, logos]);+ const lis = items.map(([s, c, tr, w]) => {+ const k = JSON.stringify([tagKind(r), s, c, tr?.model, tr?.served, aboutKey(w), logos]);const old = was.get(k);if (old) { was.delete(k); return { li: old }; }- return { k, s, c, tr };+ return { k, s, c, tr, w };});keepIcons(...was.values());replaceKeeping(steps, lis.map((x) => {if (x.li) return x.li;- const { k, s, c, tr } = x;+ const { k, s, c, tr, w } = x;const li = el("li", c);li.dataset.k = k;- li.append(...(/^(why|ok|bad|wait|aside)$/.test(c) ? logoed(s, r) : [s]));+ li.append(...(/^(why|ok|bad|wait|aside)$/.test(c) ? logoed(s, r, w) : [s]));if (c === "aside kind") li.prepend(kindTag(r), " ");if (c === "swap") li.prepend(swapTag(tr), " ");if (c === "aside time") li.replaceChildren(timeElement(tr));diff --git a/internal/gui/tests/routing-log-icons.test.cjs b/internal/gui/tests/routing-log-icons.test.cjsindex f3c3fb1e4..9652de2f3 100644--- a/internal/gui/tests/routing-log-icons.test.cjs+++ b/internal/gui/tests/routing-log-icons.test.cjs@@ -14,11 +14,17 @@ const day = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map((n) => Stconst at = (i) => new Date(now.getTime() - (i + 1) * 60e3).toISOString();const glm = { id: "zhipu/a1", provider: "zhipu", name: "Zhipu", icon: "zhipu-color", who: "18610345303", kind: "account", agent: "claude", model: "glm-5.3-flash", routing: "order", shared: true, used: 20 };const gpt = { id: "openai/k1", provider: "openai", name: "OpenAI", icon: "openai", who: "work", kind: "key", model: "glm-5.3-flash", routing: "order", fallback: true, used: 0 };+// two named alike (#3953, MYCF711): a key in the order and a member the+// gateway skipped before trying it (r.left), each "API key"+const ds = { id: "deepseek/k1", provider: "deepseek", name: "DeepSeek", icon: "deepseek-color", who: "API key", kind: "key", model: "glm-5.3-flash", routing: "order", fallback: true, used: 0 };+const zen = { id: "opencode-zen-free", provider: "opencode-zen-free", name: "OpenCode Zen Free", icon: "opencode", who: "API key", kind: "account", agent: "claude", model: "deepseek-v4.1-flash-free", routing: "", used: 0, window: 200000 };const routes = [{id: 100, seq: 100, time: at(0), agent: "claude", model: "glm-5.3-flash", provider: "zhipu",- order: [glm, gpt],+ order: [glm, ds, gpt],+ left: [zen],tries: [{ id: glm.id, model: glm.model, start: at(0), done: true, status: 429, ms: 400, error: "rate limited" },+ { id: ds.id, model: ds.model, start: at(0), done: true, status: 500, ms: 300, error: "upstream error" },{ id: gpt.id, model: gpt.model, start: at(0), done: true, status: 200, ms: 22000 },],done: true, status: 200, ms: 22400, tokens: 1200,@@ -89,6 +95,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.deepEqual(l.size, [14, 14], JSON.stringify(l));assert(l.before && l.inline, JSON.stringify(l));}+ // a line about one of the two named "API key" leads with that one's+ // logo: the skipped one's line with Zen's, the order key's try with+ // DeepSeek's, whichever list is looked in first+ const skipped = lines.find((l) => l.cls === "aside" && l.text.includes("200K"));+ assert.equal(skipped?.logo, "opencode", JSON.stringify(lines));+ assert.equal(skipped.name, "API key", JSON.stringify(skipped));+ assert(skipped.before && skipped.inline, JSON.stringify(skipped));+ const dsTry = of("bad")[1];+ assert.equal(dsTry?.logo, "deepseek-color", JSON.stringify(lines));+ assert.equal(dsTry.name, "API key", JSON.stringify(dsTry));// what the vendor said is word for word, with no logo in itassert(!lines.some((l) => /said/.test(l.cls) && l.logo), JSON.stringify(lines));assert.deepEqual(errors, []);