agent: When opening a remote thread check that the linked worktree path exists (#54353)

If the path doesn't exist we fallback to the main worktree path. This
handles the edge case where a git linked worktree is deleted on a remote
machine, and a user tries to open a thread based on that.

We fallback to the main git worktree in this case, if that doesn't exist
the project will open in an error state (empty workspace) like we
already do

Self-Review Checklist:

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

Closes #ISSUE

Release Notes:

- N/A
4b48819072Anthony Eid committed on 4/20/2026, 9:18:09 PM· committed by GitHubparent66a77d2
1 file changedLine totals unavailable