Skip to content

fix(/provider): add Anthropic option to switch back without restarting (#1426)#1439

Open
ajsai47 wants to merge 1 commit into
Gitlawb:mainfrom
ajsai47:fix/1426-switch-back-to-anthropic
Open

fix(/provider): add Anthropic option to switch back without restarting (#1426)#1439
ajsai47 wants to merge 1 commit into
Gitlawb:mainfrom
ajsai47:fix/1426-switch-back-to-anthropic

Conversation

@ajsai47
Copy link
Copy Markdown

@ajsai47 ajsai47 commented May 29, 2026

Problem

Fixes #1426.

Once a third-party provider was activated via /provider, the "Set active provider" screen offered no path back to Anthropic. Users had to manually edit ~/.openclaude.json, set activeProviderProfileId to null, clear providerProfiles, and fully restart. Even then, openclaude auth status still showed authMethod: third_party until the restart completed.

Root cause

renderProfileSelection in ProviderManager.tsx only listed saved third-party profiles and (optionally) GitHub Models. There was no Anthropic entry and no function to clear the active provider profile from config.

Fix

src/utils/providerProfiles.ts

  • Add clearActiveProviderProfile() — sets activeProviderProfileId: undefined in global config and deletes the startup profile file so Anthropic is used on next launch too

src/utils/providerProfile.ts

  • Export PROFILE_ENV_KEYS (was const) so ProviderManager can use the authoritative list of provider env vars to wipe

src/components/ProviderManager.tsx

  • Add ANTHROPIC_PROVIDER_ID = '__anthropic__' sentinel
  • Add includeAnthropic option to renderProfileSelection — appends "Anthropic / Claude" to the list, marked "(active)" when no third-party profile is set
  • Pass includeAnthropic: true to the select-active screen
  • Handle the sentinel in activateSelectedProvider: calls clearActiveProviderProfile(), wipes all PROFILE_ENV_KEYS from process.env, clears the startup override — switch takes effect immediately without a restart

src/utils/providerProfiles.test.ts

  • New test: activates an OpenAI provider profile, then calls clearActiveProviderProfile() and asserts activeProviderProfileId is cleared

Test plan

  • Start with Anthropic (default)
  • Run /provider → add a DeepSeek profile → activate it
  • Confirm DeepSeek is used for a message
  • Run /provider → "Set active provider" → select "Anthropic / Claude"
  • Confirm the next message uses Anthropic without restarting
  • Restart OpenClaude — confirm it still starts on Anthropic
  • bun test src/utils/providerProfiles.test.ts — 193 pass, 0 fail

🤖 Generated with Claude Code

…n switch back without restarting (Gitlawb#1426)

Previously, once a third-party provider was activated via /provider, the
"Set active provider" screen had no way to return to Anthropic — users had
to manually edit ~/.openclaude.json and restart. This change:

- Adds an "Anthropic / Claude" entry to the "Set active provider" list
- Selecting it calls clearActiveProviderProfile() which clears
  activeProviderProfileId from config and deletes the startup profile file
- Wipes all CLAUDE_CODE_USE_* and provider-specific env vars from the
  running process so the switch takes effect immediately without a restart
- Marks the Anthropic option as "(active)" when no third-party profile is set

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

/provider: Cannot switch back to Anthropic after adding any third-party provider

1 participant