@@ -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,
@@ -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)
})
+ })
},
)),
)