Skip to content

feat(worktrees): attach existing worktrees to folder workspaces and nest them in the sidebar and board - #18199

Open
DominionZA2 wants to merge 13 commits into
stablyai:mainfrom
DominionZA2:feat/folder-workspace-attached-nesting
Open

DominionZA2 wants to merge 13 commits into
stablyai:mainfrom
DominionZA2:feat/folder-workspace-attached-nesting

Conversation

@DominionZA2

@DominionZA2 DominionZA2 commented Sep 2, 2026 •

Copy link
Copy Markdown

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:

  1. worktree set accepts a folder workspace parent. updateRuntimeManagedWorktreeMetadata resolves --parent-worktree through the lineage controller's workspace-aware resolveParent (the same routing create gained 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_CONFLICT otherwise). The folder side is resolved with resolveFolderWorkspaceHost, so local and runtime: compare as the same host and SSH compares by target id; a folder that resolves as ambiguous or missing is 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: folder executionHostId is a renderer-only stamp, not persisted authority. No runtime-environment comparison is made against that absent field. Worktree parents are unchanged. Help text for worktree set now lists the folder/worktree selector forms.
  2. Sidebar nesting. getAttachedWorktreesByFolderWorkspaceId derives each rendered folder's attached children from workspaceLineageByChildKey, matching each lineage record to its child by host-qualified identity and childInstanceId, 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; appendFolderWorkspaceRows emits the folder row followed by its children at depth 1, in every Group by mode and lane. FolderWorkspaceRow carries attachedChildCount / 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.
  3. Workspace Board. buildWorkspaceBoardWorktrees feeds the board git worktrees minus attached children plus each live folder workspace via folderWorkspaceToWorktree. 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-aware updateWorktreeMeta path.

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.
  • Original feature validation: sidebar suite plus runtime metadata tests (304 files / 2,554 tests), typecheck and lint/format checks passed. The current correction validation is listed below.

Notes

The right sidebar's existing getLineageChildWorktree still 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

  • 31 focused test files: 311 passed, 0 failed, 0 skipped (runtime metadata/lineage, persistence, CLI/RPC routing, folder-host resolution, and affected sidebar/board/catalog tests).
  • pnpm run typecheck
  • pnpm 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-ratchet
  • git diff --cached --check

Copilot AI lite review requested due to automatic review settings September 2, 2026 15:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment on lines +121 to +134
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))
)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Two rough edges worth a look — neither blocks merging.

Reviewed changes

  • Worktree→folder attach via worktree set — updateRuntimeManagedWorktreeMetadata resolves --parent-worktree through the lineage controller's resolveParent; a folder parent writes workspace lineage only (clearing any worktree-lineage row) and rejects cross-host folders with LINEAGE_PARENT_CONTEXT_CONFLICT.
  • Sidebar nesting — attached children are derived from workspaceLineageByChildKey and 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 54315b51-db8e-4083-a1ae-905f4e29b56d

📥 Commits

Reviewing files that changed from the base of the PR and between ed9d761 and 80f624cd6b1bf54b8fcb5099cbaaaae32713e7dc.

📒 Files selected for processing (26)
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/main/runtime/orca-runtime-create-managed-remote-worktree.ts
  • src/main/runtime/runtime-managed-worktree-metadata.test.ts
  • src/main/runtime/runtime-managed-worktree-metadata.ts
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/rendered-sidebar-worktree-order.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.test.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.ts
  • src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.test.ts
  • src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.folder-workspace-lanes.test.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.test.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-rows.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/group-keys.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/group-sections.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/row-builders.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/row-types.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
  • src/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsx
  • src/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts
🚧 Files skipped from review as they are similar to previous changes (25)
  • src/renderer/src/components/sidebar/rendered-sidebar-worktree-order.ts
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.folder-workspace-lanes.test.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/row-builders.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-rows.ts
  • src/cli/help.ts
  • src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.test.ts
  • src/main/runtime/orca-runtime-create-managed-remote-worktree.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/row-types.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.test.ts
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/main/runtime/runtime-managed-worktree-metadata.test.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/group-keys.ts
  • src/cli/index.test.ts
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.tsx
  • src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/group-sections.ts
  • src/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsx
  • src/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The change adds folder-workspace parent lineage handling to runtime metadata updates. It adds board conversion that folds attached worktrees into live folder workspace entries and applies host filtering. Sidebar grouping nests attached worktrees under folder workspace rows with collapse metadata and lineage depth. Workspace lineage data and toggle handlers flow through sidebar row construction and rendering. Tests cover runtime lineage updates, board conversion, archived folders, nested rows, collapse behavior, pinned children, stale lineage, and host conflicts.

Fixed issue severity: Medium

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 80f62

