Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Emit agent thread status change events (#60057)
David Scarpettic3a4bda33183
diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rsindex 07c6cb092e9..a7bbdc3a650 100644--- a/crates/acp_thread/src/acp_thread.rs+++ b/crates/acp_thread/src/acp_thread.rs@@ -1779,6 +1779,7 @@ impl From<&AcpThread> for ActionLogTelemetry {#[derive(Debug)]pub enum AcpThreadEvent {+ StatusChanged,PromptUpdated,NewEntry,TitleUpdated,@@ -3268,6 +3269,7 @@ impl AcpThread {tx.send(f(this, cx).await).ok();}),});+ cx.emit(AcpThreadEvent::StatusChanged);cx.spawn(async move |this, cx| {let response = rx.await;@@ -3293,6 +3295,7 @@ impl AcpThread {// state even when the send_task is cancelled before tx.send().if is_same_turn {this.running_turn.take();+ cx.emit(AcpThreadEvent::StatusChanged);}let Ok(response) = response else {@@ -3410,6 +3413,7 @@ impl AcpThread {Self::flush_streaming_text(&mut self.streaming_text_buffer, cx);self.mark_pending_entries_as_canceled(cx);+ cx.emit(AcpThreadEvent::StatusChanged);// Wait for the send task to completecx.background_spawn(turn.send_task)diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rsindex 316c7aaeeb5..8a329bdc7c8 100644--- a/crates/agent_ui/src/agent_diff.rs+++ b/crates/agent_ui/src/agent_diff.rs@@ -1431,6 +1431,7 @@ impl AgentDiff {self.update_reviewing_editors(workspace, window, cx);}AcpThreadEvent::TitleUpdated+ | AcpThreadEvent::StatusChanged| AcpThreadEvent::TokenUsageUpdated| AcpThreadEvent::SubagentSpawned(_)| AcpThreadEvent::EntriesRemoved(_)diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rsindex 50d45fbaba6..e3e941a140b 100644--- a/crates/agent_ui/src/conversation_view.rs+++ b/crates/agent_ui/src/conversation_view.rs@@ -277,6 +277,7 @@ impl Conversation {}}AcpThreadEvent::NewEntry+ | AcpThreadEvent::StatusChanged| AcpThreadEvent::TitleUpdated| AcpThreadEvent::TokenUsageUpdated| AcpThreadEvent::EntryUpdated(_)@@ -521,6 +522,7 @@ fn affects_thread_metadata(event: &AcpThreadEvent) -> bool {| AcpThreadEvent::WorkingDirectoriesUpdated => true,// --AcpThreadEvent::EntryUpdated(_)+ | AcpThreadEvent::StatusChanged| AcpThreadEvent::EntriesRemoved(_)| AcpThreadEvent::Retry(_)| AcpThreadEvent::TokenUsageUpdated@@ -1486,6 +1488,13 @@ impl ConversationView {cx.emit(RootThreadUpdated);}match event {+ AcpThreadEvent::StatusChanged => {+ if let Some(active) = self.thread_view(&session_id) {+ active.update(cx, |active, cx| {+ active.sync_generating_indicator(cx);+ });+ }+ }AcpThreadEvent::NewEntry => {let len = thread.read(cx).entries().len();let index = len - 1;