Skip to content

Read OpenCode 2.x sessions - #27

Merged
wilbeibi merged 2 commits into
mainfrom
fix/opencode-v2
Oct 24, 2026
Merged

wilbeibi merged 2 commits into
mainfrom
fix/opencode-v2

Conversation

@wilbeibi

Copy link
Copy Markdown
Owner

OpenCode 2.x moved sessions into session_v2 and their transcripts into session_message, so catchup found no sessions on 2.x databases. catchup now reads those tables when session_v2 exists and keeps the legacy session/message/part path for 1.x databases. Listing, --id, -q, reading and --since-compact work on both.

On 2.x, user rows and assistant text form the timeline, a tool item with state.status error becomes a failure entry, and a completed compaction row becomes a compaction marker carrying its summary. Synthetic and system rows are injected context and stay off the timeline.

Verified against @opencode/cli 2.1.4: fresh sessions, a 1.19.4 database migrated by 2.1.4, and a 291-session database written by the 2.x beta and migrated by 2.1.4. Every session reads without errors or unknown-type warnings. The test fixtures follow those real row shapes, and the list/read/query tests run over both layouts.

Runtime +203/-21, tests +82/-29, docs none.

Fixes #26. Thanks @jiz4oh for the report and the schema details that pinned this down.

OpenCode 2.x keeps sessions in session_v2 and transcripts in
session_message, so catchup found no sessions after the upgrade. When
session_v2 exists, list, resolve, and read from the 2.x tables, which
OpenCode's startup migration fills with every legacy session; older
databases keep the legacy path.

In 2.x transcripts, injected synthetic and system rows no longer appear
as user turns, and a completed compaction carries its summary. A
session without a title no longer fails the listing.

Fixes #26
@wilbeibi
wilbeibi merged commit c59fed3 into main Oct 24, 2026
2 checks passed
@wilbeibi
wilbeibi deleted the fix/opencode-v2 branch October 24, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode: no sessions found on OpenCode 2.x (sessions moved to session_v2 / session_message)

1 participant