Sync agent-created worktrees with the active Codex thread/UI context
What variant of Codex are you using?
App
What feature would you like to see?
Summary
Please add first-class support for agent-created worktree handoff in the Codex App so the thread and UI stay synced with the actual worktree and branch the agent moved into.
Current behavior
Codex works well when I manually move a thread into a worktree, because the UI understands that the thread is now attached to a different workspace and branch context.
But when the agent itself creates a new git worktree and switches work there, the thread UI can remain attached to the original workspace and branch. That creates a mismatch between where the agent is actually working and what the Codex App thinks the thread is attached to.
What goes wrong
In my workflow, I had the agent:
- plan a Linear issue
- move it through
Ready -> Todo - start implementation
- create a dedicated branch and worktree
- continue coding in that worktree
The implementation itself worked, but the UX became inconsistent:
- the thread UI still looked attached to the original workspace/branch
- the Codex App did not clearly reflect that the agent had moved to a different worktree
- reviewing diffs and following the implementation became harder than it should be
- if I used the Codex UI to commit, push, or open a PR without asking the agent, it would operate on the local/original workspace instead of the worktree, so those UI flows became unusable
Why this matters
This weakens one of the main reasons to use worktrees in the app in the first place: isolated execution with good supervision, review, and follow-up Git actions from the UI.
The value proposition is strongest when the Codex App stays synchronized with the agent’s real execution context.
Requested behavior
When the agent creates a worktree and begins working there, the Codex thread/UI should update to reflect that new worktree and branch context.
At minimum, I’d like:
- the thread to clearly show the active worktree path
- the thread to clearly show the active branch for that worktree
- diff review in the UI to follow the worktree the agent is actually using
- app-level Git actions like commit, push, and PR creation to target the active worktree, not the original workspace
Possible implementation direction
Codex already appears to use structured app directives for git/UI synchronization, for example around branch creation, staging, commits, pushes, and PR creation.
A similar directive for worktree creation/handoff seems like a natural fit, for example:
::git-create-worktree{cwd="/abs/path/to/repo" worktree="/abs/path/to/worktree" branch="branch-name"}
More generally, any equivalent mechanism would be useful as long as it lets the app switch the thread’s active workspace context to the worktree the agent actually created and entered.
Additional information
This request is based on the workflow described here:
https://github.com/openai/codex/discussions/16440
A maintainer asked me on April 2, 2026 to file this as an enhancement request in the issue tracker so it can be prioritized via issue upvotes.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