Skip to content

fix(claude): pin Desktop mode when disabling CLI first-party routing - #659

Closed
luvs01 wants to merge 3 commits into
devfrom
codex/propose-fix-for-desktop-interception-issue
Closed

luvs01 wants to merge 3 commits into
devfrom
codex/propose-fix-for-desktop-interception-issue

Conversation

@luvs01

@luvs01 luvs01 commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a configured standalone-CLI first-party environment from being misattributed to Desktop after an authenticated CLI opt-out and a restart, which could cause Desktop traffic to be routed through the local intercept unexpectedly.

Description

  • Always capture and persist a pre-mutation resolved Desktop mode when cliFirstParty is changed so an absent desktopMode is pinned before writing or removing the shared settings env. (change in src/server/management/agent-settings-routes.ts).
  • Add a regression test that exercises the direct-config/ensure scenario and verifies CLI opt-out pins a Desktop mode, removes the shared proxy environment, and reports the post-mutation status. (added test in tests/claude-integration/claude-management-api.test.ts).
  • Update the configuration contract/documentation to state that changing CLI first-party (both enable and disable) pins an absent Desktop mode prior to shared-settings reconciliation. (edit in structure/config.md).

Testing

  • Ran bun test tests/claude-integration/claude-management-api.test.ts which passed (55 tests in that suite passed).
  • Ran bun run typecheck which completed successfully.
  • Ran bun run structure:check which completed successfully.
  • Ran bun run privacy:scan which completed successfully.

Codex Task


Devin Review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 56ee4c93-2f14-444b-87ad-27012931dce0


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Sep 26, 2026
@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

devin-ai-integration[bot]

This comment was marked as resolved.

…e on CLI opt-out

observeClaudeDesktopMode suppresses an owned shared env while
cliFirstParty is set, so an opt-out that pinned from the pre-mutation
observation resolved gateway and removed a proxy a legacy Desktop
install could still be using. The pin now observes with the flag
cleared — the same state Desktop inference sees after the write — so an
owned env pins first-party and survives, while an env that is not ours
still pins gateway.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
devin-ai-integration[bot]

This comment was marked as resolved.

A CLI-only env established outside the flag flow (hand-configured
cliFirstParty plus an env written by ocx ensure) is indistinguishable
from a legacy Desktop first-party install — the shared env carries no
client marker. Retaining it would silently keep interception on after
opt-out, so the success response now warns 'shared_proxy_retained' when
the retained env's ownership was ambiguous, telling the operator to pin
claudeCode.desktopMode explicitly to release it.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

Devin Review

Comment on lines +1640 to +1642
warnings: [
...(committed.retainedAmbiguous ? ["shared_proxy_retained"] : []),
...(residual ? ["settings_residual"] : []),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 more

The ocx claude config set --first-party off command calls this API, but handleClaudeConfigCommand passes a fixed success line to printData for non-JSON output. That line hides shared_proxy_retained, although the warning is meant to tell operators their shared proxy is still active. The dashboard also discards the successful PUT body in toggleFirstParty; neither interactive client presents the warning.

Example: With cliFirstParty: true, no Desktop mode marker, and an owned shared proxy, opt-out pins Desktop to first-party. The API responds with warnings: ["shared_proxy_retained"], but the CLI displays only “Claude Code settings updated.”

Recommended fix: Render recognized warnings from successful responses in handleClaudeConfigCommand and toggleFirstParty, with localized dashboard copy explaining how to select Desktop gateway mode. Preserve the structured warnings for JSON callers.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +1585 to +1589
// 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 } };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 more

The 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 clientIntegrations['claude-desktop'] = false, cliFirstParty = true, leave desktopMode absent, and install an owned proxy env. PUT cliFirstParty: false pins first-party but removes the env; the response still includes shared_proxy_retained.

Recommended fix: Only emit shared_proxy_retained when the post-mutation Desktop integration actually desires first-party and the proxy remains present after reconciliation; add a focused test covering disabled Desktop integration.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@luvs01

luvs01 commented Sep 27, 2026

Copy link
Copy Markdown
Owner Author

이관됨: lidge-jun#6046

@luvs01

luvs01 commented Sep 27, 2026

Copy link
Copy Markdown
Owner Author

동일 수정이 상류 저장소에 제출되어 이 포크 PR의 목적은 달성됐습니다.

@luvs01 luvs01 closed this Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant