From d16c595d574ddd914e571bd8ac320539003b2e75 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Wed, 2 Jul 2025 11:31:51 -0300 Subject: [PATCH] Fix always allow, and update acp confirmation types --- crates/acp/src/server.rs | 4 +- crates/acp/src/thread_view.rs | 117 +++++++++++++++++++++++++++------- 2 files changed, 97 insertions(+), 24 deletions(-) diff --git a/crates/acp/src/server.rs b/crates/acp/src/server.rs index ed4032777f97915fc47cc906dcc8681bbe76c6aa..98bb3c35e5d0babf2fa86827184299888e473909 100644 --- a/crates/acp/src/server.rs +++ b/crates/acp/src/server.rs @@ -185,7 +185,7 @@ impl acp::Client for AcpClientDelegate { let ToolCallRequest { id, outcome } = cx .update(|cx| { self.update_thread(&request.thread_id.into(), cx, |thread, cx| { - thread.request_tool_call(request.title, request.confirmation, cx) + thread.request_tool_call(request.display_name, request.confirmation, cx) }) })? .context("Failed to update thread")?; @@ -204,7 +204,7 @@ impl acp::Client for AcpClientDelegate { let entry_id = cx .update(|cx| { self.update_thread(&request.thread_id.into(), cx, |thread, cx| { - thread.push_tool_call(request.title, cx) + thread.push_tool_call(request.display_name, cx) }) })? .context("Failed to update thread")?; diff --git a/crates/acp/src/thread_view.rs b/crates/acp/src/thread_view.rs index 1ca02dab325b6ad8b6ae8a9141a31439f3637c06..7c8336961febf73d79bf771f7060ca543887fca5 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()) @@ -349,6 +348,7 @@ impl AcpThreadView { ToolCallConfirmation::Edit { file_name, file_diff, + description, } => v_flex() .border_color(cx.theme().colors().border) .border_t_1() @@ -357,26 +357,30 @@ impl AcpThreadView { // todo! nicer rendering .child(file_name.clone()) .child(file_diff.clone()) + .children(description.clone()) .child( h_flex() .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") @@ -417,6 +421,7 @@ impl AcpThreadView { ToolCallConfirmation::Execute { command, root_command, + description, } => v_flex() .border_color(cx.theme().colors().border) .border_t_1() @@ -424,13 +429,14 @@ impl AcpThreadView { .py_1p5() // todo! nicer rendering .child(command.clone()) + .children(description.clone()) .child( h_flex() .justify_end() .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) @@ -488,6 +494,7 @@ impl AcpThreadView { server_name, tool_name: _, tool_display_name, + description, } => v_flex() .border_color(cx.theme().colors().border) .border_t_1() @@ -495,13 +502,14 @@ impl AcpThreadView { .py_1p5() // todo! nicer rendering .child(format!("{server_name} - {tool_display_name}")) + .children(description.clone()) .child( h_flex() .justify_end() .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 +529,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) @@ -575,19 +583,84 @@ impl AcpThreadView { ), ) .into_any(), - ToolCallConfirmation::Info { prompt, urls: _ } => v_flex() + ToolCallConfirmation::Fetch { description, urls } => v_flex() + .border_color(cx.theme().colors().border) + .border_t_1() + .px_2() + .py_1p5() + // todo! nicer rendering + .children(urls.clone()) + .children(description.clone()) + .child( + h_flex() + .justify_end() + .gap_1() + .child( + Button::new(("always_allow", tool_call_id.as_u64()), "Always Allow") + .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") + .icon(IconName::Check) + .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::Allow, + cx, + ); + } + })), + ) + .child( + Button::new(("reject", tool_call_id.as_u64()), "Reject") + .icon(IconName::X) + .icon_position(IconPosition::Start) + .icon_size(IconSize::Small) + .icon_color(Color::Error) + .on_click(cx.listener({ + let id = tool_call_id; + move |this, _, _, cx| { + this.authorize_tool_call( + id, + acp::ToolCallConfirmationOutcome::Reject, + cx, + ); + } + })), + ), + ) + .into_any(), + ToolCallConfirmation::Other { description } => v_flex() .border_color(cx.theme().colors().border) .border_t_1() .px_2() .py_1p5() // todo! nicer rendering - .child(prompt.clone()) + .child(description.clone()) .child( h_flex() .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)