zed/crates/title_bar
Xin Zhao fdc1005e71
Fix worktree creation on Windows remote from Unix host (#63075)
# Objective

Closes #63067

Another issue with path handling when connecting from Unix to a Windows
remote, similar to #62038. When we create a git worktree from Zed's
title bar, Zed computes the target path using many standard library
`Path` APIs, such as `Path::file_name()`, `Path::parent()`, and
`Path::starts_with()`. All of these methods are platform-dependent.
Since we build the Windows path on a Unix client, these methods don't
work as intended, which introduces errors.

## Solution

This PR does two things. First, it fixes the worktree creation issue.
The main change is replacing the standard `Path` APIs with the
corresponding ones in `PathStyle` across the methods involved in the
worktree path computation chain, mainly
`RepositorySnapshot::main_worktree_abs_path()`,
`Repository::path_for_new_linked_worktree()`, and
`worktrees_directory_for_repo`. This lets us build correct worktree
paths on Windows. Additionally, to make the logic testable, the core of
`Repository::path_for_new_linked_worktree()` was moved to
`RepositorySnapshot`.


Second, it fixes the worktree display. The main change is in the
`linked_worktree_short_name` function; the rest updates its callers,
including the title bar, sidebar, and the agent thread UI.

## Testing

Added new tests, and also built and tested locally; a video recording is
attached.

## 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 adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable


---

Release Notes:

- Fixed worktree cannot be created when remote connecting from unix
system to windows.
2026-10-06 16:17:29 +00:00
..
src Fix worktree creation on Windows remote from Unix host (#63075) 2026-10-06 16:17:29 +00:00
Cargo.toml Add disable_ai check for "Agent Panel" MenuItem (#63580) 2026-09-04 17:19:04 +00:00
LICENSE-GPL