opencode
opencode copied to clipboard
fix: desktop app worktree collision - use separate ID per worktree
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|worktreeHashformat for unique IDs - Stores worktree hash in separate
.git/opencode-worktreefile 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/opencodebut then there's a bad upgrade experience.
- without this, it can be quite jarring to upgrade versions, as all of the previous conversations disappear. ideally, there'd only be the original
- 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