Skip to content

Improve workspace cleanup list - #7053

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/fix-duplicate-clean-badge
Jul 9, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/fix-duplicate-clean-badge

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Simplify workspace cleanup rows into compact icon-first rows with inline expand/collapse details.
  • Keep the deletion modal open during removal with closable in-modal progress like x/n deleted, and only toast when deletion completes or fails.
  • Mark queued cleanup-delete worktrees in the sidebar using the existing disabled/grey delete overlay with Queued for deletion.
  • Stabilize cleanup scan activity/progress, avoid duplicate/unclear git status badges, and use linked worktree gitdir metadata so recently active local worktrees are less likely to be suggested as inactive.
  • Address CodeRabbit cleanup-removal feedback by bounding background row removal, isolating result-callback failures from user-facing removal outcomes, and surfacing all failure messages in the final failure toast.
  • Address the perf audit findings by forwarding abort signals to local and SSH relay git worktree list, making streamed cleanup progress avoid count-only row copies plus repeated full candidate-index rebuilds, preventing stale queued progress from recreating the scan-local index after final completion, and clearing cleanup enrichment cache on final completion.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/workspace-cleanup-activity.test.ts src/main/ipc/workspace-cleanup.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.test.tsx src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.test.ts src/renderer/src/store/slices/workspace-cleanup.test.ts src/renderer/src/store/slices/store-cascades.test.ts src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx
  • pnpm exec vitest run --config config/vitest.config.ts src/main/repo-worktrees.test.ts src/main/ipc/workspace-cleanup-activity.test.ts src/main/ipc/workspace-cleanup.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.test.tsx src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.test.ts src/renderer/src/store/slices/workspace-cleanup.test.ts src/renderer/src/store/slices/store-cascades.test.ts src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx
  • pnpm exec vitest run --config config/vitest.config.ts src/main/repo-worktrees.test.ts src/renderer/src/store/slices/workspace-cleanup.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/workspace-cleanup.test.ts src/main/repo-worktrees.test.ts src/main/ipc/workspace-cleanup.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/relay/git-handler.test.ts src/main/providers/ssh-git-provider.test.ts src/main/repo-worktrees.test.ts src/main/ipc/workspace-cleanup-activity.test.ts src/main/ipc/workspace-cleanup.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.test.tsx src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.test.ts src/renderer/src/store/slices/workspace-cleanup.test.ts src/renderer/src/store/slices/store-cascades.test.ts src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx
  • pnpm exec oxlint src/main/repo-worktrees.ts src/main/repo-worktrees.test.ts src/renderer/src/store/slices/workspace-cleanup.ts src/renderer/src/store/slices/workspace-cleanup.test.ts
  • pnpm exec oxlint src/relay/git-handler.ts src/relay/git-handler.test.ts src/renderer/src/store/slices/workspace-cleanup.ts src/renderer/src/store/slices/workspace-cleanup.test.ts src/main/repo-worktrees.ts src/main/repo-worktrees.test.ts
  • pnpm exec oxlint src/main/ipc/workspace-cleanup-scan.ts src/main/ipc/workspace-cleanup-activity.ts src/main/ipc/workspace-cleanup-activity.test.ts src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-labels.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.test.tsx src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.test.ts src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx src/renderer/src/store/slices/workspace-cleanup.ts src/renderer/src/store/slices/workspace-cleanup.test.ts src/renderer/src/store/slices/worktree-helpers.ts src/renderer/src/store/slices/worktrees.ts src/renderer/src/store/slices/store-cascades.test.ts
  • pnpm run verify:localization-catalog && pnpm run verify:localization-coverage
  • pnpm exec tsgo --noEmit -p config/tsconfig.node.json
  • pnpm run tc:web
  • git diff --check

Screenshots

  • Cleanup dialog compact rows, expanded details, deletion progress modal, and queued sidebar state were captured during manual validation. Evidence images remain local scratch files and are not committed.

