GeezerVison is showing github.com — /sessions empty after 1.x → 2.x migration in non-git directory (sessions orphaned under global project) · Issue #55142 · anomalyco/opencode
/sessions empty after 1.x → 2.x migration in non-git directory (sessions orphaned under global project) #55142Description/sessions empty after 1.x → 2.x migration in non-git directory (sessions orphaned under global project)
Environment
- OpenCode v2.0.27 → v2.0.28, Linux (Mint 21.3)
- Previous line: 1.x (sessions with
version 1.3.2 … 1.19.0)
- Working directory is not a git repo:
/home/gabriel/Repos/privado
Symptom
/sessions in the TUI shows an empty list, although 104 sessions exist in ~/.local/share/opencode/opencode.db with directory = cwd.
all-sessions shows sessions from other directories but hides exactly the 104 of the cwd.
- Standing in a git worktree (
~/Repos/apl-educubo), all-sessions does show the 104. So data is intact; it is a listing/scoping bug, not data loss.
Root cause (verified in SQLite)
On first 2.0 launch (2026-10-12), a new per-directory project row was created:
ebdc21788a3e0c5e7df44d6630f17cf32003088b | /home/gabriel/Repos/privado | (no vcs)
but it holds 0 sessions: all 104 pre-existing sessions kept project_id = 'global' (the 1.x-era project, worktree /). Sessions created under git worktrees kept project ids that survived migration, so git dirs list fine — only the non-git cwd is orphaned:
project_id | count
global | 131 (104 privado + 19 /tmp + 8 ~)
ebdc21… | 0 (worktree = cwd, non-git)
d5a7b3… | 11 (apl-educubo, git — lists fine)
/sessions resolves the current project by worktree (ebdc21…) → 0 rows → empty. all-sessions excludes the cwd group → the 104 are invisible exactly when standing in that directory.
Expected
Migration (or the list query) should backfill session.project_id from session.directory → project.worktree, or the session list should fall back to a directory match when the resolved project has no sessions.
Related
Local workaround applied
UPDATE session SET project_id='ebdc21…' WHERE directory='…' AND project_id='global';
(104 rows; DB backed up first.) /sessions lists them again after this. Activityopencode-agent commented on Oct 13, 2026 Thanks for the detailed write-up and the verified SQL diagnosis! I think this is a duplicate of #49827. After the V1→V2 migration, sessions that V1 created in non-git directories stay under the global project. V2 gives each of those directories its own project, so the per-directory session list hides them even though the data is intact.
Possible duplicates and closely related issues, ordered from most to least likely:
A note on your workaround, from #54815: when you move sessions by hand, also set path = '' (not NULL). Otherwise the TUI list, which also filters on the subpath, may still hide them.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Please follow #49827 and PR #51935 for updates.
opencode-agent commented on Oct 14, 2026 We haven't heard back, so I'm closing this as a duplicate of #49827. V1 sessions from non-git directories stay under the global project after the V1→V2 migration, so V2's session list for that directory hides them. Please follow #49827 and the open fix PR #51935 for updates.
Until the fix lands, your SQL workaround still works. If /sessions still hides any of them, also set path = '' (not NULL) on those rows. If your problem turns out to be different from #49827, reply here and we can reopen. Thanks again for the very clear diagnosis!
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|