feat(tui): managed worktrees#21435
Draft
fcoury-oai wants to merge 12 commits into
Draft
Conversation
This was referenced May 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Codex users already work across multiple local Git worktrees, and the App can create managed worktrees under
$CODEX_HOME/worktrees. The CLI/TUI did not have an equivalent first-class workflow: users had to create raw Git worktrees themselves, sessions did not explain which workspace they belonged to, and cleanup/removal had no Codex ownership boundary.This PR adds a managed worktree workflow that keeps CLI/TUI sessions legible without taking over ordinary Git worktrees. CLI-created worktrees use predictable sibling paths, App-created worktrees are still discoverable, and only Codex-owned worktrees can be removed through Codex.
What Changed
codex-worktreecrate for managed worktree lifecycle behavior:fail,ignore,copy-tracked,copy-all,move-tracked, andmove-all;--worktree <BRANCH>--worktree-base <REF>--worktree-dirty <MODE>codex worktree list|path|remove|prune/worktreeworkflow for creating, switching, locating, and removing worktrees, plus workspace labels in startup, resume, and fork surfaces.--remote.How to Test
CLI lifecycle
../codex.fcoury-worktree-smoke.cli,app, and rawgitentries.refusing to remove a worktree not managed by Codex.TUI workflow
/worktreeand create a new worktree.Move tracked./worktree, select the current row, and confirm it saysAlready in worktree ..../worktree remove <clean-worktree>and confirm the removal prompt appears before deletion.Remote regression
--remote.Move trackedflow above.Targeted tests:
cargo test -p codex-worktreecargo test -p codex-tui remote_worktree::tests::raw_git_stdout_preserves_patch_newline_and_disables_output_capDocumentation
This adds user-facing CLI flags,
codex worktreesubcommands, and the TUI/worktreeworkflow. The Codex CLI documentation on developers.openai.com should be updated before this ships broadly.