anomalyco / anomalyco/opencode
Desktop: session row silently deleted from opencode.db after app restart (no deletion event, data recoverable from event log)
@jlongster is already working on this.
Since Sep 5, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
A session with ~90 messages vanished from the session list after an app restart. ~2.5 h of active work.
What I found in ~/.local/share/opencode/opencode.db (read-only queries):
- the
sessionrow is gone: 207session.created.1events vs 206 rows in thesessiontable - the
eventtable has no deletion event type at all (onlysession.created/session.updated/message.updated/message.part.updated/message.removed), so a deletion leaves no audit trail - all 787 events of that session are still present, so the full conversation (messages, tool calls, per-message cost) is recoverable from the event log
Context that may matter:
- Desktop app 1.18.5, macOS 15.6, arm64; the session had already survived 4 app restarts earlier the same day
- it disappeared at the 5th restart, ~30 s after the last assistant message, which was still streaming when the app was quit
- the auto-updater was in
readystate (1.18.29 downloaded) at that moment - a CLI instance was running concurrently against the same DB
I rebuilt the whole conversation from the event log (last message.part.updated.1 per part id, grouped by messageID, ordered by info.time.created), so nothing was ultimately lost, but from the user's perspective the session silently vanished with no error and no recovery path.
Suggestions: log a session.deleted event (user / cleanup / migration), and consider a startup reconciliation that restores rows for any session.created id missing from the session table.
Plugins
No response
OpenCode version
1.18.5 (Desktop app, macOS arm64)
Steps to reproduce
Not fully deterministic, best guess:
- In the Desktop app, work in a session until an assistant message is streaming
- Quit the app while the message is still in flight
- Reopen: the session is gone from the list; its row is deleted from the
sessiontable while all its events remain in theeventtable
Screenshot and/or share link
No response
Operating System
macOS 15.6
Terminal
n/a (Desktop app)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.