Skip to content

[FEATURE]:[Feature Request] Native background session autosaver / crash recovery mechanism #32713

Closed as not planned

Description

@zinzied

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Is your feature request related to a problem? Please describe.

Yes. Currently, if OpenCode is closed abruptly (e.g., clicking the 'X' on a terminal window, a sudden power failure, or a system crash), the active session history, chat logs, and UI layout are entirely wiped or corrupted. Because the SQLite DB (opencode.db) and localized session JSONs fall out of sync on sudden exit, the next launch results in a completely blank session slate.

Relying purely on /exit for a graceful flush is highly fragile for long developer sessions.

Describe the solution you'd like

I would love to see a native, internal Autosaver/Guardian mechanism built into the OpenCode background server architecture.

  • It could periodically snapshot or flush the current terminal state, database caches, and session history into a temporary delta file or backup directory at a set interval (e.g., every 30 or 60 seconds).
  • If OpenCode launches and detects a previously non-graceful shutdown, it should prompt the user: "We detected an unsaved session from [Timestamp]. Would you like to restore it?" or seamlessly recover it.

Describe alternatives you've considered

Currently, I have to run a custom python background script daemon that watches ~/.cache/opencode every 30 seconds and manually copies snapshots to a backup directory, paired with a recovery script to paste them back if a crash happens. While this works, a native internal solution would be significantly more robust and benefit the entire community.

Additional context

This would dramatically reduce developer anxiety surrounding crashes or accidental terminal closures during deep AI development sessions.

Activity

  1. dev-tnsq commented on Jun 20, 2026

    @dev-tnsq

    @zinzied ,
    I would like to work on this issue.

    My approach would be to add a periodic session snapshot mechanism that saves the active session state to a crash-recovery file at a configurable interval, and on next launch detects unclean shutdowns and offers to restore. Let me know if that sounds good or if there are any constraints I should be aware of.

  2. zinzied commented on Jun 20, 2026

    @zinzied
    Author

    That sounds like a perfect approach! The combination of a lockfile for detection and a configurable periodic snapshot loop is exactly what this feature needs to be robust.

    Please go ahead and take it on! Let me know if you need any testing or feedback once you have a draft or a Pull Request ready. Thanks for volunteering! 🙏

  3. github-actions commented on Aug 20, 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

No one assigned

    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