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
Description
Running
opencode -cfrom 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:Starting
opencode -cinsidebiggerpocketsresumed 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-cbehavior were all closed as not planned:-cfrom a parent dir picks the wrong child session--continueresumes latest session across root-level git worktrees instead of current worktree #25963 —--continueresumes latest session across root-level git worktrees instead of current worktree--continueRoot 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-cpicks the globally most recent session.Expected
opencode -cshould 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 -ccan resume the most recently updated session from a different worktree of the same repo.Environment