fix: extend provider guard to protect anthropic profiles from cross-terminal override (#641)
The provider profile activation guard in applyActiveProviderProfileFromConfig() only checked CLAUDE_CODE_USE_* environment flags, which are never set for the default anthropic provider. This allowed two terminals sharing ~/.claude.json to overwrite each other's active provider when one was using anthropic and the other a third-party provider. Now also checks the OCODE_PROVIDER_PROFILE_APPLIED flag, which is set by all profiles including anthropic, preventing cross-terminal interference. Co-authored-by: Ali Alakbarli <ali.alakbarli@users.noreply.github.com>
This commit is contained in:
@@ -417,7 +417,7 @@ export function applyActiveProviderProfileFromConfig(
|
||||
processEnv[PROFILE_ENV_APPLIED_FLAG] === '1' &&
|
||||
trimOrUndefined(processEnv[PROFILE_ENV_APPLIED_ID]) === activeProfile.id
|
||||
|
||||
if (!options?.force && hasProviderSelectionFlags(processEnv)) {
|
||||
if (!options?.force && (hasProviderSelectionFlags(processEnv) || processEnv[PROFILE_ENV_APPLIED_FLAG] === '1')) {
|
||||
// Respect explicit startup provider intent. Auto-heal only when this
|
||||
// exact active profile previously applied the current env.
|
||||
if (!isCurrentEnvProfileManaged) {
|
||||
|
||||
Reference in New Issue
Block a user