Skip to content

feat(file-explorer): confirm multi-select deletes with a single batch prompt - #7459

Merged
AmethystLiang merged 3 commits into
stablyai:mainfrom
tomdebres:feat/batch-delete-confirmation
Jul 11, 2026
Merged

AmethystLiang merged 3 commits into
stablyai:mainfrom
tomdebres:feat/batch-delete-confirmation

Conversation

@tomdebres

Copy link
Copy Markdown
Contributor

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), so requestDeleteAll'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:

  • The batch flow (confirm-once + sequential root deletion) and the existing descendant-root filtering moved to a new file-explorer-batch-deletion.ts module so both are unit-testable, following the pattern of the other extracted helpers in right-sidebar/.
  • runDelete gains an optional { skipConfirmation } used only by the batch path; the sequential-settle ordering, dirty-buffer save, undo capture, and selection-restore logic are untouched.
  • The batch prompt appears when any selected root is remote (per-node isRemoteRuntimeFileOperation check, same as before).
  • New strings added to all locale catalogues (en/es/ja/ko/zh) with keys generated per 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-existing switch-exhaustiveness failure on main in SourceControlActionRepoOverrideNote.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 typecheck
  • pnpm test
  • pnpm build
  • Added file-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 pass skipConfirmation down, verified by tests; (2) regression of the descendant-filtering race protection — logic moved verbatim into selectDeletionRoots with 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 deleteRuntimePath per-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.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f40cd13c-641d-4265-8166-5e9d57158d10

📥 Commits

Reviewing files that changed from the base of the PR and between 6cb72c9 and 69f250e.

📒 Files selected for processing (2)
  • src/renderer/src/components/right-sidebar/useFileDeletion.ts
  • src/renderer/src/i18n/locales/zh.json
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/right-sidebar/useFileDeletion.ts

📝 Walkthrough

Walkthrough

This PR adds batch-delete helpers for file explorer selections, wires them into useFileDeletion, and updates delete-all to confirm once, delete sequentially, and clear selection from the returned deleted roots. It also adds tests for the new helpers and extends localized confirmation text for bulk and directory-inclusive deletions.

Changes

Cohort / File(s) Summary
Batch deletion helpers — file-explorer-batch-deletion.ts New selectDeletionRoots and runBatchDeletion functions with supporting types
Integration — useFileDeletion.ts Adds getDeletionContext/isRemoteDeletion, updates runDelete, rewrites requestDeleteAll
Tests — file-explorer-batch-deletion.test.ts New Vitest suite for both helper functions
Localization — en.json, es.json, ja.json, ko.json, zh.json New confirmation strings for bulk/directory deletion

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
Loading

Related issues: None found in provided context.
Related PRs: None found in provided context.
Suggested labels: enhancement, tests, i18n
Suggested reviewers: None found in provided context.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a single batch prompt for multi-select file deletes.
Description check ✅ Passed The PR description covers the required template sections and provides summary, testing, review, security, and notes details.
Linked Issues check ✅ Passed The changes match #7457 by hoisting confirmation to a single batch prompt, preserving single-file and local behavior, and keeping descendant filtering.
Out of Scope Changes check ✅ Passed The added tests, helper extraction, and locale updates are all directly tied to the batch-delete confirmation feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 (1)
src/renderer/src/components/right-sidebar/useFileDeletion.ts (1)

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

Duplicate isRemote derivation between isRemoteDeletion and runDelete.

Both isRemoteDeletion (Lines 75-81) and the start of runDelete (Lines 90-92) independently call getDeletionContext() and recompute connectionId !== undefined || isRemoteRuntimeFileOperation(fileContext, node.path) the same way. Consider having runDelete reuse isRemoteDeletion(node) (while still keeping fileContext/connectionId from getDeletionContext() 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

📥 Commits

Reviewing files that changed from the base of the PR and between eee2d98 and 6cb72c9.

📒 Files selected for processing (8)
  • src/renderer/src/components/right-sidebar/file-explorer-batch-deletion.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-batch-deletion.ts
  • src/renderer/src/components/right-sidebar/useFileDeletion.ts
  • 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

Comment thread src/renderer/src/i18n/locales/zh.json Resolved
tomdebres and others added 3 commits July 11, 2026 14:22
… 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>
@AmethystLiang
AmethystLiang force-pushed the feat/batch-delete-confirmation branch from 69f250e to 75aabbf Compare July 11, 2026 21:32

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

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.

@AmethystLiang
AmethystLiang merged commit 80164d6 into stablyai:main Jul 11, 2026
1 of 3 checks passed
AmethystLiang added a commit that referenced this pull request Jul 12, 2026
* 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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… 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>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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.
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.

[Feature Request]: Single batch confirmation when deleting multiple selected files in the file explorer

3 participants