Environment panel shows wrong branch for worktree-backed agent

Open 💬 1 comment Opened Jun 17, 2026 by AaronMeyers

What version of the Codex App are you using (From “About Codex” dialog)?

26.611.62324

What subscription do you have?

ChatGPT Pro

What platform is your computer?

Darwin 25.5.0 arm64 arm

What issue are you seeing?

When using a Codex agent that is running inside a worktree, the Environment panel shows the wrong branch as selected.

Expected behavior:

  • The Environment panel should show the branch/worktree that the current agent is actually using.

Actual behavior:

  • The agent is running in a worktree on branch codex/draw-mode, but the Environment panel shows main as the selected branch.
  • Opening the branch dropdown shows codex/draw-mode in the branch list, but the checkmark is on main.
  • Selecting codex/draw-mode from the dropdown fails with:

Failed to switch branch: fatal: 'codex/draw-mode' is already used by worktree at '/Users/aaron/.codex/worktrees/scoper-draw-mode'

The agent reports the following:

pwd

/Users/aaron/.codex/worktrees/scoper-draw-mode

git branch --show-current

codex/draw-mode

git rev-parse --abbrev-ref HEAD

codex/draw-mode

This indicates that the agent is correctly running in the worktree, but the Environment panel appears to think the current branch is main.

This behavior appears to be a regression. The Environment panel previously displayed the active worktree/branch correctly.

What steps can reproduce the bug?

  1. Create or open a Codex agent that is running in a worktree-backed branch (for example codex/draw-mode).
  2. In the agent, verify the current branch and location:

pwd
git branch --show-current
git rev-parse --abbrev-ref HEAD

Example output:

/Users/aaron/.codex/worktrees/scoper-draw-mode
codex/draw-mode
codex/draw-mode

  1. Open the Environment panel.
  2. Observe that the branch selector shows main as the selected branch.
  3. Open the branch dropdown.
  4. Observe that the actual branch (codex/draw-mode) appears in the list, but the checkmark is still on main.
  5. Select codex/draw-mode from the dropdown.
  6. Codex displays:

Failed to switch branch: fatal: 'codex/draw-mode' is already used by worktree at '/Users/aaron/.codex/worktrees/scoper-draw-mode'

What is the expected behavior?

The Environment panel should reflect the branch and worktree that the current agent is actually using.

If the agent is running in:

/Users/aaron/.codex/worktrees/scoper-draw-mode

and Git reports:

codex/draw-mode

then the Environment panel should show codex/draw-mode as the selected branch.

Selecting the currently active branch should not trigger a checkout operation or produce an error.

Additional information

This appears to be a regression. The Environment panel previously displayed the active worktree/branch correctly.

The issue does not appear to be a Git problem. The agent is operating correctly inside the worktree and Git reports the expected branch. The inconsistency appears to be between the agent’s execution environment and the state tracked by the Environment panel UI.

Screenshots attached showing:

  • Environment panel displaying main
  • Branch dropdown containing codex/draw-mode
  • Error shown when attempting to select codex/draw-mode

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