Skip to content

Bug: Desktop session save failure caused by corrupted opencode.global.dat index #20450

Closed as not planned

Description

@torkucloud

Bug Report: OpenCode Desktop Session Save Failure & Index Coupling (opencode.global.dat)

🐛 Describe the bug

OpenCode Desktop silently fails to save or display new sessions (workspaces) when its global index file (opencode.global.dat) becomes corrupted or out-of-sync.

Users who encounter this issue find that new chats/sessions are not persisted or are invisible upon restarting the app. Furthermore, manually backing up and restoring .dat session files (opencode.workspace.[id].dat) does not work unless the original corrupted opencode.global.dat is also restored, which in turn immediately revives the session-saving bug.

🔄 To Reproduce

  1. The user uses the app over a period of time until opencode.global.dat enters a corrupted/desynced state in %APPDATA%\ai.opencode.desktop.
  2. The user creates a new chat/session. The session appears during the active window, but upon app restart, the new session is gone.
  3. The user tries to clear cache (EBWebView) but the problem persists.
  4. The user copies opencode.workspace.*.dat files to a backup location and deletes %APPDATA%\ai.opencode.desktop\*.dat.
  5. The user opens OpenCode and new sessions save perfectly again (app works as intended).
  6. However, when the user copies their old opencode.workspace.*.dat files back into the directory, OpenCode completely ignores them because they are not indexed in the newly generated opencode.global.dat.
  7. Restoring the old opencode.global.dat brings the old sessions back into the UI, but the "cannot save/display new sessions" bug instantly returns.

🎯 Expected behavior

  1. Directory Scanning: The application should not rely entirely on opencode.global.dat as a single point of failure to index sessions. It should dynamically scan the %APPDATA%\ai.opencode.desktop directory for orphaned opencode.workspace.*.dat files and auto-index them.
  2. Graceful Degradation: If opencode.global.dat discovers a corrupted workspace entry, it should log a warning instead of failing the entirely new session save operations.
  3. Session Export/Import: The desktop application currently lacks a built-in session export/import feature, leaving users with no safe way to salvage their workspace histories without inheriting the corrupted settings file. (Note: Popular AI assistants like Claude often hallucinate that OpenCode Desktop has an opencode sessions list/export CLI command, which misleads users into thinking they can export their sessions via terminal).

💻 Environment

  • OS: Windows (Tested on Windows 11 / %APPDATA% directory)
  • App: OpenCode Desktop (ai.opencode.desktop)
  • Data Path: C:\Users\[User]\AppData\Roaming\ai.opencode.desktop

🛠️ Proposed Solution (For Devs)

Implement validation checks on the global.dat file during the startup launch procedure. If a workspace ID listed in the index is unreadable or malformed, omit it rather than causing the internal state to block new writes. Add an "Import Workspaces from Disk" function that scans for opencode.workspace.[id].dat files and rebuilds the global.dat index dynamically.

Activity

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

    @github-actions
    Contributor

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

    If your issue is distinct from these, please add a note explaining how it differs.

  3. removed
    webRelates to opencode on web / desktop
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 4, 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