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() {