Skip to content

fix: desktop app worktree collision - use separate ID per worktree#5647

Open
Eric162 wants to merge 5 commits intoanomalyco:devfrom
Eric162:desktop-worktrees
Open

fix: desktop app worktree collision - use separate ID per worktree#5647
Eric162 wants to merge 5 commits intoanomalyco:devfrom
Eric162:desktop-worktrees

Conversation

@Eric162
Copy link
Contributor

@Eric162 Eric162 commented Dec 16, 2025

Fixes #5638

Problem

Opening multiple git worktrees from the same repository in the desktop app causes the second worktree to replace the first one's project data. This happens because project IDs were derived from the root commit hash only, which is identical across all worktrees.

Solution

  • Main worktree: Uses root commit as project ID (backwards compatible)
  • Linked worktrees: Uses rootCommit|worktreeHash format for unique IDs
  • Stores worktree hash in separate .git/opencode-worktree file for linked worktrees
    • without this, it can be quite jarring to upgrade versions, as all of the previous conversations disappear. ideally, there'd only be the original .git/opencode but then there's a bad upgrade experience.
  • Migrates sessions from old format to new when upgrading
  • Disables git fsmonitor in snapshot repos to prevent hangs with linked worktrees

Testing

  • All existing tests pass
  • Added new test to verify different ID formats for main vs linked worktrees
  • Verified backwards compatibility: old opencode can still access main worktree sessions

@madeleineostoja
Copy link

Is there anything blocking this getting merged? It's a blocking issue for us migrating from TUI to the desktop app

@s7dhansh
Copy link

@adamdotdevin kindly see if this can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants

Comments