From 7a3105b0c6b780659d2fd916f83bb62e198d55d0 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Wed, 2 Jul 2025 12:03:35 +0200 Subject: [PATCH] Wire up push_tool_call Co-authored-by: Antonio Scandurra --- crates/acp/src/acp.rs | 31 ++++++++++++++++++++----------- crates/acp/src/server.rs | 21 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/crates/acp/src/acp.rs b/crates/acp/src/acp.rs index 403915ec3c8f456a5d326c126940009a3815d380..652016eade05ceb2562583604d9bdfb23f8e45ab 100644 --- a/crates/acp/src/acp.rs +++ b/crates/acp/src/acp.rs @@ -273,11 +273,20 @@ impl AcpThread { &mut self, title: String, description: String, - respond_tx: oneshot::Sender, + confirmation_tx: Option>, cx: &mut Context, ) -> ToolCallId { let language_registry = self.project.read(cx).languages().clone(); + let description = cx.new(|cx| { + Markdown::new( + description.into(), + Some(language_registry.clone()), + None, + cx, + ) + }); + let entry_id = self.push_entry( AgentThreadEntryContent::ToolCall(ToolCall { // todo! clean up id creation @@ -285,16 +294,16 @@ impl AcpThread { tool_name: cx.new(|cx| { Markdown::new(title.into(), Some(language_registry.clone()), None, cx) }), - status: ToolCallStatus::WaitingForConfirmation { - description: cx.new(|cx| { - Markdown::new( - description.into(), - Some(language_registry.clone()), - None, - cx, - ) - }), - respond_tx, + status: if let Some(respond_tx) = confirmation_tx { + ToolCallStatus::WaitingForConfirmation { + description, + respond_tx, + } + } else { + ToolCallStatus::Allowed { + status: acp::ToolCallStatus::Running, + content: Some(description), + } }, }), cx, diff --git a/crates/acp/src/server.rs b/crates/acp/src/server.rs index d8b4fa115e027bb5d6eecaa46f729dcabee8507f..213588fc5314cf87878a88c9732757bf5a49aced 100644 --- a/crates/acp/src/server.rs +++ b/crates/acp/src/server.rs @@ -214,8 +214,7 @@ impl acp::Client for AcpClientDelegate { format!("Info: {prompt}\n{urls:?}") } }; - // todo! tools that don't require confirmation - thread.push_tool_call(request.title, description, tx, cx) + thread.push_tool_call(request.title, description, Some(tx), cx) }) })? .context("Failed to update thread")?; @@ -232,6 +231,24 @@ impl acp::Client for AcpClientDelegate { }) } + async fn push_tool_call( + &self, + request: acp::PushToolCallParams, + ) -> Result { + let cx = &mut self.cx.clone(); + let entry_id = cx + .update(|cx| { + self.update_thread(&request.thread_id.into(), cx, |thread, cx| { + thread.push_tool_call(request.title, request.description, None, cx) + }) + })? + .context("Failed to update thread")?; + + Ok(acp::PushToolCallResponse { + id: entry_id.into(), + }) + } + async fn update_tool_call( &self, request: acp::UpdateToolCallParams,