fix(project): repair split project IDs across worktrees#14287
fix(project): repair split project IDs across worktrees#14287benoitheinrich wants to merge 7 commits intoanomalyco:devfrom
Conversation
|
Updated the PR description to match the PR template sections. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
CI note: the only failing check is The Windows log shows failures in prompt e2e tests with Bun reporting missing I don't see the project repair running in that job (no "Found duplicate projects" output), so this looks unrelated to the project-id/worktree changes. Would appreciate a rerun of the Windows e2e check. |
|
Added a test to assert returns the same when called from the repo root vs any git worktree path (: ). Commit bc711ab1b. |
|
Added a test to assert Commit: bc711ab1b |
|
I manually validated the one-time repair path locally. Command:
Observed output: |
|
Added coverage for the Commit: 17c9e1b7d |
a0afa70 to
a7a1c19
Compare
46f258d to
7a42ecd
Compare
b072ed4 to
d9d9dce
Compare
|
@adamdotdevin any chance to get this PR reviewed soon ? thanks 😄 |
d9d9dce to
f930618
Compare
cfa9cb4 to
7d1804c
Compare
Finding: separate clones were colliding\n\nWhile fixing #14082 (worktrees splitting project IDs), we noticed another scenario: two separate clones of the same git repo can end up sharing a project identity if the ID is derived from repo history (eg. root commit). In the UI this shows up as selecting one project selecting both.\n\n## Fix\n- Git project identity is now a per-clone UUID cached in the git common dir ().\n - Worktrees share the same common dir → same project id\n - Separate clones have different common dirs → different project id\n- Legacy root-commit IDs (40-hex) are migrated in (DB backup + migrate Project/Session/Permission rows) — does not perform DB repairs. |
Correction (shell escaping)
|

Issue for this PR
Closes #14082
Type of change
What does this PR do?
When using git worktrees/sandboxes, the same repo can end up with multiple OpenCode
project.idvalues for a singleproject.worktree. That splits sessions (and other project-scoped data) across IDs. In the Web UI with workspaces enabled this shows up as empty session lists for some sandboxes (/session?directory=<sandbox>&roots=true...) even though sessions exist.This PR:
vcs='git'project row.How did you verify your code works?
cd packages/opencode && bun test test/project/project.test.tsproject.currentresolves to the same project id for root and sandbox directories./session?directory=<sandbox>&roots=true...returns the expected sessions.Screenshots / recordings
N/A (backend-only change)
Checklist