You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: orphan sessions when project id drifts after git history rewrite #30683
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.
If your issue is distinct from the above (e.g., specifically about root-commit SHA drift after history rewrite rather than directory rename), feel free to clarify.
Activity
github-actions commentedon Jun 4, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is distinct from the above (e.g., specifically about root-commit SHA drift after history rewrite rather than directory rename), feel free to clarify.
github-actions commentedon Aug 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.