Start a task from an existing task-less worktree#3528
Conversation
Each repo group in the sidebar gets a nested "Worktrees (N)" dropdown listing linked worktrees no task uses. Clicking one creates a promptless task named after the branch, adopts the worktree via the existing reuseExistingWorktree flow, and opens the task's chat + shell with an idle agent session. - workspace-server: listAdoptableWorktrees filters linked worktrees to branch-bearing, task-less ones, excluding registered folders and the local-backgrounding stash worktree - core: buildWorktreeAdoptionInput + worktreeAdoption input flag so a synthesized taskDescription passes createTask validation without content (no initial agent prompt) - ui: GroupWorktreesSection nested under each repo group, with useAdoptableWorktrees / useStartTaskFromWorktree hooks Generated-By: PostHog Code Task-Id: 24032eac-82cc-4c5f-a7e9-30ed9278a6e1
Settings → Worktrees gains a "Show worktrees in sidebar" toggle (on by default) that hides the per-repo worktrees dropdown and skips its queries entirely. The dropdown also starts collapsed: expansion is tracked as the exception in a new expandedWorktreeSections set, since collapsedSections defaults sections to expanded. Generated-By: PostHog Code Task-Id: 24032eac-82cc-4c5f-a7e9-30ed9278a6e1
- Validation in createTask now accepts content OR taskDescription instead of enumerating per-flow flags; the worktreeAdoption input flag existed only to gate that check, so it's gone - listAdoptableWorktrees builds occupied-path and registered-folder sets in one pass instead of re-querying workspace tables per worktree candidate - SidebarSection reuses the INDENT_SIZE constant from SidebarItem instead of a third copy of the indent unit Generated-By: PostHog Code Task-Id: 24032eac-82cc-4c5f-a7e9-30ed9278a6e1
With the section hidden until the user enables it in Settings → Worktrees, expanded-by-default is the right behavior for those who opted in. That removes the need for expandedWorktreeSections — the inverse-polarity twin of collapsedSections — so the section now uses the shared collapsedSections/toggleSection mechanism like every other sidebar section. Generated-By: PostHog Code Task-Id: 24032eac-82cc-4c5f-a7e9-30ed9278a6e1
|
😎 Merged successfully - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "Make sidebar worktrees opt-in and drop t..." | Re-trigger Greptile |
- Add showSidebarWorktrees to settings rehydration test - Clarify padding calculation comment in SidebarSection - Use AdoptableWorktree named type instead of inline object type
There was a problem hiding this comment.
No showstoppers. The opt-in sidebar worktree adoption feature follows established service patterns correctly. The greptile bot's path-aliasing concern is on an older commit and describes a pre-existing, documented design choice (verbatim git-path comparison, explicitly noted at line 1422–1424 of workspace.ts) — the new code mirrors the same pattern as getWorktreeTasks. The validation broadening in taskService.ts is intentional and has clear test coverage.
|
/trunk merge |
4 similar comments
|
/trunk merge |
|
/trunk merge |
|
/trunk merge |
|
/trunk merge |
Problem
A workflow some of us use: have the agent spin up several worktrees, kick off work in them, and later pick each one up as a first-class task. PostHog Code can create a task from an existing worktree branch today, but only by going through the full task-creation form — and worktrees that no task owns are invisible in the sidebar, so there's no quick way to jump back into one.
Changes
reuseExistingWorktreeflow (including its occupancy race re-check),workspace.listAdoptableWorktreestRPC query (single-pass occupancy/registered-folder filtering).buildWorktreeAdoptionInputhelper;createTaskvalidation now acceptscontentORtaskDescriptioninstead of enumerating per-flow flags.GroupWorktreesSection+useAdoptableWorktrees/useStartTaskFromWorktreehooks;SidebarSectiongained adepthprop for nesting.How did you test this?
reuseExistingWorktreepassthrough, adoption input builder, and thecreateTaskvalidation gate.pnpm typecheckand Biome clean.Automatic notifications
Created with PostHog Code