Fix clicking on tool confirmation buttons

Antonio Scandurra and Ben Brandt created

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>

Change summary

crates/acp/src/acp.rs         | 30 -------------------------
crates/acp/src/thread_view.rs | 42 +++++++++++++++++++-----------------
2 files changed, 23 insertions(+), 49 deletions(-)

Detailed changes

crates/acp/src/acp.rs 🔗

@@ -446,13 +446,11 @@ pub struct ToolCallRequest {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use futures::{FutureExt as _, channel::mpsc, select};
     use gpui::{AsyncApp, TestAppContext};
     use project::FakeFs;
     use serde_json::json;
     use settings::SettingsStore;
-    use smol::stream::StreamExt;
-    use std::{env, path::Path, process::Stdio, time::Duration};
+    use std::{env, path::Path, process::Stdio};
     use util::path;
 
     fn init_test(cx: &mut TestAppContext) {
@@ -549,32 +547,6 @@ mod tests {
         });
     }
 
-    async fn run_until_tool_call(thread: &Entity<AcpThread>, cx: &mut TestAppContext) {
-        let (mut tx, mut rx) = mpsc::channel(1);
-
-        let subscription = cx.update(|cx| {
-            cx.subscribe(thread, move |thread, _, cx| {
-                if thread
-                    .read(cx)
-                    .entries
-                    .iter()
-                    .any(|e| matches!(e.content, AgentThreadEntryContent::ToolCall(_)))
-                {
-                    tx.try_send(()).unwrap();
-                }
-            })
-        });
-
-        select! {
-            _ = cx.executor().timer(Duration::from_secs(5)).fuse() => {
-                panic!("Timeout waiting for tool call")
-            }
-            _ = rx.next().fuse() => {
-                drop(subscription);
-            }
-        }
-    }
-
     pub fn gemini_acp_server(project: Entity<Project>, mut cx: AsyncApp) -> Result<Arc<AcpServer>> {
         let cli_path =
             Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../gemini-cli/packages/cli");

crates/acp/src/thread_view.rs 🔗

@@ -62,7 +62,6 @@ impl AcpThreadView {
         let child = util::command::new_smol_command("node")
             .arg(cli_path)
             .arg("--acp")
-            .args(["--model", "gemini-2.5-flash"])
             .current_dir(root_dir)
             .stdin(std::process::Stdio::piped())
             .stdout(std::process::Stdio::piped())
@@ -362,21 +361,24 @@ impl AcpThreadView {
                         .justify_end()
                         .gap_1()
                         .child(
-                            Button::new(("allow", tool_call_id.as_u64()), "Always Allow Edits")
-                                .icon(IconName::CheckDouble)
-                                .icon_position(IconPosition::Start)
-                                .icon_size(IconSize::Small)
-                                .icon_color(Color::Success)
-                                .on_click(cx.listener({
-                                    let id = tool_call_id;
-                                    move |this, _, _, cx| {
-                                        this.authorize_tool_call(
-                                            id,
-                                            acp::ToolCallConfirmationOutcome::AlwaysAllow,
-                                            cx,
-                                        );
-                                    }
-                                })),
+                            Button::new(
+                                ("always_allow", tool_call_id.as_u64()),
+                                "Always Allow Edits",
+                            )
+                            .icon(IconName::CheckDouble)
+                            .icon_position(IconPosition::Start)
+                            .icon_size(IconSize::Small)
+                            .icon_color(Color::Success)
+                            .on_click(cx.listener({
+                                let id = tool_call_id;
+                                move |this, _, _, cx| {
+                                    this.authorize_tool_call(
+                                        id,
+                                        acp::ToolCallConfirmationOutcome::AlwaysAllow,
+                                        cx,
+                                    );
+                                }
+                            })),
                         )
                         .child(
                             Button::new(("allow", tool_call_id.as_u64()), "Allow")
@@ -430,7 +432,7 @@ impl AcpThreadView {
                         .gap_1()
                         .child(
                             Button::new(
-                                ("allow", tool_call_id.as_u64()),
+                                ("always_allow", tool_call_id.as_u64()),
                                 format!("Always Allow {root_command}"),
                             )
                             .icon(IconName::CheckDouble)
@@ -501,7 +503,7 @@ impl AcpThreadView {
                         .gap_1()
                         .child(
                             Button::new(
-                                ("allow", tool_call_id.as_u64()),
+                                ("always_allow_server", tool_call_id.as_u64()),
                                 format!("Always Allow {server_name}"),
                             )
                             .icon(IconName::CheckDouble)
@@ -521,7 +523,7 @@ impl AcpThreadView {
                         )
                         .child(
                             Button::new(
-                                ("allow", tool_call_id.as_u64()),
+                                ("always_allow_tool", tool_call_id.as_u64()),
                                 format!("Always Allow {tool_display_name}"),
                             )
                             .icon(IconName::CheckDouble)
@@ -587,7 +589,7 @@ impl AcpThreadView {
                         .justify_end()
                         .gap_1()
                         .child(
-                            Button::new(("allow", tool_call_id.as_u64()), "Always Allow")
+                            Button::new(("always_allow", tool_call_id.as_u64()), "Always Allow")
                                 .icon(IconName::CheckDouble)
                                 .icon_position(IconPosition::Start)
                                 .icon_size(IconSize::Small)