# Fix worktree grouping for bare checkouts \(\#59968\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/ea87b0579464067eb45a1c1a1f2c1bdb80af7e1f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: ea87b0579464067eb45a1c1a1f2c1bdb80af7e1f

Requested commit: ea87b0579464067eb45a1c1a1f2c1bdb80af7e1f

Commit: ea87b0579464067eb45a1c1a1f2c1bdb80af7e1f

Tree: c50b94eae49f01aacee8ef59ab7e8849f419f272

Author: Anant Goel

Committer: GitHub

## Message

```
Fix worktree grouping for bare checkouts (#59968)

Summary

- Track whether a worktree root is itself a linked Git worktree.
- Use that metadata when computing project group keys so bare checkout
worktrees group under the repository identity path.
- Propagate the metadata through remote worktree protocols and add
local/remote regression coverage.

Background

Bare checkout layouts can place linked worktrees under the repository
identity directory, e.g. `/monty/.bare` with worktrees like
`/monty/feature-a`. We were treating those linked worktree paths as
separate project identities, which caused the sidebar to move agent
threads under the active worktree instead of the shared repository
group.
We also exclude adding this to collab intentionally, we can open a
different PR for that if we need to.

Closes #59910
Closes AI-431

Test Plan

- `cargo fmt --package project --package worktree --package
remote_server --package workspace --package collab --package proto`
- `git --no-pager diff --check`
- `cargo test -p project test_project_group_key -- --nocapture`
- `cargo test -p remote_server test_remote_root_repo_common_dir --
--nocapture`
- `cargo test -p worktree remote_worktree -- --nocapture`
- `cargo test -p workspace
test_remote_project_root_dir_changes_update_groups -- --nocapture`
- `cargo check -p collab`

Self-Review Checklist:

 I've reviewed my own diff for quality, security, and reliability
 Unsafe blocks (if any) have justifying comments
The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
 Tests cover the new/changed behavior
 Performance impact has been considered and is acceptable

Release Notes:

- Fixed agent thread/sidebar grouping for Git worktrees backed by bare
checkouts.

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
```

## Parents

- [31fc9d5f4710e30a4908525f6f0b930fce71e6f6](https://git.cafe/gitcafe/zed/commit/31fc9d5f4710e30a4908525f6f0b930fce71e6f6?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/ea87b0579464067eb45a1c1a1f2c1bdb80af7e1f?format=markdown)
