claude-desktop: after Use Claude Magpie the lit row is Claude Magpie, and its Code tab's row says it is on magpie (xMopf7RF on X)
xMopf7RF on X, 0.1.4111: clicking Use Claude Magpie seemed to connect their own Claude Desktop, and left "Claude Code · Claude Magpie" saying "Not connected · uses its own settings" with its switch off. The wiring was right: with the Separate app on, connecting claude-desktop writes only Claude-Magpie-3p's config (desktopSets), and the user's own Desktop is left alone. The page said otherwise twice: - the row that turned on was still named Claude Desktop. While the Separate app is on, state() now names the claude-desktop row Claude Magpie (desktopiso.Name), since that is the only config it wires. - the claude#magpie-desktop row is not wired itself, and need not be: Desktop's Code tab runs Claude Code with CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST, so its requests go through Claude Magpie whatever that folder's settings.json says. While Claude Magpie is on magpie, the row carries twinCode (agent.DesktopTwinCode) and its line, lit, says "On magpie through Claude Magpie" (en, zh, zh-TW, ja, de). The core script budget goes up 67 for that one connectLine line, cut to the shortest words that say it; the Agents rows draw it, so there is no page to move it to. docs/subsystems/agent-wiring.md says both. Tests: - TestClaudeMagpieCodeTabRowIsOnThroughIt (agent): DesktopTwinCode only for claude#magpie-desktop, only while Claude Magpie is on magpie. - TestClaudeMagpieRowsAfterUseClaudeMagpie (gui): sandbox HOME, POST connect after turning the Separate app on: the wired row is named Claude Magpie, the Code tab row has twinCode, the user's own Desktop config is unchanged and no Claude-3p folder is made. - desktop-twin-code.test.cjs: clicks Use Claude Magpie; no lit row is named Claude Desktop, the Code tab row's line is lit and fits, the click doesn't scroll; en/zh/zh-TW/ja/de, 1100 and 640 wide, Chromium and WebKit. Run (mica; mote's load was over its cores), ate0889719c+ this change (the one later main commit,a83fe2325, is CSS and Go appearance only): - gofmt -l clean; go vet -tags nogui ./internal/agent ./internal/gui on darwin, GOOS=linux and GOOS=windows: ok. - go test -tags nogui -count=1 ./internal/gui (whole package, budget included): ok; ./internal/agent -run 'Claude|Desktop': ok. - node --test, both engines, every agent-*, desktop-*, library-desktop-* and i18n-* file (78 files, 1358 tests): 1303 pass, 55 red in 4 files, each red the same at origin/maine0889719cand filed: agent-details-ready (#6373, #6369), agent-switch-accounts (#5925), agent-menu-label (#6371), desktop-tiers (#6475). desktop-twin-code 20 of 20, desktop-twin, desktop-isolated, desktop-isolated-claude, library-desktop-twin, i18n-keys, i18n-en-no-cjk ok. Broken by hand: at origin/maine0889719c(api.go given only the TwinCode field, DesktopTwinCode stubbed false), both Go tests are red ("Claude Magpie on: \"Claude Desktop\" wired false"; the code row not on), and desktop-twin-code is 20 of 20 red ("Not connected · Claude Code · Claude Magpie uses its own settings"). Not tried: a real Claude Magpie.app in a sandbox HOME on this change (005178104did one for the button itself); this change only names rows and reads the same wiring.
This commit is contained in:
@@ -196,7 +196,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. 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. In the Library it is an agent of its own (see [library](library.md), Claude Magpie): `DesktopTwinApp` (`claude-desktop#magpie`) takes MCP servers and Cowork skills in Claude-Magpie-3p, and the `claude#magpie-desktop` row takes instructions, skills and servers in `~/.claude-magpie-desktop`; `DesktopConfigs3p` no longer includes Claude-Magpie-3p's config. The "Use Claude Magpie" button, beside Claude Desktop's switch while it isn't on magpie (its own button there, not words in the status line, so it reads as a way that doesn't connect the user's own Desktop), 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. It shows whenever Desktop isn't on magpie, with Claude Magpie made already too (where connecting wires only Claude-Magpie-3p, `desktopSets`, and the button also makes the app again if it was deleted; xMopf7RF on X, 0.1.4076); then the row's status line says connecting puts Claude Magpie on magpie, not that Desktop opens a separate profile. `TestClaudeDesktopIsolatedClaudeDir`, `TestClaudeMagpieTwinLeavesTheOriginal`, `TestClaudeMagpieOwnFolderKeepsWhatWasSet`, `TestScriptClaudeConfigDir`, `desktop-isolated-claude.test.cjs`, `desktop-twin.test.cjs`.
|
||||
- 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. In the Library it is an agent of its own (see [library](library.md), Claude Magpie): `DesktopTwinApp` (`claude-desktop#magpie`) takes MCP servers and Cowork skills in Claude-Magpie-3p, and the `claude#magpie-desktop` row takes instructions, skills and servers in `~/.claude-magpie-desktop`; `DesktopConfigs3p` no longer includes Claude-Magpie-3p's config. The "Use Claude Magpie" button, beside Claude Desktop's switch while it isn't on magpie (its own button there, not words in the status line, so it reads as a way that doesn't connect the user's own Desktop), 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. It shows whenever Desktop isn't on magpie, with Claude Magpie made already too (where connecting wires only Claude-Magpie-3p, `desktopSets`, and the button also makes the app again if it was deleted; xMopf7RF on X, 0.1.4076); then the row's status line says connecting puts Claude Magpie on magpie, not that Desktop opens a separate profile. While the Separate app is on, the `claude-desktop` row is named Claude Magpie (`state()` in [`api.go`](../../internal/gui/api.go)): the only config it wires then is Claude-Magpie-3p's, so the row that turns on after Use Claude Magpie never reads Claude Desktop (xMopf7RF on X, 0.1.4111, who read it as their own Desktop being connected). The `claude#magpie-desktop` row isn't wired itself (Desktop's Code tab runs Claude Code with `CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`, so its requests go through Claude Magpie whatever that folder's settings.json says); while Claude Magpie is on magpie it carries `twinCode` (`agent.DesktopTwinCode`) and its status line, lit, says it is on magpie through Claude Magpie, instead of "not connected, its own settings". `TestClaudeMagpieCodeTabRowIsOnThroughIt`, `TestClaudeMagpieRowsAfterUseClaudeMagpie`, `desktop-twin-code.test.cjs`, `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).
|
||||
|
||||
@@ -121,6 +121,27 @@ func desktopCodeDir(home string) string {
|
||||
return desktopIsolatedClaudeDir(home)
|
||||
}
|
||||
|
||||
// DesktopTwinCode says a is the Claude Code row of Claude Magpie's Code
|
||||
// tab folder (#6459) while Claude Magpie is on magpie. That tab runs its
|
||||
// Claude Code with the provider managed by the host, so its requests go
|
||||
// to magpie through Claude Magpie's own gateway whatever the row's
|
||||
// settings.json says: the row isn't "not connected, on its own settings"
|
||||
// then (xMopf7RF on X, 0.1.4111: right after Use Claude Magpie it read so,
|
||||
// as if Claude Magpie had been left off).
|
||||
func DesktopTwinCode(a *Agent) bool {
|
||||
// the settings read only for a claude# row: asked of every row
|
||||
if a.WSL != "" || !strings.HasPrefix(a.ID, "claude#") {
|
||||
return false
|
||||
}
|
||||
home, _ := os.UserHomeDir()
|
||||
d := desktopCodeDir(home)
|
||||
if d == "" || a.ID != "claude#"+claudeDirName(filepath.Base(d)) {
|
||||
return false
|
||||
}
|
||||
iso, ok := desktopIsolatedSet(desktopdir.OS, home, os.Getenv)
|
||||
return ok && desktopWired(iso)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
||||
@@ -450,3 +450,48 @@ func TestClaudeMagpieOwnFolderKeepsWhatWasSet(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// After Use Claude Magpie (xMopf7RF on X, 0.1.4111), the Claude Code row
|
||||
// of Claude Magpie's Code tab folder is that tab's, on magpie through
|
||||
// Claude Magpie (DesktopTwinCode): not before Claude Magpie is wired, not
|
||||
// for ~/.claude's row or another folder's, not once Claude Magpie is off.
|
||||
func TestClaudeMagpieCodeTabRowIsOnThroughIt(t *testing.T) {
|
||||
home, _ := desktopWindowSandbox(t)
|
||||
old := desktopdir.OS
|
||||
desktopdir.OS = "darwin"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
_, iso, _, _ := isolatedFakes(t, home)
|
||||
other := filepath.Join(home, ".claude-work")
|
||||
if err := os.MkdirAll(other, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
desktopWrite(t, filepath.Join(other, "settings.json"), `{}`)
|
||||
rows := func() map[string]bool {
|
||||
out := map[string]bool{}
|
||||
for _, a := range append([]*Agent{claude(home)}, claudeDirAgents(home)...) {
|
||||
out[a.ID] = DesktopTwinCode(a)
|
||||
}
|
||||
return out
|
||||
}
|
||||
if _, err := SetDesktopIsolated(home, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := rows(); got["claude#magpie-desktop"] || got["claude"] || got["claude#work"] {
|
||||
t.Fatalf("on magpie before Claude Magpie is wired: %v", got)
|
||||
}
|
||||
if err := claudeDesktop(home).Field("provider").Set("magpie"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !desktopWired(iso) {
|
||||
t.Fatal("Claude Magpie not wired")
|
||||
}
|
||||
if got := rows(); !got["claude#magpie-desktop"] || got["claude"] || got["claude#work"] {
|
||||
t.Fatalf("wired: %v", got)
|
||||
}
|
||||
if _, err := SetDesktopIsolated(home, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := rows(); got["claude#magpie-desktop"] {
|
||||
t.Fatalf("Claude Magpie off: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"github.com/yetone/magpie/internal/autostart"
|
||||
"github.com/yetone/magpie/internal/bark"
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/desktopiso"
|
||||
"github.com/yetone/magpie/internal/filememo"
|
||||
"github.com/yetone/magpie/internal/fonts"
|
||||
"github.com/yetone/magpie/internal/fx"
|
||||
@@ -236,6 +237,9 @@ type agentJSON struct {
|
||||
// Isolated: Claude Desktop's Claude Magpie app (#5671), only where it
|
||||
// can be (macOS): whether it is on, and the app
|
||||
Isolated *agent.DesktopIsolated `json:"isolated,omitempty"`
|
||||
// TwinCode: this Claude Code folder is Claude Magpie's Code tab's,
|
||||
// which is on magpie through Claude Magpie (agent.DesktopTwinCode)
|
||||
TwinCode bool `json:"twinCode,omitempty"`
|
||||
// Telemetry: the agent's own telemetry to its vendor, where magpie
|
||||
// knows the switch for it (agent/telemetry.go)
|
||||
Telemetry *agent.TelemetryState `json:"telemetry,omitempty"`
|
||||
@@ -3314,8 +3318,19 @@ func state() stateJSON {
|
||||
if a.ID == "claude-desktop" && a.WSL == "" {
|
||||
if iso, ok := agent.DesktopIsolatedHere(); ok {
|
||||
aj.Isolated = &iso
|
||||
// while Claude Magpie is on, the row's switch wires it
|
||||
// alone (desktopSets) and the user's own Desktop stays
|
||||
// signed in with Anthropic: the row is Claude Magpie's.
|
||||
// Named Claude Desktop, it read as if their own Desktop
|
||||
// had been connected (xMopf7RF on X, 0.1.4111)
|
||||
if iso.On {
|
||||
aj.Name = desktopiso.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
if !aj.Wired && agent.DesktopTwinCode(a) {
|
||||
aj.TwinCode = true
|
||||
}
|
||||
if a.Telemetry != nil {
|
||||
// Settings › Privacy's switch for every agent reaches one
|
||||
// found since as it is seen
|
||||
|
||||
@@ -1405,6 +1405,8 @@ function connectLine(a, kind) {
|
||||
else if (sw?.p.switchOnly) say(t("Not connected · switching accounts only"));
|
||||
// with Claude Magpie made, connecting wires it, not the user's own Desktop (desktopSets; xMopf7RF on X)
|
||||
else if (a.isolated?.on) say(t("Not connected · connecting puts Claude Magpie on magpie; your own Claude Desktop stays signed in with Anthropic"));
|
||||
// Claude Magpie's Code tab folder, the tab on magpie through Claude Magpie (agent.DesktopTwinCode; xMopf7RF on X)
|
||||
else if (a.twinCode) say(t("On magpie through Claude Magpie"), "on");
|
||||
else if (CONNECT_BEFORE[kindOf(a)]) say(t(CONNECT_BEFORE[kindOf(a)]));
|
||||
else if (src === "sub") say(t("Not connected · now on its Claude subscription"));
|
||||
else if (src === "chatgpt") say(t("Not connected · now signed in with ChatGPT · OpenAI's models stay available once connected"));
|
||||
|
||||
@@ -4957,6 +4957,7 @@ const I18N = {
|
||||
"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 后生效",
|
||||
"Not connected · connecting puts Claude Magpie on magpie; your own Claude Desktop stays signed in with Anthropic": "未接入 · 接入的是 Claude Magpie,你自己的 Claude Desktop 保持 Anthropic 登录",
|
||||
"On magpie through Claude Magpie": "经 Claude Magpie 接入 magpie",
|
||||
"Use Claude Magpie": "启用 Claude Magpie",
|
||||
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "在「应用程序」里加一个接入 magpie 的 Claude Desktop 分身,你自己的 Claude Desktop 保持不变。仅限 macOS。",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "从「应用程序」打开 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 保持 Anthropic 登录。",
|
||||
@@ -10202,6 +10203,7 @@ const I18N = {
|
||||
"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 後生效",
|
||||
"Not connected · connecting puts Claude Magpie on magpie; your own Claude Desktop stays signed in with Anthropic": "未接入 · 接入的是 Claude Magpie,你自己的 Claude Desktop 維持 Anthropic 登入",
|
||||
"On magpie through Claude Magpie": "經 Claude Magpie 接入 magpie",
|
||||
"Use Claude Magpie": "啟用 Claude Magpie",
|
||||
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "在「應用程式」裡加一個接入 magpie 的 Claude Desktop 分身,你自己的 Claude Desktop 保持不變。僅限 macOS。",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "從「應用程式」打開 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 維持 Anthropic 登入。",
|
||||
@@ -15449,6 +15451,7 @@ const I18N = {
|
||||
"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 を終了して開き直すと反映されます",
|
||||
"Not connected · connecting puts Claude Magpie on magpie; your own Claude Desktop stays signed in with Anthropic": "未接続 · 接続するのは Claude Magpie です。ご自身の Claude Desktop は Anthropic にサインインしたままです",
|
||||
"On magpie through Claude Magpie": "Claude Magpie 経由で magpie に接続",
|
||||
"Use Claude Magpie": "Claude Magpie を使う",
|
||||
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "magpie につながる 2 つ目の Claude Desktop を「アプリケーション」に追加します。ご自身の Claude Desktop は変わりません。macOS のみ。",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "「アプリケーション」から Claude Magpie を開くと、magpie で Claude Desktop を使えます。ご自身の Claude Desktop は Anthropic にサインインしたままです。",
|
||||
@@ -20696,6 +20699,7 @@ const I18N = {
|
||||
"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",
|
||||
"Not connected · connecting puts Claude Magpie on magpie; your own Claude Desktop stays signed in with Anthropic": "Nicht verbunden · verbunden wird Claude Magpie; dein eigenes Claude Desktop bleibt bei Anthropic angemeldet",
|
||||
"On magpie through Claude Magpie": "Über Claude Magpie auf magpie",
|
||||
"Use Claude Magpie": "Claude Magpie nutzen",
|
||||
"A second Claude Desktop, on magpie, in Applications. Your own Claude Desktop isn't changed. macOS only.": "Ein zweites Claude Desktop auf magpie unter Programme. Dein eigenes Claude Desktop bleibt, wie es ist. Nur macOS.",
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "Öffne Claude Magpie unter Programme, um Claude Desktop über magpie zu nutzen. Dein eigenes Claude Desktop bleibt bei Anthropic angemeldet.",
|
||||
|
||||
@@ -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_268_961 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to
|
||||
coreScriptBudget = 1_269_028 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to
|
||||
)
|
||||
|
||||
// codeBytes is how many bytes of b are code: its blank lines, its lines
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/desktopdir"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// xMopf7RF on X, 0.1.4111: after Use Claude Magpie the Agents page lit a
|
||||
// row named Claude Desktop, though only Claude Magpie was wired, and left
|
||||
// "Claude Code · Claude Magpie" reading not connected. While Claude Magpie
|
||||
// is on, the claude-desktop row (whose switch wires it alone) is named
|
||||
// Claude Magpie, and once it is wired, its Code tab folder's row says it
|
||||
// is on magpie through it (twinCode). The user's own Desktop isn't wired.
|
||||
func TestClaudeMagpieRowsAfterUseClaudeMagpie(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("USERPROFILE", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
old := desktopdir.OS
|
||||
desktopdir.OS = "darwin"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m1"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// the user's own Desktop, signed in with Anthropic
|
||||
own := filepath.Join(home, "Library", "Application Support", "Claude")
|
||||
os.MkdirAll(own, 0o755)
|
||||
ownCfg := filepath.Join(own, "claude_desktop_config.json")
|
||||
os.WriteFile(ownCfg, []byte(`{"mcpServers":{}}`+"\n"), 0o600)
|
||||
// Claude Magpie as SetDesktopIsolated leaves it: on, its folder and its
|
||||
// Code tab's Claude Code folder made
|
||||
iso := desktopdir.Isolated("darwin", home)
|
||||
os.MkdirAll(iso, 0o755)
|
||||
code := filepath.Join(home, ".claude-magpie-desktop")
|
||||
os.MkdirAll(code, 0o700)
|
||||
os.WriteFile(filepath.Join(code, "settings.json"), []byte("{}\n"), 0o600)
|
||||
|
||||
h := Handler(nil, nil)
|
||||
call := func(path, body string) stateJSON {
|
||||
t.Helper()
|
||||
method := "POST"
|
||||
if body == "" {
|
||||
method = "GET"
|
||||
}
|
||||
rec := httptest.NewRecorder()
|
||||
h.ServeHTTP(rec, httptest.NewRequest(method, path, strings.NewReader(body)))
|
||||
if rec.Code != 200 {
|
||||
t.Fatalf("%s %d %s", path, rec.Code, rec.Body)
|
||||
}
|
||||
var s stateJSON
|
||||
json.Unmarshal(rec.Body.Bytes(), &s)
|
||||
return s
|
||||
}
|
||||
row := func(s stateJSON, id string) agentJSON {
|
||||
t.Helper()
|
||||
for _, a := range s.Agents {
|
||||
if a.ID == id {
|
||||
return a
|
||||
}
|
||||
}
|
||||
t.Fatalf("no %s in %+v", id, s.Agents)
|
||||
return agentJSON{}
|
||||
}
|
||||
|
||||
if a := row(call("/api/state", ""), "claude-desktop"); a.Name != "Claude Desktop" || a.Isolated == nil || a.Isolated.On {
|
||||
t.Fatalf("Claude Magpie off: %q %+v", a.Name, a.Isolated)
|
||||
}
|
||||
s := settings.Load()
|
||||
s.DesktopIsolated, s.DesktopIsolatedClaude = true, true
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
st := call("/api/state", "")
|
||||
if a := row(st, "claude-desktop"); a.Name != "Claude Magpie" || a.Wired {
|
||||
t.Fatalf("Claude Magpie on: %q wired %v", a.Name, a.Wired)
|
||||
}
|
||||
if a := row(st, "claude#magpie-desktop"); a.TwinCode {
|
||||
t.Fatal("its Code tab on magpie before Claude Magpie is wired")
|
||||
}
|
||||
ownWas, _ := os.ReadFile(ownCfg)
|
||||
|
||||
st = call("/api/agents/connect/claude-desktop", "{}")
|
||||
if a := row(st, "claude-desktop"); a.Name != "Claude Magpie" || !a.Wired {
|
||||
t.Fatalf("connected: %q wired %v", a.Name, a.Wired)
|
||||
}
|
||||
if a := row(st, "claude#magpie-desktop"); a.Wired || !a.TwinCode {
|
||||
t.Fatalf("its Code tab's row: wired %v, twinCode %v", a.Wired, a.TwinCode)
|
||||
}
|
||||
for _, a := range st.Agents {
|
||||
if a.TwinCode && a.ID != "claude#magpie-desktop" {
|
||||
t.Fatalf("%s said to be Claude Magpie's Code tab", a.ID)
|
||||
}
|
||||
}
|
||||
if b, _ := os.ReadFile(ownCfg); string(b) != string(ownWas) {
|
||||
t.Fatalf("the user's own Desktop changed:\n%s\nwas:\n%s", b, ownWas)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, "Library", "Application Support", "Claude-3p")); err == nil {
|
||||
t.Fatal("the user's own Desktop's Claude-3p made")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// After Use Claude Magpie (xMopf7RF on X, 0.1.4111: "点击启用 Claude Magpie
|
||||
// 还是会先把 Claude Desktop 接入,反而留下一个 Claude Magpie 显示未接入"):
|
||||
// - the row the switch wires is Claude Magpie's, named so by the state
|
||||
// (api.go names claude-desktop "Claude Magpie" while it is on), so no
|
||||
// row named Claude Desktop turns on;
|
||||
// - "Claude Code · Claude Magpie", the folder Claude Magpie's Code tab
|
||||
// runs on, no longer reads "not connected, on its own settings": the
|
||||
// tab is on magpie through Claude Magpie (twinCode), and its line says
|
||||
// so, lit. Before the click it still reads not connected.
|
||||
// Every language, wide and narrow, both engines. No backend: faked here,
|
||||
// as api.go answers.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
function fixture(lang) {
|
||||
const settings = { lang, theme: "light" };
|
||||
const iso = { on: false, claude: false, claudeDir: "/test/.claude-magpie-desktop" };
|
||||
let wired = false;
|
||||
const state = () => ({
|
||||
agents: [{
|
||||
id: "claude-desktop", name: iso.on ? "Claude Magpie" : "Claude Desktop", path: "/test/claude_desktop_config.json", icon: "claude-color", wired,
|
||||
fields: [{ key: "provider", label: "provider", value: wired ? "magpie" : "", options: [{ value: "magpie", label: "magpie", icon: "magpie" }] }],
|
||||
models: { shown: 2, listed: 2, by: [{ name: "OpenCode Go", icon: "opencode", n: 2 }], names: ["DeepSeek V4 Pro", "Exo Free"] },
|
||||
isolated: { ...iso },
|
||||
}, {
|
||||
id: "claude#magpie-desktop", name: "Claude Code · Claude Magpie", path: "/test/.claude-magpie-desktop/settings.json", icon: "claudecode-color", wired: false,
|
||||
fields: [{ key: "provider", label: "provider", value: "", options: [{ value: "magpie", label: "magpie", icon: "magpie" }] }],
|
||||
...(wired && iso.on && iso.claude ? { twinCode: true } : {}),
|
||||
}],
|
||||
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") {
|
||||
iso.on = req.postDataJSON().on;
|
||||
iso.claude = iso.on;
|
||||
iso.launcher = "/test/Applications/Claude Magpie.app";
|
||||
return json(state());
|
||||
}
|
||||
if (url.pathname === "/api/agents/connect/claude-desktop") {
|
||||
wired = true;
|
||||
return json(state());
|
||||
}
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true } });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
}
|
||||
return { serve };
|
||||
}
|
||||
|
||||
const W = {
|
||||
en: { before: "Not connected · Claude Code · Claude Magpie uses its own settings", after: "On magpie through Claude Magpie" },
|
||||
zh: { before: "未接入 · 用 Claude Code · Claude Magpie 自己的设置", after: "经 Claude Magpie 接入 magpie" },
|
||||
"zh-TW": { after: "經 Claude Magpie 接入 magpie" },
|
||||
ja: { after: "Claude Magpie 経由で magpie に接続" },
|
||||
de: { after: "Über Claude Magpie auf magpie" },
|
||||
};
|
||||
const cd = '.row.agent[data-id="claude-desktop"]';
|
||||
const code = '.row.agent[data-id="claude#magpie-desktop"]';
|
||||
|
||||
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: after Use Claude Magpie the lit row is Claude Magpie, and its Code tab's row says it is on magpie`, async (t) => {
|
||||
const w = W[lang];
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await browser.newPage({ viewport: { width, height: 800 } });
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", fixture(lang).serve);
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator(cd).waitFor({ state: "attached" });
|
||||
if (await page.locator(`.agent-fold ${cd}`).count()) {
|
||||
await page.locator(".agent-more").click();
|
||||
await page.waitForFunction(() => !document.querySelector(".agent-fold-inner")?.inert);
|
||||
}
|
||||
assert.equal(await page.locator(`${cd} .name`).textContent(), "Claude Desktop");
|
||||
const line = page.locator(`${code} .ag-st`);
|
||||
if (w.before) assert.equal((await line.locator(".ag-st-t").textContent()).trim(), w.before);
|
||||
assert.equal(await line.evaluate((n) => n.classList.contains("on")), false, "lit before Claude Magpie is on magpie");
|
||||
|
||||
const y = await page.evaluate(() => scrollY);
|
||||
await page.locator(`${cd} .ag-twin`).click();
|
||||
await page.locator(`${cd} .ag-conn.on`).waitFor();
|
||||
// the lit row is Claude Magpie's; none named Claude Desktop is on
|
||||
assert.equal(await page.locator(`${cd} .name`).textContent(), "Claude Magpie");
|
||||
assert.equal(await page.evaluate(() => scrollY), y, "a click scrolled the page");
|
||||
const lit = await page.locator(".row.agent").evaluateAll((rs) => rs.filter((r) => r.querySelector(".ag-conn.on")).map((r) => r.querySelector(".name").textContent));
|
||||
assert.ok(!lit.includes("Claude Desktop"), `on: ${lit}`);
|
||||
// the Code tab's row: on magpie through Claude Magpie, not "not connected"
|
||||
await page.locator(code).scrollIntoViewIfNeeded();
|
||||
assert.equal((await line.locator(".ag-st-t").textContent()).trim(), w.after);
|
||||
assert.equal(await line.evaluate((n) => n.classList.contains("on")), true, "its line isn't lit");
|
||||
const box = await line.boundingBox(), row = await page.locator(code).boundingBox();
|
||||
assert.ok(box.x + box.width <= row.x + row.width + 1 && box.x + box.width <= width, `past the row: ${JSON.stringify([box, row])}`);
|
||||
assert.equal(await page.locator("select").count(), 0, "a native select");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user