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
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.
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.
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! 🙏
Activity
dev-tnsq commentedon Jun 20, 2026
@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.
zinzied commentedon Jun 20, 2026
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! 🙏
github-actions commentedon Aug 20, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.