fix: packaged app gateway connection; default Google to API key (#359)

This commit is contained in:
paisley
2026-03-09 13:24:59 +08:00
committed by GitHub
Unverified
parent 2c5c82bb74
commit d32d84f1a9

View File

@@ -680,8 +680,9 @@ function AddProviderDialog({
expiresIn: number; expiresIn: number;
} | null>(null); } | null>(null);
const [oauthError, setOauthError] = useState<string | null>(null); const [oauthError, setOauthError] = useState<string | null>(null);
// For providers that support both OAuth and API key, let the user choose // For providers that support both OAuth and API key, let the user choose.
const [authMode, setAuthMode] = useState<'oauth' | 'apikey'>('oauth'); // 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 typeInfo = PROVIDER_TYPE_INFO.find((t) => t.id === selectedType);
const showModelIdField = shouldShowProviderModelId(typeInfo, devModeUnlocked); const showModelIdField = shouldShowProviderModelId(typeInfo, devModeUnlocked);
@@ -697,6 +698,13 @@ function AddProviderDialog({
// Effective OAuth mode: pure OAuth providers, or dual-mode with oauth selected // Effective OAuth mode: pure OAuth providers, or dual-mode with oauth selected
const useOAuthFlow = isOAuth && (!supportsApiKey || authMode === 'oauth'); 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. // Keep refs to the latest values so event handlers see the current dialog state.
const latestRef = React.useRef({ selectedType, typeInfo, onAdd, onClose, t }); const latestRef = React.useRef({ selectedType, typeInfo, onAdd, onClose, t });
const pendingOAuthRef = React.useRef<{ accountId: string; label: string } | null>(null); const pendingOAuthRef = React.useRef<{ accountId: string; label: string } | null>(null);