Skip to content

migration: V1 "global" project sessions invisible in V2 session list after upgrade #55275

Closed as duplicate

Description

@yzy-15

Summary

After upgrading from OpenCode v1.19.0 to v2.0.28, sessions created in V1 under the fallback "global" project no longer appear in the V2 session list (/sessions picker and opencode session list), even when opencode is opened in the exact directory where those sessions were created. The v1→v2 data migration reports completed, but those sessions remain attached to the global project instead of being re-associated with the per-directory project that V2 resolves.

Environment

  • opencode version: 2.0.28 (upgraded from 1.19.0)
  • OS: Linux 7.0.0-38-generic (linux x64)
  • Terminal: TERM=xterm
  • Shell: /bin/bash
  • Install/channel: npm global @opencode/cli@2.0.28 (latest)
  • Active plugins: a local path plugin (loads fine), oh-my-openagent (fails to load — V1 plugin API, unrelated to this issue)

Reproduction

  1. On V1 (1.19.0), start opencode in a directory that is NOT a git worktree root — in my case a repo-tool multi-repo checkout (~/workspace/openharmony, has .repo/ but no .git at the root). Create sessions there. In the V1 database these sessions get project_id = "global" (the global project row has worktree = "/").
  2. Upgrade to OpenCode v2.0.28. The v1→v2 migration runs and kv["migration.v1-v2"] reports {"phase":"completed"}.
  3. Start opencode in the same directory. V2 creates a NEW project row for that directory (e.g. project 225ebdf…, worktree = <that directory>).
  4. Open /sessions or run opencode session list. The list is empty.

Expected Behavior

The v1→v2 migration re-associates V1 "global"-project sessions with the project V2 resolves for their directory (or the session list falls back to matching by directory), so history created in V1 stays visible in the same directory after upgrading.

Actual Behavior

  • opencode session list in the original directory returns nothing ("List top-level sessions in the current project").
  • The sessions still exist in opencode.db (session_v2 table) with project_id = "global" and the correct directory; total counts are unchanged (437 sessions / ~17k messages in my case — no data loss).
  • GET /api/session?directory=<dir> and GET /api/session?project=global both return the "missing" sessions, so only the project scoping hides them.
  • Sessions created in V1 inside git worktrees (which already had real project IDs in V1) display correctly in V2. Only "global"-project sessions are affected.

Additional Context

  • Workaround: POST /api/session/{id}/move with {"directory": "<original directory>"} re-associates a session with the project V2 resolves for that directory. I moved all 392 affected sessions this way and they reappeared in /sessions immediately.
  • Caveats of the workaround: move updates time_updated (affects list ordering), and child sessions (subagent runs) do NOT follow their parent, so every session must be moved individually.
  • Suggested fix: during the v1→v2 migration, re-resolve project_id for "global" sessions from their directory field so upgraded history stays visible.

Activity

  1. opencode-agent commented on Oct 14, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report, the move workaround and the notes on its caveats (child sessions not following their parent, time_updated changing).

    I think this is a duplicate of #49827. Sessions V1 created in directories with no git repo (your repo-tool checkout has .repo/ but no .git) stay on the global project after the V1→V2 migration. V2's session list only shows the current directory's project, so those sessions are hidden even though the data is intact.

    Possible duplicates and related issues, ordered by likelihood:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Your details about child sessions and time_updated would also be useful as a comment on #49827.

  2. opencode-agent commented on Oct 15, 2026

    @opencode-agent
    Contributor

    Closing this as a duplicate of #49827. No reply came in the day after I flagged the overlap, so I'm treating it as the same problem: V1 sessions from non-git directories stay on the global project after the V1→V2 migration and drop out of V2's per-directory session list. Please follow #49827 for updates. Open PRs #51935 and #54048 propose fixes.

    Your notes on the POST /api/session/{id}/move workaround (child sessions don't follow their parent, and time_updated changes) would be useful as a comment on #49827. If your case turns out to be different, reply here and we can reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions