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
2026-09-13 18:53:06 +00:00
committed by copyberry
parent 44b9011611
commit 6f39a47bb3
49 changed files with 734 additions and 57 deletions
+2
View File
@@ -216,6 +216,7 @@ pub(super) const KEYMAP_ACTIONS: &[KeymapActionDescriptor] = &[
action("agents", "Agents", "resume", "Open the session resume picker."),
action("agents", "Agents", "search", "Search the available agent tasks."),
action("agents", "Agents", "new_task", "Open a new session in the selected checkout."),
action("agents", "Agents", "new_worktree", "Open a new session in a worktree from the project default branch."),
action("agents", "Agents", "rename", "Rename the selected task."),
action("agents", "Agents", "stop", "Stop the selected running task."),
action("agents", "Agents", "archive", "Archive the selected task and its child agents."),
@@ -396,6 +397,7 @@ pub(super) fn binding_slot<'a>(
("agents", "resume") => Some(&mut keymap.agents.resume),
("agents", "search") => Some(&mut keymap.agents.search),
("agents", "new_task") => Some(&mut keymap.agents.new_task),
("agents", "new_worktree") => Some(&mut keymap.agents.new_worktree),
("agents", "rename") => Some(&mut keymap.agents.rename),
("agents", "stop") => Some(&mut keymap.agents.stop),
("agents", "archive") => Some(&mut keymap.agents.archive),