fix(opencode): sessions lost after git init in existing project#16814
fix(opencode): sessions lost after git init in existing project#16814rekram1-node merged 4 commits intoanomalyco:devfrom
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one related PR that might be worth noting: Related PR (not a duplicate):
PR #15772 -
No duplicate PRs found |
300436f to
32309e3
Compare
…y startup migrateFromGlobal had two bugs: it ran before the target project row was inserted (FK constraint silently rejected the update), and it only ran on first project creation so late-arriving global sessions were permanently orphaned. Move the call after the upsert and remove the first-creation gate so it runs on every startup.
b75985a to
b6b4b5b
Compare
|
looks like there is a merge conflict now |
…-init # Conflicts: # packages/opencode/src/project/project.ts
|
@rekram1-node looks like upstream replaced all the |
|
Sweet thanks! looking over it now |
|
it looks like the migrateFromGlobal function never got touched rlly after the sqlite migration, it should have been updated it looks very inefficient now, not that it matters too much. I'll fix that separately. This lgtm tho Thanks for the PR! |
…alyco#16814) Co-authored-by: Aiden Cline <[email protected]>
…alyco#16814) Co-authored-by: Aiden Cline <[email protected]>
…alyco#16814) Co-authored-by: Aiden Cline <[email protected]>
…alyco#16814) Co-authored-by: Aiden Cline <[email protected]>
Issue for this PR
Closes #16812
Closes #15678
Type of change
What does this PR do?
migrateFromGlobal()had two bugs that caused sessions created under the shared"global"project ID to become permanently orphaned when a git repo is initialized:session.project_id → project.idsilently rejected the update, and the.catch()handler swallowed the error.if (!row)branch). Sessions that accumulated under"global"after the real project ID already existed were never migrated.The fix moves the call to after the project row upsert and removes the first-creation gate so it runs on every startup. This is safe because the function already filters by directory match and is a no-op when no global sessions exist (two cheap indexed reads).
Related PR: #16389 — fixes a different orphaning scenario (worktree cache location and
rev-list --allinstability).How did you verify your code works?
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.