Skip to content

New session created via /new gets projectID=global instead of the directory's project, making prior sessions invisible in /sessions #42230

Closed as not planned

Description

@licsky

Description

Environment

  • opencode version: 1.18.17
  • OS: macOS (darwin), TUI
  • 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

  1. Start opencode in /path/to/repo (git repo).
  2. Do some work in a session; the session gets assigned to the directory's project (projectID=).
  3. Press /new to start a new session in the same directory.
  4. 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;)

Activity

  1. github-actions commented on Aug 13, 2026

    @github-actions
    Contributor

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

    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.

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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