Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Refresh UI when sending first message (#28180)
Agus Zubiagab1f7133a7b70
diff --git a/crates/agent/src/assistant_panel.rs b/crates/agent/src/assistant_panel.rsindex 3a1dcb855a0..1f1f7bd00b3 100644--- a/crates/agent/src/assistant_panel.rs+++ b/crates/agent/src/assistant_panel.rs@@ -170,6 +170,7 @@ pub struct AssistantPanel {language_registry: Arc<LanguageRegistry>,thread_store: Entity<ThreadStore>,thread: Entity<ActiveThread>,+ _thread_subscription: Subscription,message_editor: Entity<MessageEditor>,context_store: Entity<assistant_context_editor::ContextStore>,context_editor: Option<Entity<ContextEditor>>,@@ -253,6 +254,12 @@ impl AssistantPanel {cx.new(|cx| HistoryStore::new(thread_store.clone(), context_store.clone(), cx));let active_view = ActiveView::thread(thread.clone(), window, cx);+ let thread_subscription = cx.subscribe(&thread, |_, _, event, cx| {+ if let ThreadEvent::MessageAdded(_) = &event {+ // needed to leave empty state+ cx.notify();+ }+ });let thread = cx.new(|cx| {ActiveThread::new(thread.clone(),@@ -273,6 +280,7 @@ impl AssistantPanel {language_registry,thread_store: thread_store.clone(),thread,+ _thread_subscription: thread_subscription,message_editor,context_store,context_editor: None,@@ -367,6 +375,14 @@ impl AssistantPanel {cx,)});++ self._thread_subscription = cx.subscribe(&thread, |_, _, event, cx| {+ if let ThreadEvent::MessageAdded(_) = &event {+ // needed to leave empty state+ cx.notify();+ }+ });+self.message_editor = cx.new(|cx| {MessageEditor::new(self.fs.clone(),diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rsindex 3cc00c39fbb..37f4c63d631 100644--- a/crates/agent/src/message_editor.rs+++ b/crates/agent/src/message_editor.rs@@ -240,14 +240,14 @@ impl MessageEditor {cx.emit(ThreadEvent::ShowError(load_error));}})- .ok();+ .log_err();thread.update(cx, |thread, cx| {let context = context_store.read(cx).context().clone();thread.insert_user_message(user_message, context, checkpoint, cx);})- .ok();+ .log_err();if let Some(wait_for_summaries) = context_store.update(cx, |context_store, cx| context_store.wait_for_summaries(cx))@@ -257,7 +257,7 @@ impl MessageEditor {this.waiting_for_summaries_to_send = true;cx.notify();})- .ok();+ .log_err();wait_for_summaries.await;@@ -265,7 +265,7 @@ impl MessageEditor {this.waiting_for_summaries_to_send = false;cx.notify();})- .ok();+ .log_err();}// Send to model after summaries are done@@ -273,7 +273,7 @@ impl MessageEditor {.update(cx, |thread, cx| {thread.send_to_model(model, request_kind, cx);})- .ok();+ .log_err();}).detach();}