anomalyco / anomalyco/opencode
[FEATURE]: Lazy session persistence to prevent empty database entries
@rekram1-node is already working on this.
Since Jul 26, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Verification
- I searched for existing feature requests.
Description
Analysis of 21 active sessions in the local opencode.db revealed that 5 out of 21 sessions (~24%) were empty entries with 0 tokens used, titled 'New session - timestamp'. OpenCode currently writes a new row to the database immediately upon session creation or switching in the TUI, regardless of whether a prompt was ever sent.
Proposed Solution
Draft/Ephemeral Session State: Keep new sessions in an in-memory Draft state and only persist them to SQLite when the user sends their first message. Also implement automatic garbage collection or startup pruning for abandoned zero-message sessions.
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.