anomalyco / anomalyco/opencode
opencode -c resumes a session from a different working directory (across root-level git worktrees of the same repo)
@nexxeln is already working on this.
Since Aug 10, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
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:
- #26099 — hierarchical session filter has no exact-match mode;
-cfrom a parent dir picks the wrong child session - #25963 —
--continueresumes latest session across root-level git worktrees instead of current worktree - #18890 — sessions from different non-git directories are mixed when using
--continue - #28972
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.