anomalyco / anomalyco/opencode

[FEATURE]: Lazy session persistence to prevent empty database entries

Open
#38,928 1 comment 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.