perf(renderer): unmount closed workspace cleanup content - #13567
Conversation
📝 WalkthroughWalkthroughThe change extracts workspace cleanup scan and removal behavior into session hooks. The dialog now delegates modal state, selection, filtering, scanning, dismissal, and removal actions to 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f01fac22-3997-4834-b04d-30f0c05f199c
📒 Files selected for processing (6)
src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.mount-gating.test.tsxsrc/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.tsxsrc/renderer/src/components/workspace-cleanup/workspace-cleanup-dialog-session.test.tsxsrc/renderer/src/components/workspace-cleanup/workspace-cleanup-dialog-session.tssrc/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-session.tssrc/renderer/src/components/workspace-cleanup/workspace-cleanup-scan-session.ts
| function formatWorkspaceCleanupReadyToastDescription( | ||
| inactiveCount: number, | ||
| suggestedCount: number | ||
| ): string { | ||
| if (inactiveCount === 0) { | ||
| return 'No inactive workspaces found.' | ||
| } | ||
| const inactiveNoun = inactiveCount === 1 ? 'workspace' : 'workspaces' | ||
| const suggestedNoun = suggestedCount === 1 ? 'suggestion' : 'suggestions' | ||
| return `${inactiveCount} inactive ${inactiveNoun} found, with ${suggestedCount} cleanup ${suggestedNoun}.` | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Localize the ready-toast description.
The toast title and action label use translate(), but this description returns raw English text. The plural choice also uses a two-form ternary, which is wrong for languages with more than two plural forms. Route the description through translate() with interpolated counts and locale keys generated by localize-renderer-strings.mjs (first 10 characters of the SHA-1 of <filePath>:<text>).
Note: src/renderer/src/components/workspace-cleanup/workspace-cleanup-dialog-session.test.tsx Line 98 asserts the literal description text, so update that assertion with the change.
Based on learnings: renderer locale keys are the first 10 characters of the SHA-1 hash of <filePath>:<text>, matching localize-renderer-strings.mjs.
Source: Learnings
ELI5
After the Workspace Cleanup dialog was opened once, closing it hid the pixels but left the whole spreadsheet recalculating behind the curtain. Remote scans stream cumulative candidate lists, so the hidden dialog kept rebuilding review metadata, filtering rows, and running three sorts as those lists grew.
This keeps a tiny session shell alive for the work that really must continue in the background, while unmounting the expensive subscribed content 300 ms after close.
The session shell owns scan completion toasts, deletion progress, confirm-time candidate snapshots, queued-delete cleanup, late-settlement fencing, and the small UI state needed on reopen. The gated content owns the broad store subscriptions and all candidate review/filter/sort projections.
Quantitative proof
useAppStoresubscriptionsDdelete entriesThe deterministic regression fixture closes the dialog, crosses the exact 300 ms boundary, then publishes 300 representative store writes: 100 streamed scans, 100 review-cache updates, and 100 delete-state updates. It observes 0 additional content renders, 0 projections, and only the one session-shell listener above baseline.
It also proves:
For a streamed scan reaching
Ncandidates, the old retained parent could repeat cumulative review/filter/index work across frames and threeO(k log k)sorts per nonempty frame. Unmounting the parent removes that hidden cumulative work entirely.Compatibility
Regression results
ENOENT;This is the Workspace Cleanup counterpart to #13525.