diff --git a/crates/agent2/src/acp.rs b/crates/agent2/src/acp.rs index 3981dda23b9e834e34bd41f061444fea46ad33ce..0269144800c0a7aa696eb35f6d22d74514dea794 100644 --- a/crates/agent2/src/acp.rs +++ b/crates/agent2/src/acp.rs @@ -5,7 +5,7 @@ use crate::{ ThreadEntryId, ThreadId, }; use agentic_coding_protocol as acp; -use anyhow::{Context as _, Result, anyhow}; +use anyhow::{Context as _, Result}; use async_trait::async_trait; use collections::HashMap; use gpui::{App, AppContext, AsyncApp, Context, Entity, Task, WeakEntity}; @@ -178,14 +178,10 @@ impl acp::Client for AcpClientDelegate { async fn glob_search(&self, request: acp::GlobSearchParams) -> Result { todo!() } - - async fn end_turn(&self, request: acp::EndTurnParams) -> Result { - todo!() - } } impl AcpAgent { - pub fn stdio(mut process: Child, project: Entity, cx: AsyncApp) -> Self { + pub fn stdio(mut process: Child, project: Entity, cx: &mut AsyncApp) -> Arc { let stdin = process.stdin.take().expect("process didn't have stdin"); let stdout = process.stdout.take().expect("process didn't have stdout"); @@ -201,13 +197,13 @@ impl AcpAgent { process.status().await.log_err(); }); - Self { + Arc::new(Self { project, connection: Arc::new(connection), threads, _handler_task: cx.foreground_executor().spawn(handler_fut), _io_task: io_task, - } + }) } } @@ -291,12 +287,6 @@ impl Agent for AcpAgent { message: crate::Message, cx: &mut AsyncApp, ) -> Result<()> { - let thread = self - .threads - .lock() - .get(&thread_id) - .cloned() - .ok_or_else(|| anyhow!("no such thread"))?; self.connection .request(acp::SendMessageParams { thread_id: thread_id.clone().into(), diff --git a/crates/agent2/src/agent2.rs b/crates/agent2/src/agent2.rs index d4e976f48841f962001d00d60682e02f1f5fdd4b..6d2dfc843b3b2ee8a61f313caa153b6ab51c7a9a 100644 --- a/crates/agent2/src/agent2.rs +++ b/crates/agent2/src/agent2.rs @@ -183,7 +183,7 @@ impl Thread { thread_id: ThreadId, entries: Vec, project: Entity, - cx: &mut Context, + _: &mut Context, ) -> Self { let mut next_entry_id = ThreadEntryId(0); Self { @@ -216,7 +216,7 @@ impl Thread { pub fn send(&mut self, message: Message, cx: &mut Context) -> Task> { let agent = self.agent.clone(); let id = self.id.clone(); - cx.spawn(async move |this, cx| { + cx.spawn(async move |_, cx| { agent.send_thread_message(id, message, cx).await?; Ok(()) }) @@ -298,7 +298,7 @@ mod tests { }); } - pub fn gemini_agent(project: Entity, cx: AsyncApp) -> Result { + pub fn gemini_agent(project: Entity, mut cx: AsyncApp) -> Result> { let cli_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../gemini-cli/packages/cli"); let child = util::command::new_smol_command("node") @@ -313,6 +313,6 @@ mod tests { .spawn() .unwrap(); - Ok(AcpAgent::stdio(child, project, cx)) + Ok(AcpAgent::stdio(child, project, &mut cx)) } }