Repository navigation
Description
Description
opencode session list and the TUI session picker can expose sessions from unrelated non-git directories.
This appears related to #18890, but it affects more than --continue.
Observed behavior:
opencode session listcan show sessions from unrelated non-git directories because it callsSession.list({ roots: true, limit })without passingdirectoryorpath.- In non-git contexts, sessions are grouped under the global project bucket, so listing from
$HOMEor another non-git directory can expose sessions that were started elsewhere. - The TUI applies a path-prefix query plus a 30-day cutoff. With non-git
worktree = "/", launching from$HOMEcan match descendant paths, so subfolder sessions can appear from the parent/global context. - Legacy sessions with
path = NULLcan also disappear from the TUI because the TUI query passespathbut notdirectory, so the legacydirectoryfallback is not used.
The risky part is resume/switch behavior. A visible session can belong to directory A, but if it is resumed from directory B, the old transcript is loaded while the runtime/model environment can still be based on the current launch directory.
That can affect:
- working directory
- workspace root
- config loading
- instruction files
- shell commands
- LSP context
- file tools
- model assumptions
Expected behavior:
- Default
session listshould be scoped to the current launch directory, not just the current project/global bucket. - TUI should not silently include parent/subfolder/global sessions unless the user explicitly chooses project/recursive/global scope.
- Legacy sessions with
path = NULLshould still match by storeddirectory, or be migrated. - Resuming/switching a session should either restore the session’s stored
directory, or warn/refuse when the current launch directory differs.
Related:
- Sessions from different non-git directories are mixed when using --continue #18890 — same root cause for
--continueacross non-git directories. - [BUG]: Session switching doesn't change working directory context #6697 — resume/switch can keep execution context bound to launch directory instead of session directory.
Plugins
None
OpenCode version
v1.2.15+ / current dev behavior
Steps to reproduce
-
Create two unrelated non-git directories:
mkdir -p /tmp/oc-a /tmp/oc-b -
Start OpenCode in the first directory and create a session:
cd /tmp/oc-a opencode -
Exit, then start OpenCode in the second directory and create another session:
cd /tmp/oc-b opencode -
Run session listing from a broader non-git context, for example
$HOME:cd ~ opencode session list --format json -
Observe that sessions from unrelated non-git directories can appear together under the global project bucket.
-
Open the TUI from
$HOMEor another parent/global context and inspect the session picker. -
Observe that sessions from subfolders/global non-git contexts may be visible, while older legacy sessions with
path = NULLmay be hidden due to the TUI path filter and 30-day cutoff. -
Resume or switch to a session that was created in another directory.
-
Observe that the transcript belongs to the old session, but the runtime/model environment can still reflect the current launch directory.
Screenshot and/or share link
No response
Operating System
macOS
Terminal
iTerm2 / zsh
Activity
github-actions commentedon May 23, 2026
This issue might be a duplicate of existing issues. Please check:
/sessionscommand no longer filters by current working directory--continue(already referenced in the issue)If this issue covers distinct aspects not addressed by the above (e.g., the legacy
path = NULLfallback regression or the resume/switch context mismatch), please clarify how it differs so maintainers can assess whether it should be tracked separately or merged.github-actions commentedon Jul 23, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.