Skip to content

tui: selecting a migrated v1 session does not open it #52924

Open

Description

@vibe-maribit

Description

Migrated v1 sessions are listed by the TUI, but selecting one does not open it, and migrated sessions are missing from the project-scoped session list.

Two symptoms after migrating from v1 (1.14.32-1.18.32) to 2.0.22. The data migration itself is fine: opencode api get /api/experimental/migration/v1 returns {"status":"completed"} and every transcript is intact.

1. Selecting a session does nothing. Pressing Ctrl+O (recent sessions and projects) does list the migrated sessions, but selecting one leaves the TUI on the current session. The session row is never touched: time_viewed stays NULL and the server log contains no activity for that session id after the upgrade. The only way I found to open it is opencode -s <sessionID>, which works and shows the full transcript.

2. Not in the normal session list. Migrated sessions keep the v1 project_id = "global" (v1 used it for directories that are not git repos), while v2 scopes /sessions and opencode session list to the current project and creates a separate project entry for that same directory. 30 of 37 migrated sessions are affected (/home/nicola 23, ~/blender 6, ~/trading 1). Sessions from git repos are unaffected and list normally.

No data loss. The session I failed to open is fully intact: 56 messages, 217 parts, every assistant message has finish and time.completed, last message `finish: "stop", 0 orphan parts.

Expected: either selecting a listed session opens it, or the migration re-maps project_id from the stored session_v2.directory/path so migrated sessions are reachable from the project-scoped views.

Plugins

none

OpenCode version

2.0.22 (channel: latest), upgraded from v1 1.14.32-1.18.32

Steps to reproduce

  1. Use v1 (1.14.x-1.18.x) from a directory that is not a git repo and create a few sessions.
  2. Upgrade to v2 (2.0.22) and start it once so the data migration completes.
  3. Start v2 in that same directory and press Ctrl+O: the migrated sessions are listed.
  4. Select one of them. Nothing opens, the TUI stays on the current session.
  5. Close and reopen v2: the session is not reachable from either view any more.
  6. opencode -s <sessionID> opens it correctly with the complete transcript.
  7. Read-only DB checks confirm it was never opened and nothing was modified:
    • SELECT time_viewed, time_updated FROM session_v2 WHERE id='<id>' -> time_viewed NULL, time_updated still the v1 timestamp
    • SELECT count(*) FROM session_message WHERE session_id='<id>' -> 56
    • grep <sessionID> ~/.local/share/opencode/log/opencode.log -> no entries after the upgrade

Screenshot and/or share link

No response

Operating System

Linux Mint 22.3 (Linux 6.8.0-111-generic)

Terminal

unknown terminal app (TERM=xterm-256color, COLORTERM=truecolor)

Activity

  1. Nitu-Bathyal commented on Oct 3, 2026

    @Nitu-Bathyal

    can you assign this to me?

  2. github-actions commented on Oct 3, 2026

    @github-actions
    Contributor

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

    • #52919: migrated V1 sessions from non-git directories remain under global and are missing from the project-scoped session list.
    • #50551: reports the same project_id = "global" migration behavior for non-git directories.
    • #52844: migrated V1 sessions are missing from the TUI /sessions list (reported with a different suspected migration cause).

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  3. rekram1-node commented on Oct 21, 2026

    @rekram1-node
    Contributor

    The missing-from-project-list part is tracked in #49827. For selecting a session not opening it: does this still happen on 2.1.x? If so, please share the session ID and any errors from the log around the time you select it.

  4. opencodejr commented on Oct 27, 2026

    @opencodejr

    Thanks for the detailed report. I reproduced the session-list part on 2.0.22, but not the Ctrl+O part.

    Sessions missing from the project list (reproduced). I created two sessions with v1 1.18.32 in a directory that isn't a git repo, then let v2.0.22 migrate them (the migration reports completed). Both sessions keep project_id = 'global', v2 creates a separate project for that directory, and opencode session list there shows nothing. The script below does this.

    On the latest dev (45b53fe6f), a fresh migration now puts these sessions under the directory's own project (#56322; no release includes it yet). However, a database that an earlier v2 release has already migrated, like yours, stays under global on dev too. The migration is marked complete and doesn't run again. So this still affects you on the latest code.

    Ctrl+O selection (not reproduced). On 2.0.22, choosing a migrated session in the Ctrl+O menu opened it for me, both from the home screen and while another session was open. My test sessions were empty, though. If this keeps happening for you, these would help:

    • whether it happens with every migrated session or only some
    • whether it also happens with sessions created in v2
    • any server log lines written right when you press Enter

    Until then, opencode -s <sessionID> remains a workaround, as you found.

    Reproduction script (repro.sh)
    #!/bin/sh
    # Repro for #52924 (symptom 2): v1 sessions from a non-git directory stay under
    # project_id "global" after the v2 migration, so `opencode session list` in that
    # directory doesn't show them, and v2 creates a separate project for the directory.
    # Needs: npm, bun, python3.
    set -e
    W=/tmp/opencode/r52924; rm -rf $W; mkdir -p $W/home $W/nongit $W/v1
    export HOME=$W/home XDG_DATA_HOME=$W/home/.local/share XDG_CONFIG_HOME=$W/home/.config \
      XDG_STATE_HOME=$W/home/.local/state XDG_CACHE_HOME=$W/home/.cache
    
    # 1. v1 1.18.32: create two sessions in a non-git directory (no model needed)
    (cd $W/v1 && npm i -s opencode-ai@1.18.32 >/dev/null)
    cd $W/nongit
    $W/v1/node_modules/.bin/opencode serve --port 4555 >/dev/null 2>&1 & PID=$!
    sleep 8
    for t in "Migrated alpha" "Migrated beta"; do
      curl -s -X POST localhost:4555/session -H 'content-type: application/json' -d "{\"title\":\"$t\"}"; echo
    done
    kill $PID; sleep 2
    
    # 2. v2 2.0.22: run the migration, then list sessions from the same directory
    bun add -g @opencode/cli@2.0.22 >/dev/null
    opencode --version
    opencode api get /api/experimental/migration/v1; echo
    echo "--- opencode session list (expected: the two migrated sessions) ---"
    opencode session list --standalone
    echo "--- DB ---"
    python3 -c "
    import sqlite3; c = sqlite3.connect('$XDG_DATA_HOME/opencode/opencode.db')
    print('sessions:', c.execute('select id, project_id, directory from session_v2').fetchall())
    print('projects:', c.execute('select id, worktree from project').fetchall())"

    Run it: sh repro.sh

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions