From d32d84f1a9337c7b9092d0cf3c5d3b6dce475f7d Mon Sep 17 00:00:00 2001 From: paisley <8197966+su8su@users.noreply.github.com> Date: Mon, 9 Mar 2026 13:24:59 +0800 Subject: [PATCH] fix: packaged app gateway connection; default Google to API key (#359) --- src/components/settings/ProvidersSettings.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/settings/ProvidersSettings.tsx b/src/components/settings/ProvidersSettings.tsx index 342f4303f..bcb9537d5 100644 --- a/src/components/settings/ProvidersSettings.tsx +++ b/src/components/settings/ProvidersSettings.tsx @@ -680,8 +680,9 @@ function AddProviderDialog({ expiresIn: number; } | null>(null); const [oauthError, setOauthError] = useState(null); - // For providers that support both OAuth and API key, let the user choose - const [authMode, setAuthMode] = useState<'oauth' | 'apikey'>('oauth'); + // For providers that support both OAuth and API key, let the user choose. + // Default to the vendor's declared auth mode instead of hard-coding OAuth. + const [authMode, setAuthMode] = useState<'oauth' | 'apikey'>('apikey'); const typeInfo = PROVIDER_TYPE_INFO.find((t) => t.id === selectedType); const showModelIdField = shouldShowProviderModelId(typeInfo, devModeUnlocked); @@ -697,6 +698,13 @@ function AddProviderDialog({ // Effective OAuth mode: pure OAuth providers, or dual-mode with oauth selected const useOAuthFlow = isOAuth && (!supportsApiKey || authMode === 'oauth'); + useEffect(() => { + if (!selectedVendor || !isOAuth || !supportsApiKey) { + return; + } + setAuthMode(selectedVendor.defaultAuthMode === 'api_key' ? 'apikey' : 'oauth'); + }, [selectedVendor, isOAuth, supportsApiKey]); + // Keep refs to the latest values so event handlers see the current dialog state. const latestRef = React.useRef({ selectedType, typeInfo, onAdd, onClose, t }); const pendingOAuthRef = React.useRef<{ accountId: string; label: string } | null>(null);