What variant of Codex are you using?
CLI (TUI) custom fork off of 0.104.0
What feature would you like to see?
Add a /cwd slash command to change the working directory inside the current TUI session, with a policy-selection step in the same flow.
Current workflow is frustrating:
- Exit TUI
cd into another repo/worktree
codex resume ...
- Re-approve sandbox/policy for that directory
This is especially painful when iterating on many sibling forks. I want Codex to keep autonomous execution within the selected repo, but I do not want to grant blanket access to the parent directory just to avoid repeated approvals.
Proposed UX:
/cwd <path> to switch current working directory
/cwd with no args opens a picker/input modal
- In the same flow, prompt for policy handling for the target directory:
- apply target directory defaults (trust/project policy)
- or keep current runtime policy override
- Show a short confirmation line in transcript (new cwd + effective approval/sandbox policy)
Additional information
Related but not equivalent: /add-dir (#11747) expands access roots; it does not switch active cwd and policy context.
Short implementation sketch:
- Wire command + dispatch
codex-rs/tui/src/slash_command.rs: add SlashCommand::Cwd with description and inline args support.
codex-rs/tui/src/chatwidget.rs: dispatch /cwd and /cwd <path> via a new app event.
- Add app-level event and handler
codex-rs/tui/src/app_event.rs: add AppEvent::ChangeCwd { path: Option<String> }.
codex-rs/tui/src/app.rs: handle ChangeCwd by resolving/validating path, then rebuilding config with existing rebuild_config_for_cwd(...).
- Apply cwd + policy atomically
- Reuse rebuilt config’s derived approval/sandbox defaults for target cwd.
- Send
Op::OverrideTurnContext { cwd: Some(...), approval_policy: Some(...), sandbox_policy: Some(...) } so core session state updates without restart.
- Update in-memory TUI state (
self.config, file-search root via file_search.update_search_dir(...), and chat widget config copy) so UI and behavior stay consistent.
- Prompt UI and tests
- Reuse/extend
codex-rs/tui/src/cwd_prompt.rs patterns for selection/confirmation.
- Add tests in
codex-rs/tui/src/chatwidget/tests.rs and codex-rs/tui/src/app.rs for command dispatch, path validation, and policy-application behavior.
Status after #38894
#38894 / commit ed32158e90ef872c5eef96baf2f14feac70aee6e is a good direction and solves the core pain point: /cd <path> can switch an idle local TUI conversation to another working directory while preserving history and reloading the destination project context.
The command naming is not considered a gap. /cd is the conventional user-facing command for changing directories, while /cwd is reasonable as an alias for /pwd.
Remaining follow-up work:
- Policy selection: add an in-flow choice between applying the destination directory's defaults and retaining the current runtime policy override. The implementation currently applies compatible overrides automatically and rejects incompatible transitions.
- Directory-switching restrictions: revisit the deliberately conservative blanket restrictions. Some currently rejected transitions may be supportable where the relevant state can be transferred safely.
- Bare command UX: open a directory picker or input prompt for bare
/cd instead of always selecting ~.
- Fork versus move semantics: the current implementation forks and replaces the active thread. Some workflows instead need to move the existing thread to the new directory without changing its identity, so this should be an explicit choice or preserve the original thread when safe.
- Confirmation: include the resulting approval and sandbox policy alongside the new path in the transcript confirmation.
The merged implementation establishes the right foundation, while these policy-selection and transition-semantics gaps remain in scope for this issue.
What variant of Codex are you using?
CLI (TUI) custom fork off of 0.104.0
What feature would you like to see?
Add a
/cwdslash command to change the working directory inside the current TUI session, with a policy-selection step in the same flow.Current workflow is frustrating:
cdinto another repo/worktreecodex resume ...This is especially painful when iterating on many sibling forks. I want Codex to keep autonomous execution within the selected repo, but I do not want to grant blanket access to the parent directory just to avoid repeated approvals.
Proposed UX:
/cwd <path>to switch current working directory/cwdwith no args opens a picker/input modalAdditional information
Related but not equivalent:
/add-dir(#11747) expands access roots; it does not switch active cwd and policy context.Short implementation sketch:
codex-rs/tui/src/slash_command.rs: addSlashCommand::Cwdwith description and inline args support.codex-rs/tui/src/chatwidget.rs: dispatch/cwdand/cwd <path>via a new app event.codex-rs/tui/src/app_event.rs: addAppEvent::ChangeCwd { path: Option<String> }.codex-rs/tui/src/app.rs: handleChangeCwdby resolving/validating path, then rebuilding config with existingrebuild_config_for_cwd(...).Op::OverrideTurnContext { cwd: Some(...), approval_policy: Some(...), sandbox_policy: Some(...) }so core session state updates without restart.self.config, file-search root viafile_search.update_search_dir(...), and chat widget config copy) so UI and behavior stay consistent.codex-rs/tui/src/cwd_prompt.rspatterns for selection/confirmation.codex-rs/tui/src/chatwidget/tests.rsandcodex-rs/tui/src/app.rsfor command dispatch, path validation, and policy-application behavior.Status after #38894
#38894 / commit
ed32158e90ef872c5eef96baf2f14feac70aee6eis a good direction and solves the core pain point:/cd <path>can switch an idle local TUI conversation to another working directory while preserving history and reloading the destination project context.The command naming is not considered a gap.
/cdis the conventional user-facing command for changing directories, while/cwdis reasonable as an alias for/pwd.Remaining follow-up work:
/cdinstead of always selecting~.The merged implementation establishes the right foundation, while these policy-selection and transition-semantics gaps remain in scope for this issue.