Repository navigation
feat(workspaces): rework cleanup discovery and dialog - #13413
Conversation
852db45 to
4788f10
Compare
Updated Electron QA: Resource Manager entry pointThe inaccurate inactive-workspace count is removed. The entry now reads Clean up workspaces, and the separate Space → Scan action supplies the disk-size facts used by cleanup filtering and sorting. Full locationControl close-upValidated on pushed commit |
…ilter-finder' into brennanb2025/review-pr-13405-snapshots
…napshots' into brennanb2025/review-pr-13406-filter-model # Conflicts: # src/shared/workspace-cleanup.ts
Electron CDP QA (post-review) — head
|
| Check | Result |
|---|---|
| App identity matches this worktree | Pass |
| Flat fleet list + row facts (activity, size, git) | Pass — Showing 592 of 592 |
| Filters popover (ACTIVITY/SIZE/STATUS/AGENT/GIT/…) | Pass |
Sort menu → Size; browse state field: size |
Pass |
Search review-pr-13413 → 1 of 592 |
Pass |
| Open workspace external-link action | Pass — dialog closes; Explorer shows this worktree files; selected id set |
| Console/app logs | No product UI regression on normal paths |
Screenshots
Local evidence (clean real-UI captures only for PR): uncropped full-window screenshots via CDP.
…napshots' into brennanb2025/review-pr-13406-filter-model
…ilter-model' into brennanb2025/review-pr-13413-dialog-ui
Electron CDP QA (follow-up after CI isolation fix) — head
|
| Check | Result |
|---|---|
| App identity matches this worktree + exact head | Pass |
| Flat fleet list + row facts (activity, size, git, repo, branch, path) | Pass — Showing 593 of 593 |
| No presets / no Ready badge | Pass |
| Filters popover (ACTIVITY / SIZE ON DISK / WORKSPACE STATUS / AGENT / LOCAL CONTEXT / GIT / REVIEW / TICKET) | Pass |
Sort menu → Size; browse state field: size |
Pass — label Sort by Size |
Search review-pr-13413 |
Pass — Showing 1 of 593 |
| Refresh scan/cache | Pass — new scanId; query retained |
| Open workspace (external-link) | Pass — dialog closes; Explorer shows worktree files; selected id ends with this path |
| Console / app logs | No product UI regression on exercised paths (env noise only: Claude 429, orchestration legacy recovery, MaxListeners) |
Screenshots
Full-window uncropped CDP captures (3456×2024) with surrounding app context — not committed to the diff.
Remaining gaps
- Did not run destructive delete/confirm-remove end-to-end
- Did not measure disk sizes (
Measure sizesleft unmeasured) - Windows / Linux not covered in this macOS CDP run
Exact-head UI evidence — Resource Manager entry points (PR #13413)Head: In Resource Manager, Scan and Clean up workspaces are separate controls:
Local path: Workspace scan in progressThe broad scan now reflects its actual scope: it collects information for all workspaces, reports progress, and can be closed and reopened while work continues. \n### After review feedback — scan progress\n\nThe progress count now uses the same typography in one label: Scanning workspaces (23/3048). The dialog also states that it can be closed and reopened while scanning continues.\n\n |
…nd dialog Correctness: - Chunk git-evidence dispatches at the shared 500-target limit and exclude queued/in-flight ids from target selection, so fleets past the limit can no longer strand rows permanently mislabeled as checked-but-unknown. - Key destructive selection pruning on the user's filter state instead of the per-tick matched-set identity; streaming reclassification no longer silently deselects rows. - Clamp the facet clock to max(scannedAt, open time): a stale hydrated snapshot no longer misbuckets idle thresholds or keeps dead agents fresh; row labels use the same clock. - Supersede and cancel the previous broad scan when a new one starts (renderer registry and same-sender guard in main) instead of racing two fleet scans. - Gate snapshot persistence on hasTargetedWorkspaceCleanupScan so worktreeIds: [] can never persist an empty fleet snapshot. - Re-apply dismissals at set-time in progress application so a dismissal landing mid-enrichment is not clobbered. - Record a one-off local snapshot prune for single (unbatched) remote deletes so removed workspaces cannot resurrect from cache. - Strip .exe when normalizing foreground process names so Windows agent processes match. Performance: - Cache per-candidate facet and review-info objects on candidate identity; no-op streaming ticks reuse the previous rows array and skip every downstream pass; matched-set identity is stable under equal membership. - Compute facet counts/options only while the filter popover is open. - Equality-bail git-evidence publishes; structural (non-stringify) facet-group comparison memoized in the toolbar. - Identity-token fast path for the enrichment cache (cache hits skip both JSON.stringify signatures); prune viewed/dismissal records on removal and expiry; bound the superseded-scan-id set. - Restore the no-op bail in removeWorkspaceSpaceWorktrees (regression). - Abort main-side scans when the renderer is destroyed; module-scope controller maps survive handler re-registration. - Batch removal preflight into one targeted scan (with refreshActivity) per 500 ids instead of one scan per row. - Scan repos at concurrency 2, report discovered counts upfront for honest progress, share fs-activity probes per path (folder workspaces), read only the reflog tail, and skip the snapshot read-before-write via a remembered scannedAt. Split workspace-cleanup-worktree-listing, workspace-cleanup-facet-row-caches, and workspace-cleanup-selection-model out of files that crossed max-lines.
- Fall back to a full reflog read when the newest record exceeds the 8KB tail window, so an oversized subject cannot hide recent ref activity. - Bound the single-removal snapshot prune batch id with a UUID; embedding the unbounded worktreeId silently failed main's 128-char validation and skipped the prune for long remote ids. - Key the main-side broad-scan supersession by sender AND scan mode so legacy suggestion-only and full-workspace scans stay isolated, matching the renderer registry.
Electron QA @ d0fe1c7Isolated Electron QA on exact head Instance (owned, not the live Orca app):
Verdict: all 7 scenarios passed. 1. Broad scan streams — PASSFirst open streamed rows with an honest discovered total, not a fake ~100% bar. Visible/store samples during refresh:
2. Filters popover + search — PASS
3. Selection stable while streaming; prunes on facet change — PASSDuring a live rescan (
Facet prune (separate from stream ticks):
4. Sort while streaming — PASSClicked Refresh ( 5. Last-active labels vs idle bucketing — PASSRelative-time chips are compact ( With idle signal No activity and threshold 33 days, every remaining row was labeled 33d–35d — same clock as the idle bucket. Confirm screen repeated those same labels ( 6. Delete confirmation — then CANCEL — PASSEntered Delete workspaces: 9? with the selected real workspaces listed. Screenshot taken. Clicked Cancel. Dialog returned to the browse list ( 7. Git: Clean filter + Checking git status — PASSEnabled Git → Clean after a refresh that had reset evidence to unknown.
No source files were modified. Isolated QA instance only. |
…er-time ref writes React Doctor (CI changed-lines gate) correctly flagged the three cache refs written during render. Each per-candidate cache now lives in one memo with the derived context it is keyed on, so the memo deps are the invalidation and interior fills stay content-addressed; the matched-set identity stabilization is dropped since its only consumer reads through a useEffectEvent and never keys on identity.
…e-cleanup-dialog # Conflicts: # src/main/ipc/workspace-cleanup-disconnected-ssh.ts # src/main/ipc/workspace-cleanup-scan.ts # src/preload/api-types.ts
…e-cleanup-dialog # Conflicts: # src/main/ipc/workspace-cleanup-candidate.ts # src/main/ipc/worktrees.ts # src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts # src/renderer/src/components/workspace-cleanup/inactive-workspace-estimate.test.ts # src/renderer/src/components/workspace-cleanup/inactive-workspace-estimate.ts # src/renderer/src/store/slices/diffComments.test.ts
Squashed integration of PR #14606 + the codex review-loop output, replayed onto current main. Granular history preserved on brennanb2025/sta-4343-review-full. Fixes the regression from #13413: a workspace id is repoId::path with no host component, so the same repo at the same path on two hosts published one id for two workspaces, and deletion routed by that id landed on whichever host routing preferred - usually the ACTIVE one, not the row the user confirmed. - removeWorktree takes a REQUIRED host-qualified WorktreeRemovalTarget; omitting the host is a type error. All destructive callers migrated. - Projections dedup on (host, id), so two hosts render as two selectable rows while the createWorktree/fetchWorktrees race duplicate still collapses. - Ephemeral VM cleanup is host-scoped. It matched on bare workspaceId, so the host-scoped delete path destroyed the SURVIVING host's VM and its unpushed filesystem - a leak fix that had become data destruction. - Selection, keyboard routing, lineage grouping and Space rows carry host identity end to end; fixing the executor dedupe alone would have turned one-row intent into deleting both hosts. Files split to stay under max-lines rather than raising any cap.
…ows selectable (STA-4343) (#15013) * fix(workspaces): host-qualified workspace deletion (STA-4343, STA-4448) Squashed integration of PR #14606 + the codex review-loop output, replayed onto current main. Granular history preserved on brennanb2025/sta-4343-review-full. Fixes the regression from #13413: a workspace id is repoId::path with no host component, so the same repo at the same path on two hosts published one id for two workspaces, and deletion routed by that id landed on whichever host routing preferred - usually the ACTIVE one, not the row the user confirmed. - removeWorktree takes a REQUIRED host-qualified WorktreeRemovalTarget; omitting the host is a type error. All destructive callers migrated. - Projections dedup on (host, id), so two hosts render as two selectable rows while the createWorktree/fetchWorktrees race duplicate still collapses. - Ephemeral VM cleanup is host-scoped. It matched on bare workspaceId, so the host-scoped delete path destroyed the SURVIVING host's VM and its unpushed filesystem - a leak fix that had become data destruction. - Selection, keyboard routing, lineage grouping and Space rows carry host identity end to end; fixing the executor dedupe alone would have turned one-row intent into deleting both hosts. Files split to stay under max-lines rather than raising any cap. * refactor: split files that crossed max-lines The review-loop commits used --no-verify, so the pre-commit hook never enforced the caps. Extracted cohesive units rather than raising any limit: renderer teardown, delete-with-toast, pinned-group rows, host-scope helpers, workspace-kind predicates, filter actions, kanban drag selection, the renderer removal result type, and the native-chat persistence tests. * refactor(workspaces): extract cleanup deletion-phase selector Clears the last max-lines violation and the import-type side effect the changed-code gate flagged. * refactor(sidebar): track the delete-dialog extraction modules * fix(workspaces): preserve host identity across remaining surfaces * fix(sidebar): re-carry host through the rewritten palette result model #15170 replaced PaletteSearchResult while this PR was open. Re-applied the host qualification on top of the new model instead of taking either side: results carry worktreeHostId again, and the board filter keys its matched set on host identity rather than the bare id. Known gap, documented in the board test rather than deleted: searchWorktrees resolves evidence through a `documents` map keyed by BARE worktree id, so two same-id host rows collapse before this code sees them. Closing that belongs with the palette work. * test(cmd-j): pin the palette collision gap instead of asserting the old model The palette collision test asserted two host-qualified rows, which #15170's rewrite made unreachable: item ids are bare again and worktreeMap is id-keyed. Rewritten to assert what holds — activation always names a host — and to pin the defect it exposes: two same-id rows render on ONE command value, so React sees duplicate keys and a click on the first row activates the second row's host. That reproduces on main, so it is pre-existing, not from this PR. Pinned rather than deleted so fixing it must update this test. --------- Co-authored-by: QA <qa@local>
…ows selectable (STA-4343) (stablyai#15013) * fix(workspaces): host-qualified workspace deletion (STA-4343, STA-4448) Squashed integration of PR stablyai#14606 + the codex review-loop output, replayed onto current main. Granular history preserved on brennanb2025/sta-4343-review-full. Fixes the regression from stablyai#13413: a workspace id is repoId::path with no host component, so the same repo at the same path on two hosts published one id for two workspaces, and deletion routed by that id landed on whichever host routing preferred - usually the ACTIVE one, not the row the user confirmed. - removeWorktree takes a REQUIRED host-qualified WorktreeRemovalTarget; omitting the host is a type error. All destructive callers migrated. - Projections dedup on (host, id), so two hosts render as two selectable rows while the createWorktree/fetchWorktrees race duplicate still collapses. - Ephemeral VM cleanup is host-scoped. It matched on bare workspaceId, so the host-scoped delete path destroyed the SURVIVING host's VM and its unpushed filesystem - a leak fix that had become data destruction. - Selection, keyboard routing, lineage grouping and Space rows carry host identity end to end; fixing the executor dedupe alone would have turned one-row intent into deleting both hosts. Files split to stay under max-lines rather than raising any cap. * refactor: split files that crossed max-lines The review-loop commits used --no-verify, so the pre-commit hook never enforced the caps. Extracted cohesive units rather than raising any limit: renderer teardown, delete-with-toast, pinned-group rows, host-scope helpers, workspace-kind predicates, filter actions, kanban drag selection, the renderer removal result type, and the native-chat persistence tests. * refactor(workspaces): extract cleanup deletion-phase selector Clears the last max-lines violation and the import-type side effect the changed-code gate flagged. * refactor(sidebar): track the delete-dialog extraction modules * fix(workspaces): preserve host identity across remaining surfaces * fix(sidebar): re-carry host through the rewritten palette result model stablyai#15170 replaced PaletteSearchResult while this PR was open. Re-applied the host qualification on top of the new model instead of taking either side: results carry worktreeHostId again, and the board filter keys its matched set on host identity rather than the bare id. Known gap, documented in the board test rather than deleted: searchWorktrees resolves evidence through a `documents` map keyed by BARE worktree id, so two same-id host rows collapse before this code sees them. Closing that belongs with the palette work. * test(cmd-j): pin the palette collision gap instead of asserting the old model The palette collision test asserted two host-qualified rows, which stablyai#15170's rewrite made unreachable: item ids are bare again and worktreeMap is id-keyed. Rewritten to assert what holds — activation always names a host — and to pin the defect it exposes: two same-id rows render on ONE command value, so React sees duplicate keys and a click on the first row activates the second row's host. That reproduces on main, so it is pre-existing, not from this PR. Pinned rather than deleted so fixing it must update this test. --------- Co-authored-by: QA <qa@local>
* fix(workspaces): support full cleanup scans * feat(workspaces): persist cleanup snapshots * feat(workspaces): add cleanup filter model * refactor(workspaces): remove cleanup presets * feat(workspaces): rework cleanup dialog * fix(workspaces): keep cleanup row ordering render-pure * refactor(workspaces): simplify cleanup browsing * refactor(workspaces): show cleanup facts * refactor(workspaces): surface cleanup row facts * fix(workspaces): remove misleading cleanup count * fix(workspaces): preserve full scan semantics * fix(workspaces): scope snapshot persistence * fix(workspaces): preserve cleanup browse compatibility * fix(workspaces): reconcile cleanup dialog state * test(workspaces): update snapshot store fixtures * test(workspaces): preserve cleanup scan modes * perf(workspace-cleanup): stream scan progress and size results * fix(workspace-cleanup): address review feedback * fix(workspace-cleanup): preserve host-scoped cleanup metadata * fix(workspace-cleanup): declare review source dependencies * fix(workspace-cleanup): align size scan banner * fix(workspace-cleanup): shorten scan action * perf(workspace-cleanup): avoid redundant scan IO * perf(workspace-cleanup): bound restarted evidence scans * fix(workspace-cleanup): satisfy scan queue lint * perf(workspace-cleanup): bound scan and snapshot work * perf(workspace-cleanup): serialize final enrichment * test(workspace-cleanup): assert final enrichment drain * fix(workspace-cleanup): stop progress after renderer teardown * perf: batch workspace cleanup git evidence scans * perf(workspace-cleanup): stop redundant snapshot and scan work * fix(workspace-cleanup): resolve review findings across scan, store, and dialog Correctness: - Chunk git-evidence dispatches at the shared 500-target limit and exclude queued/in-flight ids from target selection, so fleets past the limit can no longer strand rows permanently mislabeled as checked-but-unknown. - Key destructive selection pruning on the user's filter state instead of the per-tick matched-set identity; streaming reclassification no longer silently deselects rows. - Clamp the facet clock to max(scannedAt, open time): a stale hydrated snapshot no longer misbuckets idle thresholds or keeps dead agents fresh; row labels use the same clock. - Supersede and cancel the previous broad scan when a new one starts (renderer registry and same-sender guard in main) instead of racing two fleet scans. - Gate snapshot persistence on hasTargetedWorkspaceCleanupScan so worktreeIds: [] can never persist an empty fleet snapshot. - Re-apply dismissals at set-time in progress application so a dismissal landing mid-enrichment is not clobbered. - Record a one-off local snapshot prune for single (unbatched) remote deletes so removed workspaces cannot resurrect from cache. - Strip .exe when normalizing foreground process names so Windows agent processes match. Performance: - Cache per-candidate facet and review-info objects on candidate identity; no-op streaming ticks reuse the previous rows array and skip every downstream pass; matched-set identity is stable under equal membership. - Compute facet counts/options only while the filter popover is open. - Equality-bail git-evidence publishes; structural (non-stringify) facet-group comparison memoized in the toolbar. - Identity-token fast path for the enrichment cache (cache hits skip both JSON.stringify signatures); prune viewed/dismissal records on removal and expiry; bound the superseded-scan-id set. - Restore the no-op bail in removeWorkspaceSpaceWorktrees (regression). - Abort main-side scans when the renderer is destroyed; module-scope controller maps survive handler re-registration. - Batch removal preflight into one targeted scan (with refreshActivity) per 500 ids instead of one scan per row. - Scan repos at concurrency 2, report discovered counts upfront for honest progress, share fs-activity probes per path (folder workspaces), read only the reflog tail, and skip the snapshot read-before-write via a remembered scannedAt. Split workspace-cleanup-worktree-listing, workspace-cleanup-facet-row-caches, and workspace-cleanup-selection-model out of files that crossed max-lines. * fix(workspace-cleanup): address verifier findings - Fall back to a full reflog read when the newest record exceeds the 8KB tail window, so an oversized subject cannot hide recent ref activity. - Bound the single-removal snapshot prune batch id with a UUID; embedding the unbounded worktreeId silently failed main's 128-char validation and skipped the prune for long remote ids. - Key the main-side broad-scan supersession by sender AND scan mode so legacy suggestion-only and full-workspace scans stay isolated, matching the renderer registry. * fix(workspace-cleanup): own facet caches with useMemo instead of render-time ref writes React Doctor (CI changed-lines gate) correctly flagged the three cache refs written during render. Each per-candidate cache now lives in one memo with the derived context it is keyed on, so the memo deps are the invalidation and interior fills stay content-addressed; the matched-set identity stabilization is dropped since its only consumer reads through a useEffectEvent and never keys on identity.
…ows selectable (STA-4343) (stablyai#15013) * fix(workspaces): host-qualified workspace deletion (STA-4343, STA-4448) Squashed integration of PR stablyai#14606 + the codex review-loop output, replayed onto current main. Granular history preserved on brennanb2025/sta-4343-review-full. Fixes the regression from stablyai#13413: a workspace id is repoId::path with no host component, so the same repo at the same path on two hosts published one id for two workspaces, and deletion routed by that id landed on whichever host routing preferred - usually the ACTIVE one, not the row the user confirmed. - removeWorktree takes a REQUIRED host-qualified WorktreeRemovalTarget; omitting the host is a type error. All destructive callers migrated. - Projections dedup on (host, id), so two hosts render as two selectable rows while the createWorktree/fetchWorktrees race duplicate still collapses. - Ephemeral VM cleanup is host-scoped. It matched on bare workspaceId, so the host-scoped delete path destroyed the SURVIVING host's VM and its unpushed filesystem - a leak fix that had become data destruction. - Selection, keyboard routing, lineage grouping and Space rows carry host identity end to end; fixing the executor dedupe alone would have turned one-row intent into deleting both hosts. Files split to stay under max-lines rather than raising any cap. * refactor: split files that crossed max-lines The review-loop commits used --no-verify, so the pre-commit hook never enforced the caps. Extracted cohesive units rather than raising any limit: renderer teardown, delete-with-toast, pinned-group rows, host-scope helpers, workspace-kind predicates, filter actions, kanban drag selection, the renderer removal result type, and the native-chat persistence tests. * refactor(workspaces): extract cleanup deletion-phase selector Clears the last max-lines violation and the import-type side effect the changed-code gate flagged. * refactor(sidebar): track the delete-dialog extraction modules * fix(workspaces): preserve host identity across remaining surfaces * fix(sidebar): re-carry host through the rewritten palette result model stablyai#15170 replaced PaletteSearchResult while this PR was open. Re-applied the host qualification on top of the new model instead of taking either side: results carry worktreeHostId again, and the board filter keys its matched set on host identity rather than the bare id. Known gap, documented in the board test rather than deleted: searchWorktrees resolves evidence through a `documents` map keyed by BARE worktree id, so two same-id host rows collapse before this code sees them. Closing that belongs with the palette work. * test(cmd-j): pin the palette collision gap instead of asserting the old model The palette collision test asserted two host-qualified rows, which stablyai#15170's rewrite made unreachable: item ids are bare again and worktreeMap is id-keyed. Rewritten to assert what holds — activation always names a host — and to pin the defect it exposes: two same-id rows render on ONE command value, so React sees duplicate keys and a click on the first row activates the second row's host. That reproduces on main, so it is pre-existing, not from this PR. Pinned rather than deleted so fixing it must update this test. --------- Co-authored-by: QA <qa@local>
































Summary
Reworks workspace cleanup into one flat, filterable list of every workspace and fixes the scan behavior that previously omitted valid rows.
Screenshots
All workspaces with search, filter, and sort controls:
Collapsed row with configured status and decision-critical facts:
Filters popover:
Sort menu:
Search results:
Additional exact-head Electron evidence:
Testing
pnpm lintpnpm run typecheck:tscnpx react-doctor@latest --verboseon changed lines: zero errors; advisory warnings reviewedAI Review Report
Each layer was reviewed to clean by same-model subagents, with focused follow-up review after fixes. The review checked legacy scan parity, optional-field remote compatibility, SSH and folder-workspace behavior, workspace identity, cache isolation and durable writes, stale cache/live-scan races, in-flight scan adoption, selection safety, deferred Git evidence, filter/sort persistence, accessibility, destructive-action gating, and render hot paths.
Findings fixed during review included SSH folder classification and disconnected paths, scan-key collisions, profile/host snapshot isolation, stale snapshot resurrection, orphan temporary files, deferred-evidence reconciliation, stale generations, size recovery, accessibility labeling, and the React Doctor hook error. Cross-platform review explicitly covered macOS, Linux, and Windows, including paths, shell behavior, shortcuts and labels, Electron behavior, Git-provider-neutral review naming, SSH hosts, and folder workspaces.
Security Audit
Reviewed persisted JSON as untrusted input, fixed sidecar path construction, atomic writes, payload bounds, typed IPC exposure, search/filter input, Git invocation boundaries, deletion preflight, auth/secrets, dependencies, and cached/live identity reconciliation.
Snapshots use fixed filenames, versioned shape validation, bounded payloads, and the existing durable-file primitive. Search and facet values remain typed renderer state and are not interpolated into commands. Removal remains explicitly selected, confirmation-gated, candidate-ID based, and revalidated before execution. The change adds no raw shell execution, credential handling, secrets, or dependencies.
Notes
includeAllWorkspacesis explicitly true.