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

+18 -1
View File
@@ -27,6 +27,8 @@ impl AgentsOverviewView {
))
} else if state.connection_notice.is_some() {
Some("ctrl+c quit · actions paused until the list is refreshed".into())
} else if state.creating_worktree {
Some("Creating worktree… ctrl+c quit".into())
} else {
None
};
@@ -40,9 +42,15 @@ impl AgentsOverviewView {
if width < 24 {
let hints = [
("new_task", &self.agents_keymap.new_task, "new"),
(
"new_worktree",
&self.agents_keymap.new_worktree,
"new worktree",
),
("search", &self.agents_keymap.search, "search"),
]
.into_iter()
.filter(|(action, _, _)| *action != "new_worktree" || self.worktrees_enabled)
.filter_map(|(action, bindings, label)| {
self.agents_keymap
.primary_hint(action, bindings)
@@ -65,6 +73,7 @@ impl AgentsOverviewView {
&self.agents_keymap.resume,
&self.agents_keymap.search,
&self.agents_keymap.new_task,
&self.agents_keymap.new_worktree,
&self.agents_keymap.rename,
&self.agents_keymap.stop,
&self.agents_keymap.archive,
@@ -125,6 +134,12 @@ impl AgentsOverviewView {
"new",
true,
);
add_hint(
self.agents_keymap
.primary_hint("new_worktree", &self.agents_keymap.new_worktree),
"new worktree",
self.worktrees_enabled,
);
add_hint(
self.agents_keymap
.primary_hint("search", &self.agents_keymap.search),
@@ -254,7 +269,9 @@ impl Renderable for AgentsOverviewView {
}
});
let attention = format!("{needs_you} need input");
if let Some(notice) = self.state().connection_notice {
if self.state().creating_worktree {
Line::from("Creating worktree…".cyan()).render(inset(summary), buf);
} else if let Some(notice) = self.state().connection_notice {
Line::from(notice.cyan()).render(inset(summary), buf);
} else if self.state().refresh_failed {
Line::from("Error loading tasks".red()).render(inset(summary), buf);