Add worktree session creation to the agents overview (#45276)

## What changed

- Add a configurable `new_worktree` action, bound to `w`, for local sessions with worktree support enabled.
- Create the worktree from the cached project default branch, preferring remote `HEAD` and falling back to conventional `main` or `master` refs without fetching. Preserve the selected subdirectory and source checkout edits.
- Start and bind a blank session in the new worktree, preserving the selected approval reviewer without sending an initial turn.
- Show creation progress, pause conflicting actions, clean up unclaimed clean worktrees, and report retained checkout paths when session startup fails. Clear pending creation state on reconnect.

## Testing

Add coverage for default-branch selection, source checkout preservation, session ownership and approval settings, cleanup, startup failures, reconnect state, and busy-state rendering. Extend Git environment isolation coverage and test unrelated non-UTF-8 refs.

GitOrigin-RevId: 771ddc12d04dbf0d12e77e9c96c8386cf31e67c5
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-13 18:53:06 +00:00
1 parent 44b9011611
commit 6f39a47bb3
49 files changed
+734 -57

No files matched your search

+12 -1
View File
@@ -134,6 +134,7 @@ impl AgentsOverviewProjectGroup {
pub(super) struct AgentsOverviewViewState {
pub(super) input: String,
pub(super) key_chord_hint: Option<Vec<(String, String)>>,
pub(super) creating_worktree: bool,
pub(super) refresh_failed: bool,
pub(super) connection_notice: Option<&'static str>,
pub(super) server_version_notice: Option<String>,
@@ -160,6 +161,7 @@ pub(super) struct AgentsOverviewView {
app_event_tx: AppEventSender,
keymap: ListKeymap,
agents_keymap: AgentsKeymap,
worktrees_enabled: bool,
}
impl AgentsOverviewView {
@@ -189,6 +191,7 @@ impl AgentsOverviewView {
app_event_tx,
keymap: keymap.list,
agents_keymap: keymap.agents,
worktrees_enabled,
};
view.state().completion = None;
let visible = view.visible_indices();
@@ -585,7 +588,7 @@ impl BottomPaneView for AgentsOverviewView {
return;
}
if self.state().connection_notice.is_some()
if (self.state().connection_notice.is_some() || self.state().creating_worktree)
&& self.keymap.action_for(key) != Some(ListAction::Cancel)
{
match self.keymap.action_for(key) {
@@ -615,6 +618,14 @@ impl BottomPaneView for AgentsOverviewView {
});
return;
}
if self.agents_keymap.new_worktree.is_pressed(key) {
if self.worktrees_enabled {
self.app_event_tx.send(AppEvent::NewAgentsOverviewWorktree {
cwd: self.selected_row().map(|row| row.thread.cwd.clone()),
});
}
return;
}
if self.agents_keymap.rename.is_pressed(key) {
if let Some(row) = self.selected_row() {
let mut state = self.state();