Files
magpie/internal/agent/claudedesktop_installed_test.go
T
yetone 3a3d161fa0 agent: Claude Desktop uninstalled on Windows is no longer listed (alien_jambob on X)
alien_jambob (Windows 11, 0.1.3603) uninstalled Claude Desktop and magpie
still listed it under 未设置. The uninstall leaves %APPDATA%\Claude behind
with its claude_desktop_config.json (their Everything search shows it),
and Desktop counted as here whenever any of its folders was.

- On Windows Desktop is listed only while its program is installed
  (desktopInstalled): Squirrel's %LOCALAPPDATA%\AnthropicClaude\claude.exe,
  the MSIX's package folder (desktopdir.Installed, as before), or its
  package in the AppX registry (Claude_… or the Store's
  AnthropicPBC.Claude_…, main package only). A Desktop still on magpie
  stays listed, so it can be turned off, as Alma's fix (1b2ad557f) keeps.
- The library's own Claude Desktop entry (apps(), the one that gets MCP
  servers and skills) had the same folder-only check: it is now
  agent.DesktopApp, with the same rule on Windows. Something magpie gave
  it is still listed by held() to be taken back.
- macOS and Linux keep folder detection (unchanged).

The path the row shows, ~\AppData\Local\Claude\claude_desktop_config.json,
is right: it is the file magpie writes deploymentMode into on Windows
(desktopdir's Mode, as CC Switch does) when Desktop is turned on, so it
doesn't exist on a Desktop never connected. Left as is.

Run: go test -run 'Desktop|MSIX' ./internal/agent ./internal/library on
Windows (win-run, xiaomi-gpu): library ok; agent's only reds are six
that fail the same on origin/main 065ca02c2 on that box, all filed
(#4115 CarriesTheLanguage/OpenLody/DesktopExec, #5068 and #5476 sealed
key, #5069 DesktopHandler). Whole internal/agent and internal/library on
mote (darwin): ok. go vet for windows, linux (nogui) and darwin; gofmt.
Whole internal/agent and internal/library on Linux (wsl-run): library
ok, agent red only on TestGrokInstalled (WSL binfmt interop, #3548).
After rebasing on 40cd70d54: vet for three OSes and -run Desktop|MSIX on
Linux, ok.
e2e on Windows: magpie ls in a sandbox USERPROFILE/APPDATA/LOCALAPPDATA
with only Roaming\Claude\claude_desktop_config.json: origin/main lists
Claude Desktop, this change doesn't; with AnthropicClaude\claude.exe
added both list it.

Broken by hand: with the Windows branch taken out (folders count again),
TestClaudeDesktopUninstalledLeftover goes red on "only the leftover",
"a resource package alone" and "another app's package".

Not tried: a real MSIX Desktop uninstalled (the box has the Squirrel
install, which is the user's own); macOS's leftover ~/Library/Application
Support/Claude after Claude.app is trashed is not changed here
(#5979).
2026-11-10 22:56:39 +08:00

104 lines
3.9 KiB
Go

package agent
import (
"os"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/desktopdir"
)
// Claude Desktop installed on Windows and not yet opened has none of its
// folders, so it wasn't listed (#1482): Squirrel's setup has put
// %LOCALAPPDATA%\AnthropicClaude\claude.exe there, the MSIX its package
// folder. Either is Desktop installed; a leftover AnthropicClaude folder
// without its claude.exe is not.
func TestClaudeDesktopInstalledNotOpened(t *testing.T) {
old := desktopdir.OS
desktopdir.OS = "windows"
t.Cleanup(func() { desktopdir.OS = old })
for _, tc := range []struct {
name string
make []string
dir bool
want bool
}{
{"nothing", nil, false, false},
{"Squirrel's setup", []string{"AnthropicClaude", "claude.exe"}, false, true},
{"an uninstall's leftover", []string{"AnthropicClaude", "packages"}, true, false},
{"the MSIX", []string{"Packages", "Claude_pzs8sxrjxfjjc"}, true, true},
{"the Store's MSIX", []string{"Packages", "AnthropicPBC.Claude_fnn82j28hfe8t"}, true, true},
} {
t.Run(tc.name, func(t *testing.T) {
home, _ := desktopSandbox(t)
local := filepath.Join(home, "AppData", "Local")
if tc.make != nil {
p := filepath.Join(append([]string{local}, tc.make...)...)
if tc.dir {
os.MkdirAll(p, 0o755)
} else {
desktopWrite(t, p, "")
}
}
if got := claudeDesktop(home).Detected(); got != tc.want {
t.Fatalf("Claude Desktop listed: %v, want %v", got, tc.want)
}
})
}
}
// alien_jambob on X (Windows 11): Claude Desktop uninstalled leaves
// %APPDATA%\Claude behind with its claude_desktop_config.json, and magpie
// still listed Desktop. On Windows only its program says it is here: the
// Squirrel claude.exe, the MSIX's package folder, or the package in the
// AppX registry. One still on magpie stays listed, to be turned off.
func TestClaudeDesktopUninstalledLeftover(t *testing.T) {
old := desktopdir.OS
desktopdir.OS = "windows"
t.Cleanup(func() { desktopdir.OS = old })
oldPkgs := windowsStorePackages
t.Cleanup(func() { windowsStorePackages = oldPkgs })
for _, tc := range []struct {
name string
pkgs []string
wired bool
exe bool
want bool
}{
{"only the leftover", nil, false, false, false},
{"Squirrel's claude.exe", nil, false, true, true},
{"the package registered", []string{"Claude_1.0.3218.0_x64__pzs8sxrjxfjjc"}, false, false, true},
{"the Store's package registered", []string{"AnthropicPBC.Claude_1.0.3218.0_x64__fnn82j28hfe8t"}, false, false, true},
{"a resource package alone", []string{"Claude_1.0.3218.0_neutral_split.scale-125_pzs8sxrjxfjjc"}, false, false, false},
{"another app's package", []string{"ClaudeLike_1.0.0.0_x64__abc"}, false, false, false},
{"still on magpie", nil, true, false, true},
} {
t.Run(tc.name, func(t *testing.T) {
pkgs := tc.pkgs
windowsStorePackages = func() []string { return pkgs }
home, _ := desktopSandbox(t)
roaming := filepath.Join(home, "AppData", "Roaming", "Claude")
desktopWrite(t, filepath.Join(roaming, "claude_desktop_config.json"), `{"mcpServers": {}}`)
desktopWrite(t, filepath.Join(roaming, "Local State"), `{}`)
local := filepath.Join(home, "AppData", "Local")
os.MkdirAll(filepath.Join(local, "Claude-3p"), 0o755)
if tc.exe {
desktopWrite(t, filepath.Join(local, "AnthropicClaude", "claude.exe"), "")
}
if tc.wired {
desktopWrite(t, filepath.Join(local, "Claude-3p", "configLibrary", "_meta.json"),
`{"appliedId":"`+desktopProfileID+`","entries":[{"id":"`+desktopProfileID+`","name":"magpie"}]}`)
}
if got := claudeDesktop(home).Detected(); got != tc.want {
t.Fatalf("Claude Desktop listed: %v, want %v", got, tc.want)
}
if tc.wired {
return
}
if got := DesktopApp(home, roaming, filepath.Join(roaming, "claude_desktop_config.json")).Detected(); got != tc.want {
t.Fatalf("the library's Claude Desktop listed: %v, want %v", got, tc.want)
}
})
}
}