From 20c1828cdefc9dc58cf5844c1a3273186441aa93 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sun, 5 Apr 2026 19:12:14 -0700 Subject: [PATCH] Fix orphan file bulk action showing deletion warning before staging option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reversed the flow: user now sees "Move to Staging" vs "Delete" choice first, instead of the scary "permanently delete N files" dialog. Staging gets a friendly confirmation. Delete ≤50 gets standard confirm. Delete >50 still requires witness-me safety gate. Updated prompt text to clarify staging is safe and reversible. (#252) --- webui/static/script.js | 54 ++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/webui/static/script.js b/webui/static/script.js index 2dde28a7..25dfdc68 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -62225,9 +62225,29 @@ async function fixAllMatchingFindings() { const jobId = jobFilter ? jobFilter.value : ''; const severity = severityFilter ? severityFilter.value : ''; - // Mass orphan safety gate - if (_isMassOrphanFix(jobId, _repairFindingsTotal)) { - if (!await showWitnessMeDialog(_repairFindingsTotal)) return; + // If fixing orphan files, prompt for action FIRST (staging vs delete) + let fixAction = null; + if (jobId === 'orphan_file_detector' || _isMassOrphanFix(jobId, _repairFindingsTotal)) { + fixAction = await _promptOrphanAction(); + if (!fixAction) return; + // Confirm before proceeding + if (fixAction === 'delete' && _repairFindingsTotal > 50) { + if (!await showWitnessMeDialog(_repairFindingsTotal)) return; + } else if (fixAction === 'delete') { + if (!await showConfirmDialog({ + title: 'Delete Orphan Files', + message: `Permanently delete ${_repairFindingsTotal} orphan files from disk? This cannot be undone.`, + confirmText: 'Delete', + destructive: true + })) return; + } else if (fixAction === 'staging') { + if (!await showConfirmDialog({ + title: 'Move to Staging', + message: `Move ${_repairFindingsTotal} orphan files to the staging folder? Files are NOT deleted — you can review and import them from staging.`, + confirmText: 'Move All to Staging', + destructive: false + })) return; + } } else { const scopeLabel = jobId ? jobId.replace(/_/g, ' ') : 'all jobs'; if (!await showConfirmDialog({ @@ -62238,13 +62258,6 @@ async function fixAllMatchingFindings() { })) return; } - // If fixing orphan files, prompt for action - let fixAction = null; - if (jobId === 'orphan_file_detector') { - fixAction = await _promptOrphanAction(); - if (!fixAction) return; - } - showToast(`Fixing ${_repairFindingsTotal} findings...`, 'info'); try { @@ -62367,7 +62380,7 @@ function _promptOrphanAction() {
Orphan File Action
- What would you like to do with this file? + Choose how to handle orphan files. Staging is safe and reversible.