fix(auth): prioritize GEMINI_API_KEY env var and skip unnecessary key… (#14745)

This commit is contained in:
Gal Zahavi
2025-12-12 17:50:21 -08:00
committed by GitHub
parent 942bcfc61e
commit 57c7b9ccce
10 changed files with 122 additions and 19 deletions

View File

@@ -55,11 +55,15 @@ export const useAuthCommand = (settings: LoadedSettings, config: Config) => {
);
const reloadApiKey = useCallback(async () => {
const envKey = process.env['GEMINI_API_KEY'];
if (envKey !== undefined) {
setApiKeyDefaultValue(envKey);
return envKey;
}
const storedKey = (await loadApiKey()) ?? '';
const envKey = process.env['GEMINI_API_KEY'] ?? '';
const key = envKey || storedKey;
setApiKeyDefaultValue(key);
return key; // Return the key for immediate use
setApiKeyDefaultValue(storedKey);
return storedKey;
}, []);
useEffect(() => {