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

@@ -135,6 +135,7 @@ impl ChatWidget {
status_account_display,
runtime_model_provider_base_url,
remote_connection: None,
local_worktree_operations: true,
token_info: None,
token_usage_pending: false,
rate_limit_snapshots_by_limit_id: BTreeMap::new(),
@@ -287,6 +288,7 @@ impl ChatWidget {
.set_collaboration_modes_enabled(/*enabled*/ true);
widget.sync_service_tier_commands();
widget.sync_personality_command_enabled();
widget.sync_worktrees_enabled();
widget.sync_plugins_command_enabled();
widget.sync_goal_command_enabled();
widget.sync_mentions_v2_enabled();