-
Notifications
You must be signed in to change notification settings - Fork 0
fix(claude): pin Desktop mode when disabling CLI first-party routing #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1a871c4
efebe4d
1788ae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1554,7 +1554,8 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise | |
| catch { return jsonResponse({ error: "Claude settings are unreadable", code: "unreadable" }, 500); } | ||
| type FirstPartyMutation = | ||
| | { refusal: { error: string; code: "intercept_disabled" | "intercept_unavailable" } } | ||
| | { claudeCode: OcxConfig["claudeCode"]; previous: { present: boolean; value: boolean }; pinnedMode: "first-party" | "gateway" | undefined }; | ||
| | { claudeCode: OcxConfig["claudeCode"]; previous: { present: boolean; value: boolean }; | ||
| pinnedMode: "first-party" | "gateway" | undefined; retainedAmbiguous: boolean }; | ||
| let outcome: ReturnType<typeof mutatePersistedConfig<FirstPartyMutation>>; | ||
| try { | ||
| outcome = mutatePersistedConfig<FirstPartyMutation>(persisted => { | ||
|
|
@@ -1569,14 +1570,23 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise | |
| const before = structuredClone(persisted); | ||
| const previous = { present: Object.hasOwn(persisted.claudeCode ?? {}, "cliFirstParty"), | ||
| value: persisted.claudeCode?.cliFirstParty === true }; | ||
| const pinnedMode = body.cliFirstParty && persisted.claudeCode?.desktopMode === undefined | ||
| ? resolveClaudeDesktopMode(before, observeClaudeDesktopMode(before)) : undefined; | ||
| // Pin the mode Desktop resolves to *after* this mutation: while cliFirstParty is set the | ||
| // shared env is suppressed as Desktop evidence, so an opt-out observed with the flag still | ||
| // on would pin gateway and disconnect a Desktop install that predates the marker. | ||
| const observedBefore = structuredClone(before); | ||
| if (!body.cliFirstParty) delete observedBefore.claudeCode?.cliFirstParty; | ||
| const pinnedMode = persisted.claudeCode?.desktopMode === undefined | ||
| ? resolveClaudeDesktopMode(before, observeClaudeDesktopMode(observedBefore)) : undefined; | ||
| const nextBlock = { ...(persisted.claudeCode ?? {}) }; | ||
| if (body.cliFirstParty) nextBlock.cliFirstParty = true; | ||
| else delete nextBlock.cliFirstParty; | ||
| if (pinnedMode) nextBlock.desktopMode = pinnedMode; | ||
| commitClaudeCodeBlock(persisted, nextBlock); | ||
| return { changed: true, value: { claudeCode: structuredClone(persisted.claudeCode), previous, pinnedMode } }; | ||
| // An opt-out that pins first-party from the shared env cannot tell whether that env was | ||
| // Desktop's or a hand-configured CLI-only one; the env is retained (Desktop keeps its | ||
| // route) and the caller is warned so it can pin gateway explicitly to release it. | ||
| const retainedAmbiguous = !body.cliFirstParty && previous.value && pinnedMode === "first-party"; | ||
| return { changed: true, value: { claudeCode: structuredClone(persisted.claudeCode), previous, pinnedMode, retainedAmbiguous } }; | ||
|
Comment on lines
+1585
to
+1589
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Removed proxy is reported as retained when Desktop integration is off With Desktop integration disabled, CLI opt-out removes the shared proxy through reconciliation. The response still warns that the proxy was retained, misleading callers about its actual state. Learn moreThe warning is computed from the previous CLI flag and pinned Desktop mode, not from whether Desktop integration is enabled or the final reconciliation result. desktopFirstPartyDesired returns false when the integration is disabled; reconcileClaudeFirstPartySettings then removes the owned env because neither Desktop nor CLI wants it. The successful response nevertheless claims it was retained. Example: Set Recommended fix: Only emit Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| }); | ||
| } catch { return jsonResponse({ error: "Could not save Claude settings", code: "write_failed" }, 500); } | ||
| if (outcome.status === "unavailable") return jsonResponse({ error: "Could not save Claude settings", code: "write_failed" }, 500); | ||
|
|
@@ -1626,7 +1636,11 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise | |
| const residual = !finalDesired.desktop && !finalDesired.cli | ||
| && readFirstPartyProxyStatus(config, bound?.proxyPort ?? null) !== "none"; | ||
| return jsonResponse({ ok: true, enabled: config.claudeCode?.enabled !== false, | ||
| cliFirstParty: body.cliFirstParty, warnings: residual ? ["settings_residual"] : [] }); | ||
| cliFirstParty: body.cliFirstParty, | ||
| warnings: [ | ||
| ...(committed.retainedAmbiguous ? ["shared_proxy_retained"] : []), | ||
| ...(residual ? ["settings_residual"] : []), | ||
|
Comment on lines
+1640
to
+1642
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 CLI users never see the retained-proxy warning When CLI opt-out retains an ambiguous proxy, the API returns a warning. The CLI command prints only a fixed success message, so operators never see the remedy. Learn moreThe Example: With Recommended fix: Render recognized warnings from successful responses in Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| ] }); | ||
| } | ||
| for (const field of ["webSearchSidecar", "visionSidecar"] as const) { | ||
| const section = body[field]; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.