Codex App creates detached worktree when a local branch is selected as the starting branch
What version of the Codex App are you using (From “About Codex” dialog)?
26.623.81905 (4598)
What subscription do you have?
Not available from this agent/tool context; the user can edit this field if needed.
What platform is your computer?
Darwin 25.5.0 arm64 arm
Git version: git version 2.54.0
What issue are you seeing?
When starting a new Codex App conversation in New worktree mode and selecting an existing local branch as the starting branch, Codex creates the worktree at the branch tip but leaves it in detached HEAD.
This is different from creating a worktree on the selected branch. It makes the UI and Git state confusing for workflows that need the new thread/worktree to remain associated with a PR or feature branch.
Observed result:
## HEAD (no branch)
HEAD
75dd6a93b400478703c37e451dddf5de7154d948
The corresponding git worktree list --porcelain entry also showed detached state:
worktree /Users/dpearson/.codex/worktrees/f153/ios-options-wheel-tracker
HEAD 75dd6a93b400478703c37e451dddf5de7154d948
detached
What steps can reproduce the bug?
- In a local Git repository, ensure a local branch exists. In this reproduction the branch was
codex/full-sync-gate-stateat commit75dd6a93b400478703c37e451dddf5de7154d948. - Ensure no other listed worktree has that local branch checked out. I removed the prior branch-owning worktree and verified
git worktree list --porcelainno longer showed anybranch refs/heads/codex/full-sync-gate-stateentry. - In Codex App, start a new conversation in New worktree mode and select the local branch
codex/full-sync-gate-stateas the starting branch. I reproduced this through the app tool path equivalent to selecting that branch:
{
"target": {
"type": "project",
"projectId": "/Users/dpearson/repos/ios-options-wheel-tracker",
"environment": {
"type": "worktree",
"startingState": {
"type": "branch",
"branchName": "codex/full-sync-gate-state"
}
}
}
}
- In the newly created worktree, run:
git status --short --branch
git symbolic-ref --short -q HEAD || echo HEAD
git rev-parse HEAD
git worktree list --porcelain
- Observe that the new worktree is detached at the selected branch tip instead of checked out on the branch.
What is the expected behavior?
If the user selects a local branch as the starting branch and that branch is not checked out by another worktree, Codex should create the new worktree checked out on that named branch.
At minimum, the UI should make the actual behavior explicit: e.g. “start detached at branch commit” rather than implying the worktree will be on the selected branch.
Additional information
This is related to, but distinct from, #10704. That issue covers missing or confusing environment actions once a worktree is detached. This report is specifically about the creation semantics: selecting a local branch creates a detached worktree even when Git would allow the branch to be checked out.
The terminal workaround works only after creation, and only when no other worktree owns the branch:
git switch codex/full-sync-gate-state
After running that manually, Git reports the worktree is on the branch:
## codex/full-sync-gate-state...origin/codex/full-sync-gate-state
codex/full-sync-gate-state