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
sessions: pre-project-row sessions stranded in global project are hidden from session lists #57629
Sessions created before their directory's project row exists are stored under the global
project (worktree /) and never appear in project-scoped session listings (opencode session list, TUI session list), even when the session's directory matches the current directory
exactly. An entire 120-session history was invisible; only sessions created after the project
row appeared were listed.
Environment
opencode version: 2.1.1
OS: Linux 6.18.40.1-microsoft-standard-WSL2+ (linux x64)
Active plugins: none found (global/project config declare no plugins; no .opencode/plugin(s)/)
Reproduction
From /home/redacted, create sessions while project has no row for that directory
(sessions are stored with project_id='global').
Later start opencode in /home/redacted again so a project row for it is created
(observed: created when a new session started).
Run opencode session list --format json from /home/redacted.
Only sessions created after the row existed are returned; all older sessions — including
ones whose directory is exactly /home/redacted — are absent even with -n 500.
Expected Behavior
Directory-scoped session listings should include sessions whose directory matches the
current directory regardless of which project bucket stored them, or older sessions should be
re-scoped to the directory's project row when it is first created.
Actual Behavior
opencode session list from /home/redacted returned exactly 1 session while session_v2
contained 141: 120 in project_id='global' (53 with directory=/home/redacted, 67 with directory=/home/redacted/redacted) and 21 in the /home/redacted project. Listing from /home/redacted/redacted returned 0 despite 67 sessions with that exact directory, because
that directory has no project row of its own. GET /api/session returns all sessions
regardless of project, so the data exists but is unreachable from directory-scoped views.
Additional Context
Frequency: user hit this previously and assumed the history was lost; reproducible whenever
sessions predate their directory's project row.
Evidence: project_directory was empty; re-pointing the 120 rows with UPDATE session_v2 SET project_id = '<directory project>' WHERE project_id='global'
(after an online backup) made session list -n 500 return all 118 top-level sessions — the
rows were intact; only the bucket was wrong.
Workaround requires direct DB editing; session export/import re-creates sessions instead
of fixing the association.
Related quirk: starting opencode in a subdirectory creates a new project row there,
stranding those sessions from the opposite direction.
Thanks for the detailed report and the database analysis. I think this is a duplicate of #49827.
In v2, a directory that isn't in a git or hg repo always gets its own project when you open it. New sessions are not stored under global. Sessions end up under global when they were imported from V1: V1 kept sessions from non-git directories in that shared project. v2 then creates a separate project for /home/redacted (and for /home/redacted/redacted), and the session list only shows sessions from the current project, so the older sessions are hidden. Your data is intact, as you found.
Possible duplicates and closely related issues, ordered by likelihood:
If you fix the rows by hand, note from #54815 and #50551 that path should also be set to '' (not NULL). Otherwise the TUI list can still hide the sessions even when opencode session list shows them.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, if these sessions were created by v2 itself and never imported from V1, please say so.
Activity
opencode-agent commentedon Oct 21, 2026
Thanks for the detailed report and the database analysis. I think this is a duplicate of #49827.
In v2, a directory that isn't in a git or hg repo always gets its own project when you open it. New sessions are not stored under
global. Sessions end up underglobalwhen they were imported from V1: V1 kept sessions from non-git directories in that shared project. v2 then creates a separate project for/home/redacted(and for/home/redacted/redacted), and the session list only shows sessions from the current project, so the older sessions are hidden. Your data is intact, as you found.Possible duplicates and closely related issues, ordered by likelihood:
globalafter upgrading and are hidden from the project-scoped list (main issue)opencode session listand the TUI; describes the runtime gap where opening a non-git directory does not take over itsglobalsessionsproject_id='global'for non-git directoriesOpen PRs that try to fix this: #51935, #54048 and #56322.
If you fix the rows by hand, note from #54815 and #50551 that
pathshould also be set to''(notNULL). Otherwise the TUI list can still hide the sessions even whenopencode session listshows them.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, if these sessions were created by v2 itself and never imported from V1, please say so.