Add managed worktree creation to TUI session commands (#43120)

## What changed

- Add `/worktree` to start a fresh conversation or fork the current conversation into a new managed checkout.
- Offer current-checkout and new-worktree choices for `/new` and `/fork`, preserving optional conversation names. Enable these choices for local Git repositories when the `worktrees` feature is enabled.
- Load destination configuration, bind the checkout to the replacement thread, and inherit conversation history only when forking.
- Reject creation from explicitly untrusted sources and require an idle primary session without queued input. Refuse forks when developer instructions differ, with guidance for removing the unused checkout.

## Testing

Add picker snapshots and tests for command availability, named selections, fresh versus forked history, destination configuration, worktree ownership, and feature and trust checks.

GitOrigin-RevId: d6c83e00217660aacf2a6d92acad50b506607e0b
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-05 22:53:48 +00:00
1 parent f5a71ff40a
commit f6976ab036
28 files changed
+980 -30

No files matched your search

+3
View File
@@ -35,6 +35,7 @@ pub enum SlashCommand {
Delete,
Resume,
Fork,
Worktree,
App,
Init,
Compact,
@@ -99,6 +100,7 @@ impl SlashCommand {
SlashCommand::Delete => "permanently delete this session and exit",
SlashCommand::Clear => "clear the terminal and start a new chat",
SlashCommand::Fork => "fork the current chat",
SlashCommand::Worktree => "start or continue a conversation in a new worktree",
SlashCommand::App => "continue this session in the Desktop app",
SlashCommand::Quit | SlashCommand::Exit => "exit Codex",
SlashCommand::Copy => "copy the last response or part of it",
@@ -210,6 +212,7 @@ impl SlashCommand {
| SlashCommand::Archive
| SlashCommand::Delete
| SlashCommand::Fork
| SlashCommand::Worktree
| SlashCommand::Init
| SlashCommand::Compact
| SlashCommand::Recap