claude-desktop: a new Claude Magpie leaves the original alone, its own Claude Code folder included (xMopf7RF on X)
xMopf7RF asked for Claude Magpie to be a full clone, like an Android app twin: making it from magpie must not wire their own Claude Desktop or touch its config. In a sandbox HOME on mote with the real Claude.app (`launcher add`, then `claude-desktop magpie`, as "Use Claude Magpie" does), origin/mainf798b4eb7left Claude's and Claude-3p's files byte-identical, but: - ~/.claude/settings.json got Desktop's Explore flag (and, with models on magpie, Desktop's windows and caps): the twin's Code tab ran on the user's own Claude Code folder, since its own folder (#6459) was opt-in; - `launcher remove` then put the user's own Desktop on magpie (deploymentMode 3p in Claude/claude_desktop_config.json, Claude-3p's configLibrary): turning the Separate app off always moved the wiring back to the usual folders, even when it never came from them. Decided (product calls are delegated): - A Claude Magpie made new gets ~/.claude-magpie-desktop (desktopIsoClaudeDefault in SetDesktopIsolated). Made new is the app off and no Claude-Magpie-3p folder yet, and the user never set the option: settings.DesktopIsolatedClaudeChosen, set by the Advanced fold and `launcher claude-dir`. A clone made before (chats in Claude-Magpie-3p, Code tab on ~/.claude) and a user's off are kept. The option itself stays where it was; no new UI. - Off moves the wiring back only when it came from the user's own Desktop (stash claude-desktop.isolated-from-own, set when the on path moves it). A twin made beside a Desktop not on magpie leaves that Desktop off magpie. A Separate app turned on before this mark (since 11-09) also leaves it off when turned off; connecting it again is one click, while wiring a signed-in Desktop the user didn't ask for is the harm reported. Run (mote, at this change on f798b4eb7; after the rebase onto7af7a3aba, which changed internal/agent, agent and settingsapi tests and vet ran again: ok): - Sandbox HOME, real Claude.app, the same three steps as above: Claude, Claude-3p, ~/.claude and ~/.claude.json byte-identical after add and connect and after remove; the twin's app script exports CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop and Desktop's Explore flag went into that folder. Second sandbox: own Desktop wired, `claude-dir off`, `launcher add` moved it into the clone (Code tab on ~/.claude, as chosen), `launcher remove` moved it back. Sandboxes removed. - go test -tags nogui agent, cli, settings, settingsapi, desktopiso, desktopdir: all ok. gui TestSettingsSaveKeeps*, TestCoreScriptBudget ok. - gofmt -l clean; go vet ./... (darwin), GOOS=linux -tags nogui and GOOS=windows go vet ./..., linux and windows builds: ok. - GUI, Chromium and WebKit: desktop-twin, desktop-isolated-claude, desktop-isolated, i18n-keys: 72 of 72 (no GUI file changed). Broken by hand: - Off always moving back (no mark check): TestClaudeMagpieTwinLeaves TheOriginal red ("the user's own on magpie true"). - No desktopIsoClaudeDefault call: the same test red ("its own folder false"). - The default not asking whether the user chose: TestClaudeMagpieOwn FolderKeepsWhatWasSet/chosen_off red ("its own folder turned on"). Not run at push: the full go test -tags nogui ./... (on the f798b4eb7-based tree) was queued on mica behind another session's suite (mote and mica both over their core count), not finished. Not tried: a Code-tab session in the real twin's UI (#6459 saw one write into the folder).
This commit is contained in:
@@ -194,8 +194,8 @@ something else shows up as drift.
|
||||
- Claude Desktop's 3p mode runs in a userData of its own (`Claude-3p`), whose `config.json` (Desktop's own settings, not `claude_desktop_config.json`) starts with no `locale`, so Desktop on magpie came up in the system's language rather than the one picked signed in with Anthropic (memory and Osal on Discord). Turning Desktop onto magpie copies that one key, `locale`, from the signed-in userData's `config.json` (`Claude`, `%APPDATA%\Claude` on Windows, the first set's before the others) into `Claude-3p/config.json` when that file is missing or a JSON object without one (`desktopCarryLocale` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)); only a name Desktop takes for a catalog is carried. A `locale` already in `Claude-3p`, Desktop's or set by hand, is never written over, and no other key of that file is ever written. Off removes the file only when magpie made it and it still holds nothing but the language carried (`TestClaudeDesktopCarriesTheLanguage`, `TestClaudeDesktopKeepsThe3pLanguage`, `TestClaudeDesktopUserEditsThenReapply`). Desktop shows the language only where its 3p window has that catalog: the window is Desktop's bundled UI (`Resources/ion-dist`, 11 catalogs and no Chinese in 2.7032, 2.9939, 3.6556.2, 4.4212.0 and 4.23118.0 (11-05; packed as `Resources/ion-dist.asar` from 4.4212.0; 4.23118.0's `frame-shell` catalogs in `app.asar` are the same 11), while 3.6556.2's main process has `zh-Hans` and `zh-Hant` for the signed-in window). On every start that window asks the main process for its own pick (`requestLocaleChange`: its localStorage, else `navigator.languages` mapped onto its 11, else `en-US`), and the main process writes it into `Claude-3p/config.json`. So a Chinese `locale` there, carried or set by hand, is `en-US` again after each start, written by Desktop and not by magpie (Dx25 on Discord, Windows); nothing magpie writes can keep it. So the GUI says it to a Chinese reader: Claude Desktop's opened row on Agents has a line that Desktop on magpie is Anthropic's gateway window, with no Chinese, and that its Chinese comes back once disconnected, and the switch-on notice says the same in Chinese (GZXYMH on X, `desktop-lang.test.cjs`).
|
||||
- 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. 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`.
|
||||
- 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. Turned off, the app goes and Claude-Magpie-3p goes off magpie; the wiring goes back to the usual sets only when it came from them (stash `claude-desktop.isolated-from-own`), so a twin made beside a Desktop not on magpie never puts the user's own Desktop on magpie (xMopf7RF on X). One turned on before that mark existed leaves the user's own Desktop off magpie too. 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): `settings.DesktopIsolatedClaude`, on for a Claude Magpie made new and off for one made before. Made new is the app off and no Claude-Magpie-3p folder yet, and the user never set it (`DesktopIsolatedClaudeChosen`, which the fold and the CLI set): then `desktopIsoClaudeDefault` turns it on before the app is made, so the twin's Code tab writes nothing of `~/.claude`, like a phone's app clone. One with chats in Claude-Magpie-3p already, or one the user turned off, keeps `~/.claude`. 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`, `TestClaudeMagpieTwinLeavesTheOriginal`, `TestClaudeMagpieOwnFolderKeepsWhatWasSet`, `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).
|
||||
@@ -242,7 +242,7 @@ go test -tags nogui ./internal/agent -run 'TestVSCode|TestZooCode'
|
||||
go test -tags nogui ./internal/agent -run '^TestStepCode'
|
||||
go test -tags nogui ./internal/agent ./internal/update ./internal/cli -run 'TestAgy|TestShellFunction|TestWithFnBlock|TestShellProfiles'
|
||||
go test -tags nogui ./internal/agent ./internal/update ./internal/cli -run 'TestClaudeLaunch|TestClaudeRun|TestLauncher|TestAddLauncher'
|
||||
go test -tags nogui ./internal/agent ./internal/desktopdir ./internal/desktopiso ./internal/cli -run 'Isolated|TestDesktopInstance|TestAddStartsDesktopOnTheFolder|TestScript|TestAddLeavesTheirs|TestClaudeDesktopLauncher'
|
||||
go test -tags nogui ./internal/agent ./internal/desktopdir ./internal/desktopiso ./internal/cli -run 'Isolated|ClaudeMagpie|TestDesktopInstance|TestAddStartsDesktopOnTheFolder|TestScript|TestAddLeavesTheirs|TestClaudeDesktopLauncher'
|
||||
node --test internal/gui/tests/desktop-isolated.test.cjs
|
||||
node --test internal/gui/tests/agy-launch.test.cjs
|
||||
go test -tags nogui ./internal/agent -run 'TestPiModelsAskedOnTheirNativeAPI|TestPiGoogle'
|
||||
|
||||
@@ -58,24 +58,52 @@ func desktopIsolatedSet(goos, home string, getenv func(string) string) (desktopP
|
||||
// sessions there, ~/.claude untouched). The windows and capabilities of
|
||||
// Desktop's models, which magpie writes into the settings.json of the
|
||||
// Claude Code the Code tab runs (desktopOn in claude.go), go there too,
|
||||
// and ~/.claude/settings.json gets none of them. Off by default
|
||||
// (settings.DesktopIsolatedClaude): the folder starts with none of
|
||||
// ~/.claude's CLAUDE.md, skills, plugins or history.
|
||||
// and ~/.claude/settings.json gets none of them. The folder starts with
|
||||
// none of ~/.claude's CLAUDE.md, skills, plugins or history. A Claude
|
||||
// Magpie made new gets it unless the user chose otherwise
|
||||
// (desktopIsoClaudeDefault); one made before keeps what it had.
|
||||
|
||||
// desktopIsolatedClaudeOn says the user gave the isolated Desktop's Code
|
||||
// tab a folder of its own; a var so a test needs no settings file.
|
||||
var desktopIsolatedClaudeOn = func() bool { return settings.Load().DesktopIsolatedClaude }
|
||||
|
||||
// saveDesktopIsolatedClaude keeps that choice; a var for tests.
|
||||
var saveDesktopIsolatedClaude = func(on bool) error {
|
||||
// desktopIsolatedClaudeChosen says the user set that themselves; a var
|
||||
// so a test needs no settings file.
|
||||
var desktopIsolatedClaudeChosen = func() bool { return settings.Load().DesktopIsolatedClaudeChosen }
|
||||
|
||||
// saveDesktopIsolatedClaude keeps that folder on or off, and chosen when
|
||||
// the user set it; a var for tests.
|
||||
var saveDesktopIsolatedClaude = func(on, chosen bool) error {
|
||||
s, err := settings.LoadChecked()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.DesktopIsolatedClaude = on
|
||||
if chosen {
|
||||
s.DesktopIsolatedClaudeChosen = true
|
||||
}
|
||||
return settings.Save(s)
|
||||
}
|
||||
|
||||
// desktopIsoClaudeDefault gives a Claude Magpie made new a Claude Code
|
||||
// folder of its own, like a phone's app twin (xMopf7RF on X): its Code
|
||||
// tab then reads and writes nothing of ~/.claude. Made new is the app
|
||||
// off and no Claude-Magpie-3p yet; one made before, with chats in that
|
||||
// folder, keeps the ~/.claude its Code tab had, and a choice the user
|
||||
// made either way stays theirs.
|
||||
func desktopIsoClaudeDefault(iso desktopPaths) error {
|
||||
if desktopIsolatedOn() || isDir(iso.dir3p) || desktopIsolatedClaudeOn() || desktopIsolatedClaudeChosen() {
|
||||
return nil
|
||||
}
|
||||
return saveDesktopIsolatedClaude(true, false)
|
||||
}
|
||||
|
||||
// desktopIsolatedFrom marks a Claude Magpie that the user's own Desktop's
|
||||
// wiring moved into when it was turned on: turning it off moves that
|
||||
// back. One made beside a Desktop not on magpie (the twin) leaves the
|
||||
// user's own Desktop off magpie when it goes.
|
||||
const desktopIsolatedFrom = "claude-desktop.isolated-from-own"
|
||||
|
||||
// desktopIsolatedClaudeDir is that folder: ~/.claude-magpie-desktop,
|
||||
// beside ~/.claude, so it is a Claude Code row of its own on the Agents
|
||||
// page (claudeDirAgents) once it holds a settings.json.
|
||||
@@ -174,7 +202,7 @@ func SetDesktopIsolatedClaude(home string, on bool) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := saveDesktopIsolatedClaude(on); err != nil {
|
||||
if err := saveDesktopIsolatedClaude(on, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if desktopiso.Here(home) != "" {
|
||||
@@ -223,11 +251,15 @@ var saveDesktopIsolated = func(on bool) error {
|
||||
}
|
||||
|
||||
// SetDesktopIsolated turns the isolated Desktop on or off for home. On:
|
||||
// Claude Magpie.app is made, and a Desktop on magpie moves there: the
|
||||
// Claude Magpie.app is made (made new, with a Claude Code folder of its
|
||||
// own: desktopIsoClaudeDefault), and a Desktop on magpie moves there: the
|
||||
// user's own Desktop is put back as it was before magpie (desktopOff),
|
||||
// and Claude-Magpie-3p gets magpie's 3p mode. Off: the other way, and the
|
||||
// app is taken away; Claude-Magpie-3p itself, with the chats in it, stays.
|
||||
// It returns the app's path when on.
|
||||
// and Claude-Magpie-3p gets magpie's 3p mode. Off: the app is taken away,
|
||||
// and Claude-Magpie-3p goes off magpie; the wiring goes back to the
|
||||
// user's own Desktop only if it came from there (desktopIsolatedFrom), so
|
||||
// a twin made beside a Desktop not on magpie never puts that one on it.
|
||||
// Claude-Magpie-3p itself, with the chats in it, stays. It returns the
|
||||
// app's path when on.
|
||||
func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
iso, ok := desktopIsolatedSet(desktopdir.OS, home, os.Getenv)
|
||||
if !ok {
|
||||
@@ -239,6 +271,9 @@ func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
if app == "" {
|
||||
return "", ErrDesktopNoApp
|
||||
}
|
||||
if err := desktopIsoClaudeDefault(iso); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := os.MkdirAll(iso.dir3p, 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -264,6 +299,7 @@ func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
stash(map[string]string{desktopIsolatedFrom: "1"})
|
||||
}
|
||||
if err := saveDesktopIsolated(true); err != nil {
|
||||
return "", err
|
||||
@@ -272,20 +308,23 @@ func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
return p, nil
|
||||
}
|
||||
if desktopWired(iso) {
|
||||
desktopAdoptStash(usual)
|
||||
src := desktopLocaleFrom(usual)
|
||||
for _, u := range usual {
|
||||
if src != "" {
|
||||
u.app = src
|
||||
}
|
||||
if err := desktopOn(u); err != nil {
|
||||
return "", err
|
||||
if unstashPeek(desktopIsolatedFrom) != "" {
|
||||
desktopAdoptStash(usual)
|
||||
src := desktopLocaleFrom(usual)
|
||||
for _, u := range usual {
|
||||
if src != "" {
|
||||
u.app = src
|
||||
}
|
||||
if err := desktopOn(u); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := desktopOff(iso); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
forget(desktopIsolatedFrom)
|
||||
if err := saveDesktopIsolated(false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -36,14 +36,15 @@ func isolatedFakes(t *testing.T, home string) (desktopPaths, desktopPaths, *bool
|
||||
if !ok {
|
||||
t.Fatal("no isolated set on darwin")
|
||||
}
|
||||
on, claudeOn := false, false
|
||||
on, claudeOn, chosen := false, false, false
|
||||
var made []string
|
||||
oldOn, oldSave, oldApp, oldAdd := desktopIsolatedOn, saveDesktopIsolated, desktopClaudeApp, desktopIsoAdd
|
||||
oldCOn, oldCSave := desktopIsolatedClaudeOn, saveDesktopIsolatedClaude
|
||||
oldCOn, oldCSave, oldChosen := desktopIsolatedClaudeOn, saveDesktopIsolatedClaude, desktopIsolatedClaudeChosen
|
||||
desktopIsolatedOn = func() bool { return on }
|
||||
saveDesktopIsolated = func(v bool) error { on = v; return nil }
|
||||
desktopIsolatedClaudeOn = func() bool { return claudeOn }
|
||||
saveDesktopIsolatedClaude = func(v bool) error { claudeOn = v; return nil }
|
||||
desktopIsolatedClaudeChosen = func() bool { return chosen }
|
||||
saveDesktopIsolatedClaude = func(v, c bool) error { claudeOn, chosen = v, chosen || c; return nil }
|
||||
claudeApp := filepath.Join(home, "Applications", "Claude.app")
|
||||
desktopClaudeApp = func() string { return claudeApp }
|
||||
desktopIsoAdd = func(home, app, dir, claudeDir string) (string, error) {
|
||||
@@ -59,7 +60,7 @@ func isolatedFakes(t *testing.T, home string) (desktopPaths, desktopPaths, *bool
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
desktopIsolatedOn, saveDesktopIsolated, desktopClaudeApp, desktopIsoAdd = oldOn, oldSave, oldApp, oldAdd
|
||||
desktopIsolatedClaudeOn, saveDesktopIsolatedClaude = oldCOn, oldCSave
|
||||
desktopIsolatedClaudeOn, saveDesktopIsolatedClaude, desktopIsolatedClaudeChosen = oldCOn, oldCSave, oldChosen
|
||||
})
|
||||
return usual, iso, &on, &made
|
||||
}
|
||||
@@ -68,7 +69,7 @@ func isolatedFakes(t *testing.T, home string) (desktopPaths, desktopPaths, *bool
|
||||
// user's own Desktop is put back as it was before magpie, byte for byte,
|
||||
// and Claude-Magpie-3p gets magpie's 3p mode, with the user's language
|
||||
// and MCP servers; the agent then reads and writes that folder. Off moves
|
||||
// it back.
|
||||
// it back, there having been its wiring before.
|
||||
func TestClaudeDesktopIsolatedMovesThere(t *testing.T) {
|
||||
home, usual, iso, on := isolatedSandbox(t)
|
||||
desktopWrite(t, usual.config, `{"mcpServers":{"fs":{"command":"npx"}}}`)
|
||||
@@ -240,6 +241,10 @@ func TestClaudeDesktopIsolatedClaudeDir(t *testing.T) {
|
||||
desktopdir.OS = "darwin"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
_, iso, _, made := isolatedFakes(t, home)
|
||||
// the user chose ~/.claude for it, so a new Claude Magpie keeps that
|
||||
if err := saveDesktopIsolatedClaude(false, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
own := filepath.Join(home, ".claude-magpie-desktop", "settings.json")
|
||||
get := func(f, k string) string { v, _ := edit.GetJSON(f, "env."+k); return v }
|
||||
where := func(want string) {
|
||||
@@ -339,3 +344,102 @@ func TestClaudeDesktopIsolatedClaudeDirOnlyOnAMac(t *testing.T) {
|
||||
t.Fatal("folder made off a Mac")
|
||||
}
|
||||
}
|
||||
|
||||
// A Claude Magpie made beside a Desktop not on magpie is a twin, like a
|
||||
// phone's app clone (xMopf7RF on X): turning it on and connecting, as
|
||||
// "Use Claude Magpie" does, writes nothing of the user's own Desktop or
|
||||
// ~/.claude, since its Code tab gets a Claude Code folder of its own, and
|
||||
// turning it off leaves the user's own Desktop off magpie.
|
||||
func TestClaudeMagpieTwinLeavesTheOriginal(t *testing.T) {
|
||||
home, path := desktopWindowSandbox(t)
|
||||
old := desktopdir.OS
|
||||
desktopdir.OS = "darwin"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
usual, iso, on, made := isolatedFakes(t, home)
|
||||
desktopWrite(t, usual.config, `{"mcpServers":{"fs":{"command":"npx"}}}`)
|
||||
desktopWrite(t, usual.app, `{"locale":"zh-CN"}`)
|
||||
before := desktopTree(t, usual)
|
||||
claudeWas, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
same := func(when string) {
|
||||
t.Helper()
|
||||
if after := desktopTree(t, usual); !reflect.DeepEqual(after, before) {
|
||||
t.Fatalf("%s, the user's own Desktop:\n%v\nwas:\n%v", when, after, before)
|
||||
}
|
||||
if b, _ := os.ReadFile(path); string(b) != string(claudeWas) {
|
||||
t.Fatalf("%s, ~/.claude/settings.json:\n%s\nwas:\n%s", when, b, claudeWas)
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := SetDesktopIsolated(home, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
own := filepath.Join(home, ".claude-magpie-desktop")
|
||||
if !*on || !desktopIsolatedClaudeOn() || desktopIsolatedClaudeChosen() {
|
||||
t.Fatalf("on %v, its own folder %v, chosen %v", *on, desktopIsolatedClaudeOn(), desktopIsolatedClaudeChosen())
|
||||
}
|
||||
if !reflect.DeepEqual(*made, []string{own}) {
|
||||
t.Fatalf("app made with %q", *made)
|
||||
}
|
||||
if err := claudeDesktop(home).Field("provider").Set("magpie"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !desktopWired(iso) || desktopWiredAny(desktopUsualSets("darwin", home, os.Getenv)) {
|
||||
t.Fatal("connecting didn't wire Claude-Magpie-3p alone")
|
||||
}
|
||||
if w, _ := edit.GetJSON(filepath.Join(own, "settings.json"), "env."+claudeContextEnv); w == "" {
|
||||
t.Fatal("its Code tab's folder has no window")
|
||||
}
|
||||
same("on and connected")
|
||||
// the round that syncs every agent keeps it so
|
||||
if err := claude(home).Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
same("synced")
|
||||
|
||||
if _, err := SetDesktopIsolated(home, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if *on || desktopWired(iso) || desktopWiredAny(desktopUsualSets("darwin", home, os.Getenv)) {
|
||||
t.Fatalf("off: on %v, isolated %v; the user's own on magpie %v", *on, desktopWired(iso), desktopWiredAny(desktopUsualSets("darwin", home, os.Getenv)))
|
||||
}
|
||||
same("off")
|
||||
}
|
||||
|
||||
// A new Claude Magpie's own Claude Code folder never overrides what was
|
||||
// there: the user's off, a Claude Magpie made before (its chats in
|
||||
// Claude-Magpie-3p, its Code tab on ~/.claude), or one on already.
|
||||
func TestClaudeMagpieOwnFolderKeepsWhatWasSet(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
setup func(t *testing.T, iso desktopPaths, on *bool)
|
||||
}{
|
||||
{"chosen off", func(t *testing.T, _ desktopPaths, _ *bool) {
|
||||
if err := saveDesktopIsolatedClaude(false, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}},
|
||||
{"made before", func(t *testing.T, iso desktopPaths, _ *bool) {
|
||||
if err := os.MkdirAll(iso.dir3p, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}},
|
||||
{"on already", func(_ *testing.T, _ desktopPaths, on *bool) { *on = true }},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
home, _, iso, on := isolatedSandbox(t)
|
||||
tc.setup(t, iso, on)
|
||||
if _, err := SetDesktopIsolated(home, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if desktopIsolatedClaudeOn() {
|
||||
t.Fatal("its own folder turned on")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, ".claude-magpie-desktop")); err == nil {
|
||||
t.Fatal("folder made")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) {
|
||||
}
|
||||
was.RedactModelOff, was.RedactModelAuto = true, true
|
||||
was.DesktopSubagentEffort = "high"
|
||||
was.DesktopIsolatedClaude = true
|
||||
was.DesktopIsolatedClaude, was.DesktopIsolatedClaudeChosen = true, true
|
||||
was.ReplyModel = settings.ReplyMember // memberModel, its mirror, is kept with it
|
||||
was.CodexAsyncCompact, was.CodexAsyncCompactPercent = true, 70
|
||||
was.ClaudeRunsMost = 3
|
||||
|
||||
@@ -923,9 +923,16 @@ type Settings struct {
|
||||
// config folder of its own (#6459, xMopf7RF on X): Claude Magpie.app
|
||||
// starts Desktop with CLAUDE_CONFIG_DIR set to ~/.claude-magpie-desktop,
|
||||
// and magpie writes the windows and capabilities of Desktop's models
|
||||
// there instead of ~/.claude/settings.json. Off by default: the folder
|
||||
// starts with none of ~/.claude's CLAUDE.md, skills, plugins or history.
|
||||
// there instead of ~/.claude/settings.json. The folder starts with none
|
||||
// of ~/.claude's CLAUDE.md, skills, plugins or history. Turned on when
|
||||
// a Claude Magpie is made new (no Claude-Magpie-3p yet) and the user
|
||||
// never chose (xMopf7RF on X: a twin like a phone's app clone); one
|
||||
// made before keeps what it had.
|
||||
DesktopIsolatedClaude bool `json:"desktopIsolatedClaude,omitempty"`
|
||||
// DesktopIsolatedClaudeChosen: the user set DesktopIsolatedClaude
|
||||
// themselves (the Advanced fold, `launcher claude-dir`), so a new
|
||||
// Claude Magpie never turns it on over their off.
|
||||
DesktopIsolatedClaudeChosen bool `json:"desktopIsolatedClaudeChosen,omitempty"`
|
||||
// GuideHidden: the user put away the Agents page's Get started card
|
||||
// (wangye1644294 on X) before finishing it. Kept here, not in the
|
||||
// page's storage, so the panel, the window and a reload agree.
|
||||
|
||||
@@ -369,6 +369,7 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err
|
||||
in.DesktopIsolated = cur.DesktopIsolated
|
||||
// and whether its Code tab has a Claude Code folder of its own (#6459)
|
||||
in.DesktopIsolatedClaude = cur.DesktopIsolatedClaude
|
||||
in.DesktopIsolatedClaudeChosen = cur.DesktopIsolatedClaudeChosen
|
||||
// and the Get started card put away, from the card itself
|
||||
in.GuideHidden = cur.GuideHidden
|
||||
|
||||
|
||||
Reference in New Issue
Block a user