Skip to content

fix(proxy): resolve merge conflicts for #580 (proxy disconnect support) - #618

Open
Erithiel wants to merge 10 commits into
codemie-ai:mainfrom
Erithiel:EPMCDME-15246-resolve-pr580-conflicts
Open

Erithiel wants to merge 10 commits into
codemie-ai:mainfrom
Erithiel:EPMCDME-15246-resolve-pr580-conflicts

Conversation

@Erithiel

@Erithiel Erithiel commented Oct 8, 2026

Copy link
Copy Markdown

Summary

This is a merge-conflict resolution on top of #580's branch, not new functionality — the actual target-handling logic from both sides is preserved as-is.

Test plan

Generated with AI

Co-Authored-By: codemie-ai codemie.ai@gmail.com

zkovacs-bit and others added 10 commits September 25, 2026 16:07
Export removeDesktopConfig() and readManagedMcpState() from desktop.ts,
reversing writeDesktopConfig's write: strips INFERENCE_KEYS, inferenceModels,
coworkEgressAllowedHosts, and marker-managed MCP entries while preserving
genuine user-added MCP entries. No-ops when nothing was connected.

EPMCDME-15246 (proxy-disconnect-support), task 1/5.
Export removeVsCodeLanguageModelsConfig(), checking both stable and Insiders
chatLanguageModels.json locations and filtering out the CodeMie provider
entry. A missing product dir (edition not installed) is treated as
nothing-to-do per location; corrupt JSON still throws.

EPMCDME-15246 (proxy-disconnect-support), task 2/5.
Export removeVsCodeClaudeCodeConfig(), stripping the ANTHROPIC_BASE_URL /
ANTHROPIC_AUTH_TOKEN managed entries from claudeCode.environmentVariables at
both stable and Insiders settings.json, via targeted jsonc-parser edits so
comments/formatting survive. Missing product dir per edition no-ops; corrupt
JSONC still throws.

EPMCDME-15246 (proxy-disconnect-support), task 3/5.
Rewrite disconnectTargets from its single codex-desktop-only branch to
independent per-target TargetResult dispatch (Claude Desktop, VS Code Copilot
Chat, VS Code Claude Code, Codex Desktop), mirroring connect-orchestrator's
shape. One target throwing sets process.exitCode = 1 without blocking a
sibling target's own outcome. Codex Desktop behavior is unchanged.

EPMCDME-15246 (proxy-disconnect-support), task 4/5.
Add --claude-desktop, --vscode, --vscode-claude-code options to the
disconnect subcommand alongside --codex-desktop, and pass all four booleans
through to disconnectTargets. Updates the existing CLI wiring test's
expectation to the new four-key targets object.

EPMCDME-15246 (proxy-disconnect-support), task 5/5.
Fixes five blocking findings from the disconnect-support review:
non-transactional config/marker writes in removeDesktopConfig now
tolerate a marker-clear failure without masking a successful config
strip; VS Code Copilot Chat and Claude Code disconnect connectors
isolate per-location (stable/Insiders) write failures so one location's
error no longer discards the other's success; disconnect-orchestrator
adopts connect-orchestrator's printSummary convention; CLI-parser tests
cover the three new disconnect flags; and removeDesktopConfig now
detects stranded gateway keys directly on the config file as a fallback
when a failed org-catalog fetch on first connect left no marker behind.

Ref: EPMCDME-15246
…_proxy-disconnect-support

# Conflicts:
#	src/cli/commands/proxy/connectors/vscode.ts
…_proxy-disconnect-support

# Conflicts:
#	src/cli/commands/proxy/__tests__/connect-wiring.test.ts
#	src/cli/commands/proxy/__tests__/disconnect-orchestrator.test.ts
#	src/cli/commands/proxy/disconnect-orchestrator.ts
#	src/cli/commands/proxy/index.ts
removeVsCodeLanguageModelsConfig and removeVsCodeClaudeCodeConfig only
wrapped the write in a per-location try/catch, so a read failure (e.g.
a permission error or corrupt file) at the stable location aborted the
loop before the Insiders location was even attempted, leaving its
managed entries behind with no indication anything was skipped.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>

