Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
assistant2: Add ability to delete past threads (#21607)
Marshall Bowersc8b3c4c6cd82
diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rsindex 2d9f563c2f6..fde3aa02bad 100644--- a/crates/assistant2/src/assistant_panel.rs+++ b/crates/assistant2/src/assistant_panel.rs@@ -106,6 +106,10 @@ impl AssistantPanel {}}+ pub(crate) fn local_timezone(&self) -> UtcOffset {+ self.local_timezone+ }+fn new_thread(&mut self, cx: &mut ViewContext<Self>) {let thread = self.thread_store@@ -147,8 +151,9 @@ impl AssistantPanel {self.message_editor.focus_handle(cx).focus(cx);}- pub(crate) fn local_timezone(&self) -> UtcOffset {- self.local_timezone+ pub(crate) fn delete_thread(&mut self, thread_id: &ThreadId, cx: &mut ViewContext<Self>) {+ self.thread_store+ .update(cx, |this, cx| this.delete_thread(thread_id, cx));}}diff --git a/crates/assistant2/src/thread_history.rs b/crates/assistant2/src/thread_history.rsindex 7216ca695a7..f183276f7b5 100644--- a/crates/assistant2/src/thread_history.rs+++ b/crates/assistant2/src/thread_history.rs@@ -127,11 +127,23 @@ impl RenderOnce for PastThread {.child(IconButton::new("delete", IconName::TrashAlt).shape(IconButtonShape::Square)- .icon_size(IconSize::Small),+ .icon_size(IconSize::Small)+ .on_click({+ let assistant_panel = self.assistant_panel.clone();+ let id = id.clone();+ move |_event, cx| {+ assistant_panel+ .update(cx, |this, cx| {+ this.delete_thread(&id, cx);+ })+ .ok();+ }+ }),),).on_click({let assistant_panel = self.assistant_panel.clone();+ let id = id.clone();move |_event, cx| {assistant_panel.update(cx, |this, cx| {diff --git a/crates/assistant2/src/thread_store.rs b/crates/assistant2/src/thread_store.rsindex 7ceee9306b9..94cb72ce430 100644--- a/crates/assistant2/src/thread_store.rs+++ b/crates/assistant2/src/thread_store.rs@@ -80,6 +80,10 @@ impl ThreadStore {.cloned()}+ pub fn delete_thread(&mut self, id: &ThreadId, cx: &mut ModelContext<Self>) {+ self.threads.retain(|thread| thread.read(cx).id() != id);+ }+fn register_context_server_handlers(&self, cx: &mut ModelContext<Self>) {cx.subscribe(&self.context_server_manager.clone(),