fix(setup): resolve the configuration MSIX Claude Desktop reads (#2426)

* fix(setup): resolve the configuration MSIX Claude Desktop reads

On Windows, setup, doctor and uninstall always used
%APPDATA%\Claude\claude_desktop_config.json. The MSIX build of Claude
Desktop (package family Claude_pzs8sxrjxfjjc) virtualizes AppData writes
and reads its package-private copy under
%LOCALAPPDATA%\Packages\<family>\LocalCache\Roaming\Claude once it exists.
Setup from an ordinary process therefore wrote a file the app never reads,
and doctor reported that file healthy.

Resolve the Claude Desktop location once, in supportedClients(): the
private copy when it exists, else the AppData file the package still
reads, else a new private copy. An unrecognized Claude_* publisher or
unreadable package storage is reported instead of falling back to AppData.

Compare one of the package's private files with its AppData path through
realpath.native to learn whether the running package started this
process. From that redirected view, or when no file can be compared,
setup and uninstall refuse to change Claude Desktop's configuration,
because the running app rewrites it from memory. From a redirected view
they also refuse writes under %APPDATA% and %LOCALAPPDATA% for other
clients and skills, which would land in the package's private storage.

Setup refuses to register a launcher stored in any MSIX package's
private storage, discloses which file the package reads, and tells the
user to quit Claude Desktop fully on every platform. Configuration fails
with target_changed if the package switched to its private copy after
the plan was shown. Uninstall removes REA from both files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(setup): record the verified MSIX Claude Desktop registration

On the Windows 11 host with the MSIX build 2.31226.1.0, setup from an
ordinary terminal with the app quit wrote the package-private copy. After
the app restarted, the entry persisted, doctor reported it aligned, and
Claude Desktop's MCP log showed REA starting and answering tools/list.
Uninstall against the real app remains unverified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style(setup): format MSIX review corrections

* fix(setup): carry the admitted legacy path through uninstall removal

clientRegistrationRemoval returned a removeLegacy boolean, and removeClient
recomputed the legacy path separately, so TypeScript could not prove the
path existed when removeLegacy was true and `tsc --noEmit` failed in
Uninstall.ts. The decision now returns the admitted legacy path itself;
preflight and removal consume that one value.

The alias regression matched new-destination children with a "/"
separator while building paths with path.join, so it failed on Windows.
It now uses path.sep.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(setup): split MSIX Claude Desktop lifecycle cases under the function length limit

The uninstall cases pushed the registration lifecycle describe past the 150-line lint limit. Group them separately, with the AppData registration case kept among the registration cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
FeeHaard
2026-10-13 22:04:22 +08:00
committed by GitHub
co-authored by Claude Opus 5.5 morluto
parent 5996d8160f
commit fd65e278be
21 changed files with 1765 additions and 125 deletions
+117 -1
View File
@@ -1,9 +1,43 @@
import { describe, expect, it } from "vitest";
import { resolve } from "node:path";
import { join, resolve } from "node:path";
import { FakeSetupHost, options } from "./Setup.fixture.js";
import { runSetup } from "./Setup.js";
import { setupRegistrationCommand } from "./SetupHost.js";
import type { MsixPackageView } from "./MsixPackageStorage.js";
import type { SetupClient } from "./SupportedClients.js";
// Host joins keep containment checks meaningful on POSIX test hosts too.
const PROFILE = String.raw`C:\Users\a`;
const ROAMING = join(PROFILE, "AppData", "Roaming");
const LOCAL = join(PROFILE, "AppData", "Local");
const PRIVATE_CONFIG = join(
LOCAL,
"Packages",
"Claude_pzs8sxrjxfjjc",
"LocalCache",
"Roaming",
"Claude",
"claude_desktop_config.json",
);
const APPDATA_CONFIG = join(ROAMING, "Claude", "claude_desktop_config.json");
/** Claude Desktop as setup resolves it from its MSIX package storage. */
const msixClaudeDesktop = (
processView: MsixPackageView["processView"],
): SetupClient => ({
name: "claude_desktop",
displayName: "Claude Desktop",
configPath: PRIVATE_CONFIG,
quitBeforeSetup: true,
msixPackage: {
packageFamilyName: "Claude_pzs8sxrjxfjjc",
privateConfigPath: PRIVATE_CONFIG,
appDataConfigPath: APPDATA_CONFIG,
virtualizedRoots: [ROAMING, LOCAL],
processView,
},
});
describe("setup workflow", () => {
it("omits an aligned managed skill from an otherwise empty plan", async () => {
@@ -293,3 +327,85 @@ describe("setup workflow action selection", () => {
expect(result.remediation).not.toContain("internal_client_key");
});
});
describe("MSIX Claude Desktop setup", () => {
it("discloses which file MSIX Claude Desktop reads and that it must be quit", async () => {
const host = new FakeSetupHost("win32");
host.hopper = join(PROFILE, "Hopper");
host.skill = "unchanged";
host.clients = [msixClaudeDesktop("direct")];
const result = await runSetup(
{ ...options(false), clientIds: ["claude_desktop"], dryRun: true },
host,
);
expect(result.status).toBe("planned");
const [action] = result.plannedActions;
expect(action?.target).toBe(PRIVATE_CONFIG);
expect(action?.detail).toContain(
`Claude Desktop is installed as MSIX package Claude_pzs8sxrjxfjjc, which reads this package-private file instead of ${APPDATA_CONFIG}.`,
);
expect(action?.detail).toContain(
"Quit Claude Desktop fully before approving; closing its window is not enough.",
);
});
it("refuses AppData writes from a process the MSIX package started", async () => {
const host = new FakeSetupHost("win32");
host.hopper = join(PROFILE, "Hopper");
host.skill = "unchanged";
const vscode = join(ROAMING, "Code", "User", "mcp.json");
host.clients = [
msixClaudeDesktop("redirected"),
{ name: "vscode", displayName: "VS Code", configPath: vscode },
{
name: "codex",
displayName: "Codex",
configPath: join(PROFILE, ".codex", "config.toml"),
},
];
const blocked = await runSetup(
{ ...options(true), clientIds: ["vscode", "codex"] },
host,
);
expect(blocked.status).toBe("needs_human");
expect(blocked.remediation).toContain(
`Changes to ${vscode} would not reach the files other apps read.`,
);
expect(host.configurations).toBe(0);
const homeOnly = await runSetup(
{ ...options(true), clientIds: ["codex"] },
host,
);
expect(homeOnly.status).toBe("ready");
expect(host.configurations).toBe(1);
});
it("refuses registrations whose launcher only one MSIX package can see", async () => {
const host = new FakeSetupHost("win32");
host.hopper = join(PROFILE, "Hopper");
host.registrationCommandBlocker = "Install REA outside the package.";
host.clients = [
{ name: "codex", displayName: "Codex", configPath: "/codex.toml" },
];
const blocked = await runSetup(
{ ...options(true), clientIds: ["codex"] },
host,
);
expect(blocked.status).toBe("needs_human");
expect(blocked.remediation).toBe("Install REA outside the package.");
expect(host.configurations).toBe(0);
expect(host.skillInstalls).toBe(0);
const skillOnly = await runSetup(
{ ...options(true), clientIds: [], installSkill: true },
host,
);
expect(skillOnly.status).toBe("ready");
expect(host.skillInstalls).toBe(1);
});
});