diff --git a/src/components/Onboarding.tsx b/src/components/Onboarding.tsx index fdd3027a..8fca79f1 100644 --- a/src/components/Onboarding.tsx +++ b/src/components/Onboarding.tsx @@ -99,7 +99,7 @@ export function Onboarding({ // Add API key step if needed // On homespace, ANTHROPIC_API_KEY is preserved in process.env for child // processes but ignored by Claude Code itself (see auth.ts). - if (!process.env.ANTHROPIC_API_KEY || isRunningOnHomespace()) { + if (!process.env.ANTHROPIC_API_KEY || isRunningOnHomespace() || !isAnthropicAuthEnabled()) { return ''; } const customApiKeyTruncated = normalizeApiKeyForConfig(process.env.ANTHROPIC_API_KEY); diff --git a/src/services/api/errors.ts b/src/services/api/errors.ts index d77c92a9..45056127 100644 --- a/src/services/api/errors.ts +++ b/src/services/api/errors.ts @@ -164,6 +164,12 @@ export const TOKEN_REVOKED_ERROR_MESSAGE = export const CCR_AUTH_ERROR_MESSAGE = 'Authentication error ยท This may be a temporary network issue, please try again' export const REPEATED_529_ERROR_MESSAGE = 'Repeated 529 Overloaded errors' +export function getCustomOffSwitchMessage(): string { + return getAPIProvider() === 'firstParty' + ? 'Opus is experiencing high load, please use /model to switch to Sonnet' + : 'The API is experiencing high load, please try again shortly or use /model to switch models' +} +// Backward-compatible constant for string matching in error handlers export const CUSTOM_OFF_SWITCH_MESSAGE = 'Opus is experiencing high load, please use /model to switch to Sonnet' export const API_TIMEOUT_ERROR_MESSAGE = 'Request timed out' @@ -457,7 +463,7 @@ export function getAssistantMessageFromError( error.message.includes(CUSTOM_OFF_SWITCH_MESSAGE) ) { return createAssistantAPIErrorMessage({ - content: CUSTOM_OFF_SWITCH_MESSAGE, + content: getCustomOffSwitchMessage(), error: 'rate_limit', }) }