Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

agents: Switch accounts only, the account a Claude Code or Codex not connected is signed in to, a click from another

yetone55299ee30441
diff --git a/docs/reference.md b/docs/reference.md
index f272086c0..cacb1bc5b 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -1815,6 +1815,15 @@ Claude Code, so no turn runs through Claude Code's SDK mode, which
spends more of the allowance than Claude Code used on its own (myduso on
Discord). Their usage is still read and shown.
+**Switch accounts only.** To use magpie only to switch Claude Code (or
+Codex) between your accounts, leave it not connected on Agents and sign
+your accounts in under Providers › Claude Code. Its row on Agents then
+shows the account it is signed in to; click it, and the *Switch accounts
+only* menu signs Claude Code in to another of them, with *Only switch
+Claude Code's sign-in* and *Manage accounts…* beside. The button says
+*Switched*, and a new Claude Code session uses the new account; one
+already open keeps its account until it is started again.
+
**How often an allowance is read.** Routing uses what was read last and
never waits for a reading, except the first one after magpie starts (3
seconds at most). A reading over a minute old is read again in the
diff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.md
index 871bc0530..5f5d45c8f 100644
--- a/docs/subsystems/providers-accounts.md
+++ b/docs/subsystems/providers-accounts.md
@@ -47,6 +47,7 @@ keys and accounts per request is in [Gateway routing and fallback](gateway-routi
| Saved accounts | `logins.json` remembers every Codex and Claude Code account seen signed in. A switch moves the credentials into the agent's own store and saves the ones it replaces. A saved account that is on (`SetLoginOn`) stands behind the agent's own. Its tokens stay in `logins.json`. While Claude Code is signed out, a saved Claude account stands in for its own (`claudeStandIn`); with every saved account's sign-in gone, Claude Code is still listed, on the one seen last, signed out (`claudeListed`), its accounts each saying to sign in again, so it never leaves the Providers list (LeeHom on Discord). Claude Code's own account while still `Held` is never listed that way, since the sign-in it may have left on disk would be served. An account whose every login in use has lapsed is `Provider.SignedOut`: `magpie providers` and the TUI say "<user> is signed out", as the app's row does. | [`logins.go`](../../internal/provider/logins.go), [`logins_on.go`](../../internal/provider/logins_on.go), [`claude_dirs.go`](../../internal/provider/claude_dirs.go) |
| Sign-in in magpie | `StartSignIn` runs the vendor's own browser OAuth with its client and takes the tokens at a callback on this machine. A browser that can't reach that callback (magpie on a server or in Docker) ends on a page that won't load; its address, pasted (`SubmitSignInCallback`), goes through the same callback handler (`pastedCallback`). ChatGPT's sign-in comes back only to port 1455; when that port can't be opened, the sign-in still starts and waits for the pasted address alone, and says why in `CallbackBlocked` with the port in `CallbackPort`: `reserved` for Windows' WSAEACCES on a port in a range it excludes for Hyper-V, WSL or Docker, `busy` for anything else, such as another program holding it (`callbackBlocked`, #1782). A plugin's browser sign-in (`auto`) whose page names a port on this machine to come back to takes its pasted address too: magpie opens it there on 127.0.0.1, for the plugin's own listener (`pluginCallback`, `loopbackPorts`); Command Code's page posts its key from script, so it offers the API key way instead. A Claude account is signed in by Claude Code itself. Signing in brings back an account removed from magpie (`ShowAccount`). A sign-in started in magpie (`StartSignIn`, `StartPluginSignIn`) reads as done (`SignInStatus`, `WaitSignIn`) only after `finish` has run `ShowAccount` for its account, so the window, which opens the account as soon as it sees done, finds it listed. If providers.json can't be written then, the account stays hidden and the sign-in still ends done. Signing in to a plugin's provider from the command line (`pluginLogin`, with a key or the browser) brings it back too. It also takes off the mark a sign-in its vendor turned away left on the account (`Lapsed`) and shows again the agent's own account removed in magpie (`clearPluginLapse`). The window's plugin sign-in does the same with the browser (`pluginDone`, then `finish`) or with a key (`PluginAPIKey`); a key and the command line share these steps in `PluginSignedIn`. A sign-in leaves through the proxy the account's own requests will use (#1663): `ProxyOfLogin` (the account's, else the subscription's, else the global one) for the account being signed in again, the subscription's for a new one. Every request of the flow goes through `signInFlow.via`, Claude Code's own login gets it as *_PROXY (`netproxy.EnvWith`), and a plugin's sign-in runs its fetch under that proxy (`via` in `host.js`; `plugins_cli.go` for the command line). The window's sign-in box shows it as a "Proxy: …" link (`signInProxyLink`, the app menu, no userinfo shown) with Global, Direct, the subscription's and each account's proxy, or a typed one; picking one starts the sign-in again through it (`SignInOptions.Proxy`), and when it ends the pick is kept as the account's (`keepSignInProxy`: the subscription's own when it is its only account, else the account's entry). Global isn't offered while the subscription has a proxy and other accounts, since nothing could keep it. The browser's own leg goes through the browser's network, not magpie's. Signing out leaves through the same exit: a ChatGPT account's refresh token is revoked through its own proxy, read before the account is forgotten (`forgetSIWCLogin`), and Devin's CLI, asked who is signed in or for its models, runs with the account's proxy (`devinCommand`, `devinProxy`). | [`signin.go`](../../internal/provider/signin.go), [`claude_signin.go`](../../internal/provider/claude_signin.go), [`pluginsignin.go`](../../internal/provider/pluginsignin.go), [`pluginsignin_paste.go`](../../internal/provider/pluginsignin_paste.go), [`proxy.go`](../../internal/provider/proxy.go), [`plugins_cli.go`](../../internal/cli/plugins_cli.go) |
| Import from files | `ImportLogins` (ChatGPT, Claude), `ImportGoogleAccounts` (Antigravity) and `ImportFactoryKeys` take other tools' files, from the window (`signin/import`) or `magpie accounts import` (#1453). ChatGPT reads Codex's `auth.json`, CLIProxyAPI's and Cockpit Tools' files, Sub2API's export (`sub2apiEntry`) and codexbar's `~/.codexbar/config.json` (`codexbarEntries`: the `openai_oauth` provider's accounts and `openAI.remoteConnectionAccounts`, the workspace from `openAIAccountId`). Each ChatGPT and Google sign-in is refreshed before it is added, so the tool the file came from is signed out of it; both surfaces say so first, and the command imports nothing without `--yes` or a yes. Claude reads CLIProxyAPI's files and Sub2API's export, whose Claude account says its email as Anthropic does, `email_address`, in `credentials` or `extra`, and keeps its `scope`, `account_uuid` and `org_uuid` as Claude Code's scopes, `accountUuid` and `organizationUuid` (#1975); a file with no email is refused, as Claude Code's own `.credentials.json` is. Claude's are kept as the file has them. A refresh token magpie holds already is `exists`, never refreshed; accounts are matched by email and workspace, or for Claude organization (`sameLogin`). An entry with an access token and no refresh token is refused (`accessOnly`). One file of several that holds no account is a failed row with its place (`ImportedAccount.File`), never skipped. The files are only read. | [`login_import.go`](../../internal/provider/login_import.go), [`google_import.go`](../../internal/provider/google_import.go), [`factory_key.go`](../../internal/provider/factory_key.go), [`accounts_cli.go`](../../internal/cli/accounts_cli.go) |
+| Switch accounts only | magpie as a Claude Code (or Codex) account switcher alone, with nothing connected (the owner on X; growaiskills, Rennix7t). In the window, the Agents row of a Claude Code or Codex not connected says the account it is signed in to (`switchEntry` in app.js, from the providers list `prefetchProviders` reads at start, so `/api/state` reads no keychain for it), also when magpie has no models to connect (`switchable`, before the `empty` line). Its menu, headed *Switch accounts only*, lists the agent's saved accounts: a pick goes through `POST /api/login/switch` (`SwitchLogin`), or `provider/keeplogin` with `keepLoginAs` when the agent is kept signed in to an account of the user's choosing, as the account rows do; the button says *Switched* for five seconds and the status line says new sessions use the account, one already open keeps its own until started again. *Only switch {agent}'s sign-in* (`SwitchOnly` above, `provider/switchonly`) is a ticked item there (Codex: with more than one usable account, as under Providers), and the row then says *Not connected · switching accounts only*. *Manage accounts…*, and a pick whose sign-in lapsed, open Providers › the agent. A Codex failing over (#1385) has it in place of the old *ChatGPT accounts* button. Not in the tray panel (it reads no provider list), not on a WSL twin's row, not on a connected agent's. | [`app.js`](../../internal/gui/assets/app.js), [`logins.go`](../../internal/provider/logins.go) |
| Used-up switch | When the account Codex or Claude Code is signed in to has used its allowance, the agent is signed in to the next account that is on and has room (#208). For Codex, *Only switch Codex's sign-in* (`SwitchOnly`, `SetSwitchOnly`) keeps magpie's `openai_base_url` failover out of Codex's config, so the switch is all magpie does (#1907); an unreadable providers.json reads as switch-only, so the failover is not written on a guess. For Claude, the same setting keeps the accounts to Claude Code (`Provider.KeptToAgent`): `On()` is false, so the gateway, catalog and groups serve nothing on them, while switching and usage, gated by `leftAlone` on the raw `Off`, go on. | [`codex_switch.go`](../../internal/provider/codex_switch.go) |
| Claude Code's proxy | Claude Code on its own subscription asks Anthropic itself, through the proxy its env names. While any Claude account has a proxy of its own (`AccountProxies`), the `env` of Claude Code's `settings.json` names the proxy of the account it is signed in to (#1807): `HTTPS_PROXY` and `HTTP_PROXY` set to that account's own, else the subscription's `Proxy` (`ProxyOfLogin`), and `NO_PROXY` to loopback; none for `direct` or a SOCKS proxy, which Claude Code can't use. It is written on every switch (`switchLogin`, the user's or `SwitchWhenSpent`), when the Claude subscription is saved, and at the gateway's look every `loginSwitchEvery` (a sign-in made in Claude Code itself). Claude Code reads its env at start, so only sessions started after the switch take it. A proxy key the user set (in either case) is theirs: magpie then writes none and takes out none of theirs. What magpie wrote is kept in `claude-proxy-env.json`, and a key is magpie's only while it holds that value. A `settings.json` that doesn't parse is left as it is. Its log lines name the proxy through `netproxy.Redact`, without its user and password (#1886); the env gets it whole. | [`claude_proxy_env.go`](../../internal/provider/claude_proxy_env.go) |
| Routing groups | User-made groups from the Routing view, and auto-found groups of the same model across providers (derived, never stored). The same model is the same id as vendors agree on it (`sameModel`): lowercase, without a vendor's prefix, a version's dot as `-`, a run of spaces, `_` and `-` as one `-` (a relay listing its display name as the id, `GPT-6 Sol`, joins `gpt-6-sol`, Chill on Discord: `TestSameModelDisplayNameAsID`), and without a YYYYMMDD or Ark YYMMDD snapshot date. Every word still counts (`gpt-6`, `gpt-6-mini` and `gpt-6-sol` stay apart), as do a `:variant`, a four-digit release and OpenAI's dashed date (`gpt-4o-2024-08-06`, a pinned snapshot whose group id agents may already name). A provider kept "Only through routing groups" joins them the same way. Members are `provider/model[:effort]`. A group can nest another (`group/<id>`); `SaveGroup` refuses loops. A group given another id (`agent.RenameGroup`: the Routing page, `magpie groups rename`, the TUI) moves every agent field on `group/<old>` to `group/<new>`, spelled as the agent spells it, through the same `renameRefs` a provider's rename uses, then `SyncCatalog`; before, the agents stayed on a group magpie no longer had (lucis0116 on X, `TestRenameGroupMovesTheAgentsOnIt`). A provider's or group's display name needs no move: `store` and `SaveGroup` drop the catalog, and `SyncCatalog` writes the new labels into every agent's list. `Match` takes a glob or `re:` pattern (#766), both matched in any case (`compilePattern`; `(?-i)` inside a `re:` makes case matter). A found group follows the providers magpie has: one removed leaves it, while one switched off stays in it (`foundGroups`, `heldOffEntries`; one without a key, such as a plugin not signed in, finds no group), skipped by `membersIn`, left off a found group's card, logos and TUI line with a count of those switched off (XYenon on Discord: `routing-provider-off.test.cjs`, `TestFoundGroupLineLeavesASwitchedOffProviderOut`) and said as switched off in its editor and the TUI's group page, so switching one of two providers off for a while doesn't take the group away from the agents, rules and groups set to it; it is back in its place once on again (#2671: `TestFoundGroupStaysWithAProviderOff`, `TestFoundGroupWithAProviderOff`, `TestReseatKeepsAFoundGroupWithAProviderOff`, `TestFoundGroupMemberOfASwitchedOffProvider`). A found group the user changed (an `auto-…` id stored) is read without the members of providers magpie no longer has (`withoutRemoved`, not written back, so a provider back under its id is back in it), except a manual group's pick, a rule's model, or all of them when none would be left. A switched-off provider's members stay in it, skipped by `membersIn`, and the Routing page says them as switched off (`memberJSON.providerOff`). The user's own groups keep their members. Three templates make a group in one click from the models the user has (`provider.Templates`, `AddTemplate`; the Routing page's cards before a first group and its Templates menu after, `magpie group template [kind] [name]`): `smart` sends a hard turn to the strongest model and an easy one or a compaction to a cheap one, asked by a classifier (the decision API when there is one, else the cheapest priced model that doesn't reason); `thrifty` starts on two cheap models of different providers and sends high reasoning to the strongest; `steady` fails over between the strongest model of up to three providers. A model is weighed by its maker's list price when known, else what its provider charges, else by its id's size words (`sizeOf`); one over `tooDear` (USD 100 a million output tokens) is never picked. A template that can't be made says what is missing (`Need`). It is saved under a name and id no group has (`freeGroupName`, shared with `CopyGroup`), never over one. A group is shared as text (`ShareGroup`, a group row's Copy to share): JSON marked `"magpie": "routing-group"` with a format `version` (`ShareVersion`), holding the group's members as it names them, patterns, routing, rules, classifier and settings. A group holds only `provider/model` ids, never a key, account or address, and the derived matches, found/hidden/off flags and the rules that hold by a folder (a path on the sharer's machine, `Rule.Folders`) stay behind; a pasted one is left out too. `ImportGroup` (the Routing page's Import, `POST /api/groups/import`) reads it with words or a code fence around it, refuses another text, a newer format or none (`ShareError`, said in the reader's language). A member whose provider the importer has is kept; else the same model (`AutoGroupOf`) under the first provider of theirs that serves it (`Instead`); else it is left out and named (`Missing`), with the rules that send to it, its place among the off and fast members, and a classifier gone takes the intent rules and auto effort with it. Nothing is added when no member is left; what is added gets a free name, never replacing a group. A group of patterns only that match nothing now (a plugin's models not listed) has no members: `/api/groups` says them, and an unmakeable template's, as `[]`, never `null`; the Routing page reads the response through `groupsFrom` and draws a group it still can't draw as one row saying so, so one bad group never hides the rest (#1585). | [`group.go`](../../internal/provider/group.go), [`grouptemplate.go`](../../internal/provider/grouptemplate.go), [`group_share.go`](../../internal/provider/group_share.go) |
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css
index 90d6410a3..695993d77 100644
--- a/internal/gui/assets/app.css
+++ b/internal/gui/assets/app.css
@@ -674,6 +674,13 @@ body.panel #agents > .row .ag-handle::before { left: -8px; }
.ag-acc { display: inline-flex; align-items: center; flex: none; height: 20px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--fg-2); font: inherit; font-size: 11.5px; line-height: 1; cursor: pointer; transition: background-color .15s, color .15s; }
.ag-acc:hover { background: var(--pill); color: var(--fg); }
.ag-acc:focus-visible { outline: 1.5px solid var(--fg-2); outline-offset: 1px; }
+/* Switch accounts only: the account the agent is signed in to, its menu a click away; a long address is cut, never the row widened */
+.ag-acc.ag-who { gap: 5px; flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 0 7px; }
+.ag-who > svg { flex: none; }
+.ag-who .v { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
+.ag-who.open { background: var(--pill); color: var(--fg); }
+.ag-who .ok { display: none; flex: none; align-items: center; gap: 3px; color: var(--green); font-weight: 600; }
+.ag-who.done .ok { display: inline-flex; }
.ag-fix.busy svg > * { transform-box: view-box; transform-origin: 50% 50%; animation: spin .8s linear infinite; }
/* what has to listen at an address no agent reaches magpie by (#1013): long addresses wrap, and it can be copied */
.drift-why { overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index c9c61f993..40e9e7ea1 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -1364,7 +1364,7 @@ function connectLine(a, kind) {
else say(t("Not added · {agent} asks to add magpie when its link opens", { agent: a.name }));
return line;
}
- if (kind === "empty") { say(t("Add a key or a subscription first; then there are models to connect")); return line; }
+ if (kind === "empty" && !switchable(a)) { say(t("Add a key or a subscription first; then there are models to connect")); return line; }
if (!a.wired && a.native && a.native.provider !== "disconnected") {
say(t(a.native.detail), "bad");
if (a.native.provider === "invalid") line.append(driftFix(a, "Reconnect"));
@@ -1372,24 +1372,22 @@ function connectLine(a, kind) {
}
if (!a.wired) {
const src = a.source || "";
+ const sw = switchEntry(a);
if (kindOf(a) === "agy") say(t("Not connected · once connected, start it with magpie's command"));
// not connected, yet through magpie for account failover (#1385): it
// read as Codex on its own while magpie served every request, so the
- // line says why, and the accounts that turn it off are a click away
+ // line says why, and its account switch (below) turns it off
else if (a.failover) {
say(t("Not connected · goes through magpie only to fail over to your other ChatGPT accounts"));
words.title = t("magpie set openai_base_url in {agent}'s config.toml, so a request the ChatGPT account {agent} is signed in to has no allowance for goes on to your other ChatGPT accounts on in magpie. {agent} keeps to its own models. To stop it, tick Only switch {agent}'s sign-in under Providers › Codex, or switch those accounts off; connecting {agent} adds magpie's models.", { agent: a.name });
- const go = el("button", "ag-acc", t("ChatGPT accounts"));
- go.type = "button";
- go.title = words.title;
- go.onclick = (e) => { e.stopPropagation(); openProvider("codex"); };
- line.append(go);
}
+ else if (sw?.p.switchOnly) say(t("Not connected · switching accounts only"));
else if (src === "sub") say(t("Not connected · now on its Claude subscription"));
else if (src === "chatgpt") say(t("Not connected · now signed in with ChatGPT · OpenAI's models stay available once connected"));
else if (src === "key") say(t("Not connected · now on an API key of its own"));
else if (src.startsWith("providers:")) say(t("Not connected · now has {n} providers of its own", { n: src.slice(10) }));
else say(t("Not connected · {agent} uses its own settings", { agent: a.name }));
+ if (sw) line.append(sw.button);
if (a.appRestart) line.append(appRestart(a));
return line;
}
@@ -1586,6 +1584,63 @@ function connectRow(a, row, who, { fields, extras, fieldBtn, sw, kind }) {
}
}
+// Switch accounts only (the owner on X): a Claude Code or Codex not
+// connected says its account, and its menu signs it in to another, as the
+// account rows do; the window's, the panel reads no provider list
+let accountSwitched = null;
+
+function switchable(a) {
+ if (a.wired || mode === "panel" || (a.id !== "claude" && a.id !== "codex")) return null;
+ const p = (providers || providersEarly?.got)?.providers?.find((x) => x.id === a.id && x.account?.agent === a.id);
+ return p && loginsInOrder(p.account, p)[0]?.user ? p : null;
+}
+
+function switchEntry(a) {
+ const p = switchable(a);
+ if (!p) return null;
+ const ls = loginsInOrder(p.account, p), cur = ls.find((l) => l.active)?.user || "", ag = { agent: a.name };
+ const b = el("button", "ag-acc ag-who"), cx = a.id === "codex";
+ b.type = "button";
+ b.setAttribute("aria-haspopup", "menu");
+ b.setAttribute("aria-expanded", "false");
+ if (cur) b.title = t("Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.", { ...ag, user: cur });
+ b.append(svg(EXTRA_GLYPH["sign-in"], 12, 1.5), el("span", "v", cur || t("Not signed in")));
+ const ago = performance.now() - (accountSwitched?.at || -1e9);
+ if (accountSwitched?.agent === a.id && accountSwitched.user === cur && ago < 5000) {
+ const ok = el("span", "ok");
+ ok.append(svg(CHECK, 10, 2.2), el("span", "", t("Switched")));
+ b.append(ok);
+ b.classList.add("done");
+ setTimeout(() => b.classList.remove("done"), 5000 - ago);
+ }
+ b.append(svg(CHEV, 10, 1.6));
+ const opts = ls.map((l) => ({ v: "u:" + l.user, name: l.user, literalName: true, note: l.lapsed ? "Sign-in required" : accountPlan({ agent: a.id, plan: l.plan }) }));
+ const on = cx ? t("magpie only switches {agent}'s sign-in; its requests go straight to OpenAI", ag) : t("magpie serves no requests on these accounts");
+ // the Only switch setting, where the accounts page offers it
+ if (!cx || ls.filter((l) => !l.lapsed && (l.active || l.on)).length > 1) opts.push({ v: "only", name: t("Only switch {agent}'s sign-in", ag), literalName: true, ticked: !!p.switchOnly, note: on });
+ opts.push({ v: "manage", name: "Manage accounts…", note: "" });
+ b.onclick = (e) => {
+ e.stopPropagation();
+ if (b.classList.contains("open")) return closeProtoMenu();
+ openProtoMenu(b, opts, "u:" + cur, (v) => {
+ const l = ls.find((x) => "u:" + x.user === v);
+ if (v === "only") accountAction("provider/switchonly", { id: p.id, switchOnly: !p.switchOnly }, !p.switchOnly ? on
+ : cx ? t("{agent}'s requests go through magpie to fail over to your other accounts again", ag) : t("magpie serves requests on these accounts again"));
+ else if (v === "manage" || l?.lapsed) openProvider(a.id);
+ else if (l && l.user !== cur) switchAccountTo(a, p, l.user);
+ }, "Switch accounts only", "sess-menu", "right");
+ };
+ return { p, button: b };
+}
+
+async function switchAccountTo(a, p, user) {
+ const said = t("{agent} is now signed in as {user}. New {agent} sessions use this account; one already open keeps its account until it is started again.", { agent: a.name, user });
+ // kept signed in to one of the user's choosing (#524): that choice moves
+ if (!await (keptLogin(p) ? accountAction("provider/keeplogin", { id: p.id, keepLogin: true, keepLoginAs: user }, said) : accountAction("login/switch", { agent: a.id, user }, said))) return;
+ accountSwitched = { agent: a.id, user, at: performance.now() };
+ renderAgents();
+}
+
// agentsLead: above the window's list, what 「接入」 does, said once in a
// line; while no agent is connected, as a welcome, with a way to add a
// provider when magpie has no models to give
@@ -6009,7 +6064,11 @@ let providersEarly = null;
function prefetchProviders() {
if (providers || providersEarly) return;
const e = providersEarly = { read: api("providers") };
- e.read.then((s) => { e.got = s; markNewPartners(); }, () => { if (providersEarly === e) providersEarly = null; });
+ e.read.then((s) => {
+ e.got = s;
+ markNewPartners();
+ if (state?.agents?.some((a) => !a.wired && (a.id === "claude" || a.id === "codex"))) renderAgents();
+ }, () => { if (providersEarly === e) providersEarly = null; });
}
// The page's first reading, while it is on its way, is the one every ask
@@ -14994,7 +15053,8 @@ function openProtoMenu(anchor, opts, value, choose, head = "Protocol this key sp
closeProtoMenu();
const multi = Array.isArray(value);
let picked = multi ? [...value] : null;
- const isOn = (v) => !multi ? v === value : v === "" ? !picked.length : picked.includes(v);
+ // an item with its own ticked (true or false) is a setting beside the pick
+ const isOn = (v, o) => typeof o?.ticked === "boolean" ? o.ticked : !multi ? v === value : v === "" ? !picked.length : picked.includes(v);
const box = el("div", "pop proto-menu" + (cls ? " " + cls : ""));
box.setAttribute("role", "menu");
box.append(el("div", "pm-head", t(head)));
@@ -15008,15 +15068,15 @@ function openProtoMenu(anchor, opts, value, choose, head = "Protocol this key sp
box.append(top);
}
const tick = (b, o) => {
- b.classList.toggle("on", isOn(o.v));
- b.setAttribute("aria-checked", isOn(o.v));
- b.firstChild.replaceChildren(...(isOn(o.v) ? [svg(CHECK, 12, 1.9)] : []));
+ b.classList.toggle("on", isOn(o.v, o));
+ b.setAttribute("aria-checked", isOn(o.v, o));
+ b.firstChild.replaceChildren(...(isOn(o.v, o) ? [svg(CHECK, 12, 1.9)] : []));
};
const items = opts.map((o) => {
const b = el("button", "pm-item");
b.type = "button";
if (o.title) b.title = o.title;
- b.setAttribute("role", multi && o.v && o.v !== "\x00" ? "menuitemcheckbox" : "menuitemradio");
+ b.setAttribute("role", multi && o.v && o.v !== "\x00" || typeof o.ticked === "boolean" ? "menuitemcheckbox" : "menuitemradio");
const words = el("span", "pm-words");
words.append(el("span", "pm-name", o.literalName ? o.name : t(o.name)), el("span", "pm-note", t(o.note)));
b.append(el("span", "pm-tick"), words);
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 309ac9df0..2dbbf942e 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -589,7 +589,6 @@ const I18N = {
"Not connected · now signed in with ChatGPT · OpenAI's models stay available once connected": "未接入 · 现在用 ChatGPT 登录 · 接入后 OpenAI 的模型照常可用",
"Not connected · goes through magpie only to fail over to your other ChatGPT accounts": "未接入 · 只为切换到你的其他 ChatGPT 账号而经过 magpie",
"magpie set openai_base_url in {agent}'s config.toml, so a request the ChatGPT account {agent} is signed in to has no allowance for goes on to your other ChatGPT accounts on in magpie. {agent} keeps to its own models. To stop it, tick Only switch {agent}'s sign-in under Providers › Codex, or switch those accounts off; connecting {agent} adds magpie's models.": "magpie 在 {agent} 的 config.toml 里写了 openai_base_url:{agent} 登录的 ChatGPT 账号额度不够时,请求会转到你在 magpie 里启用的其他 ChatGPT 账号。{agent} 只列出它自己的模型。要停止,请在 供应商 › Codex 里勾选「只切换 {agent} 的登录」,或停用那些账号;接入 {agent} 则会加上 magpie 的模型。",
- "ChatGPT accounts": "ChatGPT 账号",
"Not connected · now on an API key of its own": "未接入 · 现在用它自己的 API key",
"Not connected · now has {n} providers of its own": "未接入 · 现在有 {n} 个自己的供应商",
"Reconnect": "重新接入",
@@ -1651,6 +1650,13 @@ const I18N = {
"Keep {agent} signed in to the first account": "{agent} 始终登录首选账号",
"Keep {agent} signed in to": "{agent} 始终登录",
"Only switch {agent}'s sign-in": "只切换 {agent} 的登录",
+ "Switch accounts only": "仅切换账号",
+ "Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.": "仅切换账号:{agent} 当前登录的是 {user}。选另一个账号,即可把 {agent} 切换过去,无需接入 magpie。",
+ "Not signed in": "未登录",
+ "Switched": "已切换",
+ "Manage accounts…": "管理账号…",
+ "{agent} is now signed in as {user}. New {agent} sessions use this account; one already open keeps its account until it is started again.": "{agent} 已切换到 {user}。新开的 {agent} 会话使用这个账号;已经打开的会话仍用原账号,重新启动后才换过来。",
+ "Not connected · switching accounts only": "未接入 · 仅切换账号",
"Stop when every account is at its cap": "所有账号都到上限时停止",
"On: once every account in use is at its cap, requests get 429 instead of going to the fallbacks.": "开启:在用的账号全部到达上限后,请求返回 429,不再转到备用。",
"Check usage again near a cap": "接近上限时重新读取用量",
@@ -4723,7 +4729,6 @@ const I18N = {
"Not connected · now signed in with ChatGPT · OpenAI's models stay available once connected": "未接入 · 現在用 ChatGPT 登入 · 接入後 OpenAI 的模型照常可用",
"Not connected · goes through magpie only to fail over to your other ChatGPT accounts": "未接入 · 只為切換到你的其他 ChatGPT 帳號而經過 magpie",
"magpie set openai_base_url in {agent}'s config.toml, so a request the ChatGPT account {agent} is signed in to has no allowance for goes on to your other ChatGPT accounts on in magpie. {agent} keeps to its own models. To stop it, tick Only switch {agent}'s sign-in under Providers › Codex, or switch those accounts off; connecting {agent} adds magpie's models.": "magpie 在 {agent} 的 config.toml 裡寫了 openai_base_url:{agent} 登入的 ChatGPT 帳號額度不夠時,請求會轉到你在 magpie 裡啟用的其他 ChatGPT 帳號。{agent} 只列出它自己的模型。要停止,請在 供應商 › Codex 裡勾選「只切換 {agent} 的登入」,或停用那些帳號;接入 {agent} 則會加上 magpie 的模型。",
- "ChatGPT accounts": "ChatGPT 帳號",
"Not connected · now on an API key of its own": "未接入 · 現在用它自己的 API key",
"Not connected · now has {n} providers of its own": "未接入 · 現在有 {n} 個自己的供應商",
"Reconnect": "重新接入",
@@ -5771,6 +5776,13 @@ const I18N = {
"Keep {agent} signed in to the first account": "{agent} 始終登入首選帳號",
"Keep {agent} signed in to": "{agent} 始終登入",
"Only switch {agent}'s sign-in": "只切換 {agent} 的登入",
+ "Switch accounts only": "僅切換帳號",
+ "Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.": "僅切換帳號:{agent} 目前登入的是 {user}。選另一個帳號,即可把 {agent} 切換過去,無需接入 magpie。",
+ "Not signed in": "未登入",
+ "Switched": "已切換",
+ "Manage accounts…": "管理帳號…",
+ "{agent} is now signed in as {user}. New {agent} sessions use this account; one already open keeps its account until it is started again.": "{agent} 已切換到 {user}。新開的 {agent} 工作階段使用這個帳號;已經開啟的工作階段仍用原帳號,重新啟動後才換過來。",
+ "Not connected · switching accounts only": "未接入 · 僅切換帳號",
"Stop when every account is at its cap": "所有帳號都到上限時停止",
"On: once every account in use is at its cap, requests get 429 instead of going to the fallbacks.": "開啟:使用中的帳號全部到達上限後,請求回傳 429,不再轉到備援。",
"Check usage again near a cap": "接近上限時重新讀取用量",
@@ -8823,7 +8835,6 @@ const I18N = {
"Not connected · now signed in with ChatGPT · OpenAI's models stay available once connected": "未接続 · 現在は ChatGPT でサインイン中 · 接続後も OpenAI のモデルは使えます",
"Not connected · goes through magpie only to fail over to your other ChatGPT accounts": "未接続 · 他の ChatGPT アカウントへ切り替えるためだけに magpie を経由しています",
"magpie set openai_base_url in {agent}'s config.toml, so a request the ChatGPT account {agent} is signed in to has no allowance for goes on to your other ChatGPT accounts on in magpie. {agent} keeps to its own models. To stop it, tick Only switch {agent}'s sign-in under Providers › Codex, or switch those accounts off; connecting {agent} adds magpie's models.": "magpie は {agent} の config.toml に openai_base_url を書き込みました。{agent} がサインインしている ChatGPT アカウントの利用枠が足りないリクエストは、magpie で有効にしている他の ChatGPT アカウントに回ります。{agent} には自身のモデルだけが表示されます。止めるには、プロバイダ › Codex で「{agent} のサインインだけを切り替える」にチェックを入れるか、それらのアカウントを停止してください。{agent} を接続すると magpie のモデルも加わります。",
- "ChatGPT accounts": "ChatGPT アカウント",
"Not connected · now on an API key of its own": "未接続 · 現在は独自の APIキーを使用中",
"Not connected · now has {n} providers of its own": "未接続 · 現在は独自のプロバイダが {n} 件あります",
"Reconnect": "再接続",
@@ -9868,6 +9879,13 @@ const I18N = {
"Keep {agent} signed in to the first account": "{agent} を最初のアカウントにサインインしたままにする",
"Keep {agent} signed in to": "{agent} のサインイン先を固定:",
"Only switch {agent}'s sign-in": "{agent} のサインインだけを切り替える",
+ "Switch accounts only": "アカウント切り替えのみ",
+ "Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.": "アカウント切り替えのみ:{agent} は {user} としてサインイン中です。別のアカウントを選ぶと、{agent} を magpie に接続せずにそのアカウントへ切り替えます。",
+ "Not signed in": "未サインイン",
+ "Switched": "切り替えました",
+ "Manage accounts…": "アカウントを管理…",
+ "{agent} is now signed in as {user}. New {agent} sessions use this account; one already open keeps its account until it is started again.": "{agent} は {user} としてサインインしました。新しい {agent} セッションはこのアカウントを使います。開いているセッションは起動し直すまで元のアカウントのままです。",
+ "Not connected · switching accounts only": "未接続 · アカウント切り替えのみ",
"Stop when every account is at its cap": "すべてのアカウントが上限に達したら止める",
"On: once every account in use is at its cap, requests get 429 instead of going to the fallbacks.": "オン:使用中のアカウントがすべて上限に達すると、リクエストはフォールバックに送らず 429 を返します。",
"Check usage again near a cap": "上限に近づいたら使用量を読み直す",
@@ -12940,7 +12958,6 @@ const I18N = {
"Not connected · now signed in with ChatGPT · OpenAI's models stay available once connected": "Nicht verbunden · derzeit mit ChatGPT angemeldet · OpenAI-Modelle bleiben nach dem Verbinden verfügbar",
"Not connected · goes through magpie only to fail over to your other ChatGPT accounts": "Nicht verbunden · läuft nur für den Wechsel zu deinen anderen ChatGPT-Konten über magpie",
"magpie set openai_base_url in {agent}'s config.toml, so a request the ChatGPT account {agent} is signed in to has no allowance for goes on to your other ChatGPT accounts on in magpie. {agent} keeps to its own models. To stop it, tick Only switch {agent}'s sign-in under Providers › Codex, or switch those accounts off; connecting {agent} adds magpie's models.": "magpie hat openai_base_url in die config.toml von {agent} geschrieben: Eine Anfrage, für die das ChatGPT-Konto, mit dem {agent} angemeldet ist, kein Kontingent mehr hat, geht an deine anderen in magpie aktiven ChatGPT-Konten. {agent} zeigt nur seine eigenen Modelle. Zum Beenden unter Anbieter › Codex „Nur die Anmeldung von {agent} wechseln“ ankreuzen oder diese Konten deaktivieren; verbindest du {agent}, kommen die Modelle von magpie hinzu.",
- "ChatGPT accounts": "ChatGPT-Konten",
"Not connected · now on an API key of its own": "Nicht verbunden · nutzt derzeit einen eigenen API-Schlüssel",
"Not connected · now has {n} providers of its own": "Nicht verbunden · hat derzeit {n} eigene Anbieter",
"Reconnect": "Erneut verbinden",
@@ -13995,6 +14012,13 @@ const I18N = {
"Keep {agent} signed in to the first account": "{agent} beim ersten Konto angemeldet lassen",
"Keep {agent} signed in to": "{agent} angemeldet lassen bei",
"Only switch {agent}'s sign-in": "Nur die Anmeldung von {agent} wechseln",
+ "Switch accounts only": "Nur Konten wechseln",
+ "Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.": "Nur Konten wechseln: {agent} ist als {user} angemeldet. Wähle ein anderes seiner Konten, um {agent} dort anzumelden, ohne es mit magpie zu verbinden.",
+ "Not signed in": "Nicht angemeldet",
+ "Switched": "Gewechselt",
+ "Manage accounts…": "Konten verwalten…",
+ "{agent} is now signed in as {user}. New {agent} sessions use this account; one already open keeps its account until it is started again.": "{agent} ist jetzt als {user} angemeldet. Neue {agent}-Sitzungen nutzen dieses Konto; eine schon offene bleibt bei ihrem Konto, bis sie neu gestartet wird.",
+ "Not connected · switching accounts only": "Nicht verbunden · nur Konten wechseln",
"Stop when every account is at its cap": "Anhalten, wenn jedes Konto sein Limit erreicht hat",
"On: once every account in use is at its cap, requests get 429 instead of going to the fallbacks.": "An: Hat jedes genutzte Konto sein Limit erreicht, bekommen Anfragen 429, statt an die Fallbacks zu gehen.",
"Check usage again near a cap": "Nutzung nahe am Limit neu lesen",
diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go
index 687b30c6d..6ab82d106 100644
--- a/internal/gui/core_budget_test.go
+++ b/internal/gui/core_budget_test.go
@@ -15,8 +15,8 @@ import (
// so a page can't quietly grow back into the core; a change that needs more
// raises them and says why in its commit.
const (
- appScriptBudget = 1_311_735 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29)
- coreScriptBudget = 1_532_602 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added
+ appScriptBudget = 1_315_316 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29); 1,315,316 with the Agents row of a Claude Code or Codex not connected saying the account it is signed in to and switching it to another (Switch accounts only, the owner on X), in place of the failover line's ChatGPT accounts button, the Agents page's, the core's own, its comments cut down, with no room added (10-30)
+ coreScriptBudget = 1_536_357 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30)
)
func TestCoreScriptBudget(t *testing.T) {
diff --git a/internal/gui/tests/agent-failover.test.cjs b/internal/gui/tests/agent-failover.test.cjs
index 9e64900ee..2d30d2060 100644
--- a/internal/gui/tests/agent-failover.test.cjs
+++ b/internal/gui/tests/agent-failover.test.cjs
@@ -2,8 +2,10 @@
// #1385 (shenghsi): Codex isn't connected, yet magpie set openai_base_url for
// it so a request its ChatGPT account has no allowance for goes on to the
// user's other ChatGPT accounts on in magpie. The row says it goes through
-// magpie for that alone, its title says what turns it off, and a button
-// opens Providers › Codex, where those accounts are switched off. A Codex
+// magpie for that alone, its title says what turns it off, and its
+// account switch (the Switch accounts only menu) has Only switch Codex's
+// sign-in and Manage accounts…, which opens Providers › Codex, where
+// those accounts are switched off. A Codex
// not failing over says what it said before. In every language, at a narrow
// width too, in Chromium and WebKit; no click moves the page.
const assert = require("node:assert/strict");
@@ -57,7 +59,8 @@ const codexProvider = {
const said = "Not connected · goes through magpie only to fail over to your other ChatGPT accounts";
const title = "magpie set openai_base_url in {agent}'s config.toml, so a request the ChatGPT account {agent} is signed in to has no allowance for goes on to your other ChatGPT accounts on in magpie. {agent} keeps to its own models. To stop it, tick Only switch {agent}'s sign-in under Providers › Codex, or switch those accounts off; connecting {agent} adds magpie's models.";
-const button = "ChatGPT accounts";
+const manage = "Manage accounts…";
+const only = "Only switch {agent}'s sign-in";
const plain = "Not connected · {agent} uses its own settings";
const row = (id) => `.row.agent[data-id="${id}"]`;
@@ -76,14 +79,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.goto("http://magpie.test/?view=agents");
await page.locator(`${row("codex")} .ag-st`).waitFor();
const tr = (k) => page.evaluate(([k, lang]) => (lang === "en" ? k : I18N[lang]?.[k]), [k, lang]);
- for (const k of [said, title, button]) assert.ok(await tr(k), `${lang} has ${k.slice(0, 40)}`);
+ for (const k of [said, title, manage, only]) assert.ok(await tr(k), `${lang} has ${k.slice(0, 40)}`);
const want = (await tr(said));
const wantTitle = (await tr(title)).replaceAll("{agent}", "Codex");
const st = page.locator(`${row("codex")} .ag-st`);
assert.ok((await st.textContent()).startsWith(want), await st.textContent());
- const go = st.locator("button.ag-acc");
- assert.equal(await go.textContent(), await tr(button));
- assert.equal(await go.getAttribute("title"), wantTitle);
+ assert.equal(await st.locator(".ag-st-t").getAttribute("title"), wantTitle);
+ const go = st.locator("button.ag-acc.ag-who");
+ assert.equal(await go.locator(".v").textContent(), "[email protected]");
// the twin not failing over says what it always did
assert.equal(await page.locator(`${row("codex@wsl:Ubuntu-24.04")} .ag-st`).textContent(),
(await tr(plain)).replace("{agent}", "Codex"));
@@ -94,6 +97,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.ok(box && box.x >= 0 && box.x + box.width <= width, `button off screen: ${JSON.stringify(box)}`);
const top = await page.evaluate(() => [document.scrollingElement.scrollTop, document.querySelector("#view-agents")?.scrollTop]);
await go.click();
+ const menu = page.locator(".proto-menu");
+ await menu.waitFor();
+ const stop = menu.locator(".pm-item", { hasText: (await tr(only)).replace("{agent}", "Codex") });
+ assert.equal(await stop.getAttribute("aria-checked"), "false");
+ await menu.locator(".pm-item", { hasText: await tr(manage) }).click();
await page.waitForFunction(() => new URL(location.href).searchParams.get("view") === "providers");
await page.waitForFunction(() => new URL(location.href).searchParams.get("edit") === "codex");
// its editor, with the accounts to switch off, is what opens
diff --git a/internal/gui/tests/agent-switch-accounts.test.cjs b/internal/gui/tests/agent-switch-accounts.test.cjs
new file mode 100644
index 000000000..394db0038
--- /dev/null
+++ b/internal/gui/tests/agent-switch-accounts.test.cjs
@@ -0,0 +1,196 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// Switch accounts only (the owner on X; growaiskills, Rennix7t): magpie as
+// a Claude Code account switcher alone, with nothing connected. The Agents
+// row of a Claude Code not connected says the account it is signed in to,
+// always; its menu, headed Switch accounts only, signs it in to another
+// (login/switch), and the button says Switched while the status line says
+// new sessions use the new account. Only switch Claude Code's sign-in is
+// ticked there and, ticked, the row says it switches accounts only. One
+// kept signed in to an account of the user's choosing moves that choice
+// (keeplogin). Codex has the same entry; with one account, no toggle.
+// With no models in magpie to connect (the switcher's case) it is there.
+// A connected Claude Code, and its WSL twin, have none. In every language,
+// at a narrow width too, in Chromium and WebKit; no click moves the page.
+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");
+// with no models in magpie (every Claude account kept to Claude Code,
+// nothing else added) the fields offer none of magpie's
+const own = [{ value: "sonnet", label: "Sonnet" }];
+const agents = (wired, options = wired ? [...own, { value: "relay/m1", label: "m1", ref: "relay/m1" }] : own) => [
+ { id: "claude", name: "Claude Code", icon: "generic", path: "/fixture/claude", source: "sub", wired, fields: [{ key: "model", label: "model", value: "sonnet", options }] },
+ { id: "claude@wsl:Ubuntu-24.04", name: "Claude Code", icon: "generic", path: "/fixture/wsl-claude", source: "sub", fields: [{ key: "model", label: "model", value: "sonnet", options }] },
+ { id: "codex", name: "Codex", icon: "generic", path: "/fixture/codex", source: "chatgpt", fields: [{ key: "model", label: "model", value: "gpt-5.5", options }] },
+];
+
+function providersOf(w) {
+ const claude = {
+ id: "claude", name: "Claude Code", icon: "claude-color", chat: "", responses: "", anthropic: "", catalog: "", routing: "smart",
+ models: [], agents: [], fallback: [], headers: {}, keyList: [], switchOnly: w.switchOnly || undefined,
+ keepLogin: !!w.keepAs || undefined, keepLoginAs: w.keepAs || undefined,
+ account: {
+ agent: "claude", agentName: "Claude Code", user: w.active, plan: "max",
+ logins: ["[email protected]", "[email protected]"].map((user) => ({ user, plan: user === "[email protected]" ? "max" : "pro", active: user === w.active, on: true })),
+ },
+ };
+ const codex = {
+ id: "codex", name: "Codex", icon: "codex-color", chat: "", responses: "", anthropic: "", catalog: "", routing: "smart",
+ models: [], agents: [], fallback: [], headers: {}, keyList: [],
+ account: { agent: "codex", agentName: "Codex", user: "[email protected]", plan: "PLUS", logins: [{ user: "[email protected]", plan: "PLUS", active: true, on: true }] },
+ };
+ return { providers: [claude, codex], presets: [], excluded: [], gateway: { running: true, window: true } };
+}
+
+function server(lang, w, posts) {
+ 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({ agents: agents(w.wired), profiles: [], settings: { lang, theme: "light" } });
+ if (url.pathname === "/api/usage/quotas") return json([]);
+ if (url.pathname === "/api/groups") return json({ groups: [] });
+ if (url.pathname === "/api/plugins") return json({ plugins: [] });
+ if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
+ if (url.pathname === "/api/providers") return json(providersOf(w));
+ if (req.method() === "POST" && ["/api/login/switch", "/api/provider/switchonly", "/api/provider/keeplogin"].includes(url.pathname)) {
+ const body = req.postDataJSON();
+ posts.push([url.pathname, body]);
+ if (url.pathname === "/api/login/switch") w.active = body.user;
+ if (url.pathname === "/api/provider/switchonly") w.switchOnly = body.switchOnly;
+ if (url.pathname === "/api/provider/keeplogin") w.active = w.keepAs = body.keepLoginAs;
+ return json(providersOf(w));
+ }
+ 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 K = {
+ head: "Switch accounts only",
+ title: "Switch accounts only: {agent} is signed in as {user}. Pick another of its accounts to sign {agent} in to it, without connecting it to magpie.",
+ switched: "Switched",
+ manage: "Manage accounts…",
+ only: "Only switch {agent}'s sign-in",
+ said: "{agent} is now signed in as {user}. New {agent} sessions use this account; one already open keeps its account until it is started again.",
+ onlyLine: "Not connected · switching accounts only",
+ sub: "Not connected · now on its Claude subscription",
+};
+const row = (id) => `.row.agent[data-id="${id}"]`;
+
+async function open(engine, lang, width, w, t) {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ t.after(() => browser.close());
+ const page = await (await browser.newContext({ viewport: { width, height: 640 }, reducedMotion: "reduce" })).newPage();
+ page.setDefaultTimeout(5000);
+ const errors = [], dialogs = [], posts = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ page.on("dialog", (d) => { dialogs.push(d.message()); d.dismiss(); });
+ await page.route("**/*", server(lang, w, posts));
+ await page.goto("http://magpie.test/?view=agents");
+ await page.locator(`${row("claude")} .ag-st`).waitFor();
+ const tr = async (k, vars = {}) => {
+ const s = await page.evaluate(([k, lang]) => (lang === "en" ? k : I18N[lang]?.[k]), [k, lang]);
+ assert.ok(s, `${lang} has ${k.slice(0, 40)}`);
+ return Object.entries(vars).reduce((s, [k, v]) => s.replaceAll(`{${k}}`, v), s);
+ };
+ const scrolled = () => page.evaluate(() => [document.scrollingElement.scrollTop, document.querySelector("#view-agents")?.scrollTop]);
+ return { page, errors, dialogs, posts, tr, scrolled };
+}
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
+ for (const width of [980, 420]) {
+ test(`${engine} ${lang} ${width}px: a Claude Code not connected says its account and switches it`, async (t) => {
+ const w = { active: "[email protected]" };
+ const { page, errors, dialogs, posts, tr, scrolled } = await open(engine, lang, width, w, t);
+ const cc = { agent: "Claude Code" };
+ for (const k of Object.values(K)) await tr(k);
+ const st = page.locator(`${row("claude")} .ag-st`);
+ const who = st.locator("button.ag-acc.ag-who");
+ await who.waitFor();
+ assert.equal(await st.locator(".ag-st-t").textContent(), await tr(K.sub));
+ assert.equal(await who.locator(".v").textContent(), "[email protected]");
+ assert.equal(await who.getAttribute("title"), await tr(K.title, { ...cc, user: "[email protected]" }));
+ assert.equal(await who.locator(".ok").isVisible(), false);
+ // the WSL twin has no list of its own here: no entry
+ assert.equal(await page.locator(`${row("claude@wsl:Ubuntu-24.04")} .ag-who`).count(), 0);
+ const wide = await page.evaluate(() => document.scrollingElement.scrollWidth - document.scrollingElement.clientWidth);
+ assert.ok(wide <= 0, `the page scrolls sideways by ${wide}px`);
+ const box = await who.boundingBox();
+ assert.ok(box && box.x >= 0 && box.x + box.width <= width, `button off screen: ${JSON.stringify(box)}`);
+ const top = await scrolled();
+
+ await who.click();
+ const menu = page.locator(".proto-menu");
+ await menu.waitFor();
+ assert.equal(await menu.locator(".pm-head").textContent(), await tr(K.head));
+ assert.equal(await who.getAttribute("aria-expanded"), "true");
+ const items = menu.locator(".pm-item .pm-name");
+ assert.deepEqual(await items.allTextContents(), ["[email protected]", "[email protected]", await tr(K.only, cc), await tr(K.manage)]);
+ assert.equal(await menu.locator(".pm-item.on .pm-name").allTextContents().then((x) => x.join()), "[email protected]");
+ const mb = await menu.boundingBox();
+ assert.ok(mb.x >= 0 && mb.x + mb.width <= width, `menu off screen: ${JSON.stringify(mb)}`);
+ await menu.locator(".pm-item", { hasText: "[email protected]" }).click();
+ await page.waitForFunction(() => document.querySelector('.row.agent[data-id="claude"] .ag-who .v')?.textContent === "[email protected]");
+ assert.deepEqual(posts, [["/api/login/switch", { agent: "claude", user: "[email protected]" }]]);
+ const now = st.locator("button.ag-who");
+ assert.ok(await now.locator(".ok").isVisible(), "Switched shows on the button");
+ assert.equal((await now.locator(".ok").textContent()).trim(), await tr(K.switched));
+ assert.equal(await page.locator("#status").textContent(), await tr(K.said, { ...cc, user: "[email protected]" }));
+
+ // Only switch Claude Code's sign-in, ticked from the same menu
+ await now.click();
+ await menu.waitFor();
+ const only = menu.locator(".pm-item", { hasText: await tr(K.only, cc) });
+ assert.equal(await only.getAttribute("role"), "menuitemcheckbox");
+ assert.equal(await only.getAttribute("aria-checked"), "false");
+ await only.click();
+ await page.waitForFunction((s) => document.querySelector('.row.agent[data-id="claude"] .ag-st-t')?.textContent === s, await tr(K.onlyLine));
+ assert.deepEqual(posts[1], ["/api/provider/switchonly", { id: "claude", switchOnly: true }]);
+ await st.locator("button.ag-who").click();
+ await menu.waitFor();
+ assert.equal(await menu.locator(".pm-item", { hasText: await tr(K.only, cc) }).getAttribute("aria-checked"), "true");
+ await page.keyboard.press("Escape");
+
+ // Codex, one account: its entry, with no toggle to offer
+ const cx = page.locator(`${row("codex")} .ag-who`);
+ assert.equal(await cx.locator(".v").textContent(), "[email protected]");
+ await cx.click();
+ await menu.waitFor();
+ assert.deepEqual(await menu.locator(".pm-item .pm-name").allTextContents(), ["[email protected]", await tr(K.manage)]);
+ await menu.locator(".pm-item", { hasText: await tr(K.manage) }).click();
+ await page.waitForFunction(() => new URL(location.href).searchParams.get("edit") === "codex");
+
+ assert.equal(posts.length, 2);
+ assert.deepEqual(dialogs, []);
+ assert.deepEqual(errors, []);
+ assert.ok(top.every((v) => v === 0 || v === undefined), `page was scrolled ${top}`);
+ });
+ }
+ }
+
+ test(`${engine}: one kept signed in to an account of its choosing moves that choice`, async (t) => {
+ const w = { active: "[email protected]", keepAs: "[email protected]" };
+ const { page, errors, posts } = await open(engine, "en", 980, w, t);
+ const who = page.locator(`${row("claude")} .ag-who`);
+ await who.click();
+ await page.locator(".proto-menu .pm-item", { hasText: "[email protected]" }).click();
+ await page.waitForFunction(() => document.querySelector('.row.agent[data-id="claude"] .ag-who .v')?.textContent === "[email protected]");
+ assert.deepEqual(posts, [["/api/provider/keeplogin", { id: "claude", keepLogin: true, keepLoginAs: "[email protected]" }]]);
+ assert.deepEqual(errors, []);
+ });
+
+ test(`${engine}: a connected Claude Code has no account switch on its row`, async (t) => {
+ const { page, errors } = await open(engine, "en", 980, { active: "[email protected]", wired: true }, t);
+ await page.locator(`${row("codex")} .ag-who`).waitFor();
+ assert.equal(await page.locator(`${row("claude")} .ag-who`).count(), 0);
+ assert.deepEqual(errors, []);
+ });
+}