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 disappear after renaming project folder - directory matching is case-sensitive with inconsistently normalized stored paths #44538
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.
Independent confirmation from a real affected install (Windows 11): I found stored directory values differing only by drive-letter case created days apart by opencode itself, matching your report. Also worth noting for the fix: beyond casing, the same lookup breaks entirely after renames/moves (#23248), and paths inside event payloads are JSON-escaped inconsistently (one and two levels). A canonical real-path comparison would solve the case issue but not the rename one — treating them as one normalization+relink problem is probably the cleaner target. Working on a proposal, will cross-link.
PR is up: #45133 - it covers the relink/migration half of this (rename+move, all stored encodings) plus groundwork docs for the delete-cascade and Desktop registry cleanup. Feedback welcome.
Activity
github-actions commentedon Aug 23, 2026
This issue might be a duplicate of or closely related to existing issues. Please check:
neohiro commentedon Aug 26, 2026
Independent confirmation from a real affected install (Windows 11): I found stored
directoryvalues differing only by drive-letter case created days apart by opencode itself, matching your report. Also worth noting for the fix: beyond casing, the same lookup breaks entirely after renames/moves (#23248), and paths inside event payloads are JSON-escaped inconsistently (one and two levels). A canonical real-path comparison would solve the case issue but not the rename one — treating them as one normalization+relink problem is probably the cleaner target. Working on a proposal, will cross-link.neohiro commentedon Aug 26, 2026
PR is up: #45133 - it covers the relink/migration half of this (rename+move, all stored encodings) plus groundwork docs for the delete-cascade and Desktop registry cleanup. Feedback welcome.
Hona commentedon Sep 2, 2026
Fixed for opencode2 launch via #46713
You can try the desktop beta here: https://github.com/anomalyco/opencode-beta