AI Review Report

  • Two independent review agents completed a focused review-code pass and reported no issues.
  • A $perf subagent audited commit ddd4525c2 and found two perf issues: dropped local cleanup-scan abort signals and O(N²) renderer append progress. Both were fixed in 4f169a85b; follow-up perf verification found a stale-cache edge fixed in 80635eb0a, then SSH relay cancellation and enrichment-cache retention gaps fixed in 414ee6768.
  • CodeRabbit comments were addressed in ddd4525c2: linked gitdir activity metadata, background-removal timeout guard, result-callback isolation, and aggregate failure descriptions.

Security Audit

  • No new secrets, external network calls, telemetry payloads, or provider-specific credentials are introduced.
  • Activity fallback reads local worktree and linked git metadata only for local repos; SSH cleanup candidates keep using persisted activity/created timestamps.
  • Cleanup removal changes affect renderer-side progress/error handling and do not broaden delete authority.
  • The perf fix forwards abort signals to local and SSH relay git listing; it does not add new process authority or shell execution.

Notes

  • Untracked screenshot evidence files are intentionally excluded from the PR.
  • Background cleanup removal now times out a stalled row after a bounded window so the modal can complete instead of waiting forever.
  • Remaining manual validation gap: no live Windows/WSL/SSH/Electron delete smoke was rerun after the perf fix; deterministic tests cover the changed signal/progress behavior.

@ghost

ghost commented Jul 1, 2026 •

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review 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
📝 Walkthrough

Walkthrough

This PR adds a main-process resolver that recalculates worktree activity timestamps from persisted values and local filesystem mtimes, then uses it during workspace scanning. On the renderer side, the workspace cleanup flow now uses extracted candidate-row, background-removal, dialog, and deletion-state modules, with expanded row support and progress-driven deletion UI. New Vitest tests cover the activity resolver, row-data helpers, background removal flow, scan coordination, and queued-deletion state.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and clearly points to the workspace cleanup list improvements covered by the PR.
Description check ✅ Passed The description is mostly complete and covers summary, testing, review, security, and notes; screenshots are only summarized, not fully filled in.

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: 2

🧹 Nitpick comments (5)
src/main/ipc/workspace-cleanup-activity.ts (1)

24-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant ?? 0 after Number.isFinite guard.

Number.isFinite(worktree.createdAt) ? (worktree.createdAt ?? 0) : 0 — if Number.isFinite returns true, worktree.createdAt is guaranteed non-nullish, making the ?? 0 unreachable. Not a bug, just slightly confusing.

src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts (3)

37-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the status-precedence rationale.

getCandidateStatus encodes a non-obvious priority order (dismissed > ready-tier/archived > first blocker > unpushed-ahead > dirty > review-tier > fallback). A short comment explaining why this ordering was chosen (e.g., why blockers are checked before ahead/dirty state) would help future maintainers avoid breaking the precedence when adding new tiers/blockers.

As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines


103-130: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Hardcoded English strings inconsistent with translate() usage in this file.

formatGitStatus, formatBranchSafetyDetails, formatContextDetails, and getDirtyGitLabel return raw English strings ('Clean git', 'Uncommitted changes', 'unpushed commit(s)', etc.) while getCandidateStatus in the same file routes every label through translate(). These strings feed the same tooltip/chip UI (see workspace-cleanup-candidate-row.tsx Lines 158-186, 164-206), so non-English locales will show a mix of translated and untranslated text.

Also applies to: 172-199


172-199: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate "unpushed commit(s)" formatting.

The pluralized count string is built twice with identical logic (Lines 180-184 and 187-190). Extract a small helper (e.g. formatUnpushedCommitsLabel(count)) to avoid divergence if the format changes later.

