Handle startup failure for gemini-cli (#35624)
This PR adds handling for the case where the user's gemini-cli binary fails to start up because it's too old to support the `--experimental-acp` flag. We previously had such handling, but it got lost as part of #35578. This doesn't yet handle the case where the server binary exits unexpectedly after the connection is established; that'll be dealt with in a follow-up PR since it needs different handling and isn't specific to gemini-cli. Release Notes: - N/A Co-authored-by: Agus <agus@zed.dev>
This commit is contained in:
parent
cf23f93917
commit
a508a9536f
1 changed files with 32 additions and 2 deletions
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::{AgentServer, AgentServerCommand};
|
||||
use acp_thread::AgentConnection;
|
||||
use acp_thread::{AgentConnection, LoadError};
|
||||
use anyhow::Result;
|
||||
use gpui::{Entity, Task};
|
||||
use project::Project;
|
||||
|
@ -53,7 +53,37 @@ impl AgentServer for Gemini {
|
|||
anyhow::bail!("Failed to find gemini binary");
|
||||
};
|
||||
|
||||
crate::acp::connect(server_name, command, &root_dir, cx).await
|
||||
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)
|
||||
.args(command.args.iter())
|
||||
.arg("--version")
|
||||
.kill_on_drop(true)
|
||||
.output();
|
||||
|
||||
let help_fut = util::command::new_smol_command(&command.path)
|
||||
.args(command.args.iter())
|
||||
.arg("--help")
|
||||
.kill_on_drop(true)
|
||||
.output();
|
||||
|
||||
let (version_output, help_output) = futures::future::join(version_fut, help_fut).await;
|
||||
|
||||
let current_version = String::from_utf8(version_output?.stdout)?;
|
||||
let supported = String::from_utf8(help_output?.stdout)?.contains(ACP_ARG);
|
||||
|
||||
if !supported {
|
||||
return Err(LoadError::Unsupported {
|
||||
error_message: format!(
|
||||
"Your installed version of Gemini {} doesn't support the Agentic Coding Protocol (ACP).",
|
||||
current_version
|
||||
).into(),
|
||||
upgrade_message: "Upgrade Gemini to Latest".into(),
|
||||
upgrade_command: "npm install -g @google/gemini-cli@latest".into(),
|
||||
}.into())
|
||||
}
|
||||
}
|
||||
result
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue