Repository navigation
migration: V1 sessions stay in the synthetic 'global' project after upgrading to V2 and vanish from the session list #55081
Description
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'anddirectory = <home>. - Upgrade to V2, keeping the same data directory (
~/.local/share/opencode), including theopencode.dbproduced by V1. - Start V2 from that same directory and run
opencode session list(or open/sessionsin 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.movebumpstime_updatedto the current time for every moved session. Sinceopencode session listis ordered bytime_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 originaltime_updatedvalues 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.
Activity
opencode-agent commentedon Oct 13, 2026
Thanks for the detailed report and for writing down the workaround. I think this is a duplicate of #49827. Your sessions were created in a non-git directory, so after the V1→V2 migration they kept
project_id = 'global'. V2 then created a separate project for the same directory, so the project-scoped session list hides them.Possible duplicates and related issues, ordered by likelihood:
globaland are hidden after upgrading. It has several confirmations on 2.0.2x and a comment about thesession moveworkaround.project_id='global'instead of resolving it from the session's directory.opencode session list.There are open, unmerged PRs that try to fix this: #51935, which assigns migrated V1 sessions to the project of their directory, and #54048. Your notes on moving sessions one by one and on
session moveresettingtime_updatedwould be useful context on #49827.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.