Description
session.path is supposed to be the session directory relative to the project worktree, but for non-git projects on Windows it is written as an absolute path. The TUI session picker filters on the relative value, so those sessions are never listed — even though they are intact in opencode.db and opencode export <id> still works.
Root cause is in packages/core/src/session.ts (dev @ 95daf906):
const project = yield* projects.resolve(input.location.directory)
...
path: path.relative(project.directory, input.location.directory).replaceAll("\\", "/"),
For a non-git directory the resolved project directory is "/" (the global project row in project has worktree = '/'). On Windows / is resolved against the current process drive, so path.relative("/", "E:/Desktop/x") is a cross-drive relative and Node returns the absolute path unchanged. The row therefore gets path === directory.
The same happens to a C: directory if the process was started from another drive. In my DB the bad rows just happen to be the E: ones — it is the process drive that decides, not the directory.
The picker's filter (packages/opencode/src/session/session.ts, listByProject) is:
eq(SessionTable.path, input.path)
like(SessionTable.path, `${input.path}/%`)
and(isNull(SessionTable.path), eq(SessionTable.directory, input.directory))
An absolute path matches none of the three.
Plugins
None.
OpenCode version
session.version on the 26 affected rows: local 17, 1.18.19 5, 1.18.25 3, 1.18.15 1. The root cause is still present in dev at 95daf906.
Steps to reproduce
- On Windows, open a non-git directory on a drive other than the one the process runs from (e.g.
E:\work while the app lives on C:).
- Create a session there.
- Open the TUI in the same directory and look at the session list. The session is missing; it appears if the query is re-run with the absolute value.
Screenshot and/or share link
No screenshot — there is no visual difference beyond the missing list entries. The DB evidence is below.
Operating System
Windows 11 (10.0.26200)
Terminal
No response
Evidence from my DB (271 sessions, shared by the v1 CLI and the v2 desktop / dev builds)
- 245 rows:
path relative
- 26 rows:
path absolute, and all 26 are byte-identical to directory
- all 26 are on
E:, none on C:
So it only shows up on a non-system drive, which makes it look intermittent. Replaying the picker's query against my DB: the relative form matches 53 sessions for that directory, the absolute form matches 9 — the absolute ones are exactly the missing ones.
Expected behavior
path stays relative to the worktree, or the picker tolerates both forms.
Related
Workaround for other users
With OpenCode closed, normalize the column so the relative form matches:
UPDATE session SET path = substr(path, 4) WHERE path GLOB '[A-Za-z]:/*';
Also patch the "path" value inside the matching session.created.1 / session.updated.1 rows in event, otherwise a projection rebuild restores the absolute value.
Description
session.pathis supposed to be the session directory relative to the project worktree, but for non-git projects on Windows it is written as an absolute path. The TUI session picker filters on the relative value, so those sessions are never listed — even though they are intact inopencode.dbandopencode export <id>still works.Root cause is in
packages/core/src/session.ts(dev @95daf906):For a non-git directory the resolved project directory is
"/"(theglobalproject row inprojecthasworktree = '/'). On Windows/is resolved against the current process drive, sopath.relative("/", "E:/Desktop/x")is a cross-drive relative and Node returns the absolute path unchanged. The row therefore getspath === directory.The same happens to a
C:directory if the process was started from another drive. In my DB the bad rows just happen to be theE:ones — it is the process drive that decides, not the directory.The picker's filter (
packages/opencode/src/session/session.ts,listByProject) is:An absolute
pathmatches none of the three.Plugins
None.
OpenCode version
session.versionon the 26 affected rows:local17,1.18.195,1.18.253,1.18.151. The root cause is still present indevat95daf906.Steps to reproduce
E:\workwhile the app lives onC:).Screenshot and/or share link
No screenshot — there is no visual difference beyond the missing list entries. The DB evidence is below.
Operating System
Windows 11 (10.0.26200)
Terminal
No response
Evidence from my DB (271 sessions, shared by the v1 CLI and the v2 desktop / dev builds)
pathrelativepathabsolute, and all 26 are byte-identical todirectoryE:, none onC:So it only shows up on a non-system drive, which makes it look intermittent. Replaying the picker's query against my DB: the relative form matches 53 sessions for that directory, the absolute form matches 9 — the absolute ones are exactly the missing ones.
Expected behavior
pathstays relative to the worktree, or the picker tolerates both forms.Related
pathwasNULLafter the column was added, not absolute.SELECT count(*) FROM session WHERE project_id = 'global' AND path LIKE '_:/%'on the reporter's DB would confirm it./… resolves to the drive root of the current process") and was closed by the automated PR cleanup rather than by review.Workaround for other users
With OpenCode closed, normalize the column so the relative form matches:
Also patch the
"path"value inside the matchingsession.created.1/session.updated.1rows inevent, otherwise a projection rebuild restores the absolute value.