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 list can show sessions from unrelated non-git directories because it calls Session.list({ roots: true, limit }) without passing directory or path.
- In non-git contexts, sessions are grouped under the global project bucket, so listing from
$HOME or 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 $HOME can match descendant paths, so subfolder sessions can appear from the parent/global context.
- Legacy sessions with
path = NULL can also disappear from the TUI because the TUI query passes path but not directory, so the legacy directory fallback 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 list should 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 = NULL should still match by stored directory, 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:
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:
-
Exit, then start OpenCode in the second directory and create another session:
-
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 $HOME or 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 = NULL may 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
Description
opencode session listand 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.$HOMEor another non-git directory can expose sessions that were started elsewhere.worktree = "/", launching from$HOMEcan match descendant paths, so subfolder sessions can appear from the parent/global context.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:
Expected behavior:
session listshould be scoped to the current launch directory, not just the current project/global bucket.path = NULLshould still match by storeddirectory, or be migrated.directory, or warn/refuse when the current launch directory differs.Related:
--continueacross non-git directories.Plugins
None
OpenCode version
v1.2.15+ / current dev behavior
Steps to reproduce
Create two unrelated non-git directories:
Start OpenCode in the first directory and create a session:
Exit, then start OpenCode in the second directory and create another session:
Run session listing from a broader non-git context, for example
$HOME: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