diff --git a/crates/agent_servers/src/gemini.rs b/crates/agent_servers/src/gemini.rs index a577b0590c83fd06f399e655c062a3664d733d1a..2cda9f97432a5c48709d19854b9a205dfa7475a6 100644 --- a/crates/agent_servers/src/gemini.rs +++ b/crates/agent_servers/src/gemini.rs @@ -53,7 +53,7 @@ impl AgentServer for Gemini { { extra_env.insert("GEMINI_API_KEY".into(), api_key); } - let (command, root_dir, auth_commands) = store + let (command, root_dir, mut auth_commands) = store .update(cx, |store, cx| { let agent = store .get_external_agent(&GEMINI_NAME.into()) @@ -68,6 +68,14 @@ impl AgentServer for Gemini { })?? .await?; + // When remote, OAuth doesn't work, so we need to use the terminal-based login + // for oauth-personal. Map it to the same terminal command as spawn-gemini-cli. + if is_remote { + if let Some(spawn_gemini_cli) = auth_commands.get("spawn-gemini-cli").cloned() { + auth_commands.insert("oauth-personal".to_string(), spawn_gemini_cli); + } + } + let connection = crate::acp::connect( name, command, diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 04678ac6a795509395553517037d40f3d7310e83..fd87942749247fd8093805ccb52a6bec4580baef 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -3268,48 +3268,34 @@ impl AcpThreadView { }) .children(connection.auth_methods().iter().enumerate().rev().map( |(ix, method)| { - let (method_id, name) = if self - .project - .read(cx) - .is_via_remote_server() - && method.id.0.as_ref() == "oauth-personal" - && method.name == "Log in with Google" - { - ("spawn-gemini-cli".into(), "Log in with Gemini CLI".into()) - } else { - (method.id.0.clone(), method.name.clone()) - }; - - Button::new(SharedString::from(method_id.clone()), name) - .label_size(LabelSize::Small) - .map(|this| { - if ix == 0 { - this.style(ButtonStyle::Tinted(TintColor::Warning)) - } else { - this.style(ButtonStyle::Outlined) - } - }) - .when_some( - method.description.clone(), - |this, description| { - this.tooltip(Tooltip::text(description)) - }, - ) - .on_click({ - cx.listener(move |this, _, window, cx| { - telemetry::event!( - "Authenticate Agent Started", - agent = this.agent.telemetry_id(), - method = method_id - ); + let method_id = method.id.clone(); + let method_id_str = method.id.0.to_string(); + Button::new( + SharedString::from(method.id.0.clone()), + method.name.clone(), + ) + .label_size(LabelSize::Small) + .map(|this| { + if ix == 0 { + this.style(ButtonStyle::Tinted(TintColor::Warning)) + } else { + this.style(ButtonStyle::Outlined) + } + }) + .when_some(method.description.clone(), |this, description| { + this.tooltip(Tooltip::text(description)) + }) + .on_click({ + cx.listener(move |this, _, window, cx| { + telemetry::event!( + "Authenticate Agent Started", + agent = this.agent.telemetry_id(), + method = method_id_str + ); - this.authenticate( - acp::AuthMethodId(method_id.clone()), - window, - cx, - ) - }) + this.authenticate(method_id.clone(), window, cx) }) + }) }, )), )