Skip to content

agent_ui: Fix worktree naming regression when using existing branches#53669

Open
rtfeldman wants to merge 3 commits intomainfrom
fix-worktree-naming-regression
Open

agent_ui: Fix worktree naming regression when using existing branches#53669
rtfeldman wants to merge 3 commits intomainfrom
fix-worktree-naming-regression

Conversation

@rtfeldman
Copy link
Copy Markdown
Contributor

@rtfeldman rtfeldman commented Apr 11, 2026

When creating a new git worktree from an existing branch (e.g. main), the worktree directory was incorrectly named after the branch instead of getting a random adjective-noun name. Additionally, if a directory with that name already existed, the rollback logic could destructively delete the pre-existing worktree.

Changes:

  • Generate a random adjective-noun name for worktree directories when no explicit name is provided
  • Collect existing worktree directory names to avoid collisions
  • Check generated paths against known worktree paths before creating
  • Reduce random name retry count from 100 to 10
  • Add regression test

Release Notes:

  • Fixed a regression where creating a git worktree from an existing branch would name the worktree directory after the branch (instead of generating a random name)

When creating a new git worktree from an existing branch (e.g. 'main'),
the worktree directory was incorrectly named after the branch instead of
getting a random adjective-noun name. This was introduced in ccb9e60
which separated branch name from worktree directory name but used the
branch name as the fallback when no explicit worktree name was provided.

Additionally, if a directory with that name already existed, the rollback
logic could destructively delete the pre-existing worktree.

Changes:
- Generate a random adjective-noun name for worktree directories when
  no explicit name is provided, instead of falling back to branch name
- Collect existing worktree directory names and pass them to the name
  generator to avoid collisions
- Check generated paths against known worktree paths before creating,
  to prevent attempting creation at an already-occupied path
- Reduce random name retry count from 100 to 10 (sufficient given
  ~59,000 possible combinations)
- Add regression test that verifies worktree directories get random
  names when using an existing branch
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Apr 11, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant