From a275ff32c8f1df3ef7e444d3a9cd9e3f226e9237 Mon Sep 17 00:00:00 2001 From: Danilo Leal Date: Thu, 9 Apr 2026 16:51:31 -0300 Subject: [PATCH] Always display the new thread icon button --- crates/sidebar/src/sidebar.rs | 69 +++++++++++++++++------------------ 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 79e69b81d1c22d66976586454603307792d74d37..a2b1a782d2d1c79796735745334060eb5f69e41c 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -1538,11 +1538,6 @@ impl Sidebar { .entries .get(ix + 1) .is_some_and(|entry| matches!(entry, ListEntry::DraftThread { .. })); - let show_new_thread_button = !has_new_thread_entry && !self.has_filter_query(cx); - let workspace = self.multi_workspace.upgrade().and_then(|mw| { - mw.read(cx) - .workspace_for_paths(key.path_list(), key.host().as_ref(), cx) - }); let key_for_toggle = key.clone(); let key_for_collapse = key.clone(); @@ -1688,37 +1683,39 @@ impl Sidebar { })), ) }) - .when_some( - workspace.filter(|_| show_new_thread_button), - |this, workspace| { - let key = key.clone(); - let focus_handle = self.focus_handle.clone(); - this.child( - IconButton::new( - SharedString::from(format!( - "{id_prefix}project-header-new-thread-{ix}", - )), - IconName::Plus, - ) - .icon_size(IconSize::Small) - .tooltip(move |_, cx| { - Tooltip::for_action_in( - "New Thread", - &NewThread, - &focus_handle, - cx, - ) - }) - .on_click(cx.listener( - move |this, _, window, cx| { - this.collapsed_groups.remove(&key); - this.selection = None; - this.create_new_thread(&workspace, window, cx); - }, - )), - ) - }, - ), + .child({ + let key = key.clone(); + let focus_handle = self.focus_handle.clone(); + IconButton::new( + SharedString::from(format!( + "{id_prefix}project-header-new-thread-{ix}", + )), + IconName::Plus, + ) + .icon_size(IconSize::Small) + .tooltip(move |_, cx| { + Tooltip::for_action_in("New Thread", &NewThread, &focus_handle, cx) + }) + .on_click(cx.listener( + move |this, _, window, cx| { + this.collapsed_groups.remove(&key); + this.selection = None; + if let Some(workspace) = + this.multi_workspace.upgrade().and_then(|mw| { + mw.read(cx).workspace_for_paths( + key.path_list(), + key.host().as_ref(), + cx, + ) + }) + { + this.create_new_thread(&workspace, window, cx); + } else { + this.open_workspace_for_group(&key, window, cx); + } + }, + )) + }), ) .map(|this| { if !has_threads && is_active {