From 1625f98fb063faac06fdbdbb14a1b9d904e3a7db Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:25:58 -0300 Subject: [PATCH] collab_panel: Fix favorite channels not surviving startup (#52541) Follow up to https://github.com/zed-industries/zed/pull/52378 This PR fixes a little race condition that was happening where we were running the favorite channel pruning function faster than the channels could load, leading to favorite channels not surviving the app restarting. The fix is to make the pruning happen only when the number of channels is bigger than 0, which means the list from the server has already been loaded. Release Notes: - N/A _(No release notes yet because this feature hasn't reached the wider public)_ --- crates/collab_ui/src/collab_panel.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 74e7a7c82b2123bfca8d4fc4a9e8f02463e3f7d3..4e3e1ec1bfac253f7d9dae3b01fdc9a17b9acd34 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -683,11 +683,13 @@ impl CollabPanel { let mut request_entries = Vec::new(); - let previous_len = self.favorite_channels.len(); - self.favorite_channels - .retain(|id| self.channel_store.read(cx).channel_for_id(*id).is_some()); - if self.favorite_channels.len() != previous_len { - self.serialize(cx); + if self.channel_store.read(cx).channel_count() > 0 { + let previous_len = self.favorite_channels.len(); + self.favorite_channels + .retain(|id| self.channel_store.read(cx).channel_for_id(*id).is_some()); + if self.favorite_channels.len() != previous_len { + self.serialize(cx); + } } let channel_store = self.channel_store.read(cx);