-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Description
When opening multiple git worktrees from the same repository in the desktop app, the app replaces the existing project instead of treating each worktree as a separate project.
Steps to Reproduce
- Create a git repository with multiple worktrees
- Open worktree A in the desktop app
- Open worktree B (from the same repo) in the desktop app
- Observe that worktree A's project is replaced with worktree B
Expected Behavior
Each worktree should be treated as a separate project, allowing users to have multiple worktrees from the same repository open simultaneously.
Actual Behavior
Opening a second worktree from the same repo replaces the first worktree's project data.
Root Cause
The project ID is derived from the git repository's root commit hash (git rev-list --max-parents=0 --all), which is identical across all worktrees of the same repository. Projects are stored/keyed by this ID, so all worktrees from the same repo collide.
Relevant code: packages/opencode/src/project/project.ts:57-70
Potential Fix Direction
The project key should incorporate the folder/worktree path to make each worktree unique, rather than relying solely on the git root commit hash.
Related
Selecting multiple folders when opening may also be affected by this same issue (needs further investigation).