fix(opencode): run migrateFromGlobal after project upsert and on every startup#16814
Open
michaeldwan wants to merge 1 commit intoanomalyco:devfrom
Open
fix(opencode): run migrateFromGlobal after project upsert and on every startup#16814michaeldwan wants to merge 1 commit intoanomalyco:devfrom
michaeldwan wants to merge 1 commit intoanomalyco:devfrom
Conversation
…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.
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
|
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 |
This was referenced Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.