Description
Environment
- OpenCode desktop app 1.18.18
- Windows 10 22H2 (build 19045)
Steps to reproduce
- Create sessions in a project folder (e.g.
D:\Documents\Default Project)
- Rename that folder to something else (e.g.
D:\Documents\OpenCode)
- Open the app on the renamed folder -> session list is empty
- Rename the folder back -> sessions still do not appear reliably
Expected behavior
Renaming a project folder should not orphan its sessions. Windows paths are
case-insensitive, so d: and D: must be treated as identical.
Actual behavior / root cause
Session listing filters by exact string comparison:
listByProject() in packages/opencode/src/session/session.ts does
eq(SessionTable.directory, input.directory) — case-sensitive SQLite match.
Meanwhile, stored session.directory values are normalized inconsistently.
Found in the same database, created by opencode itself:
D:/Documents/Default Project
d:/Documents/Default Project <-- lowercase drive letter
The desktop app also stores the registered project as d:\\Documents\\OpenCode
(lowercase) in its state file, while other components use uppercase. So even
after manually updating all DB paths to the "correct" casing shown by Explorer,
/api/session?directory=D:\Documents\OpenCode returned 6 sessions but the UI
requested d:\Documents\OpenCode and got 0.
The event-sourced payloads (event table, type session.created/updated)
also embed the old directory path inside their JSON, which kept stale paths
alive after fixing the session table.
Data loss appearance
Nothing was actually lost (messages live in the global opencode.db), but from
the user's perspective ALL sessions vanish after a folder rename, which looks
catastrophic.
Suggested fix
Resolve both sides to a canonical real path (e.g. via realpath) before storing
and before comparing, or compare case-insensitively on Windows.
Workaround used
Directly updated opencode.db: session.directory, session.path and every
JSON directory field inside the event table, matching the exact casing the
app sends (d:\Documents\OpenCode). Sessions reappeared after app restart.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
Environment
Steps to reproduce
D:\Documents\Default Project)D:\Documents\OpenCode)Expected behavior
Renaming a project folder should not orphan its sessions. Windows paths are
case-insensitive, so
d:andD:must be treated as identical.Actual behavior / root cause
Session listing filters by exact string comparison:
listByProject()inpackages/opencode/src/session/session.tsdoeseq(SessionTable.directory, input.directory)— case-sensitive SQLite match.Meanwhile, stored
session.directoryvalues are normalized inconsistently.Found in the same database, created by opencode itself:
D:/Documents/Default Projectd:/Documents/Default Project<-- lowercase drive letterThe desktop app also stores the registered project as
d:\\Documents\\OpenCode(lowercase) in its state file, while other components use uppercase. So even
after manually updating all DB paths to the "correct" casing shown by Explorer,
/api/session?directory=D:\Documents\OpenCodereturned 6 sessions but the UIrequested
d:\Documents\OpenCodeand got 0.The event-sourced payloads (
eventtable, typesession.created/updated)also embed the old directory path inside their JSON, which kept stale paths
alive after fixing the
sessiontable.Data loss appearance
Nothing was actually lost (messages live in the global
opencode.db), but fromthe user's perspective ALL sessions vanish after a folder rename, which looks
catastrophic.
Suggested fix
Resolve both sides to a canonical real path (e.g. via realpath) before storing
and before comparing, or compare case-insensitively on Windows.
Workaround used
Directly updated
opencode.db:session.directory,session.pathand everyJSON
directoryfield inside theeventtable, matching the exact casing theapp sends (
d:\Documents\OpenCode). Sessions reappeared after app restart.Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response