You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New session created via /new gets projectID=global instead of the directory's project, making prior sessions invisible in /sessions #42230
Working directory: a git repo with a linked worktree (.worktrees/magazine-portfolio)
git config --global safe.directory = *
Description
After pressing /new in a directory that already has an associated project, the new session is created with projectID=global instead of the project ID. Since the /sessions picker appears to filter by project, only "global" sessions are shown, and all prior sessions (which belong to the real project) disappear from the list. Data is not lost — the old sessions are intact in the DB — but the user cannot switch back to them from the UI.
Steps to reproduce
Start opencode in /path/to/repo (git repo).
Do some work in a session; the session gets assigned to the directory's project (projectID=).
Press /new to start a new session in the same directory.
Run /sessions — only the current session is listed.
Expected behavior
The new session inherits the directory's existing project ID; /sessions shows all sessions for that directory.
Actual behavior
The new session is created with projectID=global; /sessions only shows global-project sessions.
Log evidence (from ~/.local/share/opencode/log/opencode.log)
02:45:46 level=INFO message="booting location services" directory=/Users/lichao/git/opencode_test workspaceID=undefined
02:45:46 level=INFO message="project copy refresh done" projectID=3c7c11a5... updated=[] removed=[]
02:46:49 level=INFO message=created id=ses_006fc1c3... projectID=global directory=/Users/lichao/git/opencode_test workspaceID=undefined title="New session - ..."
Note that projectID=3c7c11a5... (the correct project) was known to the same instance ~1 minute earlier, and a session created at 02:44:37 got the correct ID.
Additional observations
The same instance also reports the directory as "not a git repo" (env detection says Is directory a git repo: no) even though git status works fine.
Timeline: the opencode instance started (01:45 UTC) before the git repo was initialized (~01:55 UTC). Sessions created before repo init got global and were later re-associated to the project — but the post-init /new session was not.
All sessions in another directory (my-daily-work, also a git repo) are under global as well, same symptom.
Workaround
Manually reassign in the DB (after quitting opencode):
sqlite3 ~/.local/share/opencode/opencode.db
"UPDATE session SET project_id='<project_id>' WHERE id='<session_id>';"
(project_id can be found via SELECT id, worktree FROM project;)
Your specific trigger (/new after late git init in a running instance) may be a distinct path worth tracking separately, but the underlying cause appears shared.
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
github-actions commentedon Aug 13, 2026
This issue might be a duplicate of existing issues. Please check:
projectID=global, causing session leakage across directories — your timeline note (opencode started before git init) matches this exactlyYour specific trigger (
/newafter late git init in a running instance) may be a distinct path worth tracking separately, but the underlying cause appears shared.thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