Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: models of one provider named alike say what tells them apart (sunset on Discord)
yetonea77ecbf8a1db
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.cssindex a16bc081e..21ed6897d 100644--- a/internal/gui/assets/app.css+++ b/internal/gui/assets/app.css@@ -2062,6 +2062,7 @@ body.window .foot { padding-left: 18px; }.pop li .option-words { display: flex; align-items: center; min-width: 0; flex: 1 1 auto; gap: 9px; }.pop li .v { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }.pop li .badge.free, .pop li .badge.ctx, .pop li .badge.rate, .pop li .badge.path { flex: none; margin-left: -4px; padding: 0 4px; font-size: 9px; line-height: 14px; align-self: center; }+.pop li .mtell { flex: none; margin-left: -4px; font-size: 11px; color: var(--muted); }.pop li .n { flex: 1 1 0; min-width: 0; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }.pop li .favorite { display: none; align-items: center; justify-content: center; color: var(--faint); width: 24px; height: 24px; border-radius: 6px; flex: none; }.pop li:hover .favorite, .pop li .favorite.on { display: inline-flex; }@@ -3063,6 +3064,9 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }.mchip:hover { color: var(--fg); border-color: var(--muted); }.mchip.on { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 500; }.mchip.on::before { content: "✓"; font-size: 10px; }+/* what tells a model from others of the same name (modelTells): quiet,+ after the name, never in the accent of a pick */+.mchip .mtell { color: var(--muted); font-weight: 400; font-size: 10.5px; }.mchip.own.on::before { content: "+"; }/* served with none picked: the vendor's list stands in for the picks. Drawnapart from a pick (no tick, no accent): a click picks it alone (#681) */diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 7f6207977..f5df7b4da 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -4542,6 +4542,11 @@ function openPicker(agent, field, anchor, ev, only) {options = [...options.filter((o) => o.reset), ...options.filter((o) => !o.reset && o.group === ROUTING_GROUPS), ...rest.filter((o) => !o.direct), ...rest.filter((o) => o.direct)];const effortPicker = !only && (field.key === "effort" || field.label === "effort" || field.label === "thinking" || field.label === SUB_EFFORT || roleLevel(field.label));options = oneRowPerModel(options, cur);+ // models of one provider that would read alike say what tells them apart+ if (!effortPicker) {+ const tells = modelTells(options.filter((o) => !o.reset && !o.run && !o.custom), (o) => o.label || "", (o) => o.value, (o) => o.group || "");+ if (tells.size) options = options.map((o) => tells.has(o.value) && !o.reset && !o.run && !o.custom ? { ...o, tell: tells.get(o.value) } : o);+ }// Current model first, then the rest in catalog order. Effort levels keep// their natural low → high order because their position is meaningful.// The row keeps its group as `home`: a provider picked in the rail still@@ -4983,6 +4988,52 @@ function rateTag(rate = 0, was = 0) {return tag;}+// modelTells: what tells apart the models of one list that would show the+// same label (sunset on Discord: the Our Free Model plugin's several+// "DeepSeek-V4.1-Flash · x0.1", told apart only by the buddy/… of their+// ids, in the tooltip). items are the list's entries, label(x) what each+// shows, id(x) its id, and key(x) the part of the list it is shown in (a+// picker's provider): labels are compared within a key. Returns a Map of+// id → tell for the entries whose label another of the same key shares; an+// entry whose label is its own gets none, and is drawn as it was.+//+// A tell is the part of its id the others' don't share: the path segments+// every id of the label begins with and ends with are dropped, so buddy/x+// and cline/x say "buddy" and "cline", p/buddy/x and p/cline/x the same,+// and buddy/x-fast and buddy/x-slow "x-fast" and "x-slow". An id left with+// nothing (x beside buddy/x) says itself whole; and where tells would+// still read alike, each says its whole id.+function modelTells(items, label = (x) => x.name || x.id, id = (x) => x.id, key = () => "") {+ const by = new Map();+ for (const x of items || []) {+ const v = id(x), l = label(x);+ if (!v || !l) continue;+ const k = key(x) + "\0" + l;+ if (!by.has(k)) by.set(k, new Set());+ by.get(k).add(v);+ }+ const out = new Map();+ for (const set of by.values()) {+ if (set.size < 2) continue;+ const ids = [...set], segs = ids.map((v) => v.split("/"));+ const first = segs[0];+ let pre = 0;+ while (segs.every((s) => s.length > pre && s[pre] === first[pre])) pre++;+ let suf = 0;+ while (segs.every((s) => s.length - suf > pre && s[s.length - 1 - suf] === first[first.length - 1 - suf])) suf++;+ let tells = segs.map((s, i) => s.slice(pre, s.length - suf).join("/") || ids[i]);+ if (new Set(tells).size < tells.length) tells = ids;+ ids.forEach((v, i) => out.set(v, tells[i]));+ }+ return out;+}++// tellTag: a model's tell (modelTells), quiet and after its name on a chip+// or a picker's row+function tellTag(tell) {+ return tell ? el("span", "mtell", tell) : null;+}+// contextTag: the small grey 1M by a model that holds a million tokens or// more (Cursor's names said it, and no longer do); the usual 128K–400K// aren't marked, as nearly every model has one of those; nor is a name@@ -5037,6 +5088,8 @@ function renderList() {// a choice of magpie's own (Codex's sign-in) reads in the page's languageconst own = pick.field.label === "sign-in";words.append(el("span", "v", own ? t(o.label || o.value) : o.label || o.value));+ const tell = tellTag(o.tell);+ if (tell) words.append(tell);if (o.free || (pick.modelPicker && o.value && namedFree(o.value, o.label))) words.append(freeBadge(o.free));const rate = rateTag(o.rate, o.rateWas);if (rate) words.append(rate);@@ -10385,12 +10438,15 @@ function addFormModels(ex) {const f = q.value.trim().toLowerCase();let shown = 0, hidden = 0;const match = listed.filter((m) => !f || m.id.toLowerCase().includes(f) || (m.name || "").toLowerCase().includes(f));+ const tells = modelTells(listed);for (const m of match) {const on = draft.extra.includes(m.id);// past the first 120 only the picked are drawn, till the rest are asked forif (shown >= 120 && !f && !showAll && !on) { hidden++; continue; }const c = el("button", "mchip" + (on ? " on" : ""));c.append(el("span", "", m.name || m.id));+ const tell = tellTag(tells.get(m.id));+ if (tell) c.append(tell);if (m.name) c.title = m.id;c.dataset.model = m.id;c.onclick = (e) => { e.preventDefault(); draft.extra = on ? draft.extra.filter((x) => x !== m.id) : [...draft.extra, m.id]; sync(); draw(); };@@ -10812,6 +10868,8 @@ function renderModels(p) {// while the card and the auto groups had all 17); after Select none,// none is servedconst served = draft.chosen.length || decideOnly(p) || draft.none ? new Set() : new Set(p.models.filter((m) => !noAPI(m)).slice(0, 24).map((m) => m.id));+ // models that would read alike say what tells them apart (modelTells)+ const tells = modelTells(p.models);// a filter is a search: what it doesn't match is left out, picked or notfor (const m of p.models) {const on = draft.chosen.includes(m.id);@@ -10822,6 +10880,8 @@ function renderModels(p) {if (shown >= 80 && !f && !showAll && !on) { hidden++; continue; }const c = el("button", "mchip" + (on ? " on" : served.has(m.id) ? " auto" : "") + (noAPI(m) ? " noapi" : ""));c.append(el("span", "", m.name && m.name !== m.id ? m.name : m.id));+ const tell = tellTag(tells.get(m.id));+ if (tell) c.append(tell);// one the plan serves at no cost to it (WorkBuddy's x0.00 credits)// or one its vendor names free (#185)const free = m.free || namedFree(m.id, m.name);@@ -11603,7 +11663,8 @@ function renderFallback(p) {const all = [];for (const o of providers.providers) {if (!o.ready || o.off) continue;- for (const m of o.models) if (m.on) all.push({ id: o.id + "/" + m.id, label: o.name + " · " + (m.name || m.id), icon: o.icon });+ const tells = modelTells(o.models.filter((m) => m.on));+ for (const m of o.models) if (m.on) all.push({ id: o.id + "/" + m.id, label: o.name + " · " + (m.name || m.id) + (tells.has(m.id) ? " · " + tells.get(m.id) : ""), icon: o.icon });}let open = false;const add = (id) => { if (id && !draft.fallback.includes(id)) draft.fallback.push(id); q.value = ""; draw(); };@@ -13888,11 +13949,14 @@ function accountModels(p, ref, isKey, name) {};const draw = () => {chips.replaceChildren();+ const tells = modelTells(ids.map((id) => p.models.find((x) => x.id === id) || { id }));for (const id of ids) {const m = p.models.find((x) => x.id === id);const on = acctModels.chosen.includes(id);const c = el("button", "mchip" + (on ? " on" : ""));c.append(el("span", "", m?.name && m.name !== id ? m.name : id));+ const tell = tellTag(tells.get(id));+ if (tell) c.append(tell);if (m?.name && m.name !== id) c.title = id;c.onclick = () => { acctModels.chosen = on ? acctModels.chosen.filter((x) => x !== id) : [...acctModels.chosen, id]; draw(); };chips.append(c);diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.jsindex 885891578..95d829ae5 100644--- a/internal/gui/assets/plugins/routing/client.js+++ b/internal/gui/assets/plugins/routing/client.js@@ -3724,7 +3724,17 @@ function routingPage(part) {const offOf = (id) => { for (const g of groups?.groups || []) { const i = g.memberInfo?.find((x) => x.id === id && x.providerOff); if (i) return i; } };const offWords = (i) => t("{name} is switched off: the group skips it until it is on again", { name: i.name });const memberIcon = (id) => { const s = subOf(id); return s ? stackIcon(groupIcons(s)) : icon(modelOf(id)?.icon || offOf(id)?.icon || "generic"); };- const memberName = (id) => { const s = subOf(id), m = modelOf(id), o = !m && offOf(id); return s ? s.name : m ? m.name || m.id : o ? o.model : id; };+ // models of one provider that would read alike (several "DeepSeek-V4.1-Flash"+ // of a plugin's sources) are said with what tells them apart (app.js's+ // modelTells), worked out once for each list the groups' state brings+ let tellsFor = null, tellsOf = null;+ const tellOf = (m) => {+ if (!m) return "";+ if (tellsFor !== groups?.models) { tellsFor = groups?.models; tellsOf = modelTells(tellsFor || [], (x) => x.name || x.id, (x) => x.id, (x) => x.provider || x.providerName || ""); }+ return tellsOf.get(m.id) || "";+ };+ const modelName = (m) => { const tell = tellOf(m); return (m.name || m.id) + (tell ? " · " + tell : ""); };+ const memberName = (id) => { const s = subOf(id), m = modelOf(id), o = !m && offOf(id); return s ? s.name : m ? modelName(m) : o ? o.model : id; };const memberNote = (id) => { const o = !subOf(id) && !modelOf(id) && offOf(id); return subOf(id) ? t("routing group") : [modelOf(id)?.providerName || o && `${o.name} · ${t("switched off")}`, fixedOf(id) && fixedWords(fixedOf(id))].filter(Boolean).join(" · "); };// a member the group sends in its vendor's fast mode (Group.Fast)const fastIn = (g, id) => !!g?.fast?.includes(id) && !subOf(id);@@ -3732,7 +3742,7 @@ function routingPage(part) {const i = g.memberInfo?.find((x) => x.id === id), m = modelOf(id), s = subOf(id), f = fixedOf(id);if (s) return `${t("routing group")} · ${s.name}`;const at = (f ? ` · ${fixedWords(f)}` : "") + (fastIn(g, id) ? ` · ${t("fast")}` : "");- if (m) return `${m.providerName} · ${m.name || m.id}${at}`;+ if (m) return `${m.providerName} · ${modelName(m)}${at}`;if (i?.providerOff) return `${i.name} · ${i.model}${at} (${t("switched off")})`;return i?.name ? `${i.name} · ${i.model}${at}` : id;}diff --git a/internal/gui/tests/model-same-name-tell.test.cjs b/internal/gui/tests/model-same-name-tell.test.cjsnew file mode 100644index 000000000..aea48dae9--- /dev/null+++ b/internal/gui/tests/model-same-name-tell.test.cjs@@ -0,0 +1,174 @@+// Run with Node's test runner and Playwright on the module path; see README.md.+// A plugin that serves one model from several sources (sunset on Discord:+// the Our Free Model plugin's buddy/deepseek-v4.1-flash, cline/… and+// kilo/…, each named "DeepSeek-V4.1-Flash" at 0.1×) drew chips that read+// alike, the source only in the tooltip. Models of one list that would+// show the same name now say, quietly after it, the part of the id that+// tells them apart (modelTells); a name no other model has is drawn as it+// was. Checked on the provider editor's chips and in a model picker, and+// modelTells itself for ids with no prefix, one prefix shared, and ids+// that differ deeper in. Chromium and WebKit, wide and narrow, in every+// language.+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 fetched = new Date(Date.now() - 3600e3).toISOString();+const models = [+ { id: "buddy/deepseek-v4.1-flash", name: "DeepSeek-V4.1-Flash", on: true, rate: 0.1 },+ { id: "cline/deepseek-v4.1-flash", name: "DeepSeek-V4.1-Flash", on: true, rate: 0.1 },+ { id: "kilo/deepseek-v4.1-flash", name: "DeepSeek-V4.1-Flash", on: true, rate: 0.1 },+ { id: "buddy/glm-5.2", name: "GLM-5.2", on: true, rate: 0.1 },+];+const provider = {+ id: "our-free-model", name: "Our Free Model", icon: "generic", host: "", chat: "", responses: "", anthropic: "", catalog: "",+ models, chosen: models.map((m) => m.id), fetched, agents: [], fallback: [], headers: {},+ key: { set: true, masked: "sk-…one" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "",+};++// the Routing page's view of the same models: a group of two of the alike+const routed = models.map((m) => ({ id: "our-free-model/" + m.id, name: m.name, provider: "our-free-model", providerName: "Our Free Model", icon: "generic" }));+const group = {+ id: "flash", name: "Flash", routing: "order", ready: true,+ members: routed.slice(0, 2).map((m) => m.id),+ memberInfo: routed.slice(0, 2).map((m) => ({ id: m.id, ready: true, name: "Our Free Model", provider: "our-free-model", model: m.id.split("/").slice(1).join("/"), icon: "generic" })),+};++function serve(lang) {+ const providers = { providers: [provider], presets: [], excluded: [], gateway: { running: true, window: true } };+ const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };+ return async (route) => {+ const req = route.request(), url = new URL(req.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/plugins") return json({ plugins: [] });+ if (url.pathname === "/api/providers") return json(providers);+ if (url.pathname === "/api/groups") return json({ models: routed, pools: [], deciders: [], found: false, groups: [group] });+ if (url.pathname === "/api/gateway/trace") {+ if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes+ return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });+ }+ if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });+ 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), contentType });+ };+}++const LANGS = ["en", "zh", "zh-TW", "ja", "de"];+const cases = [...LANGS.map((lang) => [lang, 1100]), ["en", 420], ["zh", 420]];++for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {+ for (const [lang, width] of cases) {+ test(`${engine} ${lang} ${width}px: models named alike say what tells them apart`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ const page = await (await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" })).newPage();+ t.after(async () => {+ if (process.env.ARTIFACT_DIR) {+ await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });+ await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-model-same-name-tell.png`) });+ }+ await browser.close();+ });+ 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=providers");++ const editor = page.locator("#modal:not([hidden]) .editor");+ await page.locator(".row.provider", { hasText: "Our Free Model" }).click();+ await editor.locator(".mchips .mchip").first().waitFor();++ // the three alike say their sources; the one of its own name says none+ const chips = editor.locator(".mchips .mchip");+ const drawn = await chips.evaluateAll((cs) => cs.map((c) => ({ name: c.querySelector("span").textContent, tell: c.querySelector(".mtell")?.textContent ?? null, title: c.title })));+ assert.deepEqual(drawn.map(({ name, tell }) => [name, tell]), [+ ["DeepSeek-V4.1-Flash", "buddy"],+ ["DeepSeek-V4.1-Flash", "cline"],+ ["DeepSeek-V4.1-Flash", "kilo"],+ ["GLM-5.2", null],+ ]);+ // the whole id is still the tooltip's+ assert.equal(drawn[0].title.split("\n")[0], "buddy/deepseek-v4.1-flash");++ // each tell inside its chip, and each chip inside the editor, narrow too+ const ed = await editor.boundingBox();+ for (let i = 0; i < 4; i++) {+ const c = await chips.nth(i).boundingBox();+ assert.ok(c.x >= ed.x - 0.5 && c.x + c.width <= ed.x + ed.width + 0.5, `chip ${i} ${JSON.stringify(c)} inside editor ${JSON.stringify(ed)}`);+ const tell = chips.nth(i).locator(".mtell");+ if (!await tell.count()) continue;+ const b = await tell.boundingBox();+ assert.ok(b.x >= c.x && b.x + b.width <= c.x + c.width + 0.5, `tell ${JSON.stringify(b)} inside chip ${JSON.stringify(c)}`);+ }++ // a model picker, its options as an agent's or Settings' come: the+ // alike rows of one provider say their sources, another provider's+ // row of the same name, alone in its group, says nothing+ await page.evaluate(() => {+ const b = document.createElement("button");+ b.id = "tellAnchor";+ b.textContent = "model";+ document.body.append(b);+ const opt = (provider, id, label) => ({ value: provider + "/" + id, label, note: provider, icon: "generic", group: provider, ref: provider + "/" + id });+ openPicker({ id: "", name: "", fields: [] }, { key: "tellTest", label: "model", value: "", onPick: () => {}, options: [+ opt("Our Free Model", "buddy/deepseek-v4.1-flash", "DeepSeek-V4.1-Flash"),+ opt("Our Free Model", "cline/deepseek-v4.1-flash", "DeepSeek-V4.1-Flash"),+ opt("Our Free Model", "buddy/glm-5.2", "GLM-5.2"),+ opt("DeepSeek", "deepseek-v4.1-flash", "DeepSeek-V4.1-Flash"),+ ] }, b, { stopPropagation() {} });+ });+ const rows = await page.locator("#list li:not(.group)").evaluateAll((ls) => ls.map((l) => [l.querySelector(".v")?.textContent, l.querySelector(".mtell")?.textContent ?? null]));+ assert.deepEqual(rows.filter(([v]) => v), [+ ["DeepSeek-V4.1-Flash", "buddy"],+ ["DeepSeek-V4.1-Flash", "cline"],+ ["GLM-5.2", null],+ ["DeepSeek-V4.1-Flash", null],+ ]);+ await page.keyboard.press("Escape");++ // the Routing page's card of a group of two alike says each one's source+ await page.evaluate(() => document.querySelector("#tellAnchor")?.remove());+ await page.goto("http://magpie.test/?view=routing");+ const mem = page.locator("#view-routing .mem", { hasText: "DeepSeek-V4.1-Flash" }).first();+ await mem.waitFor();+ const said = await mem.textContent();+ assert.ok(said.includes("DeepSeek-V4.1-Flash · buddy") && said.includes("DeepSeek-V4.1-Flash · cline"), said);+ await page.goto("http://magpie.test/?view=providers");+ await page.locator(".row.provider", { hasText: "Our Free Model" }).click();+ await editor.locator(".mchips .mchip").first().waitFor();++ // the helper on its own: no prefix, one prefix shared, a difference+ // deeper in, and labels that are already apart+ const tells = await page.evaluate(() => Object.fromEntries(modelTells([+ { id: "deepseek-v4.1-flash", name: "Flash" },+ { id: "buddy/deepseek-v4.1-flash", name: "Flash" },+ { id: "buddy/a/x", name: "X" },+ { id: "buddy/b/x", name: "X" },+ { id: "buddy/x-fast", name: "Y" },+ { id: "buddy/x-slow", name: "Y" },+ { id: "only/one", name: "Z" },+ { id: "no-name" },+ { id: "other/no-name", name: "no-name" },+ ])));+ assert.deepEqual(tells, {+ "deepseek-v4.1-flash": "deepseek-v4.1-flash",+ "buddy/deepseek-v4.1-flash": "buddy",+ "buddy/a/x": "a",+ "buddy/b/x": "b",+ "buddy/x-fast": "x-fast",+ "buddy/x-slow": "x-slow",+ "no-name": "no-name",+ "other/no-name": "other",+ });+ assert.deepEqual(errors, []);+ });+ }+}