# agent: Wait until linked git worktree state is loaded \(\#51395\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 372ce88725a8af603e0ab9a4364ded5223b49f59

Requested commit: 372ce88725a8af603e0ab9a4364ded5223b49f59

Commit: 372ce88725a8af603e0ab9a4364ded5223b49f59

Tree: cb3c7b6da7d804ddbab88f7e66bea1397c3f4112

Author: Anthony Eid

Committer: GitHub

## Message

```
agent: Wait until linked git worktree state is loaded (#51395)

### Context 

This fixes a bug where the sidebar would show a newly created git
worktree thread as its own project while the recently created workspace
is loading its git state. The fix is adding project APIs to await the
initial worktree store scan and then each git repo initial snapshot;
then awaiting on them before adding the new workspace to the
multi-workspace.

### Architecture:

I added the `Worktree::Remote::wait_for_snapshot` API to
`Worktree::Local` to enable `WorktreeStore` to await for both remote and
local projects until there's an initial scan. The `WorktreeStore` uses
the watcher pattern so it can update the initial scan state whenever
visible worktrees are added or removed from the store.

Before you mark this PR as ready for review, make sure that you have:
- [x] Added solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
```

## Parents

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

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