Skip to content

sessions: V1 sessions hidden after V2 project split (global vs /home/foxkovsky) #51283

Closed as not planned

Description

@Foxkovsky

Summary

After updating from V1 to V2 (2.0.16), existing sessions are no longer shown in the TUI session list. The rows were migrated from session (113) to session_v2 (114 including 1 new session), but all old rows kept project_id='global' (worktree /) while V2 created a new project for /home/foxkovsky, and the filtered session list only returns the new project's sessions.

Environment

  • opencode version: 2.0.16
  • OS: Linux Foxkovsky-Redmi-Book-Pro-15-2023 7.0.0-34-generic Codex mini #34~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 4 15:38:29 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • Terminal: TERM=xterm-256color, TERM_PROGRAM=(empty), COLORTERM=truecolor
  • Shell: /bin/bash
  • Install/channel: latest (release, local=false in service log)
  • Active plugins: None found in config (config defines only mcp servers: playwright, aseprite, svg-mcp, gcode-toolpath; no plugins entries, no .opencode/plugins/)

Reproduction

  1. Have a V1 database with ~113 sessions, all with project_id='global', directory mostly /home/foxkovsky (plus 3 subdirectories under it).
  2. Install/start opencode v2.0.16 in /home/foxkovsky.
  3. V2 creates a second project row: id='9c1236c28ccbabd065b67815c9b78f013475e8a4', worktree='/home/foxkovsky' (time_created 2026-09-25 05:41:36 UTC scope), while old project global (/) remains.
  4. Create/open any session in /home/foxkovsky (e.g. ses_f28df4e92ffed1wU6wxN5Kg4DX, projectID='9c12...').
  5. Call opencode api get "/api/session?directory=/home/foxkovsky" or open the TUI session picker in /home/foxkovsky — only the 1 new session is returned.
  6. Call opencode api get /api/session without filter — old sessions are still present (e.g. ses_f2b4b85f2ffe5IpLnwGJXP2OXn with projectID='global', same directory='/home/foxkovsky').

Expected Behavior

Sessions whose directory is /home/foxkovsky (or a subdirectory of it) should be visible when working in /home/foxkovsky after V1→V2 migration — either by reassigning them to the new project or by including the previous project's sessions in the filtered list. No manual DB edit should be required.

Actual Behavior

Filtered list returns only sessions of the new project, so 113 migrated sessions are hidden. Data is not lost (session=113, session_v2=114; every old session.id exists in session_v2; only the new session ID is unique to session_v2), but from the user's perspective "старые сессии не перенеслись".

Evidence from read-only queries on ~/.local/share/opencode/opencode.db:

  • session: 113 rows, all project_id='global'
  • session_v2: 114 rows — global: 113, 9c1236c28ccbabd065b67815c9b78f013475e8a4: 1
  • session_v2 directories: /home/foxkovsky: 110, plus 2 + 1 + 1 rows in subdirectories of /home/foxkovsky
  • project: ('global', '/'), ('9c12...', '/home/foxkovsky')
  • GET /api/project confirms both projects exist with canonical / and /home/foxkovsky.

Additional Context

  • Consistent / reproducible: every filtered request hides the old sessions; unfiltered request always shows them.
  • Recent change: update V1 → V2 2.0.16; first V2 project row for /home/foxkovsky created on 2026-09-25.
  • Workarounds tried: none that modify data. Read-only verification only (opencode api get /api/session, sqlite3 in mode=ro via python). Did not edit opencode.db (per troubleshooting guidance) — expecting either an official backfill or guidance.
  • Question for maintainers: is the V2 project-splitting (/ → /home/foxkovsky) intentional, and if so, should migration reassign session_v2.project_id for matching directories, or should the session list query span ancestor/descendant projects?
  • Logs available on request (~/.local/share/opencode/log/opencode.log); no error at startup, service healthy (opencode service status → http://127.0.0.1:49374).

Activity

  1. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Please use the Bug Report template and include its required Description field; the report currently uses Summary instead.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    • #51176: V1 global sessions are retained after migration and hidden from V2's project-scoped session list.
    • #50999: Imported V1 sessions left under global are invisible in project-scoped lists.
    • #50551: The importer preserves project_id='global', hiding migrated sessions from per-directory pickers.

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. Foxkovsky commented on Sep 25, 2026

    @Foxkovsky
    Author

    Local workaround verified: all 113 old rows in session_v2 had project_id='global' (worktree /) with directories under /home/foxkovsky, while V2 created project 9c1236c28ccbabd065b67815c9b78f013475e8a4 (canonical /home/foxkovsky). After backing up opencode.db (sqlite backup API, no service stop) I ran: UPDATE session_v2 SET project_id='<new>' WHERE project_id='global' AND (directory='/home/foxkovsky' OR directory LIKE '/home/foxkovsky/%') (same for legacy session table). Filtered GET /api/session?directory=/home/foxkovsky now returns the old sessions (50 on first page, all with the new projectID) instead of just 1. Suggests migration should reassign sessions whose directory falls under a newly detected project worktree, or the session list should span ancestor/descendant projects.

  3. Foxkovsky commented on Sep 25, 2026

    @Foxkovsky
    Author

    Update: project_id alone was not enough. Old rows also had a stale path (subpath relative to old worktree /, e.g. path='home/foxkovsky'), while V2 sessions at the project root use path=''. The TUI session picker filters on that too, so I recomputed path relative to the new worktree /home/foxkovsky (root sessions -> '', subdir sessions -> relative remainder, e.g. 'Документы/...'). 113 rows fixed in both session_v2 and legacy session. Now GET /api/session/<old-id> returns location:{directory:/home/foxkovsky} with no subpath, identical in shape to a native V2 session, and the filtered list returns them. Full migration needs both: project_id AND path recomputed against the new project worktree.

  4. Foxkovsky commented on Sep 25, 2026

    @Foxkovsky
    Author

    Confirmed fixed on my machine: after recomputing both project_id and path, old sessions are visible again in the TUI /sessions picker (user confirmed). Full local recipe: 1) backup ~/.local/share/opencode/opencode.db via sqlite backup API; 2) UPDATE session_v2 SET project_id='<new-project-id>' WHERE project_id='global' AND (directory='/home/foxkovsky' OR directory LIKE '/home/foxkovsky/%') (same for legacy session); 3) recompute path relative to the new worktree (root -> '', subdirs -> relative remainder); 4) restart the opencode TUI. No data was lost at any point. Thanks!

  5. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

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