Add managed worktrees to codex exec (#42652)

## What changed

- Add the experimental `worktrees` feature and a shared `--worktree` flag for new and forked `codex exec` sessions.
- Create each enabled session in a managed Git worktree, use that checkout as the session working directory, and bind the checkout to the new thread.
- Share the configured worktree pool with Desktop while leaving automatic cleanup disabled for CLI allocations.
- Reject unsupported commands, remote execution, ignored user configuration, ephemeral sessions, and use without the feature enabled before allocating a worktree.

## Testing

- Cover flag placement and inheritance, supported and rejected command combinations, worktree allocation and thread ownership, configuration gating, and compatibility with existing worktree-backed sessions.

GitOrigin-RevId: 011ff4639b09e8992c50d7b823df23e71798670e
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-04 01:56:38 +00:00
1 parent f46671b14a
commit eb5a00b068
18 files changed
+631 -9

No files matched your search

@@ -2998,6 +2998,7 @@ async fn apps_popup_for_not_installed_app_uses_install_only_selected_description
async fn experimental_features_popup_snapshot() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let worktrees = Feature::Worktrees.stage();
let features = vec![
ExperimentalFeatureItem {
feature: Some(Feature::JsRepl),
@@ -3011,6 +3012,12 @@ async fn experimental_features_popup_snapshot() {
description: "Allow the model to run shell commands.".to_string(),
enabled: true,
},
ExperimentalFeatureItem {
feature: Some(Feature::Worktrees),
name: worktrees.experimental_menu_name().unwrap().to_string(),
description: worktrees.experimental_menu_description().unwrap().to_string(),
enabled: false,
},
];
let view = ExperimentalFeaturesView::new(
features,