opencode: no sessions found on OpenCode 2.x (sessions moved to session_v2 / session_message)
Summary
catchup opencode finds no sessions on OpenCode 2.x. OpenCode 2.0 moved live sessions out of the session table (and transcripts out of message/part) into new tables, so internal/opencode/opencode.go queries tables that are now empty or frozen.
Versions
- catchup 1.3.0 (Homebrew
wilbeibi/tap/catchup; 1.1.0 behaved the same) - OpenCode v2.0.32 (background service mode)
- macOS (Apple Silicon)
Repro
catchup opencode --list
# -> no opencode sessions found
catchup opencode --list --dir /path/to/project
# -> no opencode sessions found
catchup opencode --id ses_XXXXXXXX -i # an id that exists in OpenCode
# -> no session with id
Expected: sessions created by OpenCode 2.x are listed and can be read by id. Actual: nothing is found, even when run from the session's own directory.
What changed in OpenCode 2.x
The DB path is unchanged (~/.local/share/opencode/opencode.db, WAL mode). On my machine the legacy session table has 1 row (last updated before the upgrade), while session_v2 has ~425. The legacy message/part tables also stop getting rows for new sessions; a 2.x session has 0 rows in message/part and ~660 rows in session_message.
catchup currently reads session (SELECT ... FROM session WHERE time_archived IS NULL ...) and part JOIN message, which is why everything comes back empty.
session_v2 columns
id, project_id, workspace_id, parent_id, fork_session_id, fork_boundary, slug,
directory, path, title, version, share_url, summary_additions, summary_deletions,
summary_files, summary_diffs, metadata, cost, tokens_input, tokens_output,
tokens_reasoning, tokens_cache_read, tokens_cache_write, revert, permission,
agent, model, time_created, time_updated, time_compacting, time_archived,
time_suspended, resume_attempts, time_idle, time_viewed, idle_outcome
session_message columns (replaces message + part)
id, session_id, type, seq, time_created, time_updated, data
Observed type values: user, assistant, system, synthetic, compaction, agent-switched, model-switched, idle.
Shape of data (JSON) per type, keys only:
user:time, text, metadataassistant:time, agent, model, content[], finish, rawFinish, cost, tokenscontent[]items:{type:"text", text},{type:"reasoning", text, state, time},{type:"tool", id, name, executed, state, time}- tool
state:status, input, content[], metadata(orerroron failure);state.content[]items are{type:"text", text}or{type:"file", uri, mime}(images come as data URIs)
compaction:time, status, reason, model, summary, recent, cost, tokenssynthetic:time, text;system:time, text, description, metadata
Other new tables: session_pending, session_inbox.
Possible approach
Order by seq within a session. Keep the legacy query as a fallback for pre-2.0 data: read session_v2 when it exists, otherwise session.
Alternatively, OpenCode 2.x ships an official exporter, opencode session export <id>, which prints {info, messages[]} where messages[] has the same shape as session_message.data plus id/type. Its HTTP API also has GET /api/session?search=… for listing. Either could be used instead of depending on the internal schema.
Thanks for the report. catchup now reads OpenCode 2.x sessions from session_v2 / session_message, and falls back to the legacy tables on 1.x databases. Verified against OpenCode 2.1.4 (fresh sessions plus databases migrated from 1.19.4 and the 2.x beta). It's on the fix/opencode-v2 branch for now and will ship in the next release.