From 8fab26d1a3ad4838c5dc02060d150fa82d0c2dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E6=BA=AF?= Date: Thu, 29 Jan 2026 23:17:12 -0800 Subject: [PATCH 1/2] fix auth not change on top bar --- packages/cli/src/ui/AppContainer.tsx | 2 +- packages/cli/src/ui/auth/useAuth.ts | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/cli/src/ui/AppContainer.tsx b/packages/cli/src/ui/AppContainer.tsx index 9ea338932..316521d99 100644 --- a/packages/cli/src/ui/AppContainer.tsx +++ b/packages/cli/src/ui/AppContainer.tsx @@ -419,7 +419,7 @@ export const AppContainer = (props: AppContainerProps) => { handleAuthSelect, openAuthDialog, cancelAuthentication, - } = useAuthCommand(settings, config, historyManager.addItem); + } = useAuthCommand(settings, config, historyManager.addItem, refreshStatic); useInitializationAuthError(initializationResult.authError, onAuthError); diff --git a/packages/cli/src/ui/auth/useAuth.ts b/packages/cli/src/ui/auth/useAuth.ts index 8e5b28499..e295e2c16 100644 --- a/packages/cli/src/ui/auth/useAuth.ts +++ b/packages/cli/src/ui/auth/useAuth.ts @@ -20,7 +20,7 @@ import type { LoadedSettings } from '../../config/settings.js'; import { getPersistScopeForModelSelection } from '../../config/modelProvidersScope.js'; import type { OpenAICredentials } from '../components/OpenAIKeyPrompt.js'; import { useQwenAuth } from '../hooks/useQwenAuth.js'; -import { AuthState, MessageType } from '../types.js'; +import { AuthState } from '../types.js'; import type { HistoryItem } from '../types.js'; import { t } from '../../i18n/index.js'; @@ -30,6 +30,7 @@ export const useAuthCommand = ( settings: LoadedSettings, config: Config, addItem: (item: Omit, timestamp: number) => void, + onAuthChange?: () => void, ) => { const unAuthenticated = config.getAuthType() === undefined; @@ -136,22 +137,14 @@ export const useAuthCommand = ( setIsAuthDialogOpen(false); setIsAuthenticating(false); + // Trigger UI refresh to update header information + onAuthChange?.(); + // Log authentication success const authEvent = new AuthEvent(authType, 'manual', 'success'); logAuth(config, authEvent); - - // Show success message - addItem( - { - type: MessageType.INFO, - text: t('Authenticated successfully with {{authType}} credentials.', { - authType, - }), - }, - Date.now(), - ); }, - [settings, handleAuthFailure, config, addItem], + [settings, handleAuthFailure, config, onAuthChange], ); const performAuth = useCallback( From c2d6c05f12ab790484aa0b58df4db0779a602be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E6=BA=AF?= Date: Thu, 29 Jan 2026 23:28:43 -0800 Subject: [PATCH 2/2] add back addItem --- packages/cli/src/ui/auth/useAuth.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ui/auth/useAuth.ts b/packages/cli/src/ui/auth/useAuth.ts index e295e2c16..82211362c 100644 --- a/packages/cli/src/ui/auth/useAuth.ts +++ b/packages/cli/src/ui/auth/useAuth.ts @@ -20,7 +20,7 @@ import type { LoadedSettings } from '../../config/settings.js'; import { getPersistScopeForModelSelection } from '../../config/modelProvidersScope.js'; import type { OpenAICredentials } from '../components/OpenAIKeyPrompt.js'; import { useQwenAuth } from '../hooks/useQwenAuth.js'; -import { AuthState } from '../types.js'; +import { AuthState, MessageType } from '../types.js'; import type { HistoryItem } from '../types.js'; import { t } from '../../i18n/index.js'; @@ -140,11 +140,22 @@ export const useAuthCommand = ( // Trigger UI refresh to update header information onAuthChange?.(); + // Add success message to history + addItem( + { + type: MessageType.INFO, + text: t('Authenticated successfully with {{authType}} credentials.', { + authType, + }), + }, + Date.now(), + ); + // Log authentication success const authEvent = new AuthEvent(authType, 'manual', 'success'); logAuth(config, authEvent); }, - [settings, handleAuthFailure, config, onAuthChange], + [settings, handleAuthFailure, config, addItem, onAuthChange], ); const performAuth = useCallback(