@@ -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<acp::GlobSearchResponse> {
todo!()
}
-
- async fn end_turn(&self, request: acp::EndTurnParams) -> Result<acp::EndTurnResponse> {
- todo!()
- }
}
impl AcpAgent {
- pub fn stdio(mut process: Child, project: Entity<Project>, cx: AsyncApp) -> Self {
+ pub fn stdio(mut process: Child, project: Entity<Project>, cx: &mut AsyncApp) -> Arc<Self> {
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(),
@@ -183,7 +183,7 @@ impl Thread {
thread_id: ThreadId,
entries: Vec<AgentThreadEntryContent>,
project: Entity<Project>,
- cx: &mut Context<Self>,
+ _: &mut Context<Self>,
) -> 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<Self>) -> Task<Result<()>> {
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<Project>, cx: AsyncApp) -> Result<AcpAgent> {
+ pub fn gemini_agent(project: Entity<Project>, mut cx: AsyncApp) -> Result<Arc<AcpAgent>> {
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))
}
}