Repository navigation
feat(file-explorer): confirm multi-select deletes with a single batch prompt - #7459
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 (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds batch-delete helpers for file explorer selections, wires them into Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant requestDeleteAll
participant runBatchDeletion
participant runDelete
User->>requestDeleteAll: trigger delete-all
requestDeleteAll->>runBatchDeletion: roots, confirmBatch
runBatchDeletion->>runDelete: delete node (skipConfirmation: true)
runDelete-->>runBatchDeletion: success/failure
runBatchDeletion-->>requestDeleteAll: deletedRoots or null
Related issues: None found in provided context. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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: 2
🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/useFileDeletion.ts (1)
75-98: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate
isRemotederivation betweenisRemoteDeletionandrunDelete.Both
isRemoteDeletion(Lines 75-81) and the start ofrunDelete(Lines 90-92) independently callgetDeletionContext()and recomputeconnectionId !== undefined || isRemoteRuntimeFileOperation(fileContext, node.path)the same way. Consider havingrunDeletereuseisRemoteDeletion(node)(while still keepingfileContext/connectionIdfromgetDeletionContext()for the rest of the function) to avoid the two copies drifting apart if the remote-classification logic changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1c0e5cfb-1342-4c3e-8498-46a5a76da883
📒 Files selected for processing (8)
src/renderer/src/components/right-sidebar/file-explorer-batch-deletion.test.tssrc/renderer/src/components/right-sidebar/file-explorer-batch-deletion.tssrc/renderer/src/components/right-sidebar/useFileDeletion.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
… prompt
Deleting a multi-file selection on a remote host prompted once per file:
requestDeleteAll awaited runDelete per root, and the remote-delete
confirmation lived inside runDelete. Hoist the confirmation for batches —
one 'Permanently delete {{count}} items?' dialog up front, then per-node
deletes with skipConfirmation. Single-file and local (Trash) deletes are
unchanged. Root filtering and the batch loop move to
file-explorer-batch-deletion.ts with unit coverage.
Fixes stablyai#7457
Address review: roots.length undercounts when a selected directory's children are also selected (could even read 'delete 1 items?'). Use the visible selection size instead. Also reword the zh strings so 项目 cannot read as 'project' in a file-delete flow.
Narrow the batch-confirm gate to a resolvable remote route so an unresolved-owner multi-select no longer pops a destructive prompt for deletes that fail closed anyway — mirroring the single-delete path. Co-authored-by: Orca <help@stably.ai>
69f250e to
75aabbf
Compare
AmethystLiang
left a comment
There was a problem hiding this comment.
Thanks for this — the batch-confirm consolidation is a real UX win for remote deletes, and the extraction into a testable file-explorer-batch-deletion.ts with unit coverage is exactly the right shape.
I rebased the branch onto latest main and resolved the conflicts: since you opened this, the delete path was refactored so remote-ness is determined per-node via node.operationOwner (kind !== 'local') instead of the old worktree-level connectionId/isRemoteRuntimeFileOperation check. I re-expressed the batch remote check on top of that model — the intent is unchanged.
One small fix on top: I narrowed the batch-confirm gate to a resolvable remote route (needsRemoteDeleteConfirmation). Previously an unresolved-owner multi-select would pop the destructive "Permanently delete N items?" dialog and then fail every node (route is null → throws), which the single-delete path never does. Now the batch mirrors the single path — no prompt, just the error toast — locked with a regression test.
Verified: typecheck, lint (incl. localization parity across all 5 locales), 16 tests green (your 8 batch tests + the two existing hook-level delete suites + the new unresolved-owner case), plus independent review and a perf pass (net reduction in work, no new hot-path cost).
Merging once checks are green.
* fix: work-item naming, usage % rounding, and terminal/delete copy Address prod-release-scan P2s: - #8238: recognize Bitbucket Server (/projects|users/.../repos/.../pull-requests/N) and Azure DevOps (/_git/REPO/pullrequest/N) PR URL shapes in work-item-reference, alongside Bitbucket Cloud; graceful fallback preserved. - #7574: getDisplayedUsagePercentage now rounds the used value before taking the `remaining` complement, so the compact status bar (raw usedPercent) and tooltip (pre-rounded clampUsedPercent) can no longer disagree by 1% at a .5 fraction. clampUsedPercent moves to the shared module as the single rounding source. - #7459: mixed remote+local batch delete confirm no longer claims the whole batch is a permanent "remote host" delete — it now states remote items are permanent while local items move to the Trash/Recycle Bin. - #8322: right-click-to-paste settings copy is platform-aware — "Control-click" on macOS, "Ctrl+right-click" on Windows/Linux — matching the ctrlKey gate. Localization catalog synced (also picks up pre-existing UsagePercentageDisplayChangeNotice drift). * Fix NaN% usage bar and label for non-finite provider values Non-finite usedPercent inputs (NaN/Infinity) propagated through Math.round/min/max into the CSS bar width (`NaN%`) and displayed copy. clampUsedPercent now short-circuits to 0 in that case, with a test covering the divergence from getDisplayedUsagePercentage for the 'remaining' case.
… prompt (stablyai#7459) * feat(file-explorer): confirm multi-select deletes with a single batch prompt Deleting a multi-file selection on a remote host prompted once per file: requestDeleteAll awaited runDelete per root, and the remote-delete confirmation lived inside runDelete. Hoist the confirmation for batches — one 'Permanently delete {{count}} items?' dialog up front, then per-node deletes with skipConfirmation. Single-file and local (Trash) deletes are unchanged. Root filtering and the batch loop move to file-explorer-batch-deletion.ts with unit coverage. Fixes stablyai#7457 * fix(file-explorer): count the full selection in the batch delete prompt Address review: roots.length undercounts when a selected directory's children are also selected (could even read 'delete 1 items?'). Use the visible selection size instead. Also reword the zh strings so 项目 cannot read as 'project' in a file-delete flow. * review: skip batch delete confirm for unresolved-owner selections Narrow the batch-confirm gate to a resolvable remote route so an unresolved-owner multi-select no longer pops a destructive prompt for deletes that fail closed anyway — mirroring the single-delete path. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Tom de Bres <tomdebres@users.noreply.github.com> Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Co-authored-by: Orca <help@stably.ai>
* fix: work-item naming, usage % rounding, and terminal/delete copy Address prod-release-scan P2s: - stablyai#8238: recognize Bitbucket Server (/projects|users/.../repos/.../pull-requests/N) and Azure DevOps (/_git/REPO/pullrequest/N) PR URL shapes in work-item-reference, alongside Bitbucket Cloud; graceful fallback preserved. - stablyai#7574: getDisplayedUsagePercentage now rounds the used value before taking the `remaining` complement, so the compact status bar (raw usedPercent) and tooltip (pre-rounded clampUsedPercent) can no longer disagree by 1% at a .5 fraction. clampUsedPercent moves to the shared module as the single rounding source. - stablyai#7459: mixed remote+local batch delete confirm no longer claims the whole batch is a permanent "remote host" delete — it now states remote items are permanent while local items move to the Trash/Recycle Bin. - stablyai#8322: right-click-to-paste settings copy is platform-aware — "Control-click" on macOS, "Ctrl+right-click" on Windows/Linux — matching the ctrlKey gate. Localization catalog synced (also picks up pre-existing UsagePercentageDisplayChangeNotice drift). * Fix NaN% usage bar and label for non-finite provider values Non-finite usedPercent inputs (NaN/Infinity) propagated through Math.round/min/max into the CSS bar width (`NaN%`) and displayed copy. clampUsedPercent now short-circuits to 0 in that case, with a test covering the divergence from getDisplayedUsagePercentage for the 'remaining' case.
Summary
Fixes #7457.
Deleting a multi-file selection in the file explorer on a remote (SSH) host shows the "Permanently delete …?" dialog once per file, sequentially — deleting 10 selected files means clicking through 10 identical dialogs. The confirmation lived inside the per-node delete path (
runDelete), sorequestDeleteAll's loop re-prompted for every root.Now a batch delete confirms once up front — "Permanently delete {{count}} items?" with the existing remote-host / cannot-be-undone wording — and the per-node deletes run with their own confirmation suppressed. Behaviour is unchanged for single-file deletes (same per-file dialog as today) and for local deletes (Trash/Recycle Bin, never prompted, still don't).
Implementation notes:
file-explorer-batch-deletion.tsmodule so both are unit-testable, following the pattern of the other extracted helpers inright-sidebar/.runDeletegains an optional{ skipConfirmation }used only by the batch path; the sequential-settle ordering, dirty-buffer save, undo capture, and selection-restore logic are untouched.isRemoteRuntimeFileOperationcheck, same as before).localize-renderer-strings.mjs(sha1(filePath:text)prefix scheme); the existing "Delete" confirm label key is reused.Screenshots
Before: one modal per selected file (N modals for N files). After: a single modal — "Permanently delete 5 items?" — for the whole selection. (Happy to attach a recording if useful.)
Testing
pnpm lint— all gates pass except the pre-existingswitch-exhaustivenessfailure onmaininSourceControlActionRepoOverrideNote.tsx(unrelated; fixed by fix(lint): remove redundant default case from exhaustive override-field switch #7451). Ran individually:oxlint,verify:localization-catalog(locale parity 10,150 keys × 5 locales),verify:localization-coverage(0 allowlisted candidates),check:reliability-gates— all green.pnpm typecheckpnpm testpnpm buildfile-explorer-batch-deletion.test.ts(8 tests): descendant-root filtering (unrelated nodes kept, children of selected dirs dropped, shared-prefix siblings kept, files not treated as containers) and batch flow (confirms exactly once, declining deletes nothing, no prompt when not needed, failed deletes excluded while the batch continues).AI Review Report
Reviewed with Claude Code. Risks checked: (1) double-confirmation or lost confirmation — single-node deletes still confirm inside
runDelete; batch deletes confirm exactly once up front and passskipConfirmationdown, verified by tests; (2) regression of the descendant-filtering race protection — logic moved verbatim intoselectDeletionRootswith new unit coverage; (3) sequential-delete ordering and selection-restore semantics preserved (same loop, same post-batch selection reconstruction); (4) mixed local/remote selections — the batch prompt shows if any root is remote, and local roots behave as before; (5) i18n — keys follow the repo's hash scheme, catalogues stay in parity across all five locales, and translations match the phrasing of the neighbouring delete strings. Cross-platform: no shortcuts, paths, or shell behaviour touched; the local-delete path (Trash vs Recycle Bin wording) is unchanged on macOS/Linux/Windows. The SSH use case is the subject of this PR and was tested as the primary scenario.Security Audit
No new security surface: the change reorders when an existing confirmation dialog is shown and reuses the existing
deleteRuntimePathper-node flow — no new IPC, no new input handling, no path construction changes. The destructive-action guarantee is preserved: every remote batch delete still requires explicit user confirmation before any file is removed.Notes
The batch dialog intentionally reports the count of deletion roots (after descendant filtering), which is what will actually be issued as delete operations. Follow-up idea (out of scope): listing the first few file names in the batch dialog body.