Skip to content

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

agents: Claude Code found only inside Claude Desktop says so

yetonefccf86d62ebd
diff --git a/internal/agent/claude_in_desktop_test.go b/internal/agent/claude_in_desktop_test.go
new file mode 100644
index 000000000..bdffae26b
--- /dev/null
+++ b/internal/agent/claude_in_desktop_test.go
@@ -0,0 +1,58 @@
+package agent
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/yetone/magpie/internal/desktopdir"
+)
+
+// cybercaius (Discord, Windows): Claude Code and Desktop uninstalled, only
+// Desktop installed again, and the Agents page still listed Claude Code by
+// its ~\.claude with nothing saying why. Desktop includes a Claude Code
+// for its Code tab (%APPDATA%\Claude\claude-code\<version>\claude.exe) that
+// reads the same ~\.claude\settings.json, so with no Claude Code of its own
+// found, the CLI says it is Desktop's, with that copy's version once
+// Desktop has fetched it; one of its own found, it is that one.
+func TestClaudeCodeInDesktop(t *testing.T) {
+ old := desktopdir.OS
+ desktopdir.OS = "windows"
+ t.Cleanup(func() { desktopdir.OS = old })
+ home, _ := desktopSandbox(t)
+ t.Setenv("PATH", t.TempDir())
+ versions, latests = memo{}, memo{}
+ t.Cleanup(func() { versions, latests = memo{}, memo{} })
+ file(t, filepath.Join(home, ".claude", "settings.json"), `{}`)
+ a := claude(home)
+
+ if c, ok := a.CLI(); ok || c.InDesktop {
+ t.Fatalf("neither Claude Code nor Desktop here: %+v", c)
+ }
+ // Desktop installed (Squirrel's setup), its Code tab not used yet
+ file(t, filepath.Join(home, "AppData", "Local", "AnthropicClaude", "claude.exe"), "MZ")
+ if c, ok := a.CLI(); !ok || !c.InDesktop || c.DesktopVersion != "" || c.Version != "" {
+ t.Fatalf("Desktop installed: %+v %v", c, ok)
+ }
+ // and the Claude Code it fetched, two versions, one in its 3p mode's folder
+ file(t, filepath.Join(home, "AppData", "Roaming", "Claude", "claude-code", "2.1.300", "claude.exe"), "MZ")
+ file(t, filepath.Join(home, "AppData", "Local", "Claude-3p", "claude-code", "2.1.310", "claude.exe"), "MZ")
+ if c, ok := a.CLI(); !ok || !c.InDesktop || c.DesktopVersion != "2.1.310" {
+ t.Fatalf("Desktop's Claude Code: %+v %v", c, ok)
+ }
+ // Claude Code's own on PATH: that one, not Desktop's
+ bin := t.TempDir()
+ file(t, filepath.Join(bin, exe("claude")), "")
+ os.Chmod(filepath.Join(bin, exe("claude")), 0o755)
+ t.Setenv("PATH", bin)
+ if c, _ := a.CLI(); c.InDesktop || c.Path == "" {
+ t.Fatalf("its own on PATH: %+v", c)
+ }
+ // in a WSL distro, never Desktop's
+ w := claude(home)
+ w.WSL = "Ubuntu"
+ t.Setenv("PATH", t.TempDir())
+ if c, _ := w.CLI(); c.InDesktop {
+ t.Fatalf("WSL: %+v", c)
+ }
+}
diff --git a/internal/agent/cliupdate.go b/internal/agent/cliupdate.go
index 9e1f1df57..737ef837e 100644
--- a/internal/agent/cliupdate.go
+++ b/internal/agent/cliupdate.go
@@ -27,6 +27,7 @@ import (
"time"
"unicode/utf16"
+ "github.com/yetone/magpie/internal/desktopdir"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/netproxy"
"github.com/yetone/magpie/internal/proc"
@@ -65,6 +66,14 @@ type CLI struct {
// 0.162.1 listed with no codex on PATH and no ~/.codex). False when
// the terminal's PATH can't be told.
OffPath bool `json:"offPath,omitempty"`
+ // InDesktop: no Claude Code of its own is found here, and Claude
+ // Desktop is, which includes one for its Code tab that reads the
+ // same ~/.claude (cybercaius: the card stayed after Claude Code was
+ // uninstalled and Desktop installed again, with nothing saying why).
+ // DesktopVersion is that copy's newest version, "" until Desktop has
+ // fetched it.
+ InDesktop bool `json:"inDesktop,omitempty"`
+ DesktopVersion string `json:"desktopVersion,omitempty"`
}
// cliSpec is where an agent's CLI is published.
@@ -815,7 +824,10 @@ func (a *Agent) CLI() (c CLI, ok bool) {
c.App = a.AppVersion()
bin, spec := a.cliBin()
if bin == "" {
- return c, c.App != ""
+ if a.ID == "claude" && a.WSL == "" {
+ c.InDesktop, c.DesktopVersion = claudeInDesktop()
+ }
+ return c, c.App != "" || c.InDesktop
}
real, u := installedAt(spec, bin)
c.Version = installedVersion(real)
@@ -830,6 +842,28 @@ func (a *Agent) CLI() (c CLI, ok bool) {
return c, true
}
+// claudeInDesktop says whether Claude Desktop is here, with the newest
+// Claude Code it keeps for its Code tab (desktopdir.ClaudeCode): its
+// bundle on a Mac, its folders or its install elsewhere (its detect).
+func claudeInDesktop() (here bool, version string) {
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return false, ""
+ }
+ for _, v := range desktopdir.ClaudeCode(desktopdir.OS, home, os.Getenv) {
+ if version == "" || Newer(v, version) {
+ version = v
+ }
+ }
+ if version != "" {
+ return true, version
+ }
+ if desktopdir.OS == "darwin" {
+ return appHere("Claude.app"), ""
+ }
+ return claudeDesktop(home).Detected(), ""
+}
+
// InstalledVersion is what the agent's CLI on PATH says its version is: ""
// for an agent without a CLI magpie knows, one not on PATH, or one that
// didn't say. Asked once per binary, like CLI's; nothing is fetched. An
diff --git a/internal/desktopdir/desktopdir.go b/internal/desktopdir/desktopdir.go
index a8d82009e..99bbb96f9 100644
--- a/internal/desktopdir/desktopdir.go
+++ b/internal/desktopdir/desktopdir.go
@@ -234,3 +234,34 @@ func windowsDir(local string, threep bool) string {
sort.Strings(found)
return filepath.Join(local, found[0])
}
+
+// ClaudeCode are the versions of Claude Code that Desktop keeps for its
+// Code tab, in any set's userData (Data, or ThreeP in its 3p mode):
+// <userData>/claude-code/<version>/ holding claude.exe on Windows, claude
+// elsewhere, or claude.app on a Mac (Desktop 2.7032's CCD storageDir and
+// getBinaryPathForTarget). That copy reads ~/.claude as Claude Code does.
+// Empty when Desktop hasn't fetched it, or isn't here.
+func ClaudeCode(goos, home string, getenv func(string) string) []string {
+ names := []string{"claude", "claude.app"}
+ if goos == "windows" {
+ names = []string{"claude.exe"}
+ }
+ var out []string
+ for _, d := range Sets(goos, home, getenv) {
+ for _, data := range []string{d.Data, d.ThreeP} {
+ ents, _ := os.ReadDir(filepath.Join(data, "claude-code"))
+ for _, e := range ents {
+ if !e.IsDir() || slices.Contains(out, e.Name()) {
+ continue
+ }
+ for _, n := range names {
+ if _, err := os.Stat(filepath.Join(data, "claude-code", e.Name(), n)); err == nil {
+ out = append(out, e.Name())
+ break
+ }
+ }
+ }
+ }
+ }
+ return out
+}
diff --git a/internal/desktopdir/desktopdir_test.go b/internal/desktopdir/desktopdir_test.go
index 8e54e3cf6..3771fcc5a 100644
--- a/internal/desktopdir/desktopdir_test.go
+++ b/internal/desktopdir/desktopdir_test.go
@@ -118,3 +118,39 @@ func TestFindOthers(t *testing.T) {
}
}
}
+
+// Claude Code that Desktop keeps for its Code tab is found in its userData
+// on Windows (%APPDATA%\Claude\claude-code\<version>\claude.exe, and the
+// 3p mode's Claude-3p), and on a Mac as Desktop's claude.app bundle; a
+// version folder with no program in it (a download cut short) is none.
+func TestClaudeCode(t *testing.T) {
+ put := func(p string) {
+ if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(p, nil, 0o755); err != nil {
+ t.Fatal(err)
+ }
+ }
+ home := t.TempDir()
+ roaming, local := filepath.Join(home, "AppData", "Roaming"), filepath.Join(home, "AppData", "Local")
+ e := env(map[string]string{"APPDATA": roaming, "LOCALAPPDATA": local})
+ if got := ClaudeCode("windows", home, e); len(got) != 0 {
+ t.Fatalf("nothing here: %v", got)
+ }
+ put(filepath.Join(roaming, "Claude", "claude-code", "2.1.300", "claude.exe"))
+ put(filepath.Join(local, "Claude-3p", "claude-code", "2.1.310", "claude.exe"))
+ if err := os.MkdirAll(filepath.Join(roaming, "Claude", "claude-code", "2.1.320"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if got, want := ClaudeCode("windows", home, e), []string{"2.1.300", "2.1.310"}; !reflect.DeepEqual(got, want) {
+ t.Fatalf("Windows: %v, want %v", got, want)
+ }
+ mac := t.TempDir()
+ if err := os.MkdirAll(filepath.Join(mac, "Library", "Application Support", "Claude", "claude-code", "2.1.300", "claude.app"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if got, want := ClaudeCode("darwin", mac, env(nil)), []string{"2.1.300"}; !reflect.DeepEqual(got, want) {
+ t.Fatalf("Mac: %v, want %v", got, want)
+ }
+}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index bec992ec7..cd5eee34d 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -2342,7 +2342,7 @@ function cliTag(a) {
return box;
}
const c = cliInfo[a.id];
- if (!c?.version && !c?.app) return box;
+ if (!c?.version && !c?.app && !c?.inDesktop) return box;
if (c.version) {
// beside its desktop app's version, the CLI's says it is the CLI's
const v = el("span", "ag-ver", c.app ? t("CLI {v}", { v: c.version }) : c.version);
@@ -2377,6 +2377,16 @@ function cliTag(a) {
v.title = t("The {agent} app {v}. It reads the same settings as the CLI: connecting {agent} here connects both", { agent: a.name, v: c.app });
box.append(v);
}
+ // no Claude Code of its own here, only the one Claude Desktop includes
+ // for its Code tab, which reads this same ~/.claude (cybercaius,
+ // young02036: a card left after Claude Code's uninstall, with nothing
+ // saying which of the Claude cards Desktop reads)
+ if (c.inDesktop) {
+ const v = el("span", "ag-ver ag-app", t("In Claude Desktop"));
+ v.title = (c.desktopVersion ? t("Claude Code {v}, included in Claude Desktop", { v: c.desktopVersion }) + "\n" : "")
+ + t("No Claude Code of its own is installed here: this is the one Claude Desktop runs in its Code tab, and it reads this same {path}. A Code session Desktop opens in WSL runs that distro's Claude Code instead, its card in WSL.", { path: a.path || "~/.claude/settings.json" });
+ box.append(v);
+ }
return box;
}
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 10a5d268b..edb443d91 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -726,6 +726,9 @@ const I18N = {
"CLI {v}": "CLI {v}",
"App {v}": "App {v}",
"The {agent} app {v}. It reads the same settings as the CLI: connecting {agent} here connects both": "{agent} App {v}。它和 CLI 读同一份设置:在这里接入 {agent},两者都会接入",
+ "In Claude Desktop": "Claude Desktop 内置",
+ "Claude Code {v}, included in Claude Desktop": "Claude Desktop 内置的 Claude Code {v}",
+ "No Claude Code of its own is installed here: this is the one Claude Desktop runs in its Code tab, and it reads this same {path}. A Code session Desktop opens in WSL runs that distro's Claude Code instead, its card in WSL.": "这里没有单独安装的 Claude Code:这是 Claude Desktop 在 Code 标签页里运行的那一份,它读的也是这个 {path}。Desktop 在 WSL 里打开的 Code 会话运行的是那个发行版的 Claude Code,对应 WSL 里的那张卡片。",
"{agent} {v} · up to date": "{agent} {v} · 已是最新",
"{agent} {v} is installed · {latest} is out": "已安装 {agent} {v} · {latest} 已发布",
"{agent} {v} · magpie can't tell how it was installed — update it the way you installed it": "{agent} {v} · 无法判断安装方式,请按原安装方式更新",
@@ -4800,6 +4803,9 @@ const I18N = {
"CLI {v}": "CLI {v}",
"App {v}": "App {v}",
"The {agent} app {v}. It reads the same settings as the CLI: connecting {agent} here connects both": "{agent} App {v}。它和 CLI 讀同一份設定:在這裡接入 {agent},兩者都會接入",
+ "In Claude Desktop": "Claude Desktop 內建",
+ "Claude Code {v}, included in Claude Desktop": "Claude Desktop 內建的 Claude Code {v}",
+ "No Claude Code of its own is installed here: this is the one Claude Desktop runs in its Code tab, and it reads this same {path}. A Code session Desktop opens in WSL runs that distro's Claude Code instead, its card in WSL.": "這裡沒有單獨安裝的 Claude Code:這是 Claude Desktop 在 Code 分頁裡執行的那一份,它讀的也是這個 {path}。Desktop 在 WSL 裡開啟的 Code 工作階段執行的是那個發行版的 Claude Code,對應 WSL 裡的那張卡片。",
"{agent} {v} · up to date": "{agent} {v} · 已是最新",
"{agent} {v} is installed · {latest} is out": "已安裝 {agent} {v} · {latest} 已釋出",
"{agent} {v} · magpie can't tell how it was installed — update it the way you installed it": "{agent} {v} · 無法判斷安裝方式,請按原安裝方式更新",
@@ -8840,6 +8846,9 @@ const I18N = {
"CLI {v}": "CLI {v}",
"App {v}": "アプリ {v}",
"The {agent} app {v}. It reads the same settings as the CLI: connecting {agent} here connects both": "{agent} アプリ {v}。CLI と同じ設定を読むので、ここで {agent} を接続すると両方が接続されます",
+ "In Claude Desktop": "Claude Desktop に内蔵",
+ "Claude Code {v}, included in Claude Desktop": "Claude Desktop に内蔵の Claude Code {v}",
+ "No Claude Code of its own is installed here: this is the one Claude Desktop runs in its Code tab, and it reads this same {path}. A Code session Desktop opens in WSL runs that distro's Claude Code instead, its card in WSL.": "ここには単体の Claude Code はインストールされていません。これは Claude Desktop が Code タブで実行するもので、同じ {path} を読みます。Desktop が WSL で開く Code セッションは、そのディストリビューションの Claude Code(WSL のカード)を実行します。",
"{agent} {v} · up to date": "{agent} {v} · 最新",
"{agent} {v} is installed · {latest} is out": "{agent} {v} がインストール済み · {latest} が公開されています",
"{agent} {v} · magpie can't tell how it was installed — update it the way you installed it": "{agent} {v} · magpie ではインストール方法を判別できません — インストールしたときの方法でアップデートしてください",
@@ -12897,6 +12906,9 @@ const I18N = {
"CLI {v}": "CLI {v}",
"App {v}": "App {v}",
"The {agent} app {v}. It reads the same settings as the CLI: connecting {agent} here connects both": "{agent}-App {v}. Sie liest dieselben Einstellungen wie die CLI: {agent} hier zu verbinden, verbindet beide",
+ "In Claude Desktop": "In Claude Desktop enthalten",
+ "Claude Code {v}, included in Claude Desktop": "Claude Code {v}, in Claude Desktop enthalten",
+ "No Claude Code of its own is installed here: this is the one Claude Desktop runs in its Code tab, and it reads this same {path}. A Code session Desktop opens in WSL runs that distro's Claude Code instead, its card in WSL.": "Hier ist kein eigenes Claude Code installiert: Das ist das, welches Claude Desktop in seinem Code-Tab ausführt, und es liest dieselbe {path}. Eine Code-Sitzung, die Desktop in WSL öffnet, führt stattdessen das Claude Code dieser Distribution aus, dessen Karte in WSL.",
"{agent} {v} · up to date": "{agent} {v} · aktuell",
"{agent} {v} is installed · {latest} is out": "{agent} {v} ist installiert · {latest} ist erschienen",
"{agent} {v} · magpie can't tell how it was installed — update it the way you installed it": "{agent} {v} · magpie kann die Installationsart nicht erkennen — aktualisieren Sie ihn auf dem Weg, auf dem Sie ihn installiert haben",
diff --git a/internal/gui/tests/claude-in-desktop.test.cjs b/internal/gui/tests/claude-in-desktop.test.cjs
new file mode 100644
index 000000000..9a2097606
--- /dev/null
+++ b/internal/gui/tests/claude-in-desktop.test.cjs
@@ -0,0 +1,83 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// cybercaius and young02036 (Discord, Windows): with only Claude Desktop
+// installed, the Agents page listed Claude Code too, by its ~/.claude, and
+// nothing said which card Desktop reads. With no Claude Code of its own
+// found, its CLI is the one Desktop includes for its Code tab, and the
+// card says so ("In Claude Desktop"), its tip naming the version, the
+// settings file and that a Code session in WSL runs the distro's card.
+// A Claude Code of its own is shown as before. In every language, wide and
+// narrow. No backend: the API is 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 models = ["model-a"].map((m) => ({ value: m, label: m }));
+const AGENTS = [{ id: "claude", name: "Claude Code", path: "C:\\Users\\me\\.claude\\settings.json", fields: [{ key: "model", label: "model", value: "model-a", options: models }] }];
+
+function server(lang, clis) {
+ return async (route) => {
+ const req = route.request(), url = new URL(req.url());
+ 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 route.fulfill({ json: { agents: AGENTS, profiles: [], settings: { lang, theme: "light" } } });
+ if (url.pathname === "/api/agents/cli" && req.method() === "GET") return route.fulfill({ json: { agents: clis, pending: false } });
+ if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
+ if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
+ if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
+ if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+const row = '.row.agent[data-id="claude"]';
+const WORDS = {
+ en: ["In Claude Desktop", /^Claude Code 2\.1\.310, included in Claude Desktop\nNo Claude Code of its own is installed here.*C:\\Users\\me\\\.claude\\settings\.json.*WSL/s],
+ zh: ["Claude Desktop 内置", /^Claude Desktop 内置的 Claude Code 2\.1\.310\n这里没有单独安装的 Claude Code.*settings\.json.*WSL/s],
+ "zh-TW": ["Claude Desktop 內建", /^Claude Desktop 內建的 Claude Code 2\.1\.310\n這裡沒有單獨安裝的 Claude Code.*settings\.json.*WSL/s],
+ ja: ["Claude Desktop に内蔵", /^Claude Desktop に内蔵の Claude Code 2\.1\.310\nここには単体の Claude Code.*settings\.json.*WSL/s],
+ de: ["In Claude Desktop enthalten", /^Claude Code 2\.1\.310, in Claude Desktop enthalten\nHier ist kein eigenes Claude Code.*settings\.json.*WSL/s],
+};
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const [lang, [tag, tip]] of Object.entries(WORDS)) {
+ for (const width of [980, 560]) {
+ test(`${engine} ${lang} ${width}: Claude Code only in Claude Desktop says so`, async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ t.after(() => browser.close());
+ const errors = [];
+ const open = async (clis) => {
+ const page = await (await browser.newContext({ viewport: { width, height: 640 } })).newPage();
+ page.setDefaultTimeout(5000);
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", server(lang, clis));
+ await page.goto("http://magpie.test/");
+ await page.locator(row).waitFor();
+ return page;
+ };
+ const page = await open({ claude: { inDesktop: true, desktopVersion: "2.1.310" } });
+ const v = page.locator(`${row} .ag-app`);
+ await v.waitFor();
+ assert.equal(await v.textContent(), tag);
+ assert.match(await v.getAttribute("title"), tip);
+ // on the name's line, and nothing wider than the window
+ const mid = (s) => page.evaluate((s) => { const b = document.querySelector(s).getBoundingClientRect(); return b.top + b.height / 2; }, s);
+ assert(Math.abs((await mid(`${row} .name`)) - (await mid(`${row} .ag-app`))) <= 2, "not on the name's line");
+ assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "the page scrolls sideways");
+ // Desktop's not fetched yet: the words, with no version line
+ const early = await open({ claude: { inDesktop: true } });
+ await early.locator(`${row} .ag-app`).waitFor();
+ assert.doesNotMatch(await early.locator(`${row} .ag-app`).getAttribute("title"), /2\.1\.310|\n/);
+ // its own Claude Code: its version, no Desktop words
+ const own = await open({ claude: { version: "2.1.299" } });
+ await own.locator(`${row} .ag-ver`).waitFor();
+ assert.equal(await own.locator(`${row} .ag-app`).count(), 0);
+ assert.deepEqual(errors, []);
+ });
+ }
+ }
+}