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

+2
View File
@@ -366,6 +366,7 @@ mod hooks;
mod interaction;
mod skills;
mod slash_dispatch;
mod worktree_picker;
use self::skills::collect_tool_mentions;
use self::skills::find_app_mentions;
use self::skills::find_skill_mentions_with_tool_mentions;
@@ -582,6 +583,7 @@ pub(crate) struct ChatWidget {
status_account_display: Option<StatusAccountDisplay>,
runtime_model_provider_base_url: Option<String>,
pub(crate) remote_connection: Option<RemoteConnectionStatus>,
pub(crate) local_worktree_operations: bool,
token_info: Option<TokenUsageInfo>,
token_usage_pending: bool,
// Status and polling use account usage reads; response streams may identify meters differently.