From a508a9536fb4a8b46e36ef74ef23a642f17daab6 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Tue, 5 Aug 2025 16:29:19 -0400 Subject: [PATCH] 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 --- crates/agent_servers/src/gemini.rs | 34 ++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/agent_servers/src/gemini.rs b/crates/agent_servers/src/gemini.rs index 2366783d22..4450f4e216 100644 --- a/crates/agent_servers/src/gemini.rs +++ b/crates/agent_servers/src/gemini.rs @@ -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 }) } }