Repository navigation
Conversation
Greptile SummaryThis PR adds a Sleep with Descendants (N) context-menu action that recursively sleeps a selected workspace and all its validated descendants, and makes the pre-existing cascading delete label explicit as Delete with Descendants…. The recursive target set is computed via the already-validated
Confidence Score: 5/5Safe to merge — the new recursive sleep action is correctly scoped through the existing validated lineage projection and the 50 ms Radix teardown guard is preserved for the subtree path. The traversal delegates entirely to the pre-existing getWorkspaceDeleteLineage, which already handles stale links, cycles, and boundary conditions. The deletion-pending guard (contextDeletePending) correctly widens from the parent-only check to parent-plus-descendants in single-context mode, and the sleep disabled logic is correctly asymmetric. Unit tests cover recursive collection, stale-lineage exclusion, and sleepability detection; the new E2E test exercises the full store-level round-trip. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/sidebar/workspace-lineage-menu-actions.ts | New module extracting hasSleepableWorkspaceActivity and adding getWorkspaceLineageMenuActions/useWorkspaceLineageMenuActions; correctly reuses getWorkspaceDeleteLineage for validated lineage traversal with proper cycle/stale-link exclusion |
| src/renderer/src/components/sidebar/WorkspaceSleepMenuItems.tsx | New presentational component cleanly wraps the single and subtree sleep menu items with tooltip guards; descendant item is conditionally hidden when count is 0 |
| src/renderer/src/components/sidebar/WorktreeContextMenu.tsx | Integrates useWorkspaceLineageMenuActions, replaces inline sleep items with WorkspaceSleepMenuItems, and correctly gates contextDeletePending for delete-pending state spanning descendants; sleepWorktreesAfterMenuClose refactored cleanly to a shared helper |
| src/renderer/src/components/sidebar/workspace-lineage-menu-actions.test.ts | Good unit coverage for recursive descent collection, stale-lineage exclusion, and sleep-activity detection; hasSleepableWorkspaceActivity tests migrated here from WorktreeContextMenu.test.ts |
| tests/e2e/worktree-lineage.spec.ts | Adds E2E test for sleep-with-descendants via store-state mocking; captureEvidence helper consolidated from the previously duplicate helpers |
| tests/e2e/workspace-board-lane-virtualization.spec.ts | Race condition fix: adds data-workspace-board-selection-surface bounding-box anchor and waits for at least one selected card before forcing the large scroll, preventing flaky failures on slow CI runners |
| src/renderer/src/i18n/locales/en.json | Adds three new i18n keys for sleepWithDescendants, sleepWithDescendantsDescription, and deleteWithDescendants |
Sequence Diagram
sequenceDiagram
participant User
participant WorktreeContextMenu
participant useWorkspaceLineageMenuActions
participant getWorkspaceDeleteLineage
participant WorkspaceSleepMenuItems
participant runSleepWorktrees
User->>WorktreeContextMenu: right-click workspace row
WorktreeContextMenu->>useWorkspaceLineageMenuActions: "{enabled: !isMultiContext, parent, worktrees, lineageById, activity}"
useWorkspaceLineageMenuActions->>getWorkspaceDeleteLineage: (parent, worktrees, lineageById)
getWorkspaceDeleteLineage-->>useWorkspaceLineageMenuActions: "{descendants, deleteAllTargets}"
useWorkspaceLineageMenuActions-->>WorktreeContextMenu: "{descendants, targets, sleepableTargets}"
WorktreeContextMenu->>WorkspaceSleepMenuItems: render with descendantCount, subtreeSleepDisabled
WorkspaceSleepMenuItems-->>User: "shows Sleep + Sleep with Descendants (N) when N > 0"
User->>WorkspaceSleepMenuItems: click Sleep with Descendants (N)
WorkspaceSleepMenuItems->>WorktreeContextMenu: onSleepSubtree()
WorktreeContextMenu->>WorktreeContextMenu: setMenuOpenState(false)
WorktreeContextMenu->>WorktreeContextMenu: window.setTimeout(..., 50ms)
Note over WorktreeContextMenu: Radix menu tears down safely
WorktreeContextMenu->>runSleepWorktrees: "sleepableTargets.map(t => t.id)"
runSleepWorktrees-->>User: parent + descendants panels closed
Reviews (4): Last reviewed commit: "test(e2e): start marquee from selection ..." | Re-trigger Greptile
📝 WalkthroughWalkthroughAdded shared workspace lineage utilities that collect descendants and identify sleepable workspaces from terminal and browser activity. Updated the worktree context menu with descendant sleep and deletion actions, combined pending-delete state, and extracted sleep menu rendering. Added English localization strings, unit tests for lineage and activity filtering, and end-to-end coverage for descendant terminal cleanup. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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.
🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/WorktreeContextMenu.tsx (1)
619-626: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the shared "close menu, then sleep after a delay" logic.
handleSleepSubtree(Line 619-626) repeatshandleCloseTerminals(Line 608-617) exactly, except for the source array. Both close the menu, then callrunSleepWorktreesinside the samewindow.setTimeout(..., 50). Extract a small helper that takes the worktree list and performs this sequence once. Reusing this helper keeps the 50 ms delay and its Radix-teardown rationale in one place instead of two, so a future timing fix cannot update one call site and miss the other.♻️ Proposed refactor
+ const sleepWorktreesAfterMenuClose = useCallback( + (worktreeIds: string[]) => { + setMenuOpenState(false) + // Why: Sleep can remount the sidebar when it clears the active workspace. + // Let Radix finish closing the menu first so its focus/portal teardown + // cannot scroll the virtualized list during that remount. + window.setTimeout(() => { + void runSleepWorktrees(worktreeIds) + }, 50) + }, + [setMenuOpenState] + ) + const handleCloseTerminals = useCallback(() => { - const worktreeIds = sleepableWorktrees.map((item) => item.id) - setMenuOpenState(false) - // Why: Sleep can remount the sidebar when it clears the active workspace. - // Let Radix finish closing the menu first so its focus/portal teardown - // cannot scroll the virtualized list during that remount. - window.setTimeout(() => { - void runSleepWorktrees(worktreeIds) - }, 50) - }, [setMenuOpenState, sleepableWorktrees]) + sleepWorktreesAfterMenuClose(sleepableWorktrees.map((item) => item.id)) + }, [sleepWorktreesAfterMenuClose, sleepableWorktrees]) const handleSleepSubtree = useCallback(() => { - const worktreeIds = subtreeSleepableWorktrees.map((item) => item.id) - setMenuOpenState(false) - window.setTimeout(() => { - void runSleepWorktrees(worktreeIds) - }, 50) - }, [setMenuOpenState, subtreeSleepableWorktrees]) + sleepWorktreesAfterMenuClose(subtreeSleepableWorktrees.map((item) => item.id)) + }, [sleepWorktreesAfterMenuClose, subtreeSleepableWorktrees])
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a31e87f3-646b-46fd-9c20-218b5c097f8a
📒 Files selected for processing (7)
src/renderer/src/components/sidebar/WorkspaceSleepMenuItems.tsxsrc/renderer/src/components/sidebar/WorktreeContextMenu.test.tssrc/renderer/src/components/sidebar/WorktreeContextMenu.tsxsrc/renderer/src/components/sidebar/workspace-lineage-menu-actions.test.tssrc/renderer/src/components/sidebar/workspace-lineage-menu-actions.tssrc/renderer/src/i18n/locales/en.jsontests/e2e/worktree-lineage.spec.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/sidebar/WorktreeContextMenu.test.ts
Summary
Screenshots
Testing
pnpm lintpnpm typecheckpnpm test— focused Vitest coverage passed; the full matrix runs in CI.pnpm build— the Electron E2E build passed; packaging runs in CI.Additional validation:
worktree-lineage.spec.tsElectron tests passed, including recursive parent/child PTY cleanup.pnpm run check:code-quality:changedandpnpm run check:react-doctor:changedpassed with zero findings.AI Review Report
Reviewed recursive traversal boundaries, stale/cyclic lineage handling, sleepability filtering, multi-selection behavior, delete pending state, React hook dependencies, and Radix menu teardown ordering. Bot review found duplicated delayed-sleep and screenshot-evidence helpers; both were consolidated and revalidated. CI trace review also found an existing virtualized-marquee test starting on a card under slow-runner layout; the test now starts from guaranteed empty board padding and waits for observable preview state before forcing its large scroll jump.
Cross-platform review covered macOS, Linux, and Windows. This change adds no shortcuts, platform labels, filesystem paths, shell commands, or platform-specific APIs. It uses the existing Electron renderer sleep flow and validated host-aware lineage projection, preserving SSH and folder-workspace behavior.
Security Audit
No new dependency, authentication, secret, command-execution, filesystem-path, or IPC surface is introduced. Workspace IDs come from existing application state; recursive targets are restricted through the existing validated lineage projection before invoking the established sleep flow. No follow-up security work is required.
Notes