Hide branch name for main worktree threads in sidebar (#54067)

Richard Feldman created

<img width="337" height="752" alt="Screenshot 2026-04-16 at 9 31 04 AM"
src="https://github.com/user-attachments/assets/174b1eb2-6a3a-46f1-abdf-006e13b80c7a"
/>

Release Notes:

- Agent sidebar now shows worktree and branch names only for linked
worktrees.

Change summary

crates/ui/src/components/ai/thread_item.rs | 46 ++---------------------
crates/zed/src/visual_test_runner.rs       |  8 ++--
2 files changed, 9 insertions(+), 45 deletions(-)

Detailed changes

crates/ui/src/components/ai/thread_item.rs 🔗

@@ -361,50 +361,14 @@ impl RenderOnce for ThreadItem {
         let has_timestamp = !self.timestamp.is_empty();
         let timestamp = self.timestamp;
 
-        let visible_worktree_count = self
-            .worktrees
-            .iter()
-            .filter(|wt| !(wt.kind == WorktreeKind::Main && wt.branch_name.is_none()))
-            .count();
-
         let mut worktree_labels: Vec<AnyElement> = Vec::new();
 
         let slash_color = Color::Custom(cx.theme().colors().text_muted.opacity(0.4));
 
         for wt in self.worktrees {
-            match (wt.kind, wt.branch_name) {
-                (WorktreeKind::Main, None) => continue,
-                (WorktreeKind::Main, Some(branch)) => {
-                    let chip_index = worktree_labels.len();
-
-                    worktree_labels.push(
-                        h_flex()
-                            .id(format!("{}-worktree-{chip_index}", self.id.clone()))
-                            .min_w_0()
-                            .when(visible_worktree_count > 1, |this| {
-                                this.child(
-                                    Label::new(wt.name)
-                                        .size(LabelSize::Small)
-                                        .color(Color::Muted)
-                                        .truncate(),
-                                )
-                                .child(
-                                    Label::new("/")
-                                        .size(LabelSize::Small)
-                                        .color(slash_color)
-                                        .flex_shrink_0(),
-                                )
-                            })
-                            .child(
-                                Label::new(branch)
-                                    .size(LabelSize::Small)
-                                    .color(Color::Muted)
-                                    .truncate(),
-                            )
-                            .into_any_element(),
-                    );
-                }
-                (WorktreeKind::Linked, branch) => {
+            match wt.kind {
+                WorktreeKind::Main => continue,
+                WorktreeKind::Linked => {
                     let chip_index = worktree_labels.len();
 
                     let label = if wt.highlight_positions.is_empty() {
@@ -432,7 +396,7 @@ impl RenderOnce for ThreadItem {
                                     .color(Color::Muted),
                             )
                             .child(label)
-                            .when_some(branch, |this, branch| {
+                            .when_some(wt.branch_name, |this, branch| {
                                 this.child(
                                     Label::new("/")
                                         .size(LabelSize::Small)
@@ -861,7 +825,7 @@ impl Component for ThreadItem {
                     .into_any_element(),
             ),
             single_example(
-                "Main Branch + Changes + Timestamp",
+                "Main Worktree (hidden) + Changes + Timestamp",
                 container()
                     .child(
                         ThreadItem::new("ti-5e", "Main worktree branch with diff stats")

crates/zed/src/visual_test_runner.rs 🔗

@@ -2939,9 +2939,7 @@ impl gpui::Render for ThreadItemBranchNameTestView {
                         }]),
                 ),
             )
-            .child(section_label(
-                "Main worktree with branch (branch only, no icon)",
-            ))
+            .child(section_label("Main worktree with branch (nothing shown)"))
             .child(
                 container().child(
                     ThreadItem::new("ti-main-branch", "Request for Long Classic Poem")
@@ -3043,7 +3041,9 @@ impl gpui::Render for ThreadItemBranchNameTestView {
                         }]),
                 ),
             )
-            .child(section_label("Main branch + diff stats + timestamp"))
+            .child(section_label(
+                "Main worktree with branch + diff stats + timestamp (branch hidden)",
+            ))
             .child(
                 container().child(
                     ThreadItem::new("ti-main-full", "Main worktree with everything")