fix: preserve env vars when saving Google Official Gemini provider (#2087)

write_gemini_live() unconditionally cleared env_map for GoogleOfficial
auth type, discarding user-configured env vars (e.g. GEMINI_MODEL).
Remove the env_map.clear() call so the user's settings_config.env is
written as-is, and merge identical Packycode/Generic match arms.
This commit is contained in:
Jason
2026-04-15 09:05:45 +08:00
parent 689ca08409
commit 6092a87b40
2 changed files with 22 additions and 18 deletions
+4 -9
View File
@@ -1143,17 +1143,12 @@ pub(crate) fn write_gemini_live(provider: &Provider) -> Result<(), AppError> {
match auth_type {
GeminiAuthType::GoogleOfficial => {
// Google official uses OAuth, clear env
env_map.clear();
// Google Official uses OAuth, no API key validation needed.
// Write user's env vars as-is (e.g. GEMINI_MODEL, custom vars).
write_gemini_env_atomic(&env_map)?;
}
GeminiAuthType::Packycode => {
// PackyCode provider, uses API Key (strict validation on switch)
validate_gemini_settings_strict(&provider.settings_config)?;
write_gemini_env_atomic(&env_map)?;
}
GeminiAuthType::Generic => {
// Generic provider, uses API Key (strict validation on switch)
GeminiAuthType::Packycode | GeminiAuthType::Generic => {
// API Key mode -- require GEMINI_API_KEY
validate_gemini_settings_strict(&provider.settings_config)?;
write_gemini_env_atomic(&env_map)?;
}