anomalyco / anomalyco/opencode

migrate-v1: non-git sessions in "global" project hidden after V1→V2 upgrade

Open
#49,827 0 comments 0 reactions 0 assignees View on GitHub

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

  1. On V1.18.31, run opencode in a non-git directory (e.g. /home/wjf) and create several sessions. They are stored with project_id = 'global'.
  2. Upgrade to V2.0.8 so the installer replaces the V1 binary.
  3. Start V2 in the same directory (/home/wjf).
  4. 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, table session_v2. Before repair: 104 sessions total, 93 with project_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/fadebreak kept a stable project id across the upgrade and stayed visible.
  • Relevant log timing: migrations ran at 2026-09-18T17:52:20Z; the new /home/wjf project row was created at 2026-09-18T17:52:21Z.
  • Workaround: Ctrl+X then L ("List all sessions") shows everything, including the global project. Inside Ctrl+O, pressing <leader>l switches to searching all sessions.
  • Repair performed locally: POST /api/session/{sessionID}/move with {"directory": "<the session's directory>"} re-bound each of the 93 global sessions to its directory project, after which they appear normally. This worked, but required knowing the sessions were hidden.
  • Likely cause: V1 used a single global project for non-git directories, while V2 derives a per-directory project id (SHA-1 of the path). No data migration re-keys V1 global sessions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.