♻️ Suggested extraction
+function formatUnpushedCommitsLabel(count: number): string {
+  return `${count} unpushed commit${count === 1 ? '' : 's'}`
+}
+
 export function getDirtyGitLabel(candidate: WorkspaceCleanupCandidate): string | null {
   if (
     candidate.blockers.includes('unknown-base') ||
     candidate.blockers.includes('git-status-error')
   ) {
     return null
   }
   if (candidate.blockers.includes('unpushed-commits')) {
     if (candidate.git.upstreamAhead && candidate.git.upstreamAhead > 0) {
-      return `${candidate.git.upstreamAhead} unpushed commit${
-        candidate.git.upstreamAhead === 1 ? '' : 's'
-      }`
+      return formatUnpushedCommitsLabel(candidate.git.upstreamAhead)
     }
     return 'Unpushed commits'
   }
   if (candidate.git.upstreamAhead && candidate.git.upstreamAhead > 0) {
-    return `${candidate.git.upstreamAhead} unpushed commit${
-      candidate.git.upstreamAhead === 1 ? '' : 's'
-    }`
+    return formatUnpushedCommitsLabel(candidate.git.upstreamAhead)
   }
src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts (1)

1-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for getCandidateStatus and the remaining formatter helpers.

Only getDirtyGitLabel/shouldShowGitMetadataChip are tested. getCandidateStatus has the most complex branching in the module (dismissed/ready/blockers/ahead/dirty/review/fallback) and has no tests here.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8103df78-ec6b-454d-aeb5-d2c0bf4906b2

📥 Commits

Reviewing files that changed from the base of the PR and between 126aae7 and 7a214520798fece45933cf913f0d5cbe6ea3e86d.

📒 Files selected for processing (11)
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx

@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-duplicate-clean-badge branch from 7a21452 to 0ee1a85 Compare July 1, 2026 22:36

@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: Pro

Run ID: ca2ef018-d77d-4fe5-a391-6695cfa70bac

📥 Commits

Reviewing files that changed from the base of the PR and between 7a214520798fece45933cf913f0d5cbe6ea3e86d and 0ee1a8589ebe9793c153e985994b6ee720e59b4c.

📒 Files selected for processing (11)
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx

@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-duplicate-clean-badge branch from 0ee1a85 to 490d2b8 Compare July 1, 2026 22:51

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

🧹 Nitpick comments (2)
src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx (2)

216-216: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document why in-flight removal skips dialog resets.

This ref guards multiple reset effects while deletion continues in the background; add a short Why: comment near the ref or first guard so future edits don’t accidentally clear progress/confirmation state. As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Suggested comment
-  const removalInFlightRef = useRef(false)
+  // Why: removal can continue after the modal closes/reopens, so reset effects
+  // must not clear confirmation/progress state until callbacks finish.
+  const removalInFlightRef = useRef(false)

Also applies to: 286-295, 340-342

Source: Coding guidelines


1163-1191: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Keep pluralized UI strings inside translate.

The new titles/buttons/progress text build English workspace/workspaces outside translation, so non-English locales can’t control plural grammar or word order. Prefer singular/plural translated fallbacks or a whole-sentence translation with count interpolation.

Also applies to: 1258-1277, 1407-1414


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 41ab5311-c5a0-4feb-915f-a75e49bdf3d2

📥 Commits

Reviewing files that changed from the base of the PR and between 0ee1a8589ebe9793c153e985994b6ee720e59b4c and 490d2b8.

📒 Files selected for processing (11)
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts

@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-duplicate-clean-badge branch from 490d2b8 to dbccaf4 Compare July 2, 2026 01:18

@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: Pro

Run ID: 17289e4d-401e-4601-ab63-a6b85896d8ac

📥 Commits

Reviewing files that changed from the base of the PR and between 490d2b8 and dbccaf4.

📒 Files selected for processing (15)
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
  • src/renderer/src/store/slices/store-cascades.test.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktrees.ts
✅ Files skipped from review due to trivial changes (2)
  • src/renderer/src/components/sidebar/WorktreeCard.tsx
  • src/renderer/src/store/slices/store-cascades.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-details.tsx
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx (1)

550-562: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add a "why" comment for the queued-phase clear logic.

The condition deleteState?.isDeleting && deleteState.error === null && deleteState.phase === 'queued' is subtle — it specifically targets candidates whose store delete-state was set to queued by markWorktreesQueuedForDeletion but never progressed (e.g. skipped because an ancestor failed, per startWorkspaceCleanupBackgroundRemoval's ancestor-skip path), so they'd otherwise be stuck showing the sidebar's "Queued for deletion" overlay forever. Without a short comment, this looks like dead/defensive code a future refactor could easily strip out.

📝 Suggested comment
         for (const failure of result.failures) {
           nextFailures[failure.worktreeId] = failure.message
           const deleteState = useAppStore.getState().deleteStateByWorktreeId[failure.worktreeId]
+          // Why: candidates skipped because a nested workspace failed (or that
+          // errored before removeCandidates ever ran) never transition past the
+          // 'queued' phase set by markWorktreesQueuedForDeletion above; clear it
+          // so the sidebar doesn't show a permanent "Queued for deletion" overlay.
           if (
             deleteState?.isDeleting &&
             deleteState.error === null &&
             deleteState.phase === 'queued'
           ) {

As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."

Source: Coding guidelines

🧹 Nitpick comments (3)
src/main/ipc/workspace-cleanup-scan.ts (1)

187-210: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate persisted-activity calculation.

getPersistedWorkspaceCleanupActivityAt re-implements the same Math.max(lastActivityAt, createdAt) finite-guard logic already present in resolveWorkspaceCleanupActivityAt (workspace-cleanup-activity.ts, lines 38-39). Consider exporting a single shared helper from workspace-cleanup-activity.ts and reusing it here to avoid the two copies drifting.

src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.ts (1)

3-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider importing the shared delete-state type instead of a local duplicate.

This file re-declares a minimal DeleteState shape rather than deriving it from the worktree slice's actual delete-state type. Works today via structural typing, but a future rename of isDeleting in the source type wouldn't be caught here.

src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts (1)

1-352: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

LGTM! Tests thoroughly cover ordering, ancestor-skip, timeout, and toast-aggregation behavior.

Given the empty-candidates gap flagged in workspace-cleanup-background-removal.ts (lines 31-41), consider adding a regression test asserting onResult still fires with {removedIds: [], failures: []} when candidates is empty.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f26e4032-31ef-49be-ad44-e295cb27d00a

📥 Commits

Reviewing files that changed from the base of the PR and between dbccaf4 and ddd4525.

📒 Files selected for processing (25)
  • src/main/ipc/workspace-cleanup-activity.test.ts
  • src/main/ipc/workspace-cleanup-activity.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/main/ipc/workspace-cleanup.test.ts
  • src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-labels.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.test.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.test.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/store/slices/store-cascades.test.ts
  • src/renderer/src/store/slices/workspace-cleanup.test.ts
  • src/renderer/src/store/slices/workspace-cleanup.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktrees.ts
✅ Files skipped from review due to trivial changes (2)
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/es.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-status-pill.tsx
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row.tsx
  • src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-row-data.ts

brennanb2025 and others added 9 commits July 9, 2026 13:33
- Fail a queued removal that now needs a force the user never approved
  (confirm-time approvedCandidates snapshot compared in preflight)
- Reword the 120s removal timeout to say removal continues in background
- Wire suppressPreservedBranchToast into cleanup removals
- Stop statting a repo after the first activity metadata timeout
- Document the WSL 9P best-effort stat gap; drop unused locale key

Co-authored-by: Orca <[email protected]>
Rebasing onto latest main pushed the combined store-slice test over the
800-line cap. Extract shared fixtures into a test harness and split the
suite into scan-progress and removal-preflight files instead of adding a
forbidden max-lines suppression.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-duplicate-clean-badge branch from a4aa7fc to 303f295 Compare July 9, 2026 23:01
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Reviewed and de-staled this end to end.

Rebase / conflicts: branch was 457 commits behind main; rebased all commits onto latest and resolved 3 conflicts (merged the two removeWorktree option sets into one signature, kept forgetLocalOnly, and dropped a now-forbidden max-lines disable). Rebasing pushed the store-slice test past the 800-line cap, so it was split into a shared test harness + two focused test files rather than suppressed.

Verification: full typecheck, oxlint on all changed files, max-lines ratchet, 360 affected tests, and localization catalog/coverage all pass.

Perf: all claimed fixes verified to hold — abort-signal forwarding to git worktree list (local + SSH, the real root-cause fix), progress-index rebuild elimination, count-only copy avoidance, enrichment-cache clearing, and stale-progress guarding; no timer/listener leaks. One accepted future-optimization gap: the scan still streams one candidate per event, so very large candidate counts hit an O(N²) copy/re-render — not a defect at realistic scale.

Code review: two independent reviewers, both clean. One accepted low nit: a nested removal that exceeds the 120s timeout is tallied as a hard failure even though it keeps running in the background (conservative/safe, rare edge).

Electron validation: exercised live with real backdated worktrees (no faked data) — compact rows, expand/collapse, the stay-open deletion progress modal (x/n deleted, toast only on completion), the "Queued for deletion" sidebar overlay (no spinner), not-suggested chips, confirm modal, and empty state all verified. Full-page screenshots captured for review.

Merging once checks are green.

@brennanb2025
brennanb2025 merged commit e7ee15f into main Jul 9, 2026
1 check passed
Jinwoo-H added a commit that referenced this pull request Jul 10, 2026
Clean auto-merge, no conflicts (109 files, +7490 from main). Brought in:
- Codex WSL runtime status hooks (#7969); WSL/SSH agent path resolution past
  shell aliases (#7867); WSL source-control path separators (#7966); WSL
  GitLab-auth wake fix (#7967); WSL Codex usage RPC refresh (#7567/#7658)
- Improve workspace cleanup list (#7053) + background removal
- mobile: per-host connection log + Tailscale wedge recovery (#7984/#7980),
  wake slept agents on mobile worktree open (#7906)
- Harden layout validation, watcher lifecycle, connection robustness (#7924)
- Disable experimental worktree card style by default (#7977)

Perf-branch structure preserved (clean auto-merge). typecheck 0 errors; lint 0
errors. CI is the release gate (local runs skipped per env lag).

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Improve workspace cleanup list

Co-authored-by: Orca <[email protected]>

* Address workspace cleanup review feedback

Co-authored-by: Orca <[email protected]>

* Fix workspace cleanup perf findings

Co-authored-by: Orca <[email protected]>

* Avoid stale cleanup progress cache

Co-authored-by: Orca <[email protected]>

* Complete workspace cleanup perf fixes

Co-authored-by: Orca <[email protected]>

* Fix worktree list option forwarding

Co-authored-by: Orca <[email protected]>

* Address workspace cleanup review nits

Co-authored-by: Orca <[email protected]>

* Fix workspace cleanup removal review findings

- Fail a queued removal that now needs a force the user never approved
  (confirm-time approvedCandidates snapshot compared in preflight)
- Reword the 120s removal timeout to say removal continues in background
- Wire suppressPreservedBranchToast into cleanup removals
- Stop statting a repo after the first activity metadata timeout
- Document the WSL 9P best-effort stat gap; drop unused locale key

Co-authored-by: Orca <[email protected]>

* Split workspace-cleanup slice test to satisfy max-lines

Rebasing onto latest main pushed the combined store-slice test over the
800-line cap. Extract shared fixtures into a test harness and split the
suite into scan-progress and removal-preflight files instead of adding a
forbidden max-lines suppression.

---------

Co-authored-by: Orca <[email protected]>
Co-authored-by: Brennan Benson <[email protected]>
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.

1 participant