The change adds folder-workspace attachment and nested board/sidebar presentation with targeted coverage; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 ⚠️ Warning 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/A with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/runtime/orca-runtime-create-managed-remote-worktree.ts
  • src/main/runtime/runtime-managed-worktree-metadata.test.ts
  • src/main/runtime/runtime-managed-worktree-metadata.ts
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/rendered-sidebar-worktree-order.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.ts
  • src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.test.ts
  • src/renderer/src/components/sidebar/workspace-kanban-folder-workspaces.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.folder-workspace-lanes.test.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/group-keys.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/group-sections.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/row-builders.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/row-types.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
  • src/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsx
  • src/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.

@DominionZA2
DominionZA2 force-pushed the feat/folder-workspace-attached-nesting branch from 89f8dad to 184c193 Compare September 8, 2026 13:39
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/runtime/runtime-managed-worktree-metadata.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.test.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.ts
  • src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-attached.test.ts
  • src/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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — describeFolderParentHostConflict now reduces the folder and worktree to resolveFolderWorkspaceHost's local / ssh:<target> level, so a runtime: folder answers local and attaches to a local worktree instead of failing closed; cross-target SSH folders are rejected by target id.
  • Board host filter for folder cards — visibleFolderWorktreeIds gates folder workspace entries through workspaceHostScope / visibleWorkspaceHostIds, matching how computeVisibleWorktrees filters git cards.
  • Host-qualified attached-child resolution — getAttachedWorktreesByFolderWorkspaceId counts 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — buildWorkspaceBoardWorktrees now keys attachedIdentities on getWorktreeHostIdentity, so a non-attached sibling of a cross-host id collision stays on the board, matching the sidebar's buildRows.
  • Runtime-environment comparison in the folder-host check — describeFolderParentHostConflict gained a runtime:env vs runtime:env environment-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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Store-scoped folder validation replaces the dead renderer-stamp guard — describeFolderParentHostConflict no longer reads folderWorkspace.executionHostId (never persisted in main); it compares only SSH target ids, treating local/runtime as the same host, and folder lookup is scoped to the owning runtime's Store through resolveParent, so a folder from another runtime fails with selector_not_found before any write.
  • Real store/resolver integration tests — a new runtime-managed-worktree-metadata.folder-store.test.ts exercises seven cases through real Store create/flush/reload and the production resolveParent + 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 connectionId instead of a fabricated executionHostId.

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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

@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

@seifer

seifer commented Oct 13, 2026

Copy link
Copy Markdown

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 worktree create --parent-worktree folder:<id>. With this PR they nest under the folder-workspace row in the left sidebar, across repos.

To try it I cherry-picked the 11 commits onto v1.4.224. Two things needed adapting (likely the same on current main):

  • runtime-managed-worktree-metadata.folder-store.test.ts reads/writes orca-data.json directly; profile state now lives in SQLite, so the test has to go through readPersistedStateJson / writePersistedStateJson and be listed in config/scripts/vitest-sqlite-runtime-files.mjs.
  • Three newer tests build SectionRowsArgs / SectionAppendContext by hand and no longer typecheck (agent-send-picker-collapse.test.tsx, host-section-reveal.test.tsx, grouping/recent-project-rank-scan-budget.test.ts); they need workspaceLineageByChildKey: {} and attachedByFolderId: new Map().

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.
@DominionZA2
DominionZA2 force-pushed the feat/folder-workspace-attached-nesting branch from d058159 to 2a99e3f Compare October 14, 2026 09:34
@DominionZA2

Copy link
Copy Markdown
Author

@nwparker screenshots below, sorry for the delay. I've also rebased onto current main, so the conflicts are gone.

Setup: one folder workspace ("Checkout redesign") and four git worktrees. Three of them are attached to the folder with orca worktree set <worktree> --parent-worktree folder:<id>.

1. Sidebar: attached worktrees nest under their folder workspace

Sidebar with three worktrees nested under the Checkout redesign folder workspace

2. The folder collapses like a parent worktree ("3 children" toggle)

Sidebar with the folder workspace's children collapsed

3. Workspace Board: the folder workspace gets its own card, with its children folded into it

Workspace Board showing the Checkout redesign folder workspace card in In progress

4. A pinned child stays only in Pinned and isn't repeated under the folder

Sidebar with Checkout API pinned and the folder showing its two remaining children

Since the last push:

  • Rebased onto main.
  • Fixed a pinned child showing twice when pinned worktrees are also shown in their groups.
  • Adapted the tests to SQLite profile state.

@seifer thanks for testing this. Both of the fixes you described are now in the branch.

— claude-opus-5-5, high reasoning

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Attach existing worktrees to a folder workspace, and nest them under it in the sidebar and Workspace Board

4 participants