anomalyco / anomalyco/opencode
migrate-v1: non-git sessions in "global" project hidden after V1→V2 upgrade
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
After upgrading from V1.18.31 to V2.0.8, sessions that V1 stored in the global project (sessions created in non-git directories) become invisible in the TUI session picker, because V2 creates a per-directory project and the picker filters to the current project. The history is still in the database, so users perceive all recent conversations as lost.
Environment
- opencode version: 2.0.8 (upgraded from 1.18.31)
- OS: Linux 6.18.33.2-microsoft-standard-WSL2 (WSL2), x86_64
- Terminal: xterm-256color
- Shell: /bin/bash
- Install/channel: latest (curl installer replaced the V1 binary)
- Active plugins:
@wallbreakerno4/opencode-commandcode
Reproduction
- On V1.18.31, run
opencodein a non-git directory (e.g./home/wjf) and create several sessions. They are stored withproject_id = 'global'. - Upgrade to V2.0.8 so the installer replaces the V1 binary.
- Start V2 in the same directory (
/home/wjf). - V2 creates a new project keyed to
/home/wjf. The session picker defaults to filtering by the current project and directory, so only sessions created after the upgrade are listed; all prior sessions are hidden.
Expected Behavior
Sessions created for the same working directory should remain visible after upgrading. V1's global sessions in a non-git directory should be migrated to that directory's V2 project (or otherwise kept visible), per the migration guide's statement that supported non-API V1 behavior stays compatible.
Actual Behavior
The sessions remain in ~/.local/share/opencode/opencode.db but are not shown in the default session list. GET /api/session returns them (they carry projectID: "global"), while the TUI picker filters client-side to projectID === current project.id && location.directory === current directory. The Ctrl+O dialog reports No matches · search all sessions with <leader>l.
Additional Context
- Database:
~/.local/share/opencode/opencode.db, tablesession_v2. Before repair: 104 sessions total, 93 withproject_id = 'global'(81 in/home/wjf, 8 in/tmp/opencode, 3 in/home/wjf/novel, 1 in/home/wjf/videos). - Sessions in a git repository were unaffected:
/home/wjf/fadebreakkept a stable project id across the upgrade and stayed visible. - Relevant log timing: migrations ran at
2026-09-18T17:52:20Z; the new/home/wjfproject row was created at2026-09-18T17:52:21Z. - Workaround:
Ctrl+XthenL("List all sessions") shows everything, including theglobalproject. InsideCtrl+O, pressing<leader>lswitches to searching all sessions. - Repair performed locally:
POST /api/session/{sessionID}/movewith{"directory": "<the session's directory>"}re-bound each of the 93globalsessions to its directory project, after which they appear normally. This worked, but required knowing the sessions were hidden. - Likely cause: V1 used a single
globalproject for non-git directories, while V2 derives a per-directory project id (SHA-1 of the path). No data migration re-keys V1globalsessions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the TUI session picker’s project and directory filter, then inspect the session_v2 records returned by GET /api/session and the existing POST /api/session/{sessionID}/move behavior. Reproduce the V1-to-V2 upgrade with non-git sessions and ensure sessions stored under the global project remain visible for their working directory after migration, while preserving the existing all-sessions workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100