Skip to content

sessions: V1 legacy session rows unfindable in V2 /sessions because session.path is not normalized to project-root-relative form #54774

Closed as duplicate

Description

@ianpodkopaev

Summary

After upgrading a V1 install (1.18.x–1.19.x) to V2, legacy sessions are not shown in the TUI /sessions view for their project. V1 stored session.path relative to $HOME (e.g. home/user/Projects/foo) and project_id under the legacy global/git-repo projects; V2's project-scoped session list requires path relative to the project root ('' for root sessions), so exact-match lookups return zero rows and the view shows "No sessions available". Data is intact but effectively orphaned until project_id and path are migrated.

Environment

  • opencode version: 2.0.27 (latest channel, curl install)
  • OS: Linux (CachyOS 7.2.9-2-cachyos, x86_64)
  • Terminal: xterm-256color (kitty), COLORTERM=truecolor
  • Shell: /bin/fish
  • Install/channel: latest
  • Active plugins: @dietrichgebert/ponytail

Reproduction

  1. Install V1 (1.18.x/1.19.x); open opencode in a directory that is not a git repo, e.g. ~/Projects/foo (or any dir), and create sessions. V1 stores these with project_id='global' (or the git repo project) and path relative to $HOME, e.g. home/user/Projects/foo.
  2. Upgrade to V2 2.0.27. Migrations run (last: 20261010180456). V2 additionally registers one project per launch directory with new project IDs and project-root-relative path semantics.
  3. Open the V2 TUI from ~/Projects/foo and run /sessions.

Expected Behavior

Legacy sessions created from that directory in V1 appear in the /sessions view (migration rebinds project_id/path to the V2 project model).

Actual Behavior

Sessions for foo → No sessions available. The sessions still exist: opencode api get '/api/session?limit=1000' lists them, and ?directory=<dir> also finds them, but the project-scoped query the TUI uses returns nothing.

Root cause (from the 2.0.27 binary, SessionStore.list):

if ("project" in e)       where project_id = e.project
if ("project" in e && e.subpath !== undefined) where path = e.subpath  // exact match

The TUI sends project=<v2-project-id>&subpath= for root sessions, while legacy rows keep path='home/<user>/...' (and project_id='global' or a V1 project ID), so path = '' never matches.

Verified: with a legacy row for /home/user/Projects/foo, ?project=<v2-id> → 0 rows, ?project=<v2-id>&subpath=home/user/Projects/foo → the row; after rewriting the row to project_id=<v2-id>, path='' the same TUI-style query returns it.

Affects every V1→V2 install with legacy sessions, including sessions that were already bound to V1 git-repo projects (root-level rows keep the old home-relative path while new V2 rows use '', so a project mixes visible and invisible sessions — e.g. only sub-directory sessions appear).

Workaround (manual SQL, after backing up the DB): for each legacy row set project_id to the V2 project owning its directory and path to the path relative to that project root ('' when the directory is the root), in both session and session_v2.

Additional Context

  • Migrations include 20260601010001_normalize_storage_paths, but it does not normalize session.path against the V2 per-directory project model.
  • No in-API path migrates/binds legacy sessions to their V2 project (session.list is the only session query endpoint; session.import is for JSON exports).
  • Consistent 100%: every legacy root-level session is affected; search and "all projects" still work as a stopgap.

Activity

  1. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the very detailed report and the verified SQL workaround. I think this is a duplicate of #49827. Sessions created in V1 keep their old project (global or a V1 project) and/or a path relative to the old root. The default folder-scoped /sessions list matches on both project and exact subpath, so those sessions are hidden even though they're still in the database.

    Possible duplicates and closely related issues, ordered by likelihood:

    The case where project_id is already correct but path is still the old home-relative value may not be fully covered by PR #51935. A short comment on #49827 or that PR with your verified query results would help.

    Until a fix lands, Ctrl+A in the session list (or "tabs": { "scope": "global" }) shows all sessions, and your SQL workaround works too.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    Contributor

    Closing this as a duplicate of #49827, since there was no reply saying how it differs. Both are about legacy V1 sessions being hidden from the folder-scoped /sessions list because their project_id and path were never updated for V2.

    Please follow #49827 and the open PRs #51935 and #54048 for progress. The case where project_id is already correct but path is still the old home-relative value may not be fully covered by #51935, so your verified query results would be useful as a comment there or on #49827. Until a fix lands, Ctrl+A in the session list (or "tabs": { "scope": "global" }) shows all sessions.

    If your problem turns out to be different, reply here and we can reopen it. Thanks again for the detailed report.

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