From fbd27148d5b7186a013b218dc95e4465f4843379 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Fri, 8 Aug 2025 01:29:07 -0400 Subject: [PATCH] fix --- crates/acp_thread/src/acp_thread.rs | 52 ++++++++++++----------------- crates/gpui/src/executor.rs | 8 +++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 71827d6948..ee39f93436 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -6,7 +6,6 @@ use anyhow::{Context as _, Result}; use assistant_tool::ActionLog; use buffer_diff::BufferDiff; use editor::{Bias, MultiBuffer, PathKey}; -use futures::future::{Fuse, FusedFuture}; use futures::{FutureExt, channel::oneshot, future::BoxFuture}; use gpui::{AppContext, Context, Entity, EventEmitter, SharedString, Task}; use itertools::Itertools; @@ -580,7 +579,7 @@ pub struct AcpThread { project: Entity, action_log: Entity, shared_buffers: HashMap, BufferSnapshot>, - send_task: Option>>, + send_task: Option>, connection: Rc, session_id: acp::SessionId, } @@ -670,11 +669,7 @@ impl AcpThread { } pub fn status(&self) -> ThreadStatus { - if self - .send_task - .as_ref() - .map_or(false, |t| !t.is_terminated()) - { + if self.send_task.as_ref().map_or(false, |t| !t.is_finished()) { if self.waiting_for_tool_confirmation() { ThreadStatus::WaitingForToolConfirmation } else { @@ -1049,31 +1044,28 @@ impl AcpThread { let (tx, rx) = oneshot::channel(); let cancel_task = self.cancel(cx); - self.send_task = Some( - cx.spawn(async move |this, cx| { - async { - cancel_task.await; + self.send_task = Some(cx.spawn(async move |this, cx| { + async { + cancel_task.await; - let result = this - .update(cx, |this, cx| { - this.connection.prompt( - acp::PromptRequest { - prompt: message, - session_id: this.session_id.clone(), - }, - cx, - ) - })? - .await; + let result = this + .update(cx, |this, cx| { + this.connection.prompt( + acp::PromptRequest { + prompt: message, + session_id: this.session_id.clone(), + }, + cx, + ) + })? + .await; - tx.send(result).log_err(); - anyhow::Ok(()) - } - .await - .log_err(); - }) - .fuse(), - ); + tx.send(result).log_err(); + anyhow::Ok(()) + } + .await + .log_err(); + })); cx.spawn(async move |this, cx| match rx.await { Ok(Err(e)) => { diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 273a3ea503..1018dded01 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -79,6 +79,14 @@ impl Task { Task(TaskState::Spawned(task)) => task.detach(), } } + + /// Whether the task has run to completion. + pub fn is_finished(&self) -> bool { + match self { + Task(TaskState::Ready(_)) => true, + Task(TaskState::Spawned(task)) => task.is_finished(), + } + } } impl Task>