@Bondimm Bondimm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Suggest merging this PR and closing #580 with a link here. This branch contains every commit of #580 (its head descends from #580's fdbdcab0), plus the merge with main and b9ccc8dc (per-location read isolation in the two VS Code removals, which #580 doesn't have). CI here is green (2026-10-08, b9ccc8dc); #580 conflicts with main and fails "Validate Commits & PR" because its title is 101 characters long. The repo squash-merges, so the PR title becomes the commit on main: consider retitling to a feat(proxy): ... title under 100 characters (for example feat(proxy): add disconnect for Claude Desktop, VS Code Copilot Chat and VS Code Claude Code) and keeping a Co-authored-by line for the #580 author.
  • Conflict resolution checked: I redid the merge of fdbdcab0 with cbdf45e6 locally. Only the four conflicted files differ from the automatic result. index.ts keeps main's --claude-code-otlp and --scope options and adds the three new flags. The orchestrator still calls removeClaudeCodeOtlpConfig({ scope }) with the same messages; the OTLP result now also goes into the summary, and a failure still sets exit code 1. All of main's OTLP orchestrator and wiring tests are still there.
  • main is now 9 commits ahead, including #609 in src/cli/commands/proxy. Merged locally with current main (no conflicts): tsc --noEmit clean, eslint on the changed files clean, vitest run --project unit src/cli/commands/proxy 19 files / 474 tests passed (472 on this head alone).
  • Checked against EPMCDME-15246: --vscode and --vscode-claude-code remove only CodeMie's entries, at both the stable and Insiders locations. Other providers and env entries survive, and so do the comments in settings.json. An unparseable file is refused without changes, and a second run reports "nothing to disconnect". The summary and exit code match --codex-desktop. The Claude Desktop gaps are in the thread below.
  • Product question: connect --vscode-claude-code also writes claudeCode.disableLoginPrompt: true, and disconnect leaves it in place. After a disconnect the extension then has neither the gateway nor a login prompt. Should disconnect remove it too? Connect doesn't record whether the user had it set before.
  • Feature flag: none. The new code runs only when one of the new flags is passed, and a bare disconnect still prints the target list. Revert: code only. The one new on-disk effect is an emptied desktop-managed-mcp-state.json, and the old code reads that as "no marker", so a revert is safe.
  • #608 also changes connectors/vscode.ts and conflicts with this PR there, so whichever merges second needs a small rebase.

What needs rechecking after the next push:

  • Claude Desktop disconnect when never connected, after switching Desktop to another config, and after a connect whose MCP catalog fetch failed;
  • CI on the new head.

);
}

const hasStrandedGatewayKeys = INFERENCE_KEYS.some((key) => key in existing);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Claude Desktop disconnect deletes provider settings CodeMie did not write

Problem: removeDesktopConfig treats the applied config as CodeMie's whenever any of inferenceProvider, inferenceGatewayBaseUrl, inferenceGatewayApiKey or inferenceGatewayAuthScheme is present, even with no marker (line 976). It then deletes all four keys plus inferenceModels and coworkEgressAllowedHosts (lines 983-987). It also edits whichever file _meta.json's appliedId points to now, not necessarily the file connect wrote. I ran removeDesktopConfig locally on temp directories:

  • never connected, with the user's own gateway (https://my-company-gateway.example.com) as the applied config: it returned removed: true and deleted all inference keys, the model list and the egress hosts;
  • inferenceProvider: "bedrock" and no marker: it deleted inferenceProvider and reported the config as removed;
  • connected, then the user switched Desktop to a second config in the library: the user's config was emptied to {} and the CodeMie config was left untouched.

The missing marker causes the opposite problem too. When the MCP catalog fetch fails at connect, or the profile has no CodeMie URL, no marker is written. Disconnect then leaves all seven bundled MCP servers in the config (Notion, Linear, Box, Canva, Vercel, Netlify, Miro).

Impact: A Claude Desktop (3P) user who runs codemie proxy disconnect --claude-desktop without an active CodeMie connection, or after switching to another config, loses their own inference provider settings, and the command prints "✓ Claude Desktop disconnected". In these cases the story ACs "nothing to disconnect is handled gracefully when the app was never connected" and "removes CodeMie's managed MCP entries" are not met.

Recommendation: Consider recording what CodeMie wrote on every connect, including connects where the catalog fetch failed: the config id, the gateway URL and the MCP names it added. Disconnect would then touch only that config file, and strip the inference keys only while inferenceGatewayBaseUrl still points at the CodeMie daemon (it always binds http://127.0.0.1:<port>). With no record and no CodeMie URL in the file, it would report "nothing to disconnect". Tests for the never-connected and switched-config cases would cover this.

@codemie-ai

Copy link
Copy Markdown
Owner

[AUTO_CLOSE_WARNING] ⏰ This pull request has had no activity for 7 days (last activity: 2026-10-13).

It will be automatically closed no earlier than 2026-10-27 (UTC) (~6 more days).

Any activity from anyone — a comment, a push, a review, reopening — restarts the countdown from that moment. This warning will be deleted automatically once that happens.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants