Repository navigation
Fix legacy worktree lineage projection after stable updates - #9913
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe change centralizes resolved worktree lineage validation and projection, including instance, repository, host, project, missing-parent, and cycle checks. Runtime and IPC worktree discovery now hydrate lineage through the shared projection. Renderer state updates preserve inline lineage, while sidebar rendering, visibility, deletion, parent selection, drag-and-drop, and context menus consume projected lineage utilities. Tests cover legacy hydration, boundary mismatches, stale records, cycles, and end-to-end inline lineage rendering. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/renderer/src/components/sidebar/worktree-lineage-projection.ts (3)
12-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLocal
WorktreeWithResolvedLineageshadows the shared type with a different shape.This file defines its own unexported
WorktreeWithResolvedLineage(only an optionallineagefield), whilesrc/shared/resolved-worktree-lineage.tsexports a same-named generic type with requiredparentWorktreeId/childWorktreeIds/lineage. Same name, different structure across two closely-related files invites confusion for future maintainers reasoning about lineage shapes.Consider renaming this local type (e.g.
WorktreeWithInlineLineage) or deriving it from the shared type viaPick/Partial.
14-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing "why" comment on the side-map precedence rule.
This function implements the PR's central design decision — the hydrated side-map is authoritative when present, inline
worktree.lineageis only a fallback — but there's no comment explaining that rationale, unlike the codebase's extensive use of// Why:comments elsewhere for similarly non-obvious logic.
As per coding guidelines: "Add concise, preferably one-line comments only for non-obvious code, explaining why rather than how."Source: Coding guidelines
81-100: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
getWorktreeLineageAncestorsbreaks the "precompute cycles once" pattern.
getLineageRenderInfoaccepts a precomputedcyclicLineageIdsso callers can compute it once and reuse it across many worktrees, butgetWorktreeLineageAncestorsdoesn't take that parameter and instead recomputesgetCyclicProjectedWorktreeLineageIds(an O(n) full-map scan) internally on every call. If this is invoked per-row (e.g. for ancestor breadcrumbs across many worktrees), that's O(n²) total instead of O(n).Consider accepting an optional precomputed
cyclicLineageIds(falling back to computing it if omitted) to match the established pattern.src/renderer/src/components/sidebar/worktree-list-groups.ts (1)
1293-1311: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant
if/else— both branches are now identical.itemsandhostContextLabelByRepoIdare already computed conditionally ongroupBy === 'repo'above (Lines 1288-1292), so bothappendWorktreeRowscalls pass the same option object. The branch can be collapsed into a single call.♻️ Collapse the identical branches
- if (groupBy === 'repo') { - appendWorktreeRows(result, items, repoMap, lineageById, worktreeMap, { - nestLineage, - collapsedGroups, - groupDepth: projectGroupDepth, - sectionKey: key, - hostContextLabelByRepoId, - cyclicLineageIds - }) - } else { - appendWorktreeRows(result, items, repoMap, lineageById, worktreeMap, { - nestLineage, - collapsedGroups, - groupDepth: projectGroupDepth, - sectionKey: key, - hostContextLabelByRepoId, - cyclicLineageIds - }) - } + appendWorktreeRows(result, items, repoMap, lineageById, worktreeMap, { + nestLineage, + collapsedGroups, + groupDepth: projectGroupDepth, + sectionKey: key, + hostContextLabelByRepoId, + cyclicLineageIds + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 94d99f76-bd93-4749-8b8d-4888a406c4f7
📒 Files selected for processing (28)
src/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/components/right-sidebar/folder-workspace-attached-worktrees.test.tssrc/renderer/src/components/right-sidebar/folder-workspace-attached-worktrees.tssrc/renderer/src/components/sidebar/WorktreeContextMenu.test.tssrc/renderer/src/components/sidebar/WorktreeContextMenu.tsxsrc/renderer/src/components/sidebar/WorktreeList.tsxsrc/renderer/src/components/sidebar/use-visible-workspace-kanban-worktree-ids.tssrc/renderer/src/components/sidebar/visible-worktrees.test.tssrc/renderer/src/components/sidebar/visible-worktrees.tssrc/renderer/src/components/sidebar/workspace-delete-lineage.test.tssrc/renderer/src/components/sidebar/workspace-delete-lineage.tssrc/renderer/src/components/sidebar/worktree-lineage-drag-drop.test.tssrc/renderer/src/components/sidebar/worktree-lineage-drag-drop.tssrc/renderer/src/components/sidebar/worktree-lineage-projection.tssrc/renderer/src/components/sidebar/worktree-list-groups.test.tssrc/renderer/src/components/sidebar/worktree-list-groups.tssrc/renderer/src/components/sidebar/worktree-parent-candidates.tssrc/renderer/src/components/sidebar/worktree-parent-eligibility.test.tssrc/renderer/src/components/sidebar/worktree-parent-eligibility.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.tssrc/shared/resolved-worktree-lineage.test.tssrc/shared/resolved-worktree-lineage.tstests/e2e/worktree-lineage-state.tstests/e2e/worktree-lineage.spec.ts
|
Fresh |
Summary
lineagebut the separately hydrated lineage side-map has no child entryDeterministic reproduction and root cause
The motivating stable state is modeled with the production identities:
b0ffd635-91cd-424f-b804-80d4bb277a4c1ceb9823-aa98-4f79-8eaa-af0b3a3d551b87e2ef9a-99d3-48e3-9a53-3d1a979b5417Both older children have mutually consistent persisted/runtime legacy lineage to
assigned-issues, butworkspaceLineage: null. A newly created child has both legacy and generalized workspace lineage. The narrow renderer fixture passes exact valid inline legacy lineage with an absent side-map entry; before this fixbuildRowsemits each child at depth 0, and after it emits the child beneath the exact parent.The semantic mismatch was that desktop grouping trusted only the separately hydrated
worktreeLineageByIdmap even though resolved worktrees already carried authoritative instance-aware legacylineage. Stable hydration could preserve and report lineage correctly while the renderer discarded it. The fix selects a side-map entry when the child key exists and otherwise falls back to resolved inline legacy lineage. BareparentWorktreeIdis never trusted.The sidebar grouping/visibility files in
v1.4.149andv1.4.150are byte-identical. Thev1.4.149 -> v1.4.150update exposed the mismatch for these workspaces, but the evidence does not support naming that update as the exact introducing commit.Safety, security, and compatibility
Projected edges require matching child/parent record IDs, exact child and parent instance IDs, the same repository, and matching host/project identities when both sides know them. Missing parents, stale instances, disagreement with an existing side-map entry, self-links, and cycles stay flat/rejected. Runtime manual reparenting enforces the same boundary before persistence.
The repair does not migrate or rewrite lineage metadata and adds no new external-input or privilege boundary. It remains path-agnostic. Local, SSH, WSL, remote-runtime, multi-host/project, folder workspace, imported worktree, pinned row, filtering/sorting, hidden-child counts, large-list virtualization, mobile summaries, and intentionally flat Kanban behavior are covered or preserved. Graph validation is precomputed for bulk surfaces; drag checks validate only the proposed parent, and folder traversal uses adjacency plus BFS.
No production metadata was rewritten or manually reparented. The running production CLI still reports both affected children under the original parent with the exact instance IDs above.
Before / after evidence
assigned-issues71474a32fa6954ae1d77bfbc2c31c30710b93e3212cb9c4863007bf052c58af4Validation
641799fa2, including legacy-only inline fallback and filtered-parent structural injectionInternal review
Iterative adversarial review found and fixed boundary/cycle, filtered-parent, unlink/reveal/delete/drag, folder PR aggregation, folder detected-hydration, and large-list performance gaps. The final independent round reported zero Critical, Important, or Minor findings and independently passed 1,191 targeted tests.
Limitation
Full
pnpm lintreaches an unrelated pre-existing switch-exhaustiveness failure atsrc/renderer/src/components/skills/skill-freshness-group.tsx:101. All changed files pass lint.