Bug: orphan sessions when project id drifts after git history rewrite
Describe the bug
After restarting opencode, the /sessions command sometimes does not show sessions that were created previously. They are not deleted from the database, but Session.list filters them out because their project_id no longer matches the currently-resolved project id.
To reproduce
- Use a git project that has no remote URL configured (so
Project.resolve falls through to deriving the id from the root commit SHA1).
- Open opencode in the project, create some sessions, then close opencode.
- Rewrite the git history so the root commit SHA1 changes. This can happen in practice via:
git rebase --root rewriting the root commit
git filter-repo or git filter-branch rewriting history
- A fresh clone / re-init that produces a different root commit
- Lose the
<git-common-dir>/opencode cache file (e.g. AV quarantine, git clean -fd, IDE rewriting .git, WSL cross-filesystem quirks).
- Restart opencode in the same project directory.
- The sessions created in step 2 no longer appear under the new project id.
Expected behavior
Sessions created in step 2 should still be visible. They should be migrated to the new project id when opencode restarts and detects the project id has changed.
Actual behavior
The sessions are stranded under the old project_id and never appear in /sessions or any list query. They occupy storage forever and are effectively unreachable from the TUI.
Cause
Project.migrateProjectId early-returns on oldID === undefined, and fromDirectory's global->specific fallback only handled project_id = "global", so non-global orphan projects are stranded.
A fix lands in PR #30682.
Bug: orphan sessions when project id drifts after git history rewrite
Describe the bug
After restarting opencode, the
/sessionscommand sometimes does not show sessions that were created previously. They are not deleted from the database, butSession.listfilters them out because theirproject_idno longer matches the currently-resolved project id.To reproduce
Project.resolvefalls through to deriving the id from the root commit SHA1).git rebase --rootrewriting the root commitgit filter-repoorgit filter-branchrewriting history<git-common-dir>/opencodecache file (e.g. AV quarantine,git clean -fd, IDE rewriting.git, WSL cross-filesystem quirks).Expected behavior
Sessions created in step 2 should still be visible. They should be migrated to the new project id when opencode restarts and detects the project id has changed.
Actual behavior
The sessions are stranded under the old
project_idand never appear in/sessionsor any list query. They occupy storage forever and are effectively unreachable from the TUI.Cause
Project.migrateProjectIdearly-returns onoldID === undefined, andfromDirectory'sglobal->specificfallback only handledproject_id = "global", so non-global orphan projects are stranded.A fix lands in PR #30682.