diff --git a/src/fgai/dashboard.py b/src/fgai/dashboard.py index a88a20f..bc50206 100644 --- a/src/fgai/dashboard.py +++ b/src/fgai/dashboard.py @@ -728,23 +728,33 @@ async function refresh() { })); async function clearIncidents(status) { const notice = document.getElementById('incidentNotice'); - const label = status ? `${status} incident states` : 'all stored incident states'; + const label = status ? `${status} incident states` : 'all incident and finding review states'; if (!confirm(`Clear ${label}? Active evidence can recreate incidents on the next monitor refresh.`)) return; if (notice) notice.textContent = `Clearing ${label}...`; try { const body = status ? {status} : {}; - const response = await fetch('/api/incidents/clear', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)}); + const endpoint = status ? '/api/incidents/clear' : '/api/review-state/clear'; + const response = await fetch(endpoint, {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body)}); let payload = {}; try { payload = await response.json(); } catch (_err) {} if (!response.ok) throw new Error(payload.error || `HTTP ${response.status}`); - if (notice) notice.textContent = `Cleared ${payload.removed || 0} incident state(s). ${payload.remaining || 0} stored state(s) remain.`; - await refresh(); + const incidentResult = payload.incidents || payload; + const feedbackResult = payload.feedback || {}; + const feedbackText = payload.feedback ? ` Feedback cleared: ${feedbackResult.removed || 0}.` : ''; + if (notice) notice.textContent = `Cleared ${incidentResult.removed || 0} incident state(s). ${incidentResult.remaining || 0} stored incident state(s) remain.${feedbackText}`; + if (!status) { + document.getElementById('incidents').innerHTML = '

Stored incident states cleared. New active incidents may appear on the next monitor refresh if evidence still exists.

'; + document.getElementById('triageQueue').innerHTML = '

Review state cleared. Triage will rebuild from current evidence on the next monitor refresh.

'; + } + setTimeout(refresh, 500); } catch (err) { if (notice) notice.textContent = `Could not clear incidents: ${err.message || err}`; } } - document.getElementById('clearResolvedIncidents')?.addEventListener('click', () => clearIncidents('resolved')); - document.getElementById('clearAllIncidents')?.addEventListener('click', () => clearIncidents('')); + const clearResolvedButton = document.getElementById('clearResolvedIncidents'); + const clearAllButton = document.getElementById('clearAllIncidents'); + if (clearResolvedButton) clearResolvedButton.onclick = () => clearIncidents('resolved'); + if (clearAllButton) clearAllButton.onclick = () => clearIncidents(''); document.getElementById('blocks').innerHTML = table(data.block_candidates || [], [ {label:'Source', key:'src_ip', render:r => entityCell(r, 'src_ip')}, {label:'Score', key:'score'},