claude-desktop: Use Claude Magpie, a twin on magpie in one click (xMopf7RF on X)

xMopf7RF asked for the Separate app to be reached like a phone's app
twin: one button that makes a second Claude Desktop on magpie and leaves
their own Claude Desktop as it is. Claude Desktop's row, while it isn't
on magpie and Desktop can run so (macOS), now has "Use Claude Magpie":
it turns the Separate app on (settings/desktop-isolated) and then
connects Desktop, so only Claude-Magpie-3p is wired, and says to open
Claude Magpie from Applications. The order matters: connecting first
would wire the user's own Desktop.

The button is drawn by claudemagpie.js with the fold; app.js keeps the
one line that places it, so the core budget goes up by 81.

Run, at this commit:
- TestCoreScriptBudget; gofmt clean.
- GUI on mote, Chromium and WebKit: desktop-twin (five languages, 1100
  and 640px: the posts in order, the status, the button gone after, no
  scroll, no native select; no button without the Separate app),
  desktop-isolated-claude, desktop-isolated, i18n-keys, i18n-en-no-cjk,
  old-webkit (its two reds are on origin/main, #6467, #5919), and every
  agent*/desktop*/claude* GUI file; its reds are all on origin/main
  (#6467, #5919, #6373, #5925, #6179, #6371, #6475).

Broken by hand: connecting before turning the Separate app on turns
desktop-twin red (the post order).

Not tried: clicking the button in a real Desktop; the two calls it makes
are the ones the commit before ran for real (launcher add, then claude-
desktop magpie, in a sandbox HOME on mote).
This commit is contained in:
yetone
2026-11-13 16:02:12 +08:00
parent 6bc0d1e203
commit 5a2d0ff478
6 changed files with 164 additions and 7 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ something else shows up as drift.
- Claude Desktop's sessions (Code and Cowork, `claude-code-sessions` and `local-agent-mode-sessions`) are kept in the userData Desktop runs in, keyed by account and organization (the claude.ai login signed in; in 3p the install id in `ant-did` and the profile's organization, both stable). So on magpie, in `Claude-3p`, the sessions made signed in with Anthropic are out of sight but untouched in `Claude`, and they show again when Desktop is switched back (lambdua on X: "切换账号,对话都不见"); claude.ai chats live on Anthropic's servers and 3p never shows them as they are. magpie never writes or removes a session. Desktop imports them itself (Settings → Import: the signed-in userData, `~/.claude/projects`, other `Claude*` folders, and Claude.ai's own chats and projects, through a Claude.ai sign-in in the importer (`arm: "direct"`, `remotePull` in 4.16336's `getImportCapabilities`) or its data export zip), copying under new ids that go on on the gateway and leaving the originals, but in 3p only when the profile's policy `claudeAiImport.enabled` is true (off by default, 3p only, from 1.28929.0). magpie's profile gets `"claudeAiImport":{"enabled":true,"bannerBehavior":"detect"}` once per folder set (`desktopSeedImport`, marked in the stash as `claude-desktop.import`): on the switch on and, for a Desktop already on magpie, from `Sync` at magpie's start. A `claudeAiImport` already there is kept, and one the user removes is not written again (`TestClaudeDesktopOffersItsSessionImport`). The opened row and the notice after On point there (`noticeClaudedesktop5`; Jacky_yyyyyyyy on X asked to go on with the earlier chats on magpie).
- Claude Desktop's 3p mode reads its MCP servers (Settings → Developer, its connector list) from `Claude-3p/claude_desktop_config.json`, a file of its own, so on magpie the servers the user added signed in with Anthropic, in `Claude/claude_desktop_config.json`, were gone from the list (aa86222 on Discord: connectors didn't sync). Turning Desktop onto magpie copies each of those `mcpServers` entries that `Claude-3p` has none of the same name for (`desktopCarryMCP` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)); one of that name already there, the user's or the Library's (which writes both files), stays. `Sync` does it once for a Desktop already on magpie (`claude-desktop.mcp-seen`), so a server the user takes out in 3p isn't brought back. What was copied is stashed (`claude-desktop.mcp`), and off takes back each one still as copied; one the user changed since stays (`TestClaudeDesktopCarriesTheMCPServers`, `TestClaudeDesktopMCPKeepsThe3pServers`, `TestClaudeDesktopSyncCarriesTheMCPServersOnce`). Claude's file is never written. A claude.ai account's connectors can't come along: Desktop calls them through claude.ai with that account (`/api/organizations/<org>/mcp/servers/<id>/tools/call`, refused with `no_active_org` without one, Desktop 2.7032), and 3p mode has no account; Anthropic's docs say "Made by Anthropic" connectors are only in standard Desktop, and others reach 3p through `managedMcpServers` or plugins (claude.com/docs/third-party/claude-desktop/extensions).
- On a Mac, Claude Desktop on magpie can run beside the user's own Claude Desktop signed in with Anthropic (#5671, baranwang on X): off by default (`settings.DesktopIsolated`); turned on by the "Separate app" switch in Claude Desktop's opened row (`POST /api/settings/desktop-isolated`) or `magpie claude-desktop launcher add`, both `SetDesktopIsolated` in [`claudedesktop_isolated.go`](../../internal/agent/claudedesktop_isolated.go). It makes `~/Applications/Claude Magpie.app` ([`desktopiso`](../../internal/desktopiso/desktopiso.go): Claude's own icon with a magpie badge, an `sh` executable that runs Claude.app's executable with `--user-data-dir=~/Library/Application Support/Claude-Magpie-3p` and opens no second one while it runs) and moves a Desktop on magpie there: the usual sets are put back as before magpie (`desktopOff`) and the isolated set (`desktopIsolatedSet`, stash key `.isolated`, MCP servers and language read from the user's own Desktop) gets the 3p mode. While on, `desktopSets` is that set alone; the row's file stays the user's own. The folder ends in `-3p` because Desktop (`GY()` in 4.4212's app.asar) adds `-3p` to a userData that doesn't, and `CLAUDE_USER_DATA_DIR` is dropped by the packaged app, so only the flag works. Windows hardcodes `%LOCALAPPDATA%\Claude-3p`, so it is macOS only (`desktopdir.Isolated` is "" elsewhere). Two Claude.app processes then run: `desktopInstance` (`restartable.macCmd`) keeps Restart and "running on the old settings" on the wired one, and Restart quits the isolated one by `pkill -TERM` on its command line (`desktopIsoQuit`) and opens the app again. The gateway's model selector reads Claude-Magpie-3p first (`desktopSelectorRoots`). Not done: the Dock shows Claude's own icon for the running isolated Desktop, and Desktop turns its Chrome pairing off in a moved userData.
- Claude Magpie's Code tab can have a Claude Code folder of its own (#6459, xMopf7RF on X): off by default (`settings.DesktopIsolatedClaude`), set under the Separate app's Advanced fold (`POST /api/settings/desktop-isolated-claude`, drawn by `claudemagpie.js`) or `magpie claude-desktop launcher claude-dir on|off`, both `SetDesktopIsolatedClaude`. While on, and the Separate app is on, the app's script exports `CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop` (`desktopiso.Script`'s `claudeDir`), which Desktop passes to its bundled Claude Code, and `desktopOn` in [`claude.go`](../../internal/agent/claude.go) writes Desktop's model windows, caps and explore entries into that folder's `settings.json` instead of `~/.claude`'s (`desktopCodeDir`, `desktopClaudeSync`); off moves them back. The folder stays when it is turned off, and it is a `claude#` row named "Claude Code · Claude Magpie" (`claudeDirAgents`). A change remakes the app; a running Claude Magpie keeps the old environment until it is quit and opened again. Its Library has no targets yet. `TestClaudeDesktopIsolatedClaudeDir`, `TestScriptClaudeConfigDir`, `desktop-isolated-claude.test.cjs`.
- Claude Magpie's Code tab can have a Claude Code folder of its own (#6459, xMopf7RF on X): off by default (`settings.DesktopIsolatedClaude`), set under the Separate app's Advanced fold (`POST /api/settings/desktop-isolated-claude`, drawn by `claudemagpie.js`) or `magpie claude-desktop launcher claude-dir on|off`, both `SetDesktopIsolatedClaude`. While on, and the Separate app is on, the app's script exports `CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop` (`desktopiso.Script`'s `claudeDir`), which Desktop passes to its bundled Claude Code, and `desktopOn` in [`claude.go`](../../internal/agent/claude.go) writes Desktop's model windows, caps and explore entries into that folder's `settings.json` instead of `~/.claude`'s (`desktopCodeDir`, `desktopClaudeSync`); off moves them back. The folder stays when it is turned off, and it is a `claude#` row named "Claude Code · Claude Magpie" (`claudeDirAgents`). A change remakes the app; a running Claude Magpie keeps the old environment until it is quit and opened again. Its Library has no targets yet. The "Use Claude Magpie" button on Claude Desktop's row while it isn't on magpie turns the Separate app on and then connects Desktop (`desktopTwinBtn`, also `claudemagpie.js`), so only Claude-Magpie-3p is wired and the user's own Desktop is left as it was. `TestClaudeDesktopIsolatedClaudeDir`, `TestScriptClaudeConfigDir`, `desktop-isolated-claude.test.cjs`, `desktop-twin.test.cjs`.
- Claude Desktop names a Claude model with reasoning levels after its own catalog ("Opus 5.5"), not by the `display_name` magpie lists, because magpie lists it as `magpie-<number>.anthropic.<model>` to keep its effort picker (`claudeLooking` in [`desktop.go`](../../internal/gateway/desktop.go)). Desktop 4.4212 labels a picker row by its catalog's name before `display_name` (only an admin's `inferenceModels` list carries the `labelOverride` that beats it; magpie writes one, with each row's `display_name`, only while a tier is picked), so two providers' rows of one model read alike and Desktop adds the tail of the id, "Opus 5.5 (…7922287072.anthropic.claude-opus-5-5)". Desktop shows the gateway's `description` under the name, before the catalog's, so such a row's description names its provider when the Provider in model names setting puts it after the name (`desktopSaidBy`: on, every one; off, only two of one name), and a 1M row listed by its `[1m]` id says "1M context window · <provider>" (4 v5 on Discord, `TestClaudeDesktopCatalogNamedSaysProvider`). The id stays as it was. The provider editor shows the number too on the model's chip (`gateway.DesktopNumber`, `desktopNumbers` in [`providers.go`](../../internal/gui/providers.go), #2578). The chip shows it only while Claude Desktop is installed and is shown that model. Every other model Desktop is shown carries no number on the chip: Desktop names it by `display_name`, which already says the provider, or by its own id.
- Codex's `spawn_agent` tool names only the first five models of its catalog to the lead (codex-rs `MAX_SPAWN_AGENT_MODEL_OVERRIDES` in `child_config.rs`, `spawn_agent_models_description`), Codex's own ahead of magpie's, though it takes any catalog model by name (`find_spawn_agent_model_name`). So a lead could put its subagents on none of magpie's models (Gearclickist on Discord). The gateway adds the rest of the catalog Codex was handed to that tool's description, after Codex's own list, at most 200 (`spawnAgentModels` in [`codex_spawn_models.go`](../../internal/gateway/codex_spawn_models.go)). A model that can search tools (`supports_search_tool`) isn't handed it in the request's tools: Codex defers its multi-agent V1 tools behind `tool_search` (codex-rs `core/src/tools/spec_plan.rs`), and the lead gets `spawn_agent` in the `tool_search_output` Codex puts in the conversation and sends again every turn, so that one is widened too. That text goes upstream with the prompt, to OpenAI too for a ChatGPT lead, so its header (`spawnMore`) stays neutral: it names neither magpie nor Codex's limit. At `CodexPath` that is Codex's own listed models less the hidden ones, then `CodexListed` unless Codex is held to its own. At `/v1` it is `CodexCatalog` under the key's allowance. A lead the ChatGPT backend answers in multi-agent V2 seals its subagents' tasks for a ChatGPT account (#619), so it gets Codex's own only. The model catalog Codex puts in context under `model_catalog_in_context` (under development, off by default) is capped at five too, and isn't widened.
- Snow CLI runs on one profile at a time (`profiles/<name>.json` in `~/.snow` or `$SNOW_CONFIG_DIR`, named in `active-profile.json`) and copies the active one over `config.json` at every start, `snow --ask` too ([`snow.go`](../../internal/agent/snow.go)). magpie writes a `magpie` profile, makes it the active one, and copies it to `config.json` itself, so a Snow already running and Snow App's "Sync Snow CLI API config" see the same. It is made from the profile the user was on, their settings kept and its OAuth sign-in left out. A vision model of that profile comes along only with an endpoint and key of its own (`snowOwnVision`), since one on the profile's would now go to the gateway. `maxContextTokens`, `maxTokens` and `supportsVision` follow the model from the catalog (`snowSynced`; `supportsVision` as every agent is told, true while magpie's Vision describes images); what magpie last wrote of them is stashed, and one the user changed since in Snow's own settings is kept through later picks and syncs. The small field is magpie's profile's `basicModel`, Snow's light model for summaries, compaction and file search: empty while it follows the main model, a model through magpie of its own kept through new main models and syncs; on a profile of the user's it offers nothing and is hidden. The thinking field is magpie's profile's `chatThinking` (`{enabled: true, reasoning_effort}`), the only thinking setting Snow reads on the chat protocol; empty deletes it, Snow's default, which sends thinking disabled. A chatThinking the user brought from their profile is shown, not written over. The profile they were on (or that there was no `active-profile.json`) and a `magpie.json` of their own are stashed and put back by Disconnect. A Snow from before profiles (`config.json` alone) gets the `default.json` Snow itself would have made of it, so its next start doesn't take magpie's for the user's. Picking a model of another of the user's profiles switches Snow to that profile. On magpie's profile, a value that is neither a model through magpie nor the model of one of the user's profiles is refused and changes nothing (#1457: `magpie snow --help` used to take magpie out and write `--help` as the model of the profile it went back to). Gemini CLI's auth field refuses an auth it doesn't know before it unroutes, for the same reason. On the CLI, `-h`/`--help` after any command or agent only prints its usage, before `run` reads or moves anything, and any other flag given to `magpie <agent> …` is refused (`help_cli.go`; `TestHelpOnEveryCommandDoesNothing` walks `run`'s switch and every agent).
+3 -2
View File
@@ -1413,6 +1413,7 @@ function connectLine(a, kind) {
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));
if (a.isolated && !a.isolated.on) line.append(isoLazy("desktopTwinBtn", a));
return line;
}
if (a.native) {
@@ -1969,8 +1970,8 @@ const desktopIsolatedLine = (iso) => agSwitchLine("ag-isolated", !!iso.on, "Clau
status(on ? t("Open Claude Magpie from Applications") : t("Claude Magpie removed"), "ok");
});
// isoLazy: Claude Magpie's Advanced fold (#6459), drawn by
// claudemagpie.js, imported the first time it shows
// isoLazy: Claude Magpie's twin button and its Advanced fold
// (#6459), drawn by claudemagpie.js, imported the first time either shows
const isoLazy = (f, x, at = el("span")) => (at.hidden = 1, import("./claudemagpie.js").then(() => at.replaceWith(window[f](x)), () => {}), at);
const desktopLongestLine = () => agSwitchLine("ag-longest", !!state.settings?.desktopLongest, t("Only each model's largest window"), t("A model of 1M or more is listed once, as its 1M entry. Quit and reopen Claude Desktop after a change."), async (on) => {
+28 -3
View File
@@ -1,6 +1,31 @@
// Claude Magpie (#6459, xMopf7RF on X): the Separate app's Advanced fold.
// app.js imports this the first time it shows (isoLazy), so it
// weighs nothing on the core.
// Claude Magpie (#6459, xMopf7RF on X): the Agents page's "Use Claude
// Magpie" button and the Separate app's Advanced fold. app.js imports this
// the first time either shows (isoLazy), so it weighs nothing on the
// core.
// desktopTwinBtn: Claude Magpie.app made and put on magpie in one go, the
// user's own Claude Desktop left as it is (xMopf7RF on X, #6459), like a
// phone's app twin: its own app, its own folder
window.desktopTwinBtn = function (a) {
const b = el("button", "ag-quiet ag-twin", t("Use Claude Magpie"));
b.type = "button";
b.title = t("A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.");
b.onclick = async (e) => {
e.stopPropagation();
if (b.disabled) return;
b.disabled = true;
try {
state = await api("settings/desktop-isolated", { on: true });
state = await api("agents/connect/" + a.id, {});
renderAgents();
status(t("Open Claude Magpie from Applications"), "ok");
} catch (err) {
renderAgents();
status(t(err.message), "err");
}
};
return b;
};
// the Claude Magpie app's Code tab on a Claude Code folder of its own
// (#6459): set once, seldom changed, so it waits under Advanced, open while
// it is on or the user opened it
+8
View File
@@ -4894,6 +4894,8 @@ const I18N = {
"Its own Claude Code folder": "这个分身自己的 Claude Code 文件夹",
"Its Code tab uses {path}, without your CLAUDE.md, skills, plugins or history. Quit and reopen Claude Magpie after a change.": "它的 Code 标签页使用 {path},不带你的 CLAUDE.md、技能、插件和历史记录。改动后退出并重新打开 Claude Magpie。",
"Saved — quit and reopen Claude Magpie to use it": "已保存——退出并重新打开 Claude Magpie 后生效",
"Use Claude Magpie": "启用 Claude Magpie",
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "在「应用程序」里加一个接入 magpie 的 Claude Desktop 分身,你自己的 Claude Desktop 保持不变。仅限 macOS。",
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "从「应用程序」打开 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 保持 Anthropic 登录。",
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "如果 Claude Magpie 正在运行,请退出它:它已不再使用 magpie。",
"Telemetry": "遥测",
@@ -10074,6 +10076,8 @@ const I18N = {
"Its own Claude Code folder": "這個分身自己的 Claude Code 資料夾",
"Its Code tab uses {path}, without your CLAUDE.md, skills, plugins or history. Quit and reopen Claude Magpie after a change.": "它的 Code 分頁使用 {path},不帶你的 CLAUDE.md、技能、外掛和歷史記錄。變更後結束並重新開啟 Claude Magpie。",
"Saved — quit and reopen Claude Magpie to use it": "已儲存——結束並重新開啟 Claude Magpie 後生效",
"Use Claude Magpie": "啟用 Claude Magpie",
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "在「應用程式」裡加一個接入 magpie 的 Claude Desktop 分身,你自己的 Claude Desktop 保持不變。僅限 macOS。",
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "從「應用程式」打開 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 維持 Anthropic 登入。",
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "如果 Claude Magpie 正在執行,請結束它:它已不再使用 magpie。",
"Telemetry": "遙測",
@@ -15256,6 +15260,8 @@ const I18N = {
"Its own Claude Code folder": "専用の Claude Code フォルダ",
"Its Code tab uses {path}, without your CLAUDE.md, skills, plugins or history. Quit and reopen Claude Magpie after a change.": "Code タブは {path} を使います。あなたの CLAUDE.md、スキル、プラグイン、履歴は引き継がれません。変更後は Claude Magpie を終了して開き直してください。",
"Saved — quit and reopen Claude Magpie to use it": "保存しました。Claude Magpie を終了して開き直すと反映されます",
"Use Claude Magpie": "Claude Magpie を使う",
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "magpie につながる 2 つ目の Claude Desktop を「アプリケーション」に追加します。ご自身の Claude Desktop は変わりません。macOS のみ。",
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "「アプリケーション」から Claude Magpie を開くと、magpie で Claude Desktop を使えます。ご自身の Claude Desktop は Anthropic にサインインしたままです。",
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "Claude Magpie を開いている場合は終了してください。もう magpie では動きません。",
"Telemetry": "テレメトリ",
@@ -20438,6 +20444,8 @@ const I18N = {
"Its own Claude Code folder": "Eigener Claude-Code-Ordner",
"Its Code tab uses {path}, without your CLAUDE.md, skills, plugins or history. Quit and reopen Claude Magpie after a change.": "Der Code-Tab nutzt {path}, ohne deine CLAUDE.md, Skills, Plugins und Verlauf. Beende Claude Magpie nach einer Änderung und öffne es neu.",
"Saved — quit and reopen Claude Magpie to use it": "Gespeichert – beende Claude Magpie und öffne es neu, um es zu nutzen",
"Use Claude Magpie": "Claude Magpie nutzen",
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "Ein zweites Claude Desktop auf magpie unter Programme. Dein eigenes Claude Desktop bleibt, wie es ist. Nur macOS.",
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "Öffne Claude Magpie unter Programme, um Claude Desktop über magpie zu nutzen. Dein eigenes Claude Desktop bleibt bei Anthropic angemeldet.",
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "Beende Claude Magpie, falls es offen ist: Es läuft nicht mehr über magpie.",
"Telemetry": "Telemetrie",
+1 -1
View File
@@ -18,7 +18,7 @@ import (
// `git log -L` of this file.
const (
appScriptBudget = 1_086_267 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had
coreScriptBudget = 1_267_942 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was (#2710)
coreScriptBudget = 1_268_023 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710)
)
// codeBytes is how many bytes of b are code: its blank lines, its lines
+123
View File
@@ -0,0 +1,123 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Claude Magpie as a twin (xMopf7RF on X, #6459): Claude Desktop's row,
// not on magpie, has a "Use Claude Magpie" button on a Mac. It turns the
// Claude Magpie app on and then connects Desktop, which puts only that
// app on magpie; the user's own Desktop isn't wired. The button is gone
// once the app is on, and isn't there off a Mac (no isolated in the state).
// No click scrolls the page. Every language, wide and narrow, both
// engines. No backend: 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");
function fixture(lang, offered = true) {
const settings = { lang, theme: "light" };
const posts = [];
const iso = { on: false };
let wired = false;
const state = () => ({
agents: [{
id: "claude-desktop", name: "Claude Desktop", path: "/test/claude_desktop_config.json", icon: "claude-color", wired,
fields: [{ key: "provider", label: "provider", value: wired ? "magpie" : "", options: [{ value: "magpie", label: "magpie", icon: "magpie" }] }],
models: { shown: 2, listed: 2, by: [{ name: "OpenCode Go", icon: "opencode", n: 2 }], names: ["DeepSeek V4 Pro", "Exo Free"] },
...(offered ? { isolated: { ...iso } } : {}),
}],
profiles: [], settings,
});
async function serve(route) {
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json(state());
if (url.pathname === "/api/settings/desktop-isolated") {
posts.push(["isolated", req.postDataJSON()]);
iso.on = req.postDataJSON().on;
iso.launcher = "/test/Applications/Claude Magpie.app";
return json(state());
}
if (url.pathname === "/api/agents/connect/claude-desktop") {
posts.push(["connect", iso.on]);
wired = true;
return json(state());
}
if (url.pathname === "/api/usage/quotas") return json([]);
if (url.pathname === "/api/groups") return json({ groups: [] });
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true } });
if (url.pathname === "/api/plugins") return json({ plugins: [] });
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 });
}
return { serve, posts };
}
const W = {
en: { b: "Use Claude Magpie", tip: "A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.", ok: "Open Claude Magpie from Applications" },
zh: { b: "启用 Claude Magpie", tip: "在「应用程序」里加一个接入 magpie 的 Claude Desktop 分身,你自己的 Claude Desktop 保持不变。仅限 macOS。", ok: "从「应用程序」打开 Claude Magpie" },
"zh-TW": { b: "啟用 Claude Magpie", tip: "在「應用程式」裡加一個接入 magpie 的 Claude Desktop 分身,你自己的 Claude Desktop 保持不變。僅限 macOS。", ok: "從「應用程式」打開 Claude Magpie" },
ja: { b: "Claude Magpie を使う", tip: "magpie につながる 2 つ目の Claude Desktop を「アプリケーション」に追加します。ご自身の Claude Desktop は変わりません。macOS のみ。", ok: "「アプリケーション」から Claude Magpie を開いてください" },
de: { b: "Claude Magpie nutzen", tip: "Ein zweites Claude Desktop auf magpie unter Programme. Dein eigenes Claude Desktop bleibt, wie es ist. Nur macOS.", ok: "Öffne Claude Magpie unter Programme" },
};
const cd = '.row.agent[data-id="claude-desktop"]';
const twin = `${cd} .ag-twin`;
async function open(engine, lang, width, offered, t) {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await browser.newPage({ viewport: { width, height: 700 } });
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
const fx = fixture(lang, offered);
await page.route("**/*", fx.serve);
t.after(() => browser.close());
await page.goto("http://magpie.test/");
await page.locator(cd).waitFor({ state: "attached" });
// not on magpie, its row is among the folded ones
if (await page.locator(`.agent-fold ${cd}`).count()) {
await page.locator(".agent-more").click();
await page.waitForFunction(() => !document.querySelector(".agent-fold-inner")?.inert);
}
return { page, fx, errors };
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(W)) {
for (const width of [1100, 640]) {
test(`${engine} ${lang} ${width}px: Use Claude Magpie makes the app and puts it alone on magpie`, async (t) => {
const w = W[lang];
const { page, fx, errors } = await open(engine, lang, width, true, t);
const b = page.locator(twin);
await b.waitFor();
assert.equal(await b.textContent(), w.b);
assert.equal(await b.getAttribute("title"), w.tip);
const box = await b.boundingBox();
assert.ok(box.x + box.width <= width && box.height > 0, JSON.stringify(box));
const y = await page.evaluate(() => scrollY);
await b.click();
await page.locator(`${cd} .ag-conn.on`).waitFor();
// the app on first, so connecting wires its folder, not the user's
assert.deepEqual(fx.posts, [["isolated", { on: true }], ["connect", true]]);
assert.equal(await page.locator("#status").textContent(), w.ok);
assert.equal(await page.locator(twin).count(), 0, "still offered once on");
assert.equal(await page.evaluate(() => scrollY), y, "a click scrolled the page");
assert.equal(await page.locator("select").count(), 0, "a native select");
assert.deepEqual(errors, []);
});
}
}
test(`${engine}: no Use Claude Magpie where Desktop can't run so`, async (t) => {
const { page, errors } = await open(engine, "en", 1100, false, t);
await page.locator(`${cd} .ag-st`).waitFor();
assert.equal(await page.locator(twin).count(), 0);
assert.deepEqual(errors, []);
});
}