Skip to content

feat(actions): optional confirmation before Direct Delete - #163

Merged
wflixu merged 2 commits into
wflixu:devfrom
Consciencieux:feat/delete-confirm-toggle
Nov 1, 2026
Merged

wflixu merged 2 commits into
wflixu:devfrom
Consciencieux:feat/delete-confirm-toggle

Conversation

@Consciencieux

@Consciencieux Consciencieux commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an optional second confirmation before Direct Delete (bypasses Trash) — on by default, nested under Direct Delete in Settings → Actions.

Also fixes delete ordering: authorize first, then confirm as the last gate, so the alert matches what will actually be removed. Re-checks hasAccess after the permission prompt (a non-nil result can still mean a failed bookmark or a different folder). Injects DeleteConfirmationProviding for unit tests (confirm / cancel / ordering / authorized subset).

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🧪 Test addition/update

Related Issue

Related to #81

Screenshots

Settings (nested toggle) Confirmation alert
(see comment below) (see comment below)

Testing

Manual Testing

  • Toggle on → Cancel keeps file; Delete removes it
  • Never-granted folder → auth panel before alert
  • Toggle off → no alert (previous behavior)
  • App / Finder menu / dark mode / settings persist / FinderSync (standard checklist)

Build Verification

Local: ActionServiceTests 9/9 passed. CI runs RClickTests on this PR.

Checklist

  • Follows project Swift conventions (CONTRIBUTING.md)
  • All UI is SwiftUI (see Notes — alert reuses existing NSAlert)
  • Tested on macOS 15.6+ / light & dark
  • Docs updated (CHANGELOG)
  • Branch up-to-date with dev

Additional Notes

  1. 关于 建议【直接删除】功能还是增加个二次确认吧 #81

    这个确认是可选的。关掉之后和以前没有任何区别,直接删除还是一步完成;开着是给需要防止误删的人多一道确认。默认开着,开关在「设置 → 操作 → 直接删除」下面的「删除时二次确认」。本改动将「删除时二次确认」设为默认开启。若维护者认为默认关闭更为合适,请告知,我会据此调整默认值。

  2. Cancel after grant keeps the bookmark (Settings → Folder Permissions). Auth-before-confirm is intentional so confirmed deletes are not silently half-skipped.

  3. NSAlert — same pattern as existing delete/AirDrop alerts in this target; not a new AppKit surface.

@Consciencieux
Consciencieux force-pushed the feat/delete-confirm-toggle branch from b8e7cb9 to c467bfb Compare October 15, 2026 12:46
@Consciencieux

Copy link
Copy Markdown
Contributor Author
截屏2026-10-15 20 28 57 截屏2026-10-15 20 29 19

Direct Delete bypasses the Trash, so add a second confirmation, on by default,
with a toggle nested under Direct Delete in Settings → Actions.

Run folder authorization before that confirmation: previously the flow was
"confirm → authorize per item → delete", so cancelling an authorization panel
after confirming silently skipped items while the alert had claimed a larger
count. Authorization also re-checks hasAccess afterwards, because a non-nil
prompt result does not guarantee access (bookmark creation may fail, or the
user may pick another folder).

Extract DeleteConfirmationProviding / AlertDeleteConfirmation and inject it into
ActionService, the same way PermissionProviding is injected, so confirm, cancel
and the ordering are unit-tested instead of only reachable through NSAlert.

Known trade-off: cancelling the confirmation leaves the folder grant in place,
since authorization now happens first.
@Consciencieux
Consciencieux force-pushed the feat/delete-confirm-toggle branch from c467bfb to 7d3ac29 Compare October 15, 2026 13:03
@Consciencieux
Consciencieux force-pushed the feat/delete-confirm-toggle branch from 6c4c9bf to 214315f Compare October 15, 2026 16:41
@wflixu

wflixu commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Thanks for the PR. After reviewing it, I feel the additional setting you added on top of the existing “Direct Delete” setting doesn’t fit well with the other settings. A cleaner approach, in my view, would be to use the Option key:

  1. If the user holds Option while clicking Direct Delete, skip the second confirmation dialog.

  2. In all other cases, still show the second confirmation dialog when deleting.

This keeps the safe default confirmation while still letting power users bypass it for a single action, without adding a new setting that feels inconsistent with the existing ones. What do you think — would you be open to adjusting the PR in this direction?

@Consciencieux

Copy link
Copy Markdown
Contributor Author

Thanks for the PR. After reviewing it, I feel the additional setting you added on top of the existing “Direct Delete” setting doesn’t fit well with the other settings. A cleaner approach, in my view, would be to use the Option key:

  1. If the user holds Option while clicking Direct Delete, skip the second confirmation dialog.

  2. In all other cases, still show the second confirmation dialog when deleting.

This keeps the safe default confirmation while still letting power users bypass it for a single action, without adding a new setting that feels inconsistent with the existing ones. What do you think — would you be open to adjusting the PR in this direction?

同意。设置里的常驻开关拿掉,确认保持默认开启。要跳过的话按住 Option,只对这一次生效。

为了让这个操作找得到,放在两处:

  • 设置 → 操作:「直接删除」下面不再放勾选,改成一行说明「按住 Option 跳过确认」。这行只在设置里,不写进右键菜单的标题。
  • 右键菜单:平时仍是「直接删除」,点击后弹出确认。按住 Option 时,这一项变成「直接删除,不再询问」,并跳过确认框。

这样日常删除还有确认。知道这个键的人不用进设置改默认值,菜单标题的变化本身就是提示。

如果这个方案可以,我就按此改。

@wflixu
wflixu merged commit 149a2cd into wflixu:dev Nov 1, 2026
1 check passed
@Consciencieux
Consciencieux deleted the feat/delete-confirm-toggle branch November 2, 2026 10:57
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.

2 participants