Fork into new worktree leaves terminal cwd in original checkout

Resolved 💬 3 comments Opened May 6, 2026 by maharris77 Closed May 7, 2026

260506_1834ET — use this:

Bug: Fork/Handoff to worktree leaves thread terminal in original checkout

Summary

In Codex Desktop, both Fork into new worktree and Handoff to Worktree appear to create Codex-managed worktree directories, but the active thread terminal continues running from the original local checkout. When asked, Codex responds that it is not in a new worktree.
This creates a mismatch between the UI/worktree state and the actual command execution context. After the operation, git worktree list shows new worktrees under $HOME/.codex/worktrees/..., but in the affected thread:

pwd
git rev-parse --show-toplevel

still report the original repo path.

Expected behavior

After selecting Fork into new worktree or Handoff to Worktree, the active thread terminal should execute from the newly associated worktree, e.g.:

$HOME/.codex/worktrees/<id>/<repo>

App-level Git actions, file edits, and terminal commands should target that worktree, not the original checkout.

Actual behavior

The thread remained in the original checkout:

/path/to/local/repo

For Fork into new worktree:

  • A new chat was created.
  • A new worktree directory appeared under $HOME/.codex/worktrees/....
  • The new chat’s terminal still ran from /path/to/local/repo.
  • The current branch did not change.

For Handoff to Worktree:

  • A new branch was created/checked out in the original checkout.
  • A Codex worktree existed on disk.
  • The thread terminal still ran from /path/to/local/repo, not from the worktree.

Evidence

Immediately after attempting the fork/handoff, from the supposedly worktree-backed thread:

$ pwd
/path/to/local/repo
$ git rev-parse --show-toplevel
/path/to/local/repo
$ git branch --show-current
codex/<chat_title>
$ git rev-parse HEAD
<head-a>
$ git worktree list
/path/to/local/repo                         <head-a> [codex/<chat_title>]
$HOME/.codex/worktrees/c026/<repo>          <head-b> (detached HEAD)
$HOME/.codex/worktrees/f257/<repo>          <head-a> (detached HEAD)

Additional inspection:

worktree $HOME/.codex/worktrees/c026/<repo>
HEAD <head-b>
detached
worktree $HOME/.codex/worktrees/f257/<repo>
HEAD <head-a>
detached

So at least one Codex-managed worktree was created and pointed at the same commit as the original checkout, but the active thread cwd remained the original checkout.

Why this matters

This can cause edits intended to be isolated in a Codex worktree to be applied to the user’s main/local checkout instead. The sidebar/worktree UI can therefore appear safe while the terminal and file operations are still targeting the original repo.

Environment

  • macOS: 26.4, build 25E5233c
  • Codex app: 26.429.61741
  • CFBundleVersion: 2429

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