Description
Summary
After upgrading from V1 to V2, the V1→V2 session migration imports all sessions but leaves sessions created in non-git directories (e.g. $HOME) attached to V1's legacy catch-all project. V2 resolves a different project for the same directory, so these migrated sessions never appear in the project-scoped session list (opencode session list, TUI /sessions).
Environment
- opencode version: 2.0.14
- OS: Darwin 27.0.0 (darwin arm64)
- Terminal: Hyper (
TERM=xterm-256color,COLORTERM=truecolor) - Shell: /bin/zsh
- Install/channel: latest
- Active plugins: None found in config
Reproduction
- With OpenCode V1 (observed with 1.18.29–1.18.31), create sessions in a directory that is not a git repository (e.g.
$HOME). - Install V2 and run it in the same directory. Let the V1→V2 session migration run to completion (
kvrowmigration.v1-v2={"phase":"completed"}). - Run
opencode session listor open/sessionsin the TUI in that directory.
Expected Behavior
Migrated V1 sessions appear in the session list for the directory they were created in.
Actual Behavior
Only natively-created V2 sessions are listed. The imported V1 sessions are still returned by GET /api/session?directory=<dir>, but not by the project-scoped session list.
Evidence from ~/.local/share/opencode/opencode.db:
- All 33 V1 sessions created in non-git directories (
$HOME, a subfolder of$HOME,/private/tmp, …) share one legacyproject_id, whoseproject.worktreepoints to a stale, unrelated path. - V2 created a new project row for
$HOMEon first launch; the session list is scoped to that project, so the imported sessions (correctdirectory, legacyproject_id) are invisible. - Git-repository directories are unaffected, because V1 and V2 derive the same project from the git worktree.
Additional Context
Workaround that restored full visibility: moving each orphaned session to its own recorded directory (the session-move operation re-resolves the V2 project). After moving all 33 sessions, opencode session list in $HOME shows all 28 expected sessions.
Suggestion: the V1→V2 migration (tracked under migration.v1-v2) should re-home sessions from the legacy catch-all project into the per-directory project that V2 computes, or the session list should match imported sessions by directory as a fallback.
Activity
github-actions commentedon Sep 23, 2026
This issue might be a duplicate of an existing issue. Please check:
project_id='global'for non-git directories, so migrated sessions never appear in the per-directory session list. That issue also identifies the exact code locations and proposes fixes.neriousy commentedon Oct 20, 2026
Thanks for the report. We're tracking this same migration problem in #50551, so I'm closing this as a duplicate. Please follow that issue for updates.