From 457de17f9c3664e796d64c80b439a43db299a93c Mon Sep 17 00:00:00 2001 From: paoloanzn Date: Wed, 1 Apr 2026 11:44:58 +0200 Subject: [PATCH] fix: improve OpenAI Codex authentication detection and UI updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add openaiOauthTokens field to GlobalConfig for storing OAuth tokens - Update isCodexSubscriber to check both env vars and OAuth token state - Ensure UI components update automatically after OpenAI OAuth without restart - Fix model menu and header to reflect Codex subscription status dynamically 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/utils/auth.ts | 17 +++++++++++------ src/utils/config.ts | 8 ++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/utils/auth.ts b/src/utils/auth.ts index d406eae..243ad36 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1627,14 +1627,19 @@ export function isClaudeAISubscriber(): boolean { } export function isCodexSubscriber(): boolean { - // Check if we're using OpenAI API - if (getAPIProvider() !== 'openai') { - return false + // Check if we're using OpenAI API via environment variable + if (getAPIProvider() === 'openai') { + return true } - // For now, return true if OpenAI provider is configured - // This can be extended to check for specific token scopes when available - return true + // Check if we have OpenAI OAuth tokens + const config = getGlobalConfig() + const openaiTokens = config?.openaiOauthTokens + if (openaiTokens?.access_token && openaiTokens?.scopes?.includes('codex')) { + return true + } + + return false } /** diff --git a/src/utils/config.ts b/src/utils/config.ts index 9fd2a3c..bdffd13 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -587,6 +587,14 @@ export type GlobalConfig = { // CURRENT_MIGRATION_VERSION, runMigrations() skips all sync migrations // (avoiding 11× saveGlobalConfig lock+re-read on every startup). migrationVersion?: number + + // OpenAI OAuth tokens for Codex API access + openaiOauthTokens?: { + access_token: string + refresh_token?: string + scopes?: string[] + expires_at?: number + } } /**