gui: Claude Code's model picker shows each model once (#496) — the rows magpie serves on the very Claude account Claude Code is signed in to fold into one, and models.dev's alias and dated id of one model are one row

Claude Code's picker had 37 rows where Codex's has 18. The Claude subscription added in magpie is, while Claude Code is signed in, the account Claude Code asks on its own, and both groups are titled "Claude Code", so every model showed twice (claude-opus-5-5, then "Claude Opus 5.5 · <account> · via magpie"); and models.dev lists claude-opus-4-5 and claude-opus-4-5-20251101 (haiku-4-5, sonnet-4-5 too) as two models. The via-magpie rows stay, as some use them (the [1m] fix, failover to their other accounts): viaMagpie now knows which provider is the agent's own sign-in (not a stand-in for a signed-out Claude Code, not paused; provider.Account.StandIn is new), and Claude Code's model field marks those options Same while its own group goes straight to Anthropic (not under a base URL of the user's, not for the tiers or a WSL distro). The picker folds them into one row, "13 models via magpie · <account> · the account Claude Code is signed in to" with a chevron, folded each time the picker opens; a click or Enter opens or closes it in place, the row staying under the pointer and the page not moving; the value set stays a row of its own, and Favorites never folds. claudeDated marks a dated Claude id whose undated id is in the same group as that one's Alias (one dated id per name only; [1m] kept), and the picker shows one row for the two: the alias, which a pick writes as before, or the dated one while that is the value set, so a choice made before still shows as picked. The option lists themselves are unchanged, so Spell, Reseat, renames and profiles still find every id. New strings have zh translations.

claude-picker-fold (Chromium and WebKit, en and zh, API fulfilled in memory) fails without the change in all 8 subtests and passes with it; TestClaudeDatedAlias covers the marking. model-pick, model-suffix-own, claude-direct, favorite-star, agent-models, unlisted-models and plain-names pass in both engines, click-scroll in WebKit; Chromium here only starts as the headless shell (the full Chrome for Testing bundle dies on icudtl.dat), where click-scroll fails the same way with the change undone. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui ./internal/agent ./internal/provider ./internal/gui (sandbox HOME) pass.
This commit is contained in:
yetone
2026-10-02 11:08:14 +08:00
parent 7ab91961d2
commit 96367cb8f4
10 changed files with 331 additions and 12 deletions
+11
View File
@@ -39,6 +39,17 @@ type Option struct {
// sign-in or key, with magpie not in the way ("Anthropic"): its config
// then names no magpie endpoint, which is right, not a failed setup
Direct string `json:"direct,omitempty"`
// Same is a model magpie serves on the very account the agent is
// signed in to itself, so the agent reaches it on its own too: the
// picker folds these into one row a click opens (Claude Code, #496)
Same bool `json:"same,omitempty"`
// Alias is the value of the option a dated id is another name of
// (claude-opus-4-5-20251101 → claude-opus-4-5): the picker shows one
// row for the two, the alias, unless the dated one is the value set
Alias string `json:"alias,omitempty"`
// own: served on the agent's own sign-in (viaMagpie), for Same
own bool
}
// Field is one tunable setting of an agent. Set with an empty value puts
+43 -6
View File
@@ -463,7 +463,10 @@ func claudeIn(at place) *Agent {
for i := range own {
own[i].Direct = direct
}
return append(group(name, own), claudeViaMagpie()...)
// magpie's Claude Code account is the one Claude Code asks on
// its own while that is Anthropic: the same models a second
// time, folded in the picker (#496)
return append(group(name, own), claudeViaMagpie(name == "Claude Code")...)
},
}, {
// the effort Claude Code starts with, as its /effort saves it: under
@@ -602,7 +605,7 @@ func claudeIn(at place) *Agent {
if !routed() {
return nil
}
return claudeViaMagpie()
return claudeViaMagpie(false)
},
})
}
@@ -635,7 +638,7 @@ func claudeIn(at place) *Agent {
if !routed() {
return nil
}
return claudeViaMagpie()
return claudeViaMagpie(false)
},
})
@@ -761,7 +764,38 @@ func claudeOwn(cur string, tier func(string) string) []Option {
own = append(own, Option{Value: m.ID, Note: m.Name, Icon: "claude-color"})
}
}
return own
return claudeDated(own)
}
// claudeDated marks each dated Claude id that another option of its group
// names undated (models.dev lists claude-opus-4-5 and
// claude-opus-4-5-20251101, the one model) as that one's Alias. Two dated
// ids of one name are two models, and left as they are.
func claudeDated(opts []Option) []Option {
const mark = "[1m]"
bare := func(v string) string { return strings.TrimSuffix(v, mark) }
type key struct{ group, value string }
alias := map[key]int{}
for i, o := range opts {
if !dated.MatchString(bare(o.Value)) {
alias[key{o.Group, bare(o.Value)}] = i
}
}
twins := map[key][]int{}
for i, o := range opts {
v := bare(o.Value)
if base := dated.ReplaceAllString(v, ""); base != v && claudeName(base) != "" {
if _, ok := alias[key{o.Group, base}]; ok {
twins[key{o.Group, base}] = append(twins[key{o.Group, base}], i)
}
}
}
for k, is := range twins {
if len(is) == 1 {
opts[is[0]].Alias = opts[alias[k]].Value
}
}
return opts
}
// claudeAliasOption is the option for one of Claude Code's aliases, named
@@ -824,7 +858,9 @@ func claudeAliasOption(v string, ms []catalog.Model, tier func(string) string) (
// claudeViaMagpie is what magpie serves Claude Code, a model with a window
// of 1M or more marked [1m]: Claude Code takes any other for 200K, and
// compacts long before a 1M model needs it. It drops the mark before asking.
func claudeViaMagpie() []Option {
// fold marks Same those on the account Claude Code is signed in to, for a
// picker that lists Claude Code's own models above them.
func claudeViaMagpie(fold bool) []Option {
big := map[string]bool{}
for _, m := range magpieModels("claude") {
big[m.ID] = m.Context >= 1_000_000
@@ -834,8 +870,9 @@ func claudeViaMagpie() []Option {
if big[o.Ref] {
opts[i].Value += "[1m]"
}
opts[i].Same = fold && o.own
}
return opts
return claudeDated(opts)
}
// claude1M marks [1m] a magpie model whose window is 1M or more, as
+29
View File
@@ -94,3 +94,32 @@ func TestClaudeAliasShown(t *testing.T) {
t.Fatalf("model = %q", v)
}
}
// TestClaudeDatedAlias (#496): models.dev lists an alias and its dated id
// as two models (claude-opus-4-5, claude-opus-4-5-20251101), and the
// picker showed both. The dated one now names its alias, for the picker to
// show one row; through magpie too, the [1m] mark and all. Two dated ids
// of one name, or a dated one with no alias beside it, are left alone.
func TestClaudeDatedAlias(t *testing.T) {
opts := claudeDated([]Option{
{Value: "claude-opus-4-5", Group: "Claude Code"},
{Value: "claude-opus-4-5-20251101", Group: "Claude Code"},
{Value: "claude/claude-sonnet-4-5[1m]", Group: "Claude Code"},
{Value: "claude/claude-sonnet-4-5-20250929[1m]", Group: "Claude Code"},
{Value: "claude-3-5-sonnet-20240620", Group: "Claude Code"},
{Value: "claude-3-7-sonnet", Group: "Other"},
{Value: "claude-3-7-sonnet-20250219", Group: "Other"},
{Value: "claude-3-7-sonnet-20250301", Group: "Other"},
{Value: "claude-haiku-4-5-20251001", Group: "Other"},
{Value: "claude-haiku-4-5", Group: "Elsewhere"},
})
want := map[string]string{
"claude-opus-4-5-20251101": "claude-opus-4-5",
"claude/claude-sonnet-4-5-20250929[1m]": "claude/claude-sonnet-4-5[1m]",
}
for _, o := range opts {
if o.Alias != want[o.Value] {
t.Errorf("%s: alias %q, want %q", o.Value, o.Alias, want[o.Value])
}
}
}
+11 -1
View File
@@ -26,6 +26,16 @@ const RoutingGroups = "Routing groups"
func viaMagpie(agent, prefix string) []Option {
var out, groups []Option
shown, _ := provider.CatalogFor(agent)
// own: whether a provider is the account the agent is signed in to,
// asked once a provider (OwnPaused reads the saved logins)
own := map[string]bool{}
for _, e := range shown {
if a := e.Provider.Account; a != nil && a.Agent == agent && !a.StandIn() {
if _, ok := own[e.Provider.ID]; !ok {
own[e.Provider.ID] = !e.Provider.OwnPaused()
}
}
}
for _, e := range shown {
if e.Group != "" {
groups = append(groups, Option{Value: prefix + e.ID, Label: e.Name, Note: "routing group · via magpie",
@@ -37,7 +47,7 @@ func viaMagpie(agent, prefix string) []Option {
note = a.User + " · via magpie"
}
out = append(out, Option{Value: prefix + e.ID, Label: e.Name, Note: note,
Icon: e.Provider.Icon, Group: e.Provider.Name, Ref: e.ID, Free: e.Free, Context: e.Context})
Icon: e.Provider.Icon, Group: e.Provider.Name, Ref: e.ID, Free: e.Free, Context: e.Context, own: own[e.Provider.ID]})
}
return append(groups, out...)
}
+2 -2
View File
@@ -188,7 +188,7 @@ var wslKinds = []wslKind{
case "model":
// whether it has a base URL of its own is the distro's file
return func(cur map[string]string) []Option {
return append(group("Claude Code", claudeOwn(cur["model"], nil)), claudeViaMagpie()...)
return append(group("Claude Code", claudeOwn(cur["model"], nil)), claudeViaMagpie(false)...)
}
case "effort":
return nil
@@ -198,7 +198,7 @@ var wslKinds = []wslKind{
if !isMagpie(cur["model"]) {
return nil
}
return claudeViaMagpie()
return claudeViaMagpie(false)
}
}},
}
+6
View File
@@ -1330,6 +1330,12 @@ body.window .foot { padding-left: 18px; }
.pop li.reset .ic { opacity: .75; }
.pop li.custom .v { color: var(--fg); }
.pop li.custom .n { color: var(--muted); }
/* the models on the agent's own account through magpie, folded into one
row (#496): a chevron says it opens, turned down while open */
.pop li.fold .v { color: var(--muted); }
.pop li.fold .chev { display: inline-flex; margin-left: auto; flex: none; color: var(--faint); transition: transform .18s cubic-bezier(.22, 1, .36, 1); }
.pop li.fold.open .chev { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .pop li.fold .chev { transition: none; } }
/* a model kept for routing groups, found by the filter: why it isn't
offered, and what to do, below the choices */
.pop li.kept, .pop.model-picker li.kept { height: auto; align-items: flex-start; padding: 8px; margin-top: 3px; border-top: 1px solid var(--line); border-radius: 0; white-space: normal; cursor: default; }
+66 -3
View File
@@ -1885,6 +1885,43 @@ function ultracodeToggle(a, f) {
return b;
}
// oneRowPerModel: an alias and its dated id (claude-opus-4-5 and
// claude-opus-4-5-20251101, models.dev's two names of one model) are one
// row, the alias's; the dated one's while it is the value set, so a pick
// made before still shows as picked (#496).
function oneRowPerModel(options, cur) {
const values = new Set(options.map((o) => o.value));
const dated = new Map(options.filter((o) => o.alias && values.has(o.alias)).map((o) => [o.alias, o.value]));
return options.filter((o) => (o.alias && values.has(o.alias) ? o.value === cur : !dated.has(o.value) || dated.get(o.value) !== cur));
}
// foldSame: magpie's rows for the very account the agent is signed in to
// itself (Claude Code's Claude subscription, added in magpie too) are the
// agent's own models a second time; they fold into one row that a click
// opens, for the few who want them (failover to more accounts, a fix that
// only magpie's way has). The value set stays a row of its own (#496).
function foldSame(items) {
if (!pick.modelPicker || pick.groupFilter === "favorites") return items;
const same = items.filter((o) => o.same && o.value !== pick.field.value);
if (!same.length) return items;
const first = same[0];
const row = { fold: true, open: !!pick.unfold, n: same.length, group: first.group, icon: first.icon,
account: (first.note || "").replace(/ · via magpie$/, "") };
const out = [];
for (const o of items) {
if (o === first) out.push(row);
if (!same.includes(o) || pick.unfold) out.push(o);
}
return out;
}
// toggleFold opens or closes the folded rows, the fold's row staying under
// the pointer (or the keys' cursor) where it was
function toggleFold() {
pick.unfold = !pick.unfold;
filter((o) => o.fold);
}
// openPicker drops the option list under a field button. `only` narrows the
// options (the providers page offers one vendor's models at a time).
function openPicker(agent, field, anchor, ev, only) {
@@ -1898,6 +1935,7 @@ function openPicker(agent, field, anchor, ev, only) {
// provider's; only the picker's own choices (Automatic, Off) above them
options = [...options.filter((o) => o.reset), ...options.filter((o) => !o.reset && o.group === ROUTING_GROUPS), ...options.filter((o) => !o.reset && o.group !== ROUTING_GROUPS)];
const effortPicker = !only && (field.key === "effort" || field.label === "effort" || field.label === "thinking" || field.label === SUB_EFFORT);
options = oneRowPerModel(options, cur);
// Current model first, then the rest in catalog order. Effort levels keep
// their natural low → high order because their position is meaningful.
const i = options.findIndex((o) => o.value === cur);
@@ -2134,7 +2172,9 @@ function renderEffortPicker() {
update();
}
function filter() {
// filter lists the options the query finds; keep: the row for the cursor,
// the first by default
function filter(keep) {
if (!pick) return;
const q = $("#q").value.trim().toLowerCase();
let source = pick.options;
@@ -2148,10 +2188,11 @@ function filter() {
if (typed && pick.free && ["model", "small", "large", ...FOLLOWS_MODEL].includes(pick.field.label) && !pick.items.some((o) => o.value === typed)) {
pick.items.push({ value: typed, note: t("use as typed"), custom: true });
}
pick.items = foldSame(pick.items);
// a model the filter finds among those kept for routing groups, which
// aren't offered: said why, rather than missing without a word
pick.kept = pick.modelPicker && q ? (state?.unlisted || []).filter((m) => [m.id, m.name].some((s) => s?.toLowerCase().includes(q))).slice(0, 3) : [];
pick.cursor = 0;
pick.cursor = typeof keep === "function" ? Math.max(0, pick.items.findIndex(keep)) : 0;
renderPickerRail();
renderList();
}
@@ -2298,6 +2339,7 @@ function renderList() {
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;
if (o.fold) { list.append(foldRow(o, idx, hasIcons)); return; }
const li = el("li", (idx === pick.cursor ? "sel" : "") + (o.value === pick.field.value ? " cur" : "") + (o.custom ? " custom" : "") + (o.reset ? " reset" : ""));
li.dataset.i = idx;
if (hasIcons) li.append(optionIcon(o));
@@ -2337,6 +2379,27 @@ function renderList() {
list.querySelector(`li[data-i="${pick.cursor}"]`)?.scrollIntoView({ block: "nearest" });
}
// foldRow: the one row the models on the agent's own account through
// magpie fold into (foldSame), opened or closed at a click
function foldRow(o, idx, hasIcons) {
const li = el("li", "fold" + (o.open ? " open" : "") + (idx === pick.cursor ? " sel" : ""));
li.dataset.i = idx;
li.setAttribute("role", "button");
li.setAttribute("aria-expanded", String(o.open));
if (hasIcons) li.append(optionIcon(o));
const words = el("span", "option-words");
words.append(el("span", "v", t(o.n === 1 ? "{n} model via magpie" : "{n} models via magpie", { n: o.n })));
words.append(el("span", "n", o.account ? t("{account} · the account {agent} is signed in to", { account: o.account, agent: pick.agent.name }) : t("the account {agent} is signed in to", { agent: pick.agent.name })));
li.append(words);
const chev = el("span", "chev");
chev.append(svg("m6 4 4 4-4 4", 12, 1.6));
li.append(chev);
li.title = t(o.open ? "Fold them away again" : "The same models as {agent}'s own, through magpie: click to show them", { agent: pick.agent.name });
li.onmousemove = () => { if (pick.cursor !== idx) { pick.cursor = idx; renderList(); } };
li.onclick = (ev) => { ev.stopPropagation(); toggleFold(); };
return li;
}
// keptNote: a model of a provider set to "Only through routing groups",
// found by the picker's filter. It isn't offered: in a group, that group
// is, picked here at a click; in none, nothing uses it, and a click makes
@@ -2465,7 +2528,7 @@ $("#q").addEventListener("input", filter);
$("#q").addEventListener("keydown", (e) => {
if (e.key === "ArrowDown" || (e.ctrlKey && e.key === "n")) { e.preventDefault(); move(1); }
else if (e.key === "ArrowUp" || (e.ctrlKey && e.key === "p")) { e.preventDefault(); move(-1); }
else if (e.key === "Enter") { e.preventDefault(); commit(pick?.items[pick.cursor]?.value); }
else if (e.key === "Enter") { e.preventDefault(); if (pick?.items[pick.cursor]?.fold) toggleFold(); else commit(pick?.items[pick.cursor]?.value); }
else if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); closePicker(); }
});
document.addEventListener("mousedown", (e) => {
+6
View File
@@ -310,6 +310,12 @@ const I18N = {
"Deleted {name}": "已删除 {name}",
"{n} server": "{n} 个服务器",
"{n} servers": "{n} 个服务器",
"{n} model via magpie": "{n} 个模型经 magpie",
"{n} models via magpie": "{n} 个模型经 magpie",
"{account} · the account {agent} is signed in to": "{account} · 即 {agent} 自己登录的账号",
"the account {agent} is signed in to": "即 {agent} 自己登录的账号",
"Fold them away again": "再次收起",
"The same models as {agent}'s own, through magpie: click to show them": "与 {agent} 自己的模型相同,只是经 magpie:点击展开",
"{n} skill": "{n} 个技能",
"{n} skills": "{n} 个技能",
"instructions": "指令",
@@ -0,0 +1,153 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Claude Code's model picker had every model twice (#496): its own, and
// the same models through magpie on the Claude subscription added there,
// which is the very account Claude Code is signed in to; and models.dev's
// alias and dated id of one model each had a row (claude-opus-4-5,
// claude-opus-4-5-20251101). The rows on its own account now fold into
// one, opened at a click without the page moving; an alias and its dated
// id are one row, the alias's, or the dated one's while that is the value
// set. In English and Chinese. No backend: 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 own = (value, note, alias) => ({ value, note, icon: "claude-color", group: "Claude Code", direct: "Anthropic", ...(alias ? { alias } : {}) });
const via = (value, label, alias) => ({ value, label, note: "me@example.com · via magpie", icon: "claudecode-color", group: "Claude Code",
ref: value.replace("[1m]", ""), same: true, ...(alias ? { alias } : {}) });
const options = [
own("claude-opus-5-5", "Claude Opus 5.5"),
own("claude-opus-4-5", "Claude Opus 4.5 (latest)"),
own("claude-opus-4-5-20251101", "Claude Opus 4.5", "claude-opus-4-5"),
own("claude-sonnet-4-5", "Claude Sonnet 4.5 (latest)"),
own("claude-sonnet-4-5-20250929", "Claude Sonnet 4.5", "claude-sonnet-4-5"),
via("claude/claude-opus-5-5[1m]", "Claude Opus 5.5"),
via("claude/claude-opus-4-5", "Claude Opus 4.5 (latest)"),
via("claude/claude-opus-4-5-20251101", "Claude Opus 4.5", "claude/claude-opus-4-5"),
{ value: "deepseek/deepseek-v4", label: "DeepSeek V4", note: "DeepSeek · via magpie", icon: "deepseek-color", group: "DeepSeek", ref: "deepseek/deepseek-v4" },
];
const state = (value) => ({
agents: [{ id: "claude", name: "Claude Code", icon: "claudecode-color", path: "/test/settings.json",
fields: [{ key: "model", label: "model", value, options }] }],
profiles: [],
});
function server(lang, value, sets) {
let cur = state(value);
return async (route) => {
const req = route.request(), url = new URL(req.url());
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 route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
if (url.pathname === "/api/set") {
const body = req.postDataJSON();
sets.push(body);
cur = state(body.value);
return route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
}
if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
if (url.pathname === "/api/agents/cli") return route.fulfill({ json: { agents: {}, pending: false } });
if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
if (url.pathname.startsWith("/api/")) return route.fulfill({ 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 row = '.row.agent[data-id="claude"]';
const words = {
en: { two: "2 models via magpie", one: "1 model via magpie", whose: "me@example.com · the account Claude Code is signed in to" },
zh: { two: "2 个模型经 magpie", one: "1 个模型经 magpie", whose: "me@example.com · 即 Claude Code 自己登录的账号" },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(engine + ": Claude Code's picker shows each model once", async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const errors = [];
t.after(async () => {
if (errors.length) console.log(errors);
await browser.close();
});
const open = async (lang, value, sets = []) => {
const page = await (await browser.newContext({ viewport: { width: 980, height: 640 } })).newPage();
page.setDefaultTimeout(5000);
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", server(lang, value, sets));
await page.goto("http://magpie.test/");
await page.locator(row).waitFor();
await page.locator(`${row} .field[data-key="model"]`).click();
await page.locator("#pop:not([hidden]) #list li").first().waitFor();
await page.waitForTimeout(400); // the picker grows open
return page;
};
// the rows as drawn: name, note, and whether it's the value set
const rows = (page) => page.locator("#list li:not(.group)").evaluateAll((ls) => ls.map((l) => ({
v: l.querySelector(".v")?.textContent, n: l.querySelector(".n")?.textContent || "",
cur: l.classList.contains("cur"), fold: l.classList.contains("fold"),
})));
for (const lang of ["en", "zh"]) {
const w = words[lang];
await t.test(lang + ": folded, opened at a click", async () => {
const sets = [];
const page = await open(lang, "claude-opus-5-5", sets);
let list = await rows(page);
const names = list.map((r) => r.v);
// an alias and its dated id: the alias alone
assert(names.includes("claude-opus-4-5") && !names.includes("claude-opus-4-5-20251101"), names.join(", "));
assert(names.includes("claude-sonnet-4-5") && !names.includes("claude-sonnet-4-5-20250929"), names.join(", "));
// Claude Code's own account through magpie: one folded row
assert(!names.some((n) => /^Claude Opus/.test(n || "")), names.join(", "));
const fold = list.filter((r) => r.fold);
assert.equal(fold.length, 1, names.join(", "));
assert.equal(fold[0].v, w.two);
assert.equal(fold[0].n, w.whose);
assert(names.includes("DeepSeek V4"), "another provider's stay unfolded");
const foldRow = page.locator("#list li.fold");
assert.equal(await foldRow.getAttribute("aria-expanded"), "false");
const view = page.locator("#view-agents");
const before = { view: await view.evaluate((v) => v.scrollTop), win: await page.evaluate(() => scrollY), box: await foldRow.boundingBox() };
await foldRow.click();
assert.equal(await page.locator("#pop:not([hidden])").count(), 1, "the picker stays open");
assert.equal(await foldRow.getAttribute("aria-expanded"), "true");
list = await rows(page);
// opened: the two through magpie, the dated one still one with its alias
assert.deepEqual(list.filter((r) => /^Claude Opus/.test(r.v)).map((r) => r.v), ["Claude Opus 5.5", "Claude Opus 4.5 (latest)"]);
assert.equal(await view.evaluate((v) => v.scrollTop), before.view, "the click moved the page");
assert.equal(await page.evaluate(() => scrollY), before.win, "the click moved the page");
assert(Math.abs((await foldRow.boundingBox()).y - before.box.y) <= 2, "the row stays under the pointer");
// closed again, then one picked through magpie after opening it
await foldRow.click();
assert(!(await rows(page)).some((r) => /^Claude Opus/.test(r.v)));
await foldRow.click();
await page.locator("#list li").filter({ has: page.locator(".v", { hasText: /^Claude Opus 5\.5$/ }) }).click();
await page.waitForFunction(() => document.querySelector("#pop").hidden);
assert.deepEqual(sets, [{ agent: "claude", field: "model", value: "claude/claude-opus-5-5[1m]" }]);
// set: it is its own row, current, and the rest fold again
await page.locator(`${row} .field[data-key="model"]`).click();
await page.locator("#pop:not([hidden]) #list li").first().waitFor();
list = await rows(page);
assert.deepEqual(list[1], { v: "Claude Opus 5.5", n: "me@example.com · via magpie", cur: true, fold: false }, JSON.stringify(list));
assert.equal(list.filter((r) => r.fold).map((r) => r.v).join(), w.one);
await page.context().close();
});
await t.test(lang + ": a dated id set before still shows as set", async () => {
const page = await open(lang, "claude-opus-4-5-20251101");
assert.equal(await page.locator(`${row} .field[data-key="model"] .v`).textContent(), "claude-opus-4-5-20251101");
const list = await rows(page);
const names = list.map((r) => r.v);
assert.deepEqual(list.filter((r) => r.cur).map((r) => r.v), ["claude-opus-4-5-20251101"]);
assert(!names.includes("claude-opus-4-5"), "its alias is the same row: " + names.join(", "));
await page.context().close();
});
}
assert.deepEqual(errors, []);
});
}
+4
View File
@@ -593,6 +593,10 @@ func claudeAccount() (Provider, bool) {
return claudeProvider(&Account{Agent: "claude", User: user, Plan: plan}), true
}
// StandIn says the account is a saved one served in the place of the
// agent's own sign-in, which is signed out.
func (a *Account) StandIn() bool { return a != nil && a.standIn }
// claudeProvider is the Claude Code provider of acct.
func claudeProvider(acct *Account) Provider {
// nothing is sent to Anthropic in Claude Code's name: a request on the