Skip to content

sidebar: Show branches and detached HEAD in agent threads - #63451

Open
joshkent94 wants to merge 1 commit into
zed-industries:mainfrom
joshkent94:sidebar/show-worktree-branch
Open

sidebar: Show branches and detached HEAD in agent threads#63451
joshkent94 wants to merge 1 commit into
zed-industries:mainfrom
joshkent94:sidebar/show-worktree-branch

Conversation

@joshkent94

@joshkent94 joshkent94 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Objective

Show accurate Git context for agent threads in the sidebar. Base checkouts display their current branch, linked worktrees display their worktree and branch, and branchless linked worktrees display Detached HEAD.

This follows up on #53900 and keeps detached state accurate for remote clients, reconnects, and late joins.

Solution

  • Render base-worktree branches and explicit detached-HEAD state in ThreadItem, using a dot separator and branch icon for linked worktree branches.
  • Carry is_detached_head through repository snapshots, protobuf updates, and collab persistence instead of encoding it as a synthetic branch name.
  • Extend FakeFs and focused sidebar, project, collab, and visual fixtures to distinguish detached state from missing Git metadata.

Testing

  • cargo fmt --all -- --check
  • cargo test -p sidebar -p gpui_platform --features gpui_platform/runtime_shaders test_apply_worktree_label_mode_for_detached_worktree -- --nocapture
  • cargo test -p sidebar -p gpui_platform --features gpui_platform/runtime_shaders test_sidebar_worktree_info_for_base_and_detached_linked_checkout -- --nocapture
  • cargo test -p sidebar -p gpui_platform --features gpui_platform/runtime_shaders test_sidebar_worktree_info_for_current_detached_linked_checkout -- --nocapture
  • cargo test -p sidebar -p gpui_platform --features gpui_platform/runtime_shaders test_multi_main_worktree_branch_labels_are_disambiguated -- --nocapture
  • cargo test -p sidebar -p gpui_platform --features gpui_platform/runtime_shaders test_worktree_info_missing_branch_returns_none -- --nocapture
  • cargo test -p fs test_detached_worktree_admin_names_are_unique
  • cargo test -p fs test_fake_worktree_lifecycle
  • cargo test -p project test_branch_list_sync
  • cargo test -p collab -p gpui_platform --features gpui_platform/runtime_shaders test_detached_head_sync
  • cargo test -p collab -p gpui_platform --features gpui_platform/runtime_shaders test_linked_worktrees_sync
  • cargo build -p zed -p gpui_platform --bin zed_visual_test_runner --features visual-tests,gpui_platform/runtime_shaders
  • ./script/clippy
  • git diff --check
  • Manually verified the base, linked-branch, and detached-HEAD labels in a local Zed build.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Before

image

After

image

Release Notes:

  • Branch name and icon is now shown for each thread in the thread sidebar including when the base branch is checked out, and it is now clear when a thread is in detached HEAD state.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 30, 2026
@ChristopherBiscardi ChristopherBiscardi added area:integrations/git Git integration feedback area:ai/agent thread Feedback for Zed's Agent Thread labels Aug 31, 2026
@zed-industries-bot

Copy link
Copy Markdown
Contributor
Fails
🚫

This PR modifies database schema files (crates/collab/migrations.sqlite/20221109000000_test_schema.sql, crates/collab/migrations/20251208000000_test_schema.sql), which requires creating a schema migration in the Cloud repository.

Once the schema migration has been created and applied, please add the following attestation to your PR description:

"The corresponding database schema migration has been created in the Cloud repo and applied to the production database."

Generated by 🚫 dangerJS against 2f8922e

@ChristopherBiscardi ChristopherBiscardi added area:ai/multiagent sidebar aka Threads sidebar, aka Parallel Agents and removed area:ai/agent thread Feedback for Zed's Agent Thread labels Aug 31, 2026
@joshkent94

Copy link
Copy Markdown
Contributor Author

Hey! This change needs a corresponding schema migration in the Cloud repo, but I don’t have access to that repo. Could someone from the Zed team help create and apply the migration for me please? The new column is project_repositories.is_detached_head, a non-null boolean with a default of false. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai/multiagent sidebar aka Threads sidebar, aka Parallel Agents area:integrations/git Git integration feedback cla-signed The user has signed the Contributor License Agreement

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants