From b1402aed4526ff2ecb87e6b6504e1600db508a05 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 74e7a7c82b..4e3e1ec1bf 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);