Repository navigation
Description
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=falsein service log) - Active plugins: None found in config (config defines only
mcpservers: playwright, aseprite, svg-mcp, gcode-toolpath; nopluginsentries, no.opencode/plugins/)
Reproduction
- Have a V1 database with ~113 sessions, all with
project_id='global',directorymostly/home/foxkovsky(plus 3 subdirectories under it). - Install/start opencode v2.0.16 in
/home/foxkovsky. - V2 creates a second project row:
id='9c1236c28ccbabd065b67815c9b78f013475e8a4',worktree='/home/foxkovsky'(time_created 2026-09-25 05:41:36 UTC scope), while old projectglobal(/) remains. - Create/open any session in
/home/foxkovsky(e.g.ses_f28df4e92ffed1wU6wxN5Kg4DX,projectID='9c12...'). - 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. - Call
opencode api get /api/sessionwithout filter — old sessions are still present (e.g.ses_f2b4b85f2ffe5IpLnwGJXP2OXnwithprojectID='global', samedirectory='/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, allproject_id='global'session_v2: 114 rows —global: 113,9c1236c28ccbabd065b67815c9b78f013475e8a4: 1session_v2directories:/home/foxkovsky: 110, plus 2 + 1 + 1 rows in subdirectories of/home/foxkovskyproject:('global', '/'),('9c12...', '/home/foxkovsky')GET /api/projectconfirms 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/foxkovskycreated on 2026-09-25. - Workarounds tried: none that modify data. Read-only verification only (
opencode api get /api/session,sqlite3inmode=rovia python). Did not editopencode.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 reassignsession_v2.project_idfor 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
github-actions commentedon Sep 25, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
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:
globalsessions are retained after migration and hidden from V2's project-scoped session list.globalare invisible in project-scoped lists.project_id='global', hiding migrated sessions from per-directory pickers.If you believe this was flagged incorrectly, please let a maintainer know.
Foxkovsky commentedon Sep 25, 2026
Local workaround verified: all 113 old rows in
session_v2hadproject_id='global'(worktree/) with directories under/home/foxkovsky, while V2 created project9c1236c28ccbabd065b67815c9b78f013475e8a4(canonical/home/foxkovsky). After backing upopencode.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 legacysessiontable). FilteredGET /api/session?directory=/home/foxkovskynow 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.Foxkovsky commentedon Sep 25, 2026
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 usepath=''. The TUI session picker filters on that too, so I recomputedpathrelative to the new worktree/home/foxkovsky(root sessions ->'', subdir sessions -> relative remainder, e.g.'Документы/...'). 113 rows fixed in bothsession_v2and legacysession. NowGET /api/session/<old-id>returnslocation:{directory:/home/foxkovsky}with nosubpath, identical in shape to a native V2 session, and the filtered list returns them. Full migration needs both:project_idANDpathrecomputed against the new project worktree.Foxkovsky commentedon Sep 25, 2026
Confirmed fixed on my machine: after recomputing both
project_idandpath, old sessions are visible again in the TUI/sessionspicker (user confirmed). Full local recipe: 1) backup~/.local/share/opencode/opencode.dbvia 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 legacysession); 3) recomputepathrelative to the new worktree (root ->'', subdirs -> relative remainder); 4) restart the opencode TUI. No data was lost at any point. Thanks!github-actions commentedon Sep 25, 2026
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.