Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cli/claude-desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/claude-integration/claude-desktop-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading