anomalyco / anomalyco/opencode
tui: selecting the current directory in the picker creates a worktree and switches session instead of no-op
@kommander is already working on this.
Since Aug 21, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
While working in an existing repository in the TUI, a directory-selection dialog
appeared. The user selected the same directory the session was already running in.
Selecting the current directory should be a no-op, but instead OpenCode created a git
worktree of the repo under ~/.local/share/opencode/worktree/<repo-hash>/new and
switched the active session's working directory to it mid-session. The user never
requested a workspace or worktree.
Environment
- opencode version: v0.0.0-beta-17793
- OS: Windows_NT 10.0.22631 (win32 x64) — Windows 11 23H2
- Terminal: TERM=xterm-256color, COLORTERM=truecolor
- Shell: cmd.exe (ComSpec)
- Install/channel: beta
- Active plugins: @plannotator/opencode@latest, micode, superpowers (git),
local pluginsherdr-agent-state.js,planning-canvas.js; no project-local config
Reproduction
-
Launch
opencode2in an existing git repo (master branch) on Windows. -
Work in a session normally — no workspace requested or created by the user.
-
A directory-selection dialog appears; select the directory the session is
already in (the repo root). -
Session emits "working directory has been changed" notices; the execution
context moves from the repo to~/.local/share/opencode/worktree/d89da5/new. -
git worktree listin the repo shows a new worktree in detached HEAD:C:/Users/<user>/source/repos/ca-fl-system b9d75e7 [master] C:/Users/<user>/.local/share/opencode/worktree/d89da5/new 205246f (detached HEAD)
Expected Behavior
Selecting the directory the session is already in should be a no-op: no worktree
creation, no session directory switch. More generally, no worktree should be created
and no execution-context switch should happen unless the user explicitly creates or
opens a different workspace.
Actual Behavior
Re-selecting the current directory was treated as a change: a worktree was created
(detached HEAD at the repo's current commit) and the running session's working
directory was switched to it mid-session. Uncommitted changes in the original working
copy are invisible from the new context, which silently changes what the agent sees
and edits — misleading for both user and model.
Additional Context
- The generated workspace name was
new, suggesting an auto-created default rather
than anything user-initiated. - Frequency: single occurrence so far.
- Workaround: keep working from the original repo directory; clean up with
git worktree remove ~/.local/share/opencode/worktree/d89da5/new && git worktree prune. - Possibly related: #20262 (workspace-bound sessions still execute at repo root),
#28581 (resume uses launch directory instead of stored session directory),
#31593 (workspace redirects to main repository path).
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.