diff --git a/src/cli/claude-desktop.ts b/src/cli/claude-desktop.ts index 238e6bb03e8..4fb5d83756e 100644 --- a/src/cli/claude-desktop.ts +++ b/src/cli/claude-desktop.ts @@ -377,7 +377,8 @@ export async function handleClaudeDesktopCommand(argv: string[], deps: ApplyProf const applyInvocation = argv.length === 0 || command === "apply" || applyFlags.length > 0; if (applyInvocation) { const rest = argv.filter(arg => arg !== "apply"); - const parsedTarget = parseDesktopApplyArgs(rest, loadConfig()); + const preApplyConfig = loadConfig(); + const parsedTarget = parseDesktopApplyArgs(rest, preApplyConfig); if ("error" in parsedTarget) { console.error(parsedTarget.error); return 2; } const { target } = parsedTarget; try { @@ -402,7 +403,7 @@ export async function handleClaudeDesktopCommand(argv: string[], deps: ApplyProf console.log(`Claude Desktop gateway 설정을 적용했습니다: ${result.path}`); for (const line of gatewayModeExplanation({ requestedExplicitly: applyFlags.some(flag => flag !== "--first-party"), - config: loadConfig(), + config: preApplyConfig, })) { console.log(line); } diff --git a/tests/claude-integration/claude-desktop-cli.test.ts b/tests/claude-integration/claude-desktop-cli.test.ts index a33026bf349..2d87d332b74 100644 --- a/tests/claude-integration/claude-desktop-cli.test.ts +++ b/tests/claude-integration/claude-desktop-cli.test.ts @@ -508,12 +508,16 @@ test("apply writes locally only when no proxy is running", async () => { }); test("no-arg and legacy mode flags apply Desktop config", async () => { + const config = loadConfig(); + config.claudeCode = { intercept: { enabled: false } }; + saveConfig(config); const log = spyOn(console, "log").mockImplementation(() => {}); const error = spyOn(console, "error").mockImplementation(() => {}); try { // Deterministic: no live proxy in the test environment, so apply writes locally. const noProxy = { findLiveProxyImpl: async () => null }; expect(await handleClaudeDesktopCommand([], noProxy)).toBe(0); + expect(log.mock.calls.flat().join(" ")).not.toContain("ocx claude desktop apply --first-party"); expect(await handleClaudeDesktopCommand(["--static"], noProxy)).toBe(0); expect(readFileSync(join(process.env.OPENCODEX_CLAUDE_DESKTOP_CONFIG_DIR!, "_meta.json"), "utf8")).toContain("opencodex"); expect(error).not.toHaveBeenCalled();