diff --git a/crates/chat_panel/src/chat_panel.rs b/crates/chat_panel/src/chat_panel.rs index 5b3df14f330b0766365d2b2b383d5ec73aabe99a..93c51a1b40e75d6db1b8528aff6f8048509eab71 100644 --- a/crates/chat_panel/src/chat_panel.rs +++ b/crates/chat_panel/src/chat_panel.rs @@ -101,11 +101,15 @@ impl ChatPanel { cx.dispatch_action(LoadMoreMessages); } }); - let _observe_status = cx.spawn(|this, mut cx| { + let _observe_status = cx.spawn_weak(|this, mut cx| { let mut status = rpc.status(); async move { while let Some(_) = status.recv().await { - this.update(&mut cx, |_, cx| cx.notify()); + if let Some(this) = this.upgrade(&cx) { + this.update(&mut cx, |_, cx| cx.notify()); + } else { + break; + } } } }); diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index ffe198a503bba8b41abdd3ae936bf8e50698a338..017eae0d7218a03c362e15509a3ad65c6e7fe61c 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -852,6 +852,7 @@ impl MutableAppContext { pub fn remove_all_windows(&mut self) { for (window_id, _) in self.cx.windows.drain() { self.presenters_and_platform_windows.remove(&window_id); + self.debug_elements_callbacks.remove(&window_id); } self.flush_effects(); } @@ -1403,6 +1404,7 @@ impl MutableAppContext { pub fn remove_window(&mut self, window_id: usize) { self.cx.windows.remove(&window_id); self.presenters_and_platform_windows.remove(&window_id); + self.debug_elements_callbacks.remove(&window_id); self.flush_effects(); }