From 7a818ac728d9153452de8ce9318d86b8a0780074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Mon, 18 May 2026 23:54:03 +0800 Subject: [PATCH] Surface ChatGPT Official OAuth status in settings Settings now mounts the ChatGPT OAuth status controls only after providers have loaded and ChatGPT Official is confirmed active. This keeps token-refreshing status reads scoped to the selected built-in provider. Constraint: OAuth status reads can refresh tokens as a side effect Rejected: Mount ChatGPT OAuth status unconditionally | it repeats the old official OAuth status misfire pattern Confidence: high Scope-risk: narrow Tested: cd desktop && bun run test -- src/__tests__/generalSettings.test.tsx --testNamePattern "ChatGPT|official OAuth|Providers tab" Tested: git diff --check --- desktop/src/__tests__/generalSettings.test.tsx | 15 +++++++++++++++ desktop/src/pages/Settings.tsx | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/desktop/src/__tests__/generalSettings.test.tsx b/desktop/src/__tests__/generalSettings.test.tsx index f59e7447..44096ec1 100644 --- a/desktop/src/__tests__/generalSettings.test.tsx +++ b/desktop/src/__tests__/generalSettings.test.tsx @@ -69,6 +69,10 @@ vi.mock('../components/settings/ClaudeOfficialLogin', () => ({ ClaudeOfficialLogin: () =>
, })) +vi.mock('../components/settings/ChatGPTOfficialLogin', () => ({ + ChatGPTOfficialLogin: () =>
, +})) + vi.mock('../pages/AdapterSettings', () => ({ AdapterSettings: () =>
Adapter Settings Mock
, })) @@ -700,6 +704,16 @@ describe('Settings > Providers tab', () => { expect(screen.queryByTestId('claude-official-login')).not.toBeInTheDocument() }) + it('does not query ChatGPT OAuth status before providers finish loading', () => { + providerStoreState.providers = [] + providerStoreState.activeId = 'openai-official' + providerStoreState.hasLoadedProviders = false + + render() + + expect(screen.queryByTestId('chatgpt-official-login')).not.toBeInTheDocument() + }) + it('shows official OAuth status only after official provider is confirmed active', () => { providerStoreState.providers = [] providerStoreState.activeId = null @@ -720,6 +734,7 @@ describe('Settings > Providers tab', () => { const openAIProvider = screen.getByTestId('openai-official-provider') expect(within(openAIProvider).getByText('ChatGPT Official')).toBeInTheDocument() expect(within(openAIProvider).getByText('Default')).toBeInTheDocument() + expect(screen.getByTestId('chatgpt-official-login')).toBeInTheDocument() expect(screen.queryByTestId('claude-official-login')).not.toBeInTheDocument() }) diff --git a/desktop/src/pages/Settings.tsx b/desktop/src/pages/Settings.tsx index 68675b38..27293317 100644 --- a/desktop/src/pages/Settings.tsx +++ b/desktop/src/pages/Settings.tsx @@ -32,6 +32,7 @@ import { ActivitySettings } from './ActivitySettings' import { MemorySettings } from './MemorySettings' import { useUIStore, type SettingsTab } from '../stores/uiStore' import { ClaudeOfficialLogin } from '../components/settings/ClaudeOfficialLogin' +import { ChatGPTOfficialLogin } from '../components/settings/ChatGPTOfficialLogin' import { OPENAI_OFFICIAL_PROVIDER_ID } from '../constants/openaiOfficialProvider' import { useUpdateStore } from '../stores/updateStore' import { formatBytes } from '../lib/formatBytes' @@ -288,6 +289,12 @@ function ProviderSettings() {
{t('settings.providers.openaiOfficialDesc')}
+ + {isOpenAIOfficialActive && ( +
+ +
+ )} {/* Saved providers */}