From 975a7e6f7f55dc096cd1c5fe25579b6ae060c6dc Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 2 Jul 2025 14:54:24 +0200 Subject: [PATCH] Fix clicking on tool confirmation buttons Co-authored-by: Ben Brandt --- crates/acp/src/acp.rs | 30 +------------------------ crates/acp/src/thread_view.rs | 42 ++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/crates/acp/src/acp.rs b/crates/acp/src/acp.rs index 0d2a9cec4fd32750458651e418ba5bbe30092527..33fa793e848d25a4bcedf3588b9652e3e64ae575 100644 --- a/crates/acp/src/acp.rs +++ b/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, 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, mut cx: AsyncApp) -> Result> { let cli_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../gemini-cli/packages/cli"); diff --git a/crates/acp/src/thread_view.rs b/crates/acp/src/thread_view.rs index 183ff22253f489699db55b8a172476355c2dc314..b311110c944537a667065d92fd523860d4d1fb2a 100644 --- a/crates/acp/src/thread_view.rs +++ b/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)