Skip to content

fix(provider): add Use Anthropic option to switch back from third-party profiles#1429

Open
0xghost42 wants to merge 1 commit into
Gitlawb:mainfrom
0xghost42:fix/provider-switch-back-anthropic
Open

fix(provider): add Use Anthropic option to switch back from third-party profiles#1429
0xghost42 wants to merge 1 commit into
Gitlawb:mainfrom
0xghost42:fix/provider-switch-back-anthropic

Conversation

@0xghost42
Copy link
Copy Markdown
Contributor

Fixes #1426

Problem

Once any third-party provider profile is active, /provider offers no way back to built-in Anthropic. getActiveProviderProfile falls back to profiles[0] whenever activeProviderProfileId is unset, so clearing the active id still re-selects a saved profile. The only escape was hand-editing ~/.openclaude.json (null the active id, empty providerProfiles) and a full restart — and auth status kept reporting third_party until then due to stale session env.

Fix

  • Add an explicit ANTHROPIC_DEFAULT_PROFILE_ID sentinel. getActiveProviderProfile resolves it to undefined (built-in Anthropic) instead of falling through to profiles[0].
  • Add clearActiveProviderProfile(): records the sentinel as the active id, clears the managed provider env from the current session (so the switch is immediate, no restart), and removes the startup profile mirror file.
  • Surface a Use Anthropic (built-in) choice in the /provider menu, shown whenever the current provider is not Anthropic. Selecting it switches mid-session and emits a provider-switch system reminder.

Saved profiles are preserved for re-selection — this only changes which one is active.

Test plan

  • bun test src/utils/providerProfiles.test.ts — added coverage: sentinel resolves to undefined while saved profiles persist; managed env cleared from session.
  • bun test src/commands/provider/provider.test.tsx
  • bun run build
  • node dist/cli.mjs --version (smoke)

…ty profiles

The /provider menu offered no way back to built-in Anthropic once any
third-party provider profile was active: getActiveProviderProfile falls
back to profiles[0] when activeProviderProfileId is unset, so clearing
the active id still re-selected a saved profile. Users had to hand-edit
~/.openclaude.json and restart.

Add an explicit ANTHROPIC_DEFAULT_PROFILE_ID sentinel that getActive-
ProviderProfile resolves to undefined (Anthropic) instead of profiles[0],
and a clearActiveProviderProfile() that records the sentinel, clears the
managed provider env in-session, and removes the startup profile mirror.
Surface it as a 'Use Anthropic (built-in)' choice in /provider, shown
whenever the current provider is not Anthropic. Saved profiles are kept
for re-selection; the switch takes effect without a restart.

Fixes Gitlawb#1426
@0xghost42
Copy link
Copy Markdown
Contributor Author

Heads up on the red smoke-and-tests: the 4 failures (getAttributionTexts coAuthoredBy, the two auto-compact cooldown tests, and breaker metadata tracking callback publishes a fresh object) are pre-existing on main, not from this change.

I checked out a clean upstream/main and ran the full suite — same 3 cooldown/breaker failures reproduce there with zero diff applied (the attribution one is order-dependent and only trips in the full CI run). On this branch:

  • bun test src/utils/providerProfiles.test.ts → 76 pass (3 new)
  • bun test src/commands/provider/provider.test.tsx → 25 pass
  • the four flaky files pass in isolation
  • bun run build + node dist/cli.mjs --version green

The diff only touches provider profile state (providerProfiles.ts, provider.tsx) — nothing in the attribution/auto-compact/breaker paths. Happy to rebase once main is green if that helps the check go through.

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