diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index b21d3c0bc..d4928ab35 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -2368,6 +2368,9 @@ body .foot .status.lift { white-space: normal; overflow-wrap: anywhere; text-ove .pop li.cur .check { display: inline-flex; } .pop li.group { height: 22px; padding: 6px 8px 0; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); pointer-events: none; } .pop li.group:not(:first-child) { margin-top: 2px; } +/* the agent's own sign-in, after a group of its own models' name: quiet, in the sentence's own case */ +.pop li.group.own { gap: 4px; white-space: nowrap; } +.pop li.group .own-sign { min-width: 0; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0; font-weight: 500; } .pop li.reset { margin-bottom: 3px; } .pop li.reset .v { color: var(--fg); } .pop li.reset .ic { opacity: .75; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 2d97e5908..a9aae5bcb 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -5276,19 +5276,11 @@ function loadTag(n) { return g; } -// modelTells: what tells apart the models of one list that would show the -// same label (sunset on Discord). 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; one whose label is its own gets none. -// -// 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. +// modelTells: id → tell for the entries whose label (label(x)) another of +// the same key(x) shares (sunset on Discord). A tell is the id less the +// path segments every id of the label starts and ends with (buddy/x, +// cline/x → buddy, cline); an id left with nothing, or tells alike, say +// the 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 || []) { @@ -5400,6 +5392,17 @@ function loadOf(ref) { return modelLoads[k] ?? (at > k.indexOf("/") + 1 ? modelLoads[k.slice(0, at)] : null); } +// groupHead: a picker section's header; the agent's own models' says whose +// sign-in, not magpie's provider of that name (maxleebeta) +function groupHead(o) { + const li = el("li", "group", o.group === ROUTING_GROUPS ? t(o.group) : o.group); + const a = pick.agent?.name; + if (!o.direct || !a || o.group === a || o.group.startsWith(a + " ")) return { key: o.group, li }; + li.classList.add("own"); + li.append(el("span", "own-sign", " · " + t("{agent}'s own sign-in", { agent: a }))); + return { key: o.group + "\0own", li }; +} + function renderList() { const list = $("#list"); list.replaceChildren(); @@ -5408,8 +5411,9 @@ function renderList() { const q = $("#q").value.trim(); let group = null; pick.items.forEach((o, idx) => { - if (!q && o.group && o.group !== group) list.append(el("li", "group", o.group === ROUTING_GROUPS ? t(o.group) : o.group)); - if (!q) group = o.group ?? group; + const head = o.group && groupHead(o); + if (!q && head && head.key !== group) list.append(head.li); + if (!q) group = head ? head.key : o.group ?? group; if (o.fold) { list.append(foldRow(o, idx, hasIcons)); return; } const li = el("li", (idx === pick.cursor ? "sel" : "") + (o.value === pick.field.value || pick.field.picked?.(o.value) ? " cur" : "") + (o.custom ? " custom" : "") + (o.reset ? " reset" : "")); li.dataset.i = idx; diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 118d75665..cfc146839 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -2219,6 +2219,7 @@ const I18N = { "turned off in Alma": "在 Alma 里是关闭的", "it is the agent's own sign-in; add the subscription in magpie": "这是 agent 自己的登录,请在 magpie 里添加订阅", "it is the agent's own sign-in": "这是 agent 自己的登录", + "{agent}'s own sign-in": "{agent} 自己的登录", "it is a sign-in, not a key; add the subscription in magpie": "这是登录账号而不是密钥,请在 magpie 里添加订阅", "it has no Azure OpenAI endpoint": "没有 Azure OpenAI 接口地址", "it points at magpie itself": "它指向的就是 magpie 自己", @@ -6808,6 +6809,7 @@ const I18N = { "turned off in Alma": "在 Alma 裡是關閉的", "it is the agent's own sign-in; add the subscription in magpie": "這是 agent 自己的登入,請在 magpie 裡新增訂閱", "it is the agent's own sign-in": "這是 agent 自己的登入", + "{agent}'s own sign-in": "{agent} 自己的登入", "it is a sign-in, not a key; add the subscription in magpie": "這是登入帳號而不是金鑰,請在 magpie 裡新增訂閱", "it has no Azure OpenAI endpoint": "沒有 Azure OpenAI 端點", "it points at magpie itself": "它指向的就是 magpie 自己", @@ -11373,6 +11375,7 @@ const I18N = { "turned off in Alma": "Alma でオフになっています", "it is the agent's own sign-in; add the subscription in magpie": "エージェント自身のサインインです。magpie でサブスクリプションを追加してください", "it is the agent's own sign-in": "エージェント自身のサインインです", + "{agent}'s own sign-in": "{agent} 自身のサインイン", "it is a sign-in, not a key; add the subscription in magpie": "キーではなくサインインです。magpie でサブスクリプションを追加してください", "it has no Azure OpenAI endpoint": "Azure OpenAI のエンドポイントがありません", "it points at magpie itself": "magpie 自身を指しています", @@ -15969,6 +15972,7 @@ const I18N = { "turned off in Alma": "in Alma ausgeschaltet", "it is the agent's own sign-in; add the subscription in magpie": "es ist die eigene Anmeldung des Agenten; fügen Sie das Abo in magpie hinzu", "it is the agent's own sign-in": "es ist die eigene Anmeldung des Agenten", + "{agent}'s own sign-in": "eigene Anmeldung von {agent}", "it is a sign-in, not a key; add the subscription in magpie": "es ist eine Anmeldung, kein Schlüssel; fügen Sie das Abo in magpie hinzu", "it has no Azure OpenAI endpoint": "es hat keinen Azure-OpenAI-Endpunkt", "it points at magpie itself": "es zeigt auf magpie selbst", diff --git a/internal/gui/tests/agent-own-direct.test.cjs b/internal/gui/tests/agent-own-direct.test.cjs index d3e82d8e6..52333aaee 100644 --- a/internal/gui/tests/agent-own-direct.test.cjs +++ b/internal/gui/tests/agent-own-direct.test.cjs @@ -8,6 +8,10 @@ // pick is asked first, Cancel leaving Pi connected, as Claude Code's own // models are (#726). The options are what /api/state sends since the fix: // an own model carries direct. Every language, wide and narrow. +// Its section's heading was OPENCODE GO alone, the name of the user's own +// OpenCode Go provider in magpie, read as magpie's section that ignored +// the one model picked there (maxleebeta); it now says it is Pi's own +// sign-in, below magpie's OpenCode Go. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); const path = require("node:path"); @@ -21,6 +25,7 @@ const options = [ { value: "opencode-go/kimi-k2.6", note: "Kimi K2.6", group: "OpenCode Go", direct: "OpenCode Go" }, { value: DS, label: "DeepSeek V4.1 Flash", ref: "deepseek/deepseek-v4.1-flash", group: "DeepSeek", note: "DeepSeek · via magpie" }, { value: "magpie/deepseek/deepseek-v4.1-pro", label: "DeepSeek V4.1 Pro", ref: "deepseek/deepseek-v4.1-pro", group: "DeepSeek", note: "DeepSeek · via magpie" }, + { value: "magpie/opencode-go/minimax-m2.7", label: "MiniMax M2.7", ref: "minimax/minimax-m2.7", group: "OpenCode Go", note: "OpenCode Go · via magpie" }, ]; function server(lang, posts) { @@ -55,7 +60,7 @@ function server(lang, posts) { } const row = '.row.agent[data-id="pi"]'; -const KEYS = ["direct, not via magpie", "via magpie", "Take {agent} off magpie?", "Cancel", "Use {model}", +const KEYS = ["{agent}'s own sign-in", "direct, not via magpie", "via magpie", "Take {agent} off magpie?", "Cancel", "Use {model}", "{model} is {agent}'s own model: {agent} asks {vendor} for it itself, with its own sign-in, not through magpie. Picking it takes {agent} off magpie, and it starts on {model}."]; for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { @@ -92,6 +97,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const at = (s) => order.findIndex((x) => x.includes(s)); assert.ok(at("DeepSeek V4.1 Pro") >= 0 && at("DeepSeek V4.1 Pro") < at("GLM-5.1"), `magpie's first: ${JSON.stringify(order)}`); + // magpie's OpenCode Go section is OpenCode Go; Pi's own says whose + // sign-in it is, in the page's language, quiet and on one line + const heads = (await page.locator("#pop #list li.group").allTextContents()).map((s) => s.trim()); + const own = "OpenCode Go · " + await tr("{agent}'s own sign-in", { agent: "Pi" }); + assert.deepEqual(heads.filter((h) => h.startsWith("OpenCode Go")), ["OpenCode Go", own], JSON.stringify(heads)); + const ownHead = order.findIndex((x) => x.trim() === own); + assert.ok(at("MiniMax M2.7") < ownHead && ownHead < at("GLM-5.1"), `Pi's own heading over its own models: ${JSON.stringify(order)}`); + const head = page.locator("#pop #list li.group.own"); + const look = await head.evaluate((li) => { + const s = li.querySelector(".own-sign"), cs = getComputedStyle(s), r = li.getBoundingClientRect(), list = li.closest("#pop").getBoundingClientRect(); + return { transform: cs.textTransform, height: r.height, inside: r.right <= list.right + 0.5, border: getComputedStyle(li).borderLeftWidth, image: getComputedStyle(li).backgroundImage }; + }); + assert.equal(look.transform, "none", "the words read as written"); + const plain = await page.locator("#pop #list li.group:not(.own)", { hasText: "OpenCode Go" }).evaluate((li) => li.getBoundingClientRect().height); + assert.equal(look.height, plain, "one line, as tall as magpie's OpenCode Go heading"); + assert.ok(look.inside, `inside the picker at ${width}px`); + assert.equal(look.border, "0px", "no stripe"); + assert.equal(look.image, "none", "no gradient"); + // the OpenCode Go model is asked first; Cancel leaves Pi connected await item("GLM-5.1").click(); const ask = page.locator("#modal .leave-ask");