Skip to content

Windows Desktop loses all session history after restart, but sessions still exist in opencode.db #17765

Closed as not planned

Description

@1401341324

Description

Description
On Windows Desktop, all session history disappears every time I close and reopen OpenCode.

This is not just a UI refresh issue. After reopening the client, the session list is completely empty.

However, I checked the local database and confirmed that the sessions are still stored locally, so the data does not appear to be deleted. This looks like a session loading / project matching / indexing bug on startup.

Environment
OpenCode version: 1.2.27
OS: Windows
Client: Desktop
Workspace type: local Windows directory
Path usage: fixed / consistent path, not switching between different path formats
WSL: not using WSL for this case
Steps to reproduce
Open OpenCode Desktop on Windows
Open a local project directory
Create or use some sessions normally
Close OpenCode Desktop
Reopen OpenCode Desktop
Observe that the session history list is now empty
Expected behavior
Previously created sessions should still appear in the session/history list after reopening the app.

Actual behavior
After reopening the app, the session/history list is completely empty.

Important local findings
I inspected the local database at:

C:\Users\14013.local\share\opencode\opencode.db

The database still contains session data:

project: 1
session: 11
message: 100
Relevant findings:

session table exists and contains records
message table exists and contains records
storage/session_diff/ also contains files matching the session IDs
But the data shape looks suspicious:

the only row in project is:
id = global
worktree = /
all session rows have:
project_id = global
directory = D:
So the persisted session data is still there, but the project/worktree mapping looks inconsistent on Windows:

project.worktree = "/"
while session.directory = "D:"
This makes me suspect that after restart, Desktop cannot match/load the existing sessions correctly, so the UI shows an empty list even though the data still exists.

Additional notes
This is on a local Windows directory
I am not changing paths
I already updated to the latest version available to me (1.2.27)
The problem happens consistently after closing and reopening the client
Possible root cause
This may be related to Windows-specific path normalization / project matching / session indexing on startup.

Plugins

ohmyopencode

OpenCode version

1.2.27

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    webRelates to opencode on web / desktop
    on Mar 16, 2026
  2. github-actions commented on Mar 16, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Your investigation pointing to project.worktree = "/" vs session.directory = "D:\\" matches the root cause documented in #16579. It may be worth checking if those fixes address your scenario as well.

  3. Xyz00777 commented on Mar 26, 2026

    @Xyz00777

    it looks like i have the same problem on linux with the terminal user interface of opencode. But it also looked like when i use the continue command like 'opencode -s ses_2fe99f6daffe9531Hu62OH7JoN' than its propably able to find the old version and load it (im not so sure if was in the sessions overfiew before but i would say no

  4. paulcatamio commented on Apr 11, 2026

    @paulcatamio

    I hit this on Windows Desktop connected to a WSL-backed server. Sessions were still being written, but the same repo could end up identified as both /home/... and \wsl.localhost... so the sidebar hid them. I opened PR #22049 with a small fix that normalizes WSL UNC-style paths both when comparing sidebar workspace keys and when saving new session directories.

  5. removed
    bugSomething isn't working
    webRelates to opencode on web / desktop
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. TrekkerTyre commented on May 10, 2026

    @TrekkerTyre

    Good day. Well i am not sure if this is a feature or a bug. I am on version OpenCode Desktop
    v1.14.46. After i am done for the day, all chats and the entire session is missing after i close the application and open it. I have checked the %localappdata% for the session .json file. All of them are at 1Kb wit only [] in them. there is no chats noting.

  7. quintalis2 commented on May 19, 2026

    @quintalis2

    This may be related to the way Opencode stores sessions and Mapped Drive letters. If you experience this behavior, and are using a mapped drive, open your project with the full UNC path instead.

  8. StevenTorval commented on May 29, 2026

    @StevenTorval

    +1 — I'm experiencing the same issue on Windows 10 with OpenCode Desktop v1.15.12.

    Environment:

    OS: Windows 10
    OpenCode Desktop version: 1.15.12
    No WSL
    Behavior:

    Sessions are created and stored in the database (opencode.db)
    After restarting Desktop, the session list is completely empty
    However, sessions are accessible via CLI: opencode session list shows all 30+ sessions
    Database verification:

    Sessions exist in %USERPROFILE%.local\share\opencode\opencode.db
    The project.worktree value shows / while session.directory shows the correct Windows path (e.g., D:)
    Workaround: Using the CLI (opencode -c or opencode -s ) works correctly and loads sessions as expected.

    This confirms the project/worktree mapping issue on Windows. Looking forward to a fix!

  9. TrekkerTyre commented on May 30, 2026

    @TrekkerTyre

    Well i had found a work around this. I just create a new project and that is how i got open code to save the chat and progress.

  10. github-actions commented on Jul 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions