Skip to content

migrate: v1 sessions from non-git directories land in 'global' project and lose leading '/' in path #50521

Closed

Description

@wk722

Summary

After installing OpenCode V2, sessions stored in non-git directories
(e.g. /Users/<user>/Downloads) are invisible in the session list.
Investigation of the migrated SQLite database shows two problems in the
migration: the old sessions are assigned to project_id = 'global', and their
path value is stored without the leading / (e.g.
Users/<user>/Downloads). When the TUI later starts in that directory, it
creates a new project row for /Users/<user>/Downloads, and the session list
(which queries by project) returns nothing. Session data is intact but
orphaned under the wrong project.

Environment

  • opencode version: v2.0.12 (latest)
  • OS: macOS (Darwin 27.0.0, arm64)
  • Terminal: Ghostty (TERM_PROGRAM=ghostty)
  • Shell: elvish
  • Install/channel: latest
  • Active plugins: none configured

Reproduction

  1. Run OpenCode V1 sessions in a non-git directory (e.g. /Users/<user>/Downloads);
    create several sessions.
  2. Upgrade to OpenCode V2 and start it in the same directory.
  3. Open the session list (<leader>l) — no previous sessions appear, even
    though the migration ran.

Expected Behavior

Post-migration, starting V2 in a directory that had V1 sessions should show
those sessions in the session list, matching V2's project scoping for that
directory.

Actual Behavior

The session list is empty for that directory. Inspecting the SQLite database
at ~/.local/share/opencode/opencode.db:

  • session rows for the affected directory have project_id = 'global' and
    path = 'Users/<user>/Downloads' (missing leading /).
  • On first V2 startup a new project is created for
    /Users/<user>/Downloads with a generated project id, so no sessions match
    it.
  • Sessions below git repositories (where a matching project row already
    existed) migrate correctly; only non-git directories appear affected.

Additional Context

  • Data was not lost; manually updating the affected sessions' project_id to
    the newly created project id restores them in the UI.
  • The old V1 storage/ directory is emptied and a migration marker file
    remains, consistent with a one-time migration step that assigned these
    sessions to global.
  • Workaround: manual SQLite update (backup first). A migration fix would be
    preferable.

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your report adds new information (the missing leading / in the path column is a distinct detail not covered in #49827), it may still be worth keeping open. Please check those issues and comment there or link them if they cover your situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions