Summary
After upgrading from OpenCode V1 to V2, previously existing sessions no longer appear in the TUI session picker or opencode session list. The session data is still present in the SQLite database (session_v2), but every migrated session remains assigned to the synthetic global project, while V2 creates a separate project for the current directory. Because the session list is scoped to the current project, the migrated sessions become invisible.
Environment
- opencode version: 2.0.27 (upgraded from V1)
- OS: Darwin 25.6.0 (Darwin Kernel 25.6.0, arm64)
- Terminal: ghostty (
TERM=xterm-256color, TERM_PROGRAM=ghostty, COLORTERM=truecolor)
- Shell:
/bin/zsh
- Install/channel:
latest (Homebrew, /opt/homebrew/bin/opencode)
- Active plugins: none found in config
Reproduction
- In V1, use OpenCode from a non-git directory (for example the home directory) and create a few sessions. V1 records them with
project_id = 'global' and directory = <home>.
- Upgrade to V2, keeping the same data directory (
~/.local/share/opencode), including the opencode.db produced by V1.
- Start V2 from that same directory and run
opencode session list (or open /sessions in the TUI).
- Only the newly created session is listed; all pre-upgrade sessions are missing.
Expected Behavior
Sessions created in V1 should remain visible after upgrading to V2, either by being mapped to the V2 project whose directory matches their stored directory, or by the session list including legacy global sessions for the current directory.
Actual Behavior
All migrated sessions keep project_id = 'global'. On first V2 start, a new project is created for the current directory (worktree = home), and the session list is filtered to that project, so the legacy sessions do not appear. opencode session list --help documents it as "List top-level sessions in the current project".
State observed before the workaround:
session_v2: 27 sessions with project_id='global' (directory = <home>)
1 session with project_id=<hash>
project: 'global' (worktree '/') and '<hash>' (worktree '<home>')
project_directory: empty
Directly after POST /api/session/{id}/move with {"directory":"<home>"}, the session's project_id changes to <hash> and it appears in the list again. No session content was ever missing — only the project assignment.
Additional Context
With ~27 legacy sessions, the only way to recover them was to move each one individually through the public API:
opencode api post /api/session/<sessionID>/move --data '{"directory":"<dir>"}'
Two related problems:
- There is no bulk "adopt sessions into this project" path, so recovery is one request per session.
session.move bumps time_updated to the current time for every moved session. Since opencode session list is ordered by time_updated (newest first), moving a batch of sessions makes them all sort as "just now" and destroys their original chronological order. I had to restore the original time_updated values from a pre-fix database backup.
A migration that maps legacy global sessions to the V2 project for their stored directory (or a bulk reassignment endpoint) would avoid both issues.
Environment note: the directory in question is the user's home directory, which is not a git repository. V1 used the synthetic global project for it, while V2 creates a real (non-VCS) project for it. The mismatch between these two identities is what hides the sessions.