acp: Handle Gemini Auth Better (#36631)

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Conrad Irwin 2025-08-20 16:12:41 -06:00 committed by GitHub
parent c9c708ff08
commit 5120b6b7f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 195 additions and 19 deletions

View file

@ -5,6 +5,7 @@ use crate::{AgentServer, AgentServerCommand};
use acp_thread::{AgentConnection, LoadError};
use anyhow::Result;
use gpui::{Entity, Task};
use language_models::provider::google::GoogleLanguageModelProvider;
use project::Project;
use settings::SettingsStore;
use ui::App;
@ -47,7 +48,7 @@ impl AgentServer for Gemini {
settings.get::<AllAgentServersSettings>(None).gemini.clone()
})?;
let Some(command) =
let Some(mut command) =
AgentServerCommand::resolve("gemini", &[ACP_ARG], None, settings, &project, cx).await
else {
return Err(LoadError::NotInstalled {
@ -57,6 +58,10 @@ impl AgentServer for Gemini {
}.into());
};
if let Some(api_key)= cx.update(GoogleLanguageModelProvider::api_key)?.await.ok() {
command.env.get_or_insert_default().insert("GEMINI_API_KEY".to_owned(), api_key.key);
}
let result = crate::acp::connect(server_name, command.clone(), &root_dir, cx).await;
if result.is_err() {
let version_fut = util::command::new_smol_command(&command.path)