Hitting this on a non-home directory as well — adding evidence in case it helps broaden the fix.
Setup
- OpenCode 1.15.6 on macOS (anomalyco fork)
- Working dir: a subfolder of
~/Desktop (not $HOME)
- Project worktree:
/ (global)
Symptom
23 of 62 sessions in this directory are invisible in /sessions. opencode session list and opencode -s <id> both find them fine.
Root cause: writer/reader contract mismatch on session.path
Two states exist for the path column on sessions in the same directory:
path value |
Count |
Visible in /sessions? |
NULL |
39 |
yes |
'' (empty string) |
23 |
no |
All 23 invisible sessions were created on OpenCode ≥ 1.14.39 (oldest 2026-05-06). All 39 visible ones are on ≤ 1.14.28. Something between those releases changed session creation from writing NULL to writing ''.
The server-side filter at packages/opencode/src/session/session.ts:1058:
input.directory
? or(...conds, and(isNull(SessionTable.path), eq(SessionTable.directory, input.directory))!)!
: or(...conds)!,
The fallback that catches "no path-prefix match" only fires for path IS NULL. Sessions with path = '' don't match either branch and get filtered out.
Why this is broader than the home-directory case
PR #29582 special-cases the home directory by switching to project scope. That only triggers when the worktree resolves to / and the directory is $HOME. My case is a Desktop subfolder, so #29582 wouldn't fix it — but the underlying bug is identical.
Proposed minimal fix (server-side, one line)
// session.ts:1058
- and(isNull(SessionTable.path), eq(SessionTable.directory, input.directory))!
+ and(or(isNull(SessionTable.path), eq(SessionTable.path, ''))!, eq(SessionTable.directory, input.directory))!
This is non-breaking and covers existing DBs without requiring a data migration. Alternatively (or additionally), normalize at the writer to always store NULL when no path applies.
Local workaround (no app restart of fix, just data normalization)
UPDATE session SET path = NULL WHERE path = '';
Confirmed on my DB: the 23 hidden sessions reappeared after restarting the TUI.