Repository navigation
feat(worktrees): attach existing worktrees to folder workspaces and nest them in the sidebar and board - #18199
DominionZA2 wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Pinned attached worktrees can be rendered twice (pinned section + nested under folder) when showPinnedWorktreesInGroups is enabled (duplicate-in-groups policy), which contradicts the intended “pinned keeps pinned placement” behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends the folder-workspace feature set so existing git worktrees can be manually attached to a folder workspace and then treated as a single “ticket unit” across the UI (sidebar + Workspace Board), with runtime support for persisting that relationship via workspace lineage.
Changes:
- Add workspace-lineage–based “attached worktrees” derivation and render those worktrees nested under their folder workspace row across sidebar grouping modes.
- Update the Workspace Board data source to include folder workspace cards and fold attached worktrees into their folder workspace card.
- Extend runtime-managed metadata updates (and CLI help text) so
worktree set --parent-worktree folder:<id>stores workspace lineage (and clears worktree lineage when the parent is a folder workspace).
File summaries
| File | Description |
|---|---|
| src/renderer/src/components/sidebar/WorktreeList.tsx | Plumbs workspaceLineageByChildKey into the sidebar row-building pipeline. |
| src/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts | Adds getLineageToggleHandler into virtual row context so folder rows can reuse the same collapse-toggle mechanics. |
| src/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsx | Renders lineage-style chip + collapse toggle for attached children on folder workspace cards. |
| src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts | Threads workspaceLineageByChildKey through section row computation. |
| src/renderer/src/components/sidebar/worktree-list/grouping/row-types.ts | Extends FolderWorkspaceRow to carry attached-child metadata for rendering + collapsing. |
| src/renderer/src/components/sidebar/worktree-list/grouping/row-builders.ts | Adds appendFolderWorkspaceRows and supports emitting worktrees at a nested base depth under folder rows. |
| src/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.ts | Uses appendFolderWorkspaceRows when building project-grouped sections. |
| src/renderer/src/components/sidebar/worktree-list/grouping/group-sections.ts | Passes attachedByFolderId through grouping section append context and emits folder rows + nested children. |
| src/renderer/src/components/sidebar/worktree-list/grouping/group-keys.ts | Introduces a collapse-group key for “folder-attached” children groups. |
| src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.ts | New helper that derives attached children per folder workspace from workspace lineage (reusing right-sidebar edge validation). |
| src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts | Filters attached children out of ordinary lanes and emits nested children under folder rows. |
| src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.folder-workspace-lanes.test.ts | Adds sidebar coverage for attachment nesting behavior across group-by modes + collapse/pin/unrendered-folder/stale-instance cases. |
| src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.tsx | Switches board projection inputs to a folder-aware worktree list builder. |
| src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx | Adds regression coverage for folder workspace cards and folding attached worktrees into them during search/layout. |
| src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.ts | New builder: board rows = all git worktrees minus attached children + live folder workspaces projected as worktree-shaped entries. |
| src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.test.ts | Unit tests for board-row composition and archived-folder behavior. |
| src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.ts | Ensures folder workspace entries bypass git-only visibility filters while keeping git worktrees filtered as before. |
| src/renderer/src/components/sidebar/rendered-sidebar-worktree-order.ts | Passes workspace lineage into row building so rendered order reflects attachment folding. |
| src/main/runtime/runtime-managed-worktree-metadata.ts | Resolves --parent-worktree via resolveParent; folder parents write workspace lineage only (and clear worktree lineage), with cross-host rejection. |
| src/main/runtime/runtime-managed-worktree-metadata.test.ts | Adds runtime tests for folder-parent behavior (workspace lineage only + cross-host rejection). |
| src/main/runtime/orca-runtime-create-managed-remote-worktree.ts | Wires resolveParent into runtime metadata update ports. |
| src/cli/help.ts | Updates worktree set help to include folder/worktree selector forms for --parent-worktree. |
Review details
- Files reviewed: 22/22 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const attachedByFolderId = new Map( | ||
| [ | ||
| ...getAttachedWorktreesByFolderWorkspaceId( | ||
| worktreesOutsidePinnedSection, | ||
| workspaceLineageByChildKey | ||
| ) | ||
| ].filter(([folderId]) => renderableFolderIds.has(folderId)) | ||
| ) | ||
| const attachedIdentities = new Set( | ||
| [...attachedByFolderId.values()].flat().map(getWorktreeHostIdentity) | ||
| ) | ||
| const naturalWorktrees = worktreesOutsidePinnedSection.filter( | ||
| (worktree) => !attachedIdentities.has(getWorktreeHostIdentity(worktree)) | ||
| ) |
There was a problem hiding this comment.
ℹ️ Two rough edges worth a look — neither blocks merging.
Reviewed changes
- Worktree→folder attach via
worktree set—updateRuntimeManagedWorktreeMetadataresolves--parent-worktreethrough the lineage controller'sresolveParent; a folder parent writes workspace lineage only (clearing any worktree-lineage row) and rejects cross-host folders withLINEAGE_PARENT_CONTEXT_CONFLICT. - Sidebar nesting — attached children are derived from
workspaceLineageByChildKeyand emitted depth-1 beneath their folder row in every Group by mode; pinned children, unrendered folders, and stale child instances fall back to ordinary rows. - Workspace Board — folder workspaces render as cards and absorb their attached children; folder entries bypass the git-only visibility filters in the projection.
The decomposition is clean, the tests make exact (not loose) assertions, and the folder: routing through updateWorktreeMeta already existed, so board status moves persist folders correctly.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 28.21% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 26 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | |
| Description check | The description explains the feature, rationale, linked issue, implementation details, and validation results. However, it omits the required Visual Proof section for UI changes and does not complete … | Add the required Visual Proof section with before-and-after screenshots or videos, or write N/A with a reason if applicable. Complete the Testing checkboxes and tested platforms, provide the AI Disclosure if applicable, complete the Revie… |
✅ Passed checks (3 passed)
-
Check name Status Explanation Linked Issues check ✅ Passed The implementation addresses all three coding objectives in [18198]: folder-parent attachment with validation, sidebar nesting across grouping modes, and Workspace Board folder cards with attached wor… Out of Scope Changes check ✅ Passed The changes remain within [18198]. Runtime attachment handling, sidebar nesting, Workspace Board integration, and related tests directly support the linked issue objectives. The explicitly deferred ri… Title check ✅ Passed The title clearly describes the main changes: attaching existing worktrees to folder workspaces and nesting them in the sidebar and Workspace Board.
Full details: Description check
-
Explanation
The description explains the feature, rationale, linked issue, implementation details, and validation results. However, it omits the required Visual Proof section for UI changes and does not complete the template's Testing, AI Disclosure, Review, Agent skill upstream boundary, and Checklist sections.
Resolution
Add the required Visual Proof section with before-and-after screenshots or videos, or write
N/Awith a reason if applicable. Complete the Testing checkboxes and tested platforms, provide the AI Disclosure if applicable, complete the Review and Agent skill upstream boundary sections, and complete the Checklist items.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: bdd62d17-68aa-44cd-8d23-03276e355b9b
📥 Commits
Reviewing files that changed from the base of the PR and between f737f34 and 89f8dadabdf57c9cae47cc0b2886c10faf63dc48.
📒 Files selected for processing (22)
src/cli/help.tssrc/main/runtime/orca-runtime-create-managed-remote-worktree.tssrc/main/runtime/runtime-managed-worktree-metadata.test.tssrc/main/runtime/runtime-managed-worktree-metadata.tssrc/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsxsrc/renderer/src/components/sidebar/WorkspaceKanbanDrawer.tsxsrc/renderer/src/components/sidebar/WorktreeList.tsxsrc/renderer/src/components/sidebar/rendered-sidebar-worktree-order.tssrc/renderer/src/components/sidebar/use-workspace-kanban-board-projection.tssrc/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.test.tssrc/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.tssrc/renderer/src/components/sidebar/worktree-list/grouping/build-rows.folder-workspace-lanes.test.tssrc/renderer/src/components/sidebar/worktree-list/grouping/build-rows.tssrc/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.tssrc/renderer/src/components/sidebar/worktree-list/grouping/group-keys.tssrc/renderer/src/components/sidebar/worktree-list/grouping/group-sections.tssrc/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.tssrc/renderer/src/components/sidebar/worktree-list/grouping/row-builders.tssrc/renderer/src/components/sidebar/worktree-list/grouping/row-types.tssrc/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.tssrc/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsxsrc/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
89f8dad to
184c193
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c02e79ec-ccfc-455a-9824-75f4012b25e6
📥 Commits
Reviewing files that changed from the base of the PR and between 184c193921650f349b5420674a99670ef26aeecf and 57f43ec81951faa776e15d2ea2e33a23a1c965f2.
📒 Files selected for processing (6)
src/main/runtime/runtime-managed-worktree-metadata.test.tssrc/main/runtime/runtime-managed-worktree-metadata.tssrc/renderer/src/components/sidebar/use-workspace-kanban-board-projection.test.tsxsrc/renderer/src/components/sidebar/use-workspace-kanban-board-projection.tssrc/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.test.tssrc/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/runtime/runtime-managed-worktree-metadata.test.ts
- src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
The board drops the non-attached sibling of a cross-host worktree-id collision (see inline). Everything else in this delta is clean — the two prior findings are resolved with exact tests.
Reviewed changes
- Canonical folder-host resolution on attach —
describeFolderParentHostConflictnow reduces the folder and worktree toresolveFolderWorkspaceHost'slocal/ssh:<target>level, so aruntime:folder answerslocaland attaches to a local worktree instead of failing closed; cross-target SSH folders are rejected by target id. - Board host filter for folder cards —
visibleFolderWorktreeIdsgates folder workspace entries throughworkspaceHostScope/visibleWorkspaceHostIds, matching howcomputeVisibleWorktreesfilters git cards. - Host-qualified attached-child resolution —
getAttachedWorktreesByFolderWorkspaceIdcounts distinct host-qualified rows per id and only nests the instance the lineage record names, so a two-host id collision no longer nests the wrong workspace.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
7631ada to
80f624c
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Important
The new runtime-environment guard reads a field that is never present on the record it reads from, so the cross-runtime rejection it is meant to add does not actually happen (see inline). The board fold fix is correct and the rest of the delta is clean.
Reviewed changes
- Board folds by host-qualified identity —
buildWorkspaceBoardWorktreesnow keysattachedIdentitiesongetWorktreeHostIdentity, so a non-attached sibling of a cross-host id collision stays on the board, matching the sidebar'sbuildRows. - Runtime-environment comparison in the folder-host check —
describeFolderParentHostConflictgained aruntime:envvsruntime:envenvironment-id comparison intended to reject cross-runtime attaches. - Exact tests — added same-environment attach, different-environment reject, and SSH-parent-for-runtime-child reject cases, plus the board cross-host sibling case.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Store-scoped folder validation replaces the dead renderer-stamp guard —
describeFolderParentHostConflictno longer readsfolderWorkspace.executionHostId(never persisted in main); it compares only SSH target ids, treatinglocal/runtimeas the same host, and folder lookup is scoped to the owning runtime's Store throughresolveParent, so a folder from another runtime fails withselector_not_foundbefore any write. - Real store/resolver integration tests — a new
runtime-managed-worktree-metadata.folder-store.test.tsexercises seven cases through real Store create/flush/reload and the productionresolveParent+resolveFolderWorkspaceHost: persisted local/runtime/SSH attachments, discarded renderer stamps, foreign-store rejection, colliding folder ids, and SSH-parent rejection. - Artificial stamped-folder fixtures removed — the unit test file now asserts the durable local/SSH ownership boundary via
connectionIdinstead of a fabricatedexecutionHostId.
The prior finding is fully resolved: the dead guard is gone, the invariant is now the owning-runtime Store (not a renderer-only field), and the SSH rejection still holds through resolveFolderWorkspaceHost.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
@DominionZA2 mind attaching some images? Would make understanding + review faster! If you do that I'll take a look -- just ping me here or on Discord |
|
Tested this locally and it does exactly what we need. Setup: a project group with four repos and one folder workspace for a coordinating agent; engineer worktrees are created with To try it I cherry-picked the 11 commits onto v1.4.224. Two things needed adapting (likely the same on current main):
After that, typecheck and the sidebar/runtime/CLI tests pass. Would love to see this merged — happy to help with the rebase. |
…a worktree set `orca worktree set --parent-worktree folder:<id>` now records workspace lineage for an existing worktree, mirroring what `worktree create` already accepts. The set path resolves the parent through the lineage controller's workspace-aware resolver; a folder parent writes workspace lineage only (replacing any worktree parent) and must share the worktree's execution host. Worktree parents are unchanged. This is the 'manual attach' item deferred by the folder-workspace attached-worktrees design (stablyai#5289).
…rkspace A worktree whose workspace lineage names a folder workspace as parent now renders nested under that folder's row in every Group by mode — including inside status and PR lanes (cross-status nesting) — instead of as a row of its own. The folder card gains the same child chip and collapse toggle worktree lineage parents have. Pinned children keep their pinned placement, and children of a folder that is not rendered stay visible as ordinary rows. This is the sidebar-nesting follow-up the folder-workspace design (stablyai#5289) deferred as 'future enhancement'.
The board built its cards from the store's git-worktree list only, so a folder workspace never appeared in any column even though the sidebar already grouped it by status. Folder workspaces now join the board through the same worktree-shaped adapter the sidebar uses, carrying their own status, and a worktree attached to a folder workspace folds into that card instead of appearing as its own. Status moves on a folder card persist through the existing folder-aware metadata update.
With pinned worktrees duplicated into their groups, a pinned child of a folder workspace also rendered under the folder card. Folder cards now skip pinned children in every pinned display policy.
…w fields The folder-store test edits saved state through the persisted-state helpers and runs with the SQLite runtime files. Section and append-context fixtures built by hand gain workspaceLineageByChildKey and attachedByFolderId.
d058159 to
2a99e3f
Compare
|
@nwparker screenshots below, sorry for the delay. I've also rebased onto current Setup: one folder workspace ("Checkout redesign") and four git worktrees. Three of them are attached to the folder with 1. Sidebar: attached worktrees nest under their folder workspace 2. The folder collapses like a parent worktree ("3 children" toggle) 3. Workspace Board: the folder workspace gets its own card, with its children folded into it 4. A pinned child stays only in Pinned and isn't repeated under the folder Since the last push:
@seifer thanks for testing this. Both of the fixes you described are now in the branch. — claude-opus-5-5, high reasoning |





ELI5
A ticket's folder workspace and its repo branches now behave as one thing: you can attach existing branches to the workspace, the sidebar tucks them under the ticket's card (in every grouping, including status lanes), and the ticket itself gets a card on the Workspace Board.
What Changed
Three feature slices, with follow-up review corrections:
worktree setaccepts a folder workspace parent.updateRuntimeManagedWorktreeMetadataresolves--parent-worktreethrough the lineage controller's workspace-awareresolveParent(the same routingcreategained in Hide workspace parent flag from worktree create CLI #5743). A folder parent writes workspace lineage only and clears any worktree-lineage row; the folder must share the worktree's execution host (LINEAGE_PARENT_CONTEXT_CONFLICTotherwise). The folder side is resolved withresolveFolderWorkspaceHost, solocalandruntime:compare as the same host and SSH compares by target id; a folder that resolves asambiguousormissingis rejected. Folder selectors are resolved only in the selected runtime's own Store, before lineage is written. The local/runtime alias is intentional within that store: folderexecutionHostIdis a renderer-only stamp, not persisted authority. No runtime-environment comparison is made against that absent field. Worktree parents are unchanged. Help text forworktree setnow lists the folder/worktree selector forms.getAttachedWorktreesByFolderWorkspaceIdderives each rendered folder's attached children fromworkspaceLineageByChildKey, matching each lineage record to its child by host-qualified identity andchildInstanceId, so two hosts sharing a bare worktree id cannot nest the wrong row (a record that cannot be pinned to exactly one row is skipped); the board folds attached children by the same host-qualified identity;appendFolderWorkspaceRowsemits the folder row followed by its children at depth 1, in every Group by mode and lane.FolderWorkspaceRowcarriesattachedChildCount/attachedGroupKey/attachedCollapsed, and the folder card gets the existing lineage chip and collapse toggle. Attached children are removed from their ordinary lanes; pinned children keep their pinned placement; children of an unrendered folder stay visible as ordinary rows.buildWorkspaceBoardWorktreesfeeds the board git worktrees minus attached children plus each live folder workspace viafolderWorkspaceToWorktree. Folder entries bypass the git-only visibility filters (default branch, detached HEAD, other devices) in the projection but honour the workspace host filter, matching the sidebar. Status moves on a folder card persist through the existing folder-awareupdateWorktreeMetapath.Why
These are the items the folder-workspace design deferred after its first slice: manual attach/detach and nesting under the folder workspace within each status lane. Without them a multi-repo ticket reads as one card in one place and several loose rows in others, and any workspace not created by Orca itself can never be linked at all.
Tests
runtime-managed-worktree-metadata.test.ts: folder parent writes workspace lineage only and clears worktree lineage; runtime-host worktree attaches to a local folder; same-target SSH attaches; cross-host and cross-target folder parents rejected.folder-workspace-attached.test.ts: same id on two hosts nests only the instance the record names, or neither when no instance is recorded; stale instance and archived child ignored.use-workspace-kanban-board-projection.test.tsx: folder card hidden when its host is filtered out, shown when visible or under the all-hosts scope.workspace-kanban-folder-workspaces.test.ts: with the same worktree id on two hosts and only one instance attached, the other host's row stays on the board.runtime-managed-worktree-metadata.folder-store.test.ts: seven cases exercise real Store creation/reload and the production folder-parent resolver: persisted local/runtime/SSH attachments, discarded renderer stamps, foreign-store folder rejection, colliding folder IDs staying store-local, and SSH-parent rejection without metadata or lineage changes. Git discovery is stubbed; these are store/resolver integration tests, not multi-runtime transport E2E tests.runtime-managed-worktree-metadata.test.ts: retains runtime-local/SSH host rejection; removes the two artificial stamped-folder fixtures.build-rows.folder-workspace-lanes.test.ts: nesting in all four Group by modes, collapse, pinned child, unrendered folder, stale child instance.workspace-kanban-folder-workspaces.test.ts+WorkspaceKanbanDrawer.search.test.tsx: folder cards on the board, attached child folded in, archived folder releases its child.Notes
The right sidebar's existing
getLineageChildWorktreestill resolves lineage children by bare worktree id, so it has the same cross-host ambiguity this PR closes in the new sidebar lookup. Left untouched here; it is a separate change to that view.Fixes #18198.
Review follow-up validation
pnpm run typecheckpnpm exec oxlint <three changed files>plus the React Doctor and type-aware configurations on those files.pnpm exec oxfmt --write <three changed files>pnpm run check:max-lines-ratchetgit diff --cached --check