Skip to content

opencode -c resumes a session from a different working directory (across root-level git worktrees of the same repo) #41562

Description

@bockets

Description

Running opencode -c from one directory resumed a session that was created in a different working directory of the same repository. In my case the directories are root-level git worktrees of the same repo:

~/code/biggerpockets   [branch A]
~/code/boggerpockets   [branch B]
~/code/buggerpockets   [branch C]

Starting opencode -c inside biggerpockets resumed the most recently updated session from a sibling worktree instead of the latest session in the launch directory. The mismatch was not obvious until I noticed the model was operating in the wrong checkout.

This is the runtime -c (continue) behavior that open issue #38529 explicitly scopes out: "This issue only covers discovery; changing runtime cwd when resuming a session is separate." The prior issues covering this exact -c behavior were all closed as not planned:

Root cause

Sessions are scoped by project-relative path (introduced in #24849). For root-level git worktrees of the same repository, the relative path resolves to "" for every worktree, so every checkout matches the same continuation scope and -c picks the globally most recent session.

Expected

opencode -c should resume the latest session whose stored directory exactly matches the launch directory (current worktree), not the most recent session across the whole project.

Actual

opencode -c can resume the most recently updated session from a different worktree of the same repo.

Environment

  • OpenCode version: 1.18.16
  • Operating System: macOS
  • Terminal: zsh
  • Plugins: None

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