From 98d4f19b61fa3e0cc0d1d45b74eaf68feeefaee2 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:58:30 -0700 Subject: [PATCH] Keep auth-required usage errors from rendering as a rate-limit Limited label The new Codex app-server error 'chatgpt authentication required to read rate limits' mentions rate limits only as the object it failed to read, but the status bar's rate-limit classifier matched the phrase and labeled the chip 'Limited'. Classify authentication-required messages as auth failures so they get the standard softened refresh copy instead. --- .../src/components/status-bar/tooltip.test.ts | 14 ++++++++++++++ .../src/components/status-bar/usage-error-copy.ts | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/status-bar/tooltip.test.ts b/src/renderer/src/components/status-bar/tooltip.test.ts index d9387633fa0..6daf47a8c1c 100644 --- a/src/renderer/src/components/status-bar/tooltip.test.ts +++ b/src/renderer/src/components/status-bar/tooltip.test.ts @@ -185,6 +185,20 @@ describe('provider usage error copy', () => { ) }) + it('classifies the Codex chatgpt-auth-required rate-limits read error as auth, not Limited', () => { + // Why: the message mentions "rate limits" only as the object it failed to + // read; labeling it "Limited" would wrongly imply the user hit a limit. + const p = provider({ + provider: 'codex', + error: 'chatgpt authentication required to read rate limits' + }) + + expect(getProviderUsageStatusLabel(p)).toBe('Refresh failed') + expect(getProviderUsageErrorMessage(p)).toBe( + 'Codex usage could not be refreshed. Agent sessions may still be signed in.' + ) + }) + it('keeps generic OAuth and network failures as raw refresh details', () => { const oauth = provider({ error: 'OAuth API returned 500' }) const network = provider({ error: 'Network error while refreshing OAuth usage: ECONNRESET' }) diff --git a/src/renderer/src/components/status-bar/usage-error-copy.ts b/src/renderer/src/components/status-bar/usage-error-copy.ts index 83fc1888beb..0b0c3bc2eb6 100644 --- a/src/renderer/src/components/status-bar/usage-error-copy.ts +++ b/src/renderer/src/components/status-bar/usage-error-copy.ts @@ -30,7 +30,13 @@ export function getProviderDisplayName(provider: ProviderRateLimits['provider']) } function isUsageRateLimitError(message: string | null): boolean { - return Boolean(message && /\brate[- ]?limits?\b|\brate[- ]?limited\b/i.test(message)) + // Why: Codex app-server's "chatgpt authentication required to read rate + // limits" mentions rate limits only as the thing it could not read; treat + // authentication-required failures as auth, never as the user being limited. + if (!message || /\bauthentication required\b/i.test(message)) { + return false + } + return /\brate[- ]?limits?\b|\brate[- ]?limited\b/i.test(message) } const USAGE_AUTH_ERROR_PATTERNS = [ @@ -45,6 +51,7 @@ const USAGE_AUTH_ERROR_PATTERNS = [ /\bauth (?:is missing|tokens are missing|does not expose)\b/i, /\bunauthori[sz]ed\b/i, /\bunauthenticated\b/i, + /\bauthentication required\b/i, /\bplease reauthenticate\b/i, /\bsign in\b/i, /\blogged in to another account\b/i,