feat(tui): codex-managed worktree workflow#21435
Draft
fcoury-oai wants to merge 3 commits intomainfrom
Draft
Conversation
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, session lists could not distinguish App-managed workspaces from ordinary checkouts, and cleanup/removal lacked Codex ownership checks.This PR adds a CLI/TUI-managed worktree flow that follows the Worktrunk-style sibling directory convention while still discovering App-created
$CODEX_HOME/worktreesentries. That gives CLI users a predictable workspace location, lets the TUI label worktree sessions, and keeps removal constrained to Codex-owned worktrees.What Changed
codex-worktreecrate for Git worktree lifecycle behavior:--worktree <BRANCH>;fail,ignore,copy-tracked, andcopy-allpolicies;--worktree <BRANCH>--worktree-base <REF>--worktree-dirty <fail|ignore|copy-tracked|copy-all>codex worktree list,path,remove, andprunesubcommands.$CODEX_HOME/worktrees.How to Test
From a Git checkout, run:
Confirm the session starts in a sibling worktree path like:
Run:
Confirm the output is column-aligned and includes
SOURCEvalues such ascli,app, andgit.Try removing a raw Git worktree shown as
SOURCE git:Confirm Codex refuses with
refusing to remove a worktree not managed by Codex.Targeted tests run:
cargo test -p codex-worktreecargo test -p codex-clicargo test -p codex-tuicargo insta pending-snapshotsjust argument-comment-lintDocumentation
This adds user-facing CLI flags and
codex worktreesubcommands. The Codex CLI documentation on developers.openai.com should be updated before this ships broadly.