claude-desktop: Claude Magpie's Code tab on a Claude Code folder of its own (#6459)
The Separate app (Claude Magpie.app, #5671) kept its own Desktop
userData, but its Code tab's bundled Claude Code still read and wrote
the user's ~/.claude: their CLAUDE.md, skills, plugins and history went
into the twin, and the twin's sessions into theirs (xMopf7RF on X).
An opt-in, macOS-only switch under the Separate app's Advanced fold
(settings.DesktopIsolatedClaude, POST /api/settings/desktop-isolated-
claude, `magpie claude-desktop launcher claude-dir on|off`) gives it
~/.claude-magpie-desktop:
- desktopiso.Script exports CLAUDE_CONFIG_DIR in the app's launch
script; turning the option on or off remakes the app, and the hint
says to quit and reopen Claude Magpie, since a running one keeps its
environment.
- desktopOn writes Desktop's model windows, caps and explore entries
into that folder's settings.json instead of ~/.claude's while it is on
(desktopCodeDir, desktopClaudeSync); off moves them back. The folder
is kept when it is turned off, and shows as the claude# row "Claude
Code · Claude Magpie".
- The fold is drawn by claudemagpie.js, imported the first time it
shows; what stays in app.js is the import (isoLazy) and the fold's
place, 216 bytes, so the core budget goes up by 180 (the 36 of room
there was taken first).
Run:
- gofmt -l clean; go vet ./internal/... on darwin, GOOS=windows and
GOOS=linux -tags nogui vet of agent, cli, desktopiso, gui, settings,
settingsapi (mote).
- go test agent, cli, desktopiso, desktopdir, settings, settingsapi,
gui, library on mote: all ok except cli's three healthcheck/update
tests, which ask the gateway mote's own magpie serves on :3425
(#6223, the same with or without this change).
- TestCoreScriptBudget and TestSettingsSaveKeepsWhatItDoesNotSend at
this commit and the next.
- GUI on mote, Chromium and WebKit: desktop-isolated-claude (five
languages, 1100 and 640px), desktop-isolated, i18n-keys,
i18n-en-no-cjk, old-webkit, and every agent*/desktop*/claude* file
(98 files, 1,595 of 1,662 pass). Every red is the same on origin/main
92bce5c72 run alone: old-webkit (#6467, #5919), agent-details-ready
(#6373), agent-switch-accounts (#5925), claude-quota-onboarding
(#6179), agent-menu-label (#6371), desktop-tiers Chromium (#6475).
- A real Claude Desktop on mote in a sandbox HOME (~/sb6459, removed
after): `claude-desktop magpie`, `launcher add`, `launcher claude-dir
on`. The window and caps moved into .claude-magpie-desktop/
settings.json, ~/.claude kept only its theme, the script exported
CLAUDE_CONFIG_DIR, and the launched Desktop's main process and
children had it in their environment. `claude-dir off` moved them
back and dropped the export; `launcher remove` removed the app.
mote's real ~/.claude was listed before and after: unchanged.
Broken by hand:
- desktopOn without the clone-folder branch: TestClaudeDesktopIsolated
ClaudeDir red (the window stays in ~/.claude).
- The fold without its ontoggle: desktop-isolated-claude red ("shut by
the redraw").
- settingsapi not keeping the field: TestSettingsSaveKeepsWhatItDoes
NotSend red.
Not tried: a Code-tab session driven in the real Desktop's UI, so
bundled Claude Code writing into the folder was not seen in this run
(an earlier look at #6459 saw it). Library has no targets for the
clone's folder yet (#6469). The whole GUI suite (1,484 files) was not
run; the files on the Agents page and every i18n file were.
This commit is contained in:
@@ -193,6 +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 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).
|
||||
|
||||
@@ -1166,6 +1166,11 @@ func claudeIn(at place) *Agent {
|
||||
if at.sys != nil {
|
||||
return desktopWiredAny(desktopSetsHere())
|
||||
}
|
||||
// the isolated Desktop's Code tab on a folder of its own (#6459):
|
||||
// that folder's Claude Code, and ~/.claude's no more
|
||||
if d := desktopCodeDir(at.home); d != "" {
|
||||
return at.dir != "" && filepath.Clean(at.dir) == filepath.Clean(d) && desktopWiredAny(desktopSets(desktopdir.OS, at.home, os.Getenv))
|
||||
}
|
||||
return at.id == "" && desktopWiredAny(desktopSets(desktopdir.OS, at.home, os.Getenv))
|
||||
}
|
||||
// Desktop's Explore compatibility flag has its own ownership: taking
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/yetone/magpie/internal/appdir"
|
||||
"github.com/yetone/magpie/internal/desktopiso"
|
||||
"github.com/yetone/magpie/internal/dirent"
|
||||
)
|
||||
|
||||
@@ -87,6 +88,10 @@ func claudeDirAgents(home string) []*Agent {
|
||||
id := "claude#" + name
|
||||
a := claudeIn(place{home: home, id: id, dir: dir})
|
||||
a.ID, a.Name = id, "Claude Code · "+name
|
||||
// the isolated Claude Desktop's Code tab's (#6459), by its app's name
|
||||
if dir == desktopIsolatedClaudeDir(home) {
|
||||
a.Name = "Claude Code · " + desktopiso.Name
|
||||
}
|
||||
// the claude row keeps the command, the names and the requests
|
||||
a.Aliases, a.UA, a.Bin = nil, nil, ""
|
||||
a.detect = func() bool { return claudeDirIsClaude(dir) }
|
||||
|
||||
@@ -427,7 +427,7 @@ func desktopApply(home string, ps []desktopPaths, v string) error {
|
||||
}
|
||||
// its Code tab is Claude Code, told what Desktop's ids for
|
||||
// magpie's models can do while that one runs on magpie
|
||||
_ = claude(home).Sync()
|
||||
desktopClaudeSync(home)
|
||||
// and a running distro's, which a Code tab session with
|
||||
// WSL as its host runs on (a stopped one is written on
|
||||
// the round after it starts)
|
||||
@@ -471,7 +471,7 @@ func desktopTierFields(home string, ps []desktopPaths) []Field {
|
||||
}
|
||||
}
|
||||
if desktopWiredAny(ps) {
|
||||
_ = claude(home).Sync()
|
||||
desktopClaudeSync(home)
|
||||
}
|
||||
return joinErrs(errs)
|
||||
},
|
||||
|
||||
@@ -49,12 +49,102 @@ func desktopIsolatedSet(goos, home string, getenv func(string) string) (desktopP
|
||||
return p, true
|
||||
}
|
||||
|
||||
// The isolated Desktop's Code tab runs Claude Code, on ~/.claude like
|
||||
// any other unless the user gives it a folder of its own (#6459, xMopf7RF
|
||||
// on X): then Claude Magpie.app starts Desktop with CLAUDE_CONFIG_DIR set
|
||||
// to desktopIsolatedClaudeDir (desktopiso.Script), which Desktop hands its
|
||||
// sessions when its own Settings set no such variable (4.23118, 2.7032:
|
||||
// its bundled Claude Code wrote .claude.json, backups, plugins and
|
||||
// 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.
|
||||
|
||||
// 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 {
|
||||
s, err := settings.LoadChecked()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.DesktopIsolatedClaude = on
|
||||
return settings.Save(s)
|
||||
}
|
||||
|
||||
// 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.
|
||||
func desktopIsolatedClaudeDir(home string) string {
|
||||
return filepath.Join(home, ".claude-magpie-desktop")
|
||||
}
|
||||
|
||||
// desktopCodeDir is the Claude Code folder Desktop's Code tab runs on
|
||||
// when it isn't the usual one: the isolated Desktop's own while both it
|
||||
// and its folder are on, else "".
|
||||
func desktopCodeDir(home string) string {
|
||||
if desktopdir.Isolated(desktopdir.OS, home) == "" || !desktopIsolatedOn() || !desktopIsolatedClaudeOn() {
|
||||
return ""
|
||||
}
|
||||
return desktopIsolatedClaudeDir(home)
|
||||
}
|
||||
|
||||
// desktopIsoClaudeArg is the folder Claude Magpie.app is made with: its
|
||||
// own while the user turned it on, "" for ~/.claude.
|
||||
func desktopIsoClaudeArg(home string) string {
|
||||
if desktopIsolatedClaudeOn() {
|
||||
return desktopIsolatedClaudeDir(home)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// desktopClaudeRow is the Claude Code row of the isolated Desktop's
|
||||
// folder, as claudeDirAgents makes it.
|
||||
func desktopClaudeRow(home string) *Agent {
|
||||
dir := desktopIsolatedClaudeDir(home)
|
||||
return claudeIn(place{home: home, id: "claude#" + claudeDirName(filepath.Base(dir)), dir: dir})
|
||||
}
|
||||
|
||||
// desktopClaudeSync writes the windows and capabilities of Desktop's
|
||||
// models where its Code tab reads them now, and takes them out of the
|
||||
// other folder: ~/.claude's Claude Code, and the isolated Desktop's own
|
||||
// where it has one.
|
||||
func desktopClaudeSync(home string) {
|
||||
_ = claude(home).Sync()
|
||||
if isDir(desktopIsolatedClaudeDir(home)) {
|
||||
_ = desktopClaudeRow(home).Sync()
|
||||
}
|
||||
}
|
||||
|
||||
// desktopIsoClaudeMake makes the isolated Desktop's Claude Code folder,
|
||||
// with an empty settings.json, which makes it a Claude Code's folder to
|
||||
// the Agents page and gives magpie the file to write; one there already
|
||||
// is left as it is.
|
||||
func desktopIsoClaudeMake(home string) error {
|
||||
dir := desktopIsolatedClaudeDir(home)
|
||||
if err := os.MkdirAll(dir, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
f := filepath.Join(dir, "settings.json")
|
||||
if _, err := os.Lstat(f); errors.Is(err, os.ErrNotExist) {
|
||||
return os.WriteFile(f, []byte("{}\n"), 0o600)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DesktopIsolated is the isolated Desktop as it is here: whether it can
|
||||
// be (only on a Mac), whether it is on, and the app that starts it, ""
|
||||
// while magpie hasn't made it.
|
||||
// while magpie hasn't made it. Claude is whether its Code tab has a
|
||||
// Claude Code folder of its own, ClaudeDir that folder.
|
||||
type DesktopIsolated struct {
|
||||
On bool `json:"on"`
|
||||
Launcher string `json:"launcher,omitempty"`
|
||||
On bool `json:"on"`
|
||||
Launcher string `json:"launcher,omitempty"`
|
||||
Claude bool `json:"claude"`
|
||||
ClaudeDir string `json:"claudeDir"`
|
||||
}
|
||||
|
||||
// DesktopIsolatedHere is the isolated Desktop on this computer; false
|
||||
@@ -64,7 +154,41 @@ func DesktopIsolatedHere() (DesktopIsolated, bool) {
|
||||
if desktopdir.Isolated(desktopdir.OS, home) == "" {
|
||||
return DesktopIsolated{}, false
|
||||
}
|
||||
return DesktopIsolated{On: desktopIsolatedOn(), Launcher: desktopiso.Here(home)}, true
|
||||
return DesktopIsolated{On: desktopIsolatedOn(), Launcher: desktopiso.Here(home), Claude: desktopIsolatedClaudeOn(), ClaudeDir: desktopIsolatedClaudeDir(home)}, true
|
||||
}
|
||||
|
||||
// SetDesktopIsolatedClaude gives the isolated Desktop's Code tab a Claude
|
||||
// Code folder of its own, or takes it back to ~/.claude. On, the folder
|
||||
// is made with a settings.json, so magpie writes Desktop's model windows
|
||||
// there and the Agents page lists it. Claude Magpie.app, when magpie has
|
||||
// made it, is made again with the new folder (or none); a Desktop running
|
||||
// from it keeps the one it started with until it is quit and opened
|
||||
// again. The folder itself, with what Claude Code keeps in it, stays when
|
||||
// turned off.
|
||||
func SetDesktopIsolatedClaude(home string, on bool) error {
|
||||
if desktopdir.Isolated(desktopdir.OS, home) == "" {
|
||||
return ErrDesktopIsolatedOS
|
||||
}
|
||||
if on {
|
||||
if err := desktopIsoClaudeMake(home); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := saveDesktopIsolatedClaude(on); err != nil {
|
||||
return err
|
||||
}
|
||||
if desktopiso.Here(home) != "" {
|
||||
app := desktopClaudeApp()
|
||||
if app == "" {
|
||||
return ErrDesktopNoApp
|
||||
}
|
||||
iso, _ := desktopIsolatedSet(desktopdir.OS, home, os.Getenv)
|
||||
if _, err := desktopIsoAdd(home, app, iso.dir3p, desktopIsoClaudeArg(home)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
desktopClaudeSync(home)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Why the isolated Desktop can't be turned on.
|
||||
@@ -118,7 +242,12 @@ func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
if err := os.MkdirAll(iso.dir3p, 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
p, err := desktopIsoAdd(home, app, iso.dir3p)
|
||||
if desktopIsolatedClaudeOn() {
|
||||
if err := desktopIsoClaudeMake(home); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
p, err := desktopIsoAdd(home, app, iso.dir3p, desktopIsoClaudeArg(home))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -139,7 +268,7 @@ func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
if err := saveDesktopIsolated(true); err != nil {
|
||||
return "", err
|
||||
}
|
||||
_ = claude(home).Sync()
|
||||
desktopClaudeSync(home)
|
||||
return p, nil
|
||||
}
|
||||
if desktopWired(iso) {
|
||||
@@ -163,7 +292,7 @@ func SetDesktopIsolated(home string, on bool) (string, error) {
|
||||
if _, err := desktopiso.Remove(home); err != nil {
|
||||
return "", err
|
||||
}
|
||||
_ = claude(home).Sync()
|
||||
desktopClaudeSync(home)
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/desktopdir"
|
||||
"github.com/yetone/magpie/internal/desktopiso"
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
)
|
||||
|
||||
// isolatedSandbox is desktopSandbox on a Mac, with the user's choice held
|
||||
@@ -19,28 +21,47 @@ func isolatedSandbox(t *testing.T) (string, desktopPaths, desktopPaths, *bool) {
|
||||
desktopdir.OS = "darwin"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
home, _ := desktopSandbox(t)
|
||||
usual, iso, on, _ := isolatedFakes(t, home)
|
||||
return home, usual, iso, on
|
||||
}
|
||||
|
||||
// isolatedFakes holds the isolated Desktop's choices in the test, its
|
||||
// Claude Code folder's too, and stubs the app: made as magpie would make
|
||||
// it (desktopiso.Here finds it), with the Claude Code folder it was last
|
||||
// made with in *made. desktopdir.OS is darwin.
|
||||
func isolatedFakes(t *testing.T, home string) (desktopPaths, desktopPaths, *bool, *[]string) {
|
||||
t.Helper()
|
||||
usual := desktopUsualSets("darwin", home, os.Getenv)[0]
|
||||
iso, ok := desktopIsolatedSet("darwin", home, os.Getenv)
|
||||
if !ok {
|
||||
t.Fatal("no isolated set on darwin")
|
||||
}
|
||||
on := false
|
||||
on, claudeOn := false, false
|
||||
var made []string
|
||||
oldOn, oldSave, oldApp, oldAdd := desktopIsolatedOn, saveDesktopIsolated, desktopClaudeApp, desktopIsoAdd
|
||||
oldCOn, oldCSave := desktopIsolatedClaudeOn, saveDesktopIsolatedClaude
|
||||
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 }
|
||||
claudeApp := filepath.Join(home, "Applications", "Claude.app")
|
||||
desktopClaudeApp = func() string { return claudeApp }
|
||||
desktopIsoAdd = func(home, app, dir string) (string, error) {
|
||||
desktopIsoAdd = func(home, app, dir, claudeDir string) (string, error) {
|
||||
if app != claudeApp || dir != iso.dir3p {
|
||||
t.Errorf("app made for %q on %q", app, dir)
|
||||
}
|
||||
p := filepath.Join(home, "Applications", "Claude Magpie.app")
|
||||
return p, os.MkdirAll(p, 0o755)
|
||||
made = append(made, claudeDir)
|
||||
p := desktopiso.Path(home)
|
||||
if err := os.MkdirAll(filepath.Join(p, "Contents"), 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return p, os.WriteFile(filepath.Join(p, "Contents", "Info.plist"), []byte("<key>CFBundleIdentifier</key><string>"+desktopiso.BundleID+"</string>"), 0o644)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
desktopIsolatedOn, saveDesktopIsolated, desktopClaudeApp, desktopIsoAdd = oldOn, oldSave, oldApp, oldAdd
|
||||
desktopIsolatedClaudeOn, saveDesktopIsolatedClaude = oldCOn, oldCSave
|
||||
})
|
||||
return home, usual, iso, &on
|
||||
return usual, iso, &on, &made
|
||||
}
|
||||
|
||||
// The isolated Desktop (#5671): turned on with Desktop on magpie, the
|
||||
@@ -203,3 +224,118 @@ func TestDesktopInstance(t *testing.T) {
|
||||
t.Error("Claude Desktop's Restart reads every Claude.app process")
|
||||
}
|
||||
}
|
||||
|
||||
// The isolated Desktop's Code tab on a Claude Code folder of its own
|
||||
// (#6459, xMopf7RF on X): Claude Magpie.app is made again with
|
||||
// CLAUDE_CONFIG_DIR on ~/.claude-magpie-desktop, the windows and
|
||||
// capabilities of Desktop's models leave ~/.claude/settings.json (the
|
||||
// user's own keys stay) and go to that folder's, which is a Claude Code
|
||||
// row of its own named for the app. Off takes them back, the app made
|
||||
// again without the folder; the folder stays. The isolated Desktop
|
||||
// turned off brings them back to ~/.claude too, its folder no longer
|
||||
// being what any Desktop runs on.
|
||||
func TestClaudeDesktopIsolatedClaudeDir(t *testing.T) {
|
||||
home, path := desktopWindowSandbox(t)
|
||||
old := desktopdir.OS
|
||||
desktopdir.OS = "darwin"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
_, iso, _, made := isolatedFakes(t, home)
|
||||
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) {
|
||||
t.Helper()
|
||||
for _, f := range []string{path, own} {
|
||||
w, c := get(f, claudeContextEnv), get(f, claudeCapsEnv)
|
||||
if f == want && (w == "" || c == "") || f != want && (w != "" || c != "") {
|
||||
t.Fatalf("%s: window %q, caps %q; want them in %s", f, w, c, want)
|
||||
}
|
||||
}
|
||||
if v, _ := edit.GetJSON(path, "theme"); v != "dark" {
|
||||
t.Fatalf("the user's own theme: %q", v)
|
||||
}
|
||||
}
|
||||
|
||||
if err := claudeDesktop(home).Field("provider").Set("magpie"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
where(path)
|
||||
window := get(path, claudeContextEnv)
|
||||
if _, err := SetDesktopIsolated(home, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !desktopWired(iso) {
|
||||
t.Fatal("isolated Desktop not on magpie")
|
||||
}
|
||||
// on ~/.claude still, as before
|
||||
where(path)
|
||||
if !reflect.DeepEqual(*made, []string{""}) {
|
||||
t.Fatalf("app made with %q", *made)
|
||||
}
|
||||
|
||||
if err := SetDesktopIsolatedClaude(home, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(*made, []string{"", filepath.Join(home, ".claude-magpie-desktop")}) {
|
||||
t.Fatalf("app made with %q", *made)
|
||||
}
|
||||
where(own)
|
||||
if got := get(own, claudeContextEnv); got != window {
|
||||
t.Errorf("its window %q, ~/.claude's was %q", got, window)
|
||||
}
|
||||
st, ok := DesktopIsolatedHere()
|
||||
if !ok || !st.Claude || st.ClaudeDir != filepath.Dir(own) {
|
||||
t.Errorf("state %+v", st)
|
||||
}
|
||||
var row *Agent
|
||||
for _, a := range claudeDirAgents(home) {
|
||||
if a.Path == own {
|
||||
row = a
|
||||
}
|
||||
}
|
||||
if row == nil || row.Name != "Claude Code · Claude Magpie" {
|
||||
t.Fatalf("its row: %+v", row)
|
||||
}
|
||||
// the round that syncs every agent keeps it so
|
||||
if err := claude(home).Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := row.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
where(own)
|
||||
|
||||
if err := SetDesktopIsolatedClaude(home, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
where(path)
|
||||
if (*made)[len(*made)-1] != "" {
|
||||
t.Fatalf("app made with %q", *made)
|
||||
}
|
||||
if _, err := os.Stat(own); err != nil {
|
||||
t.Fatal("its folder went:", err)
|
||||
}
|
||||
|
||||
// on again, then the isolated Desktop off: ~/.claude again
|
||||
if err := SetDesktopIsolatedClaude(home, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
where(own)
|
||||
if _, err := SetDesktopIsolated(home, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
where(path)
|
||||
}
|
||||
|
||||
// Off a Mac there is no such folder to give it.
|
||||
func TestClaudeDesktopIsolatedClaudeDirOnlyOnAMac(t *testing.T) {
|
||||
old := desktopdir.OS
|
||||
desktopdir.OS = "windows"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
home, _ := desktopSandbox(t)
|
||||
if err := SetDesktopIsolatedClaude(home, true); !errors.Is(err, ErrDesktopIsolatedOS) {
|
||||
t.Fatalf("err %v", err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, ".claude-magpie-desktop")); err == nil {
|
||||
t.Fatal("folder made off a Mac")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ import (
|
||||
const claudeDesktopLauncherUsage = `magpie claude-desktop launcher [add|remove]
|
||||
Claude Magpie.app (macOS): Claude Desktop on magpie in a folder of
|
||||
its own, beside your own Claude Desktop signed in with Anthropic
|
||||
magpie claude-desktop launcher claude-dir [on|off]
|
||||
its Code tab's Claude Code on a folder of its own
|
||||
(CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop), or on ~/.claude
|
||||
`
|
||||
|
||||
// claudeDesktopLaunchCmd is `magpie claude-desktop launcher …`; ok false
|
||||
@@ -42,11 +45,17 @@ var setDesktopIsolated = agent.SetDesktopIsolated
|
||||
// desktopIsolatedHere is agent.DesktopIsolatedHere; tests set it.
|
||||
var desktopIsolatedHere = agent.DesktopIsolatedHere
|
||||
|
||||
// setDesktopIsolatedClaude is agent.SetDesktopIsolatedClaude; tests set it.
|
||||
var setDesktopIsolatedClaude = agent.SetDesktopIsolatedClaude
|
||||
|
||||
func claudeDesktopLauncher(args []string) error {
|
||||
what := "status"
|
||||
if len(args) > 0 {
|
||||
what = args[0]
|
||||
}
|
||||
if what == "claude-dir" {
|
||||
return claudeDesktopClaudeDir(args[1:])
|
||||
}
|
||||
if len(args) > 1 {
|
||||
return fmt.Errorf("magpie claude-desktop launcher takes one word, not %q", args[1])
|
||||
}
|
||||
@@ -84,3 +93,40 @@ func claudeDesktopLauncher(args []string) error {
|
||||
fmt.Println("no Claude Magpie app: run `magpie claude-desktop launcher add`")
|
||||
return nil
|
||||
}
|
||||
|
||||
// claudeDesktopClaudeDir is `magpie claude-desktop launcher claude-dir
|
||||
// [on|off]` (#6459): the Code tab of Claude Magpie.app's Desktop on a
|
||||
// Claude Code folder of its own, or on ~/.claude; nothing says which.
|
||||
func claudeDesktopClaudeDir(args []string) error {
|
||||
if len(args) > 1 {
|
||||
return fmt.Errorf("magpie claude-desktop launcher claude-dir takes one word, not %q", args[1])
|
||||
}
|
||||
st, ok := desktopIsolatedHere()
|
||||
if !ok {
|
||||
return errors.New("Claude Desktop runs in a folder of its own on macOS only")
|
||||
}
|
||||
if len(args) == 0 {
|
||||
if st.Claude {
|
||||
fmt.Println(st.ClaudeDir)
|
||||
} else {
|
||||
fmt.Println("~/.claude: run `magpie claude-desktop launcher claude-dir on` for a folder of its own")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if args[0] != "on" && args[0] != "off" {
|
||||
return fmt.Errorf("magpie claude-desktop launcher claude-dir: on, off or nothing, not %q", args[0])
|
||||
}
|
||||
home, _ := os.UserHomeDir()
|
||||
if err := setDesktopIsolatedClaude(home, args[0] == "on"); err != nil {
|
||||
return err
|
||||
}
|
||||
if args[0] == "on" {
|
||||
fmt.Println("Claude Code in Claude Magpie:", st.ClaudeDir)
|
||||
} else {
|
||||
fmt.Println("Claude Code in Claude Magpie: ~/.claude")
|
||||
}
|
||||
if st.Launcher != "" {
|
||||
fmt.Println("Quit Claude Magpie and open it again to use it.")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,3 +60,51 @@ func TestClaudeDesktopLauncher(t *testing.T) {
|
||||
t.Fatalf("calls %v", calls)
|
||||
}
|
||||
}
|
||||
|
||||
// `magpie claude-desktop launcher claude-dir` (#6459): on and off reach
|
||||
// the setting, nothing says which folder, another word refuses, and off a
|
||||
// Mac it refuses too.
|
||||
func TestClaudeDesktopLauncherClaudeDir(t *testing.T) {
|
||||
helpHome(t)
|
||||
var calls []bool
|
||||
st := agent.DesktopIsolated{On: true, Launcher: "/Users/x/Applications/Claude Magpie.app", ClaudeDir: "/Users/x/.claude-magpie-desktop"}
|
||||
here := true
|
||||
oldSet, oldHere := setDesktopIsolatedClaude, desktopIsolatedHere
|
||||
t.Cleanup(func() { setDesktopIsolatedClaude, desktopIsolatedHere = oldSet, oldHere })
|
||||
setDesktopIsolatedClaude = func(_ string, on bool) error {
|
||||
calls = append(calls, on)
|
||||
st.Claude = on
|
||||
return nil
|
||||
}
|
||||
desktopIsolatedHere = func() (agent.DesktopIsolated, bool) { return st, here }
|
||||
for _, c := range []struct {
|
||||
args []string
|
||||
want string
|
||||
calls []bool
|
||||
}{
|
||||
{[]string{"claude-desktop", "launcher", "claude-dir"}, "~/.claude: run", nil},
|
||||
{[]string{"claude-desktop", "launcher", "claude-dir", "on"}, "Quit Claude Magpie and open it again", []bool{true}},
|
||||
{[]string{"claude-desktop", "launcher", "claude-dir"}, "/Users/x/.claude-magpie-desktop\n", []bool{true}},
|
||||
{[]string{"claude-desktop", "launcher", "claude-dir", "off"}, "Claude Code in Claude Magpie: ~/.claude", []bool{true, false}},
|
||||
} {
|
||||
out, err := runOut(t, c.args...)
|
||||
if err != nil || !strings.Contains(out, c.want) {
|
||||
t.Errorf("%v: %q %v, want %q", c.args, out, err, c.want)
|
||||
}
|
||||
if len(calls) != len(c.calls) {
|
||||
t.Fatalf("%v: calls %v, want %v", c.args, calls, c.calls)
|
||||
}
|
||||
}
|
||||
for _, bad := range [][]string{{"claude-desktop", "launcher", "claude-dir", "yes"}, {"claude-desktop", "launcher", "claude-dir", "on", "x"}} {
|
||||
if _, err := runOut(t, bad...); err == nil {
|
||||
t.Errorf("%v took", bad)
|
||||
}
|
||||
}
|
||||
here = false
|
||||
if _, err := runOut(t, "claude-desktop", "launcher", "claude-dir", "on"); err == nil || !strings.Contains(err.Error(), "macOS only") {
|
||||
t.Errorf("off a Mac: %v", err)
|
||||
}
|
||||
if len(calls) != 2 {
|
||||
t.Fatalf("calls %v", calls)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,6 +301,7 @@ var notYet = map[string]string{
|
||||
"POST /api/settings/codex-warm-at": S2, // api.go
|
||||
"POST /api/settings/cors": S2, // api.go
|
||||
"POST /api/settings/desktop-isolated": A, // api.go; `magpie claude-desktop launcher`, an agent's form this check can't read
|
||||
"POST /api/settings/desktop-isolated-claude": A, // api.go; `magpie claude-desktop launcher claude-dir`, an agent's form this check can't read
|
||||
"POST /api/settings/desktop-longest": S2, // api.go
|
||||
"POST /api/settings/disabled-models": S2, // api.go
|
||||
"POST /api/settings/full-context": S2, // api.go
|
||||
|
||||
@@ -75,12 +75,23 @@ func Here(home string) string {
|
||||
// claudeApp (else in /Applications or ~/Applications, where it may have
|
||||
// moved since) run on dir. A Desktop already running on dir is not started
|
||||
// a second time on it: two copies on one userData share no lock.
|
||||
func Script(claudeApp, exe, dir string) string {
|
||||
//
|
||||
// With claudeDir, the Claude Code Desktop's Code tab runs keeps its files
|
||||
// there (#6459): Desktop takes CLAUDE_CONFIG_DIR from its environment when
|
||||
// its own Settings set none (Desktop 4.23118 and 2.7032), and starts its
|
||||
// sessions with it. "" leaves it ~/.claude, or whatever the user's own
|
||||
// environment says.
|
||||
func Script(claudeApp, exe, dir, claudeDir string) string {
|
||||
q := func(s string) string { return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'" }
|
||||
env := ""
|
||||
if claudeDir != "" {
|
||||
env = "export CLAUDE_CONFIG_DIR=" + q(claudeDir) + "\n"
|
||||
}
|
||||
return "#!/bin/sh\n" +
|
||||
"# Claude Desktop on magpie, in a folder of its own; " + mark + ".\n" +
|
||||
"# magpie's Claude Desktop settings take it away again.\n" +
|
||||
"dir=" + q(dir) + "\n" +
|
||||
env +
|
||||
"exe=" + q(exe) + "\n" +
|
||||
"if /usr/bin/pgrep -f -- \"--user-data-dir=$dir( |\\$)\" >/dev/null 2>&1; then exit 0; fi\n" +
|
||||
"for app in " + q(claudeApp) + " /Applications/Claude.app \"$HOME/Applications/Claude.app\"; do\n" +
|
||||
@@ -154,9 +165,10 @@ var register = func(p string) {
|
||||
var ErrTheirs = errors.New(Name + ".app is there already and isn't magpie's")
|
||||
|
||||
// Add makes the app for home, starting the Desktop at claudeApp on dir,
|
||||
// and gives its path. One of magpie's there already is made again; one
|
||||
// that isn't magpie's stays, and Add fails (ErrTheirs).
|
||||
func Add(home, claudeApp, dir string) (string, error) {
|
||||
// its Code tab's Claude Code on claudeDir when one is given (Script), and
|
||||
// gives its path. One of magpie's there already is made again; one that
|
||||
// isn't magpie's stays, and Add fails (ErrTheirs).
|
||||
func Add(home, claudeApp, dir, claudeDir string) (string, error) {
|
||||
p := Path(home)
|
||||
if _, err := os.Lstat(p); err == nil && !Mine(p) {
|
||||
return "", ErrTheirs
|
||||
@@ -181,7 +193,7 @@ func Add(home, claudeApp, dir string) (string, error) {
|
||||
if err := os.WriteFile(filepath.Join(tmp, "Contents", "Info.plist"), []byte(plist(claudeApp)), 0o644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(tmp, "Contents", "MacOS", exeName), []byte(Script(claudeApp, exe, dir)), 0o755); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(tmp, "Contents", "MacOS", exeName), []byte(Script(claudeApp, exe, dir, claudeDir)), 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
// the icon: Claude's with magpie's badge, or none when Claude's can't
|
||||
|
||||
@@ -40,7 +40,8 @@ func fakeClaude(t *testing.T, root, out string) string {
|
||||
if err := os.WriteFile(filepath.Join(app, "Contents", "Info.plist"), []byte(info), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
exe := "#!/bin/sh\nprintf '%s\\n' \"$@\" > '" + out + "'\n"
|
||||
// and the CLAUDE_CONFIG_DIR it was given to out.env
|
||||
exe := "#!/bin/sh\nprintf '%s\\n' \"$@\" > '" + out + "'\nprintf '%s' \"${CLAUDE_CONFIG_DIR-unset}\" > '" + out + ".env'\n"
|
||||
if err := os.WriteFile(filepath.Join(app, "Contents", "MacOS", "Claude"), []byte(exe), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -84,7 +85,7 @@ func TestAddStartsDesktopOnTheFolder(t *testing.T) {
|
||||
claudeApp := fakeClaude(t, filepath.Join(home, "Applications"), out)
|
||||
dir := filepath.Join(home, "Library", "Application Support", "Claude-Magpie-3p")
|
||||
|
||||
p, err := Add(home, claudeApp, dir)
|
||||
p, err := Add(home, claudeApp, dir, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -126,7 +127,7 @@ func TestAddStartsDesktopOnTheFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
// made again: still one app, magpie's
|
||||
if _, err := Add(home, claudeApp, dir); err != nil {
|
||||
if _, err := Add(home, claudeApp, dir, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ents, _ := os.ReadDir(filepath.Dir(p))
|
||||
@@ -156,7 +157,7 @@ func TestScriptFindsClaudeMoved(t *testing.T) {
|
||||
fakeClaude(t, filepath.Join(home, "Applications"), out)
|
||||
dir := filepath.Join(home, "iso-3p")
|
||||
s := filepath.Join(home, "run.sh")
|
||||
os.WriteFile(s, []byte(Script(filepath.Join(home, "Gone", "Claude.app"), "Claude", dir)), 0o755)
|
||||
os.WriteFile(s, []byte(Script(filepath.Join(home, "Gone", "Claude.app"), "Claude", dir, "")), 0o755)
|
||||
if b, err := exec.Command(s).CombinedOutput(); err != nil {
|
||||
t.Fatalf("%v: %s", err, b)
|
||||
}
|
||||
@@ -180,7 +181,7 @@ func TestScriptQuotes(t *testing.T) {
|
||||
app := fakeClaude(t, home, out)
|
||||
dir := filepath.Join(home, "it's $HOME `x`")
|
||||
s := filepath.Join(home, "run.sh")
|
||||
os.WriteFile(s, []byte(Script(app, "Claude", dir)), 0o755)
|
||||
os.WriteFile(s, []byte(Script(app, "Claude", dir, "")), 0o755)
|
||||
if b, err := exec.Command(s).CombinedOutput(); err != nil {
|
||||
t.Fatalf("%v: %s", err, b)
|
||||
}
|
||||
@@ -189,6 +190,44 @@ func TestScriptQuotes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// With a Claude Code folder of its own (#6459), Desktop is started with
|
||||
// CLAUDE_CONFIG_DIR set to it, whatever the user's own environment says,
|
||||
// a name with quotes in it whole; without one, the environment's own (or
|
||||
// none) reaches it as it is.
|
||||
func TestScriptClaudeConfigDir(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("shell script")
|
||||
}
|
||||
home := t.TempDir()
|
||||
out := filepath.Join(home, "args")
|
||||
app := fakeClaude(t, home, out)
|
||||
dir := filepath.Join(home, "iso-3p")
|
||||
cc := filepath.Join(home, ".claude-it's $HOME `x`")
|
||||
for _, c := range []struct{ claudeDir, env, want string }{
|
||||
{cc, "", cc},
|
||||
{cc, "/elsewhere", cc},
|
||||
{"", "", "unset"},
|
||||
{"", "/theirs", "/theirs"},
|
||||
} {
|
||||
s := filepath.Join(home, "run.sh")
|
||||
os.WriteFile(s, []byte(Script(app, "Claude", dir, c.claudeDir)), 0o755)
|
||||
cmd := exec.Command(s)
|
||||
cmd.Env = []string{"PATH=/usr/bin:/bin", "HOME=" + home}
|
||||
if c.env != "" {
|
||||
cmd.Env = append(cmd.Env, "CLAUDE_CONFIG_DIR="+c.env)
|
||||
}
|
||||
if b, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("%v: %s", err, b)
|
||||
}
|
||||
if got, _ := os.ReadFile(out + ".env"); string(got) != c.want {
|
||||
t.Errorf("claudeDir %q, env %q: CLAUDE_CONFIG_DIR %q, want %q", c.claudeDir, c.env, got, c.want)
|
||||
}
|
||||
if args, _ := os.ReadFile(out); string(args) != "--user-data-dir="+dir+"\n" {
|
||||
t.Fatalf("args %q", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A Claude Magpie.app of the user's own is never written over or removed.
|
||||
func TestAddLeavesTheirs(t *testing.T) {
|
||||
noRegister(t)
|
||||
@@ -196,7 +235,7 @@ func TestAddLeavesTheirs(t *testing.T) {
|
||||
theirs := Path(home)
|
||||
os.MkdirAll(filepath.Join(theirs, "Contents"), 0o755)
|
||||
os.WriteFile(filepath.Join(theirs, "Contents", "Info.plist"), []byte("<plist><dict><key>CFBundleIdentifier</key><string>me.mine</string></dict></plist>"), 0o644)
|
||||
if _, err := Add(home, filepath.Join(home, "Claude.app"), "/x"); !errors.Is(err, ErrTheirs) {
|
||||
if _, err := Add(home, filepath.Join(home, "Claude.app"), "/x", ""); !errors.Is(err, ErrTheirs) {
|
||||
t.Fatalf("add over theirs: %v", err)
|
||||
}
|
||||
if got, err := Remove(home); got != "" || err != nil {
|
||||
|
||||
@@ -1433,6 +1433,21 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
}
|
||||
writeJSON(rw, state())
|
||||
})
|
||||
// its Code tab's Claude Code on a folder of its own, or back on
|
||||
// ~/.claude (#6459): the app made again with the folder or without
|
||||
mux.HandleFunc("POST /api/settings/desktop-isolated-claude", func(rw http.ResponseWriter, r *http.Request) {
|
||||
var in struct{ On bool }
|
||||
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
home, _ := os.UserHomeDir()
|
||||
if err := agent.SetDesktopIsolatedClaude(home, in.On); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
writeJSON(rw, state())
|
||||
})
|
||||
// an agent's own telemetry off, or back (agent/telemetry.go)
|
||||
mux.HandleFunc("POST /api/agents/telemetry/{id}", func(rw http.ResponseWriter, r *http.Request) {
|
||||
var in struct{ Off bool }
|
||||
|
||||
@@ -5163,8 +5163,18 @@ body.window .row + .row.agent.conn > .who { min-height: 41px; } /* the line abov
|
||||
.ag-menu-cap > .ag-dot { margin-top: calc(0.8em - 3px); }
|
||||
.ag-menu-cap > span:last-child { flex: 1; min-width: 0; }
|
||||
/* Claude Desktop's "largest window only" switch (#1272): its words beside it, the hint after them */
|
||||
.ag-longest, .ag-isolated { cursor: pointer; }
|
||||
.ag-longest-say, .ag-isolated-say { color: var(--fg-2); }
|
||||
.ag-longest, .ag-isolated, .ag-iso-claude { cursor: pointer; }
|
||||
.ag-longest-say, .ag-isolated-say, .ag-iso-claude-say { color: var(--fg-2); }
|
||||
/* the Claude Magpie app's own Claude Code folder (#6459), folded under Advanced */
|
||||
.ag-iso-more > summary { font-size: 12px; line-height: 18px; color: var(--fg-2); list-style: none; display: inline-flex; align-items: center; gap: 5px; padding: 3px 0; border-radius: 4px; cursor: pointer; transition: color .12s ease; }
|
||||
.ag-iso-more > summary::-webkit-details-marker { display: none; }
|
||||
.ag-iso-more > summary::before { content: ""; flex: none; width: 10px; height: 10px; background: var(--muted); transition: transform .2s cubic-bezier(.23, 1, .32, 1), background-color .12s ease;
|
||||
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3.6 1.6 7 5 3.6 8.4' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3.6 1.6 7 5 3.6 8.4' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
|
||||
.ag-iso-more[open] > summary::before { transform: rotate(90deg); }
|
||||
@media (hover: hover) and (pointer: fine) { .ag-iso-more > summary:hover { color: var(--fg); } }
|
||||
.ag-iso-more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
@media (prefers-reduced-motion: reduce) { .ag-iso-more > summary, .ag-iso-more > summary::before { transition: none; } }
|
||||
/* which copy is left on the old list: a sentence that wraps as one, under the warning's words */
|
||||
.ag-vl.ag-stale-copy { display: block; padding-left: 14px; font-size: 12px; line-height: 1.6; color: var(--fg-2); }
|
||||
/* Codex's daemon: restarted from its line, a button that sits in the sentence */
|
||||
|
||||
@@ -1969,6 +1969,10 @@ 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
|
||||
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) => {
|
||||
prefs = await writingPrefs(api("settings/desktop-longest", { on }));
|
||||
state.settings = prefs;
|
||||
@@ -2185,7 +2189,7 @@ function connectPanel(a, { fields, fieldBtn }) {
|
||||
kv(t("In {agent}", { agent: a.name }), ...p);
|
||||
} else if (AIR_KINDS.has(kindOf(a))) kv(t("In {agent}", { agent: a.name }), ...airSaid(a, line));
|
||||
// Claude Magpie.app (#5671), macOS only
|
||||
if (a.id === "claude-desktop" && a.isolated) kv(t("Separate app"), desktopIsolatedLine(a.isolated));
|
||||
if (a.id === "claude-desktop" && a.isolated) kv(t("Separate app"), desktopIsolatedLine(a.isolated), ...(a.isolated.on ? [isoLazy("desktopIsolatedMore", a.isolated)] : []));
|
||||
// Claude Code's tiers, each with the /model that picks it
|
||||
if (kindOf(a) === "claude") {
|
||||
const tiers = a.fields.filter((f) => TIERS.includes(f.label) && f.options.length);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
// 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
|
||||
let desktopIsoMoreOpen = false;
|
||||
window.desktopIsolatedMore = function (iso) {
|
||||
const d = el("details", "ag-iso-more");
|
||||
d.open = desktopIsoMoreOpen || !!iso.claude;
|
||||
d.ontoggle = () => { desktopIsoMoreOpen = d.open; };
|
||||
d.append(el("summary", "", t("Advanced")), agSwitchLine("ag-iso-claude", !!iso.claude, t("Its own Claude Code folder"), t("Its Code tab uses {path}, without your CLAUDE.md, skills, plugins or history. Quit and reopen Claude Magpie after a change.", { path: iso.claudeDir || "~/.claude-magpie-desktop" }), async (on) => {
|
||||
state = await api("settings/desktop-isolated-claude", { on });
|
||||
status(t("Saved — quit and reopen Claude Magpie to use it"), "ok");
|
||||
}));
|
||||
return d;
|
||||
};
|
||||
@@ -4891,6 +4891,9 @@ const I18N = {
|
||||
"Your own Claude Desktop stays signed in with Anthropic. macOS only.": "你自己的 Claude Desktop 保持 Anthropic 登录。仅限 macOS。",
|
||||
"Claude Magpie removed": "已移除 Claude Magpie",
|
||||
"Open Claude Magpie from Applications": "从「应用程序」打开 Claude Magpie",
|
||||
"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 后生效",
|
||||
"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": "遥测",
|
||||
@@ -10068,6 +10071,9 @@ const I18N = {
|
||||
"Your own Claude Desktop stays signed in with Anthropic. macOS only.": "你自己的 Claude Desktop 維持 Anthropic 登入。僅限 macOS。",
|
||||
"Claude Magpie removed": "已移除 Claude Magpie",
|
||||
"Open Claude Magpie from Applications": "從「應用程式」打開 Claude Magpie",
|
||||
"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 後生效",
|
||||
"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": "遙測",
|
||||
@@ -15247,6 +15253,9 @@ const I18N = {
|
||||
"Your own Claude Desktop stays signed in with Anthropic. macOS only.": "ご自身の Claude Desktop は Anthropic にサインインしたままです。macOS のみ。",
|
||||
"Claude Magpie removed": "Claude Magpie を削除しました",
|
||||
"Open Claude Magpie from Applications": "「アプリケーション」から Claude Magpie を開いてください",
|
||||
"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 を終了して開き直すと反映されます",
|
||||
"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": "テレメトリ",
|
||||
@@ -20426,6 +20435,9 @@ const I18N = {
|
||||
"Your own Claude Desktop stays signed in with Anthropic. macOS only.": "Dein eigenes Claude Desktop bleibt bei Anthropic angemeldet. Nur macOS.",
|
||||
"Claude Magpie removed": "Claude Magpie entfernt",
|
||||
"Open Claude Magpie from Applications": "Öffne Claude Magpie unter Programme",
|
||||
"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",
|
||||
"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",
|
||||
|
||||
@@ -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_762 // 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 (#2710)
|
||||
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)
|
||||
)
|
||||
|
||||
// codeBytes is how many bytes of b are code: its blank lines, its lines
|
||||
|
||||
@@ -214,6 +214,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) {
|
||||
}
|
||||
was.RedactModelOff, was.RedactModelAuto = true, true
|
||||
was.DesktopSubagentEffort = "high"
|
||||
was.DesktopIsolatedClaude = true
|
||||
was.ReplyModel = settings.ReplyMember // memberModel, its mirror, is kept with it
|
||||
was.CodexAsyncCompact, was.CodexAsyncCompactPercent = true, 70
|
||||
was.ClaudeRunsMost = 3
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The Claude Magpie app's Code tab on a Claude Code folder of its own
|
||||
// (#6459, xMopf7RF on X): with Claude Magpie on, Claude Desktop's opened
|
||||
// row folds an "Advanced" part under its switch, shut while the folder is
|
||||
// off, open while it is on. Its switch posts the new choice, follows the
|
||||
// state the reply carries, names the folder, and the fold stays open
|
||||
// through the redraw; no click scrolls the page. Claude Magpie off: no
|
||||
// fold. Every language, wide and narrow. 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");
|
||||
const DIR = "/test/home/.claude-magpie-desktop";
|
||||
|
||||
function fixture(lang, iso) {
|
||||
const settings = { lang, theme: "light" };
|
||||
const posts = [];
|
||||
const state = () => ({
|
||||
agents: [{
|
||||
id: "claude-desktop", name: "Claude Desktop", path: "/test/claude_desktop_config.json", icon: "claude-color", wired: true,
|
||||
fields: [{ key: "provider", label: "provider", value: "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"] },
|
||||
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-claude") {
|
||||
const body = req.postDataJSON();
|
||||
posts.push(body);
|
||||
iso.claude = body.on;
|
||||
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: { adv: "Advanced", say: "Its own Claude Code folder", hint: `Its Code tab uses ${DIR}, without your CLAUDE.md, skills, plugins or history. Quit and reopen Claude Magpie after a change.`, ok: "Saved — quit and reopen Claude Magpie to use it", details: "Details" },
|
||||
zh: { adv: "高级", say: "这个分身自己的 Claude Code 文件夹", hint: `它的 Code 标签页使用 ${DIR},不带你的 CLAUDE.md、技能、插件和历史记录。改动后退出并重新打开 Claude Magpie。`, ok: "已保存——退出并重新打开 Claude Magpie 后生效", details: "详情" },
|
||||
"zh-TW": { adv: "進階", say: "這個分身自己的 Claude Code 資料夾", hint: `它的 Code 分頁使用 ${DIR},不帶你的 CLAUDE.md、技能、外掛和歷史記錄。變更後結束並重新開啟 Claude Magpie。`, ok: "已儲存——結束並重新開啟 Claude Magpie 後生效", details: "詳情" },
|
||||
ja: { adv: "詳細設定", say: "専用の Claude Code フォルダ", hint: `Code タブは ${DIR} を使います。あなたの CLAUDE.md、スキル、プラグイン、履歴は引き継がれません。変更後は Claude Magpie を終了して開き直してください。`, ok: "保存しました。Claude Magpie を終了して開き直すと反映されます", details: "詳細" },
|
||||
de: { adv: "Erweitert", say: "Eigener Claude-Code-Ordner", hint: `Der Code-Tab nutzt ${DIR}, ohne deine CLAUDE.md, Skills, Plugins und Verlauf. Beende Claude Magpie nach einer Änderung und öffne es neu.`, ok: "Gespeichert – beende Claude Magpie und öffne es neu, um es zu nutzen", details: "Details" },
|
||||
};
|
||||
const cd = '.row.agent[data-id="claude-desktop"]';
|
||||
const more = `${cd} .ag-exp .ag-iso-more`;
|
||||
const sw = `${more} .ag-iso-claude .lib-switch`;
|
||||
|
||||
async function open(engine, lang, width, iso, 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, iso);
|
||||
await page.route("**/*", fx.serve);
|
||||
t.after(() => browser.close());
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator(cd).waitFor();
|
||||
await page.locator(`${cd} .ag-link`, { hasText: W[lang].details }).click();
|
||||
await page.locator(`${cd} .ag-exp .ag-isolated`).waitFor();
|
||||
// the fold comes from claudemagpie.js, imported when it first shows
|
||||
if (iso.on) await page.locator(more).waitFor({ state: "attached" });
|
||||
return { page, fx, errors };
|
||||
}
|
||||
|
||||
const isOpen = (page) => page.evaluate((sel) => document.querySelector(sel)?.open, more);
|
||||
|
||||
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: Claude Magpie's own Claude Code folder, under Advanced`, async (t) => {
|
||||
const w = W[lang];
|
||||
const { page, fx, errors } = await open(engine, lang, width, { on: true, launcher: "/test/Applications/Claude Magpie.app", claude: false, claudeDir: DIR }, t);
|
||||
assert.equal(await isOpen(page), false, "open while off");
|
||||
assert.equal(await page.locator(`${more} > summary`).textContent(), w.adv);
|
||||
assert.equal(await page.locator(`${more} .ag-iso-claude`).isVisible(), false);
|
||||
|
||||
const y = await page.evaluate(() => scrollY);
|
||||
await page.locator(`${more} > summary`).click();
|
||||
const line = page.locator(`${more} .ag-iso-claude`);
|
||||
await line.waitFor();
|
||||
assert.equal(await line.locator(".ag-iso-claude-say").textContent(), w.say);
|
||||
assert.equal(await line.locator(".ag-hint").textContent(), w.hint);
|
||||
assert.equal(await page.locator(sw).getAttribute("aria-checked"), "false");
|
||||
const box = await line.boundingBox();
|
||||
assert.ok(box.x + box.width <= width && box.height > 0, JSON.stringify(box));
|
||||
|
||||
await page.locator(sw).click();
|
||||
await page.waitForFunction((sel) => document.querySelector(sel)?.getAttribute("aria-checked") === "true", sw);
|
||||
assert.deepEqual(fx.posts, [{ on: true }]);
|
||||
assert.equal(await page.locator("#status").textContent(), w.ok);
|
||||
assert.equal(await isOpen(page), true, "shut by the redraw");
|
||||
// and off again, by its words: still open
|
||||
await line.locator(".ag-iso-claude-say").click();
|
||||
await page.waitForFunction((sel) => document.querySelector(sel)?.getAttribute("aria-checked") === "false", sw);
|
||||
assert.deepEqual(fx.posts, [{ on: true }, { on: false }]);
|
||||
assert.equal(await isOpen(page), true, "shut by the redraw");
|
||||
// the Claude Magpie switch is still the first line
|
||||
assert.equal(await page.locator(`${cd} .ag-isolated .lib-switch`).getAttribute("aria-checked"), "true");
|
||||
|
||||
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}: on, the fold opens by itself`, async (t) => {
|
||||
const { page, errors } = await open(engine, "en", 1100, { on: true, claude: true, claudeDir: DIR }, t);
|
||||
assert.equal(await isOpen(page), true);
|
||||
assert.equal(await page.locator(sw).getAttribute("aria-checked"), "true");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
test(`${engine}: no fold while Claude Magpie is off`, async (t) => {
|
||||
const { page, errors } = await open(engine, "en", 1100, { on: false }, t);
|
||||
assert.equal(await page.locator(more).count(), 0);
|
||||
assert.equal(await page.locator(`${cd} .ag-iso-claude`).count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
@@ -180,9 +180,10 @@ test("compat.js is the first of the page's own scripts", async () => {
|
||||
// plugingrid.js when Plugins first draws;
|
||||
// rotfig.js when a routing's In turn is first shown;
|
||||
// ompadvisor.js when an omp's settings first show;
|
||||
// claudemagpie.js when Claude Desktop's twin button or Advanced fold first shows;
|
||||
// the checks above
|
||||
// still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "rotfig.js", "ompadvisor.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "rotfig.js", "ompadvisor.js", "claudemagpie.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
});
|
||||
|
||||
test("the styles hold up in Safari 15.0", async () => {
|
||||
|
||||
@@ -919,6 +919,13 @@ type Settings struct {
|
||||
// --user-data-dir set to it, beside the user's own signed-in Desktop,
|
||||
// which is left as it is. macOS only (desktopdir.Isolated).
|
||||
DesktopIsolated bool `json:"desktopIsolated,omitempty"`
|
||||
// DesktopIsolatedClaude gives that Desktop's Code tab a Claude Code
|
||||
// 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.
|
||||
DesktopIsolatedClaude bool `json:"desktopIsolatedClaude,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.
|
||||
|
||||
@@ -367,6 +367,8 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err
|
||||
in.DesktopLongest = cur.DesktopLongest
|
||||
// and whether it runs in a folder of its own, set there too (#5671)
|
||||
in.DesktopIsolated = cur.DesktopIsolated
|
||||
// and whether its Code tab has a Claude Code folder of its own (#6459)
|
||||
in.DesktopIsolatedClaude = cur.DesktopIsolatedClaude
|
||||
// and the Get started card put away, from the card itself
|
||||
in.GuideHidden = cur.GuideHidden
|
||||
|
||||
|
||||
Reference in New Issue
Block a user