Skip to content

Desktop app: opening multiple git worktrees from the same repo replaces existing project #5638

@Eric162

Description

@Eric162

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

  1. Create a git repository with multiple worktrees
  2. Open worktree A in the desktop app
  3. Open worktree B (from the same repo) in the desktop app
  4. 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).

Metadata

Metadata

Assignees

Labels

webRelates to opencode on web / desktop

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions