From d82a0d6004e9a825891d0c8de476028c782c4e4f Mon Sep 17 00:00:00 2001 From: StyxX65 <150797939+StyxX65@users.noreply.github.com> Date: Wed, 10 Jun 2026 11:30:41 +0200 Subject: [PATCH] Keep redacted cards in grid until next scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Redacting a card (✏) previously removed it from the grid and from S.flaggedData/S.filteredData immediately. Now the item is marked _redacted and kept: greyed via card-resolved styling, shown with a "✏ Redacted" badge, and its delete/redact buttons hidden so it can't be re-processed. The grid is rebuilt on the next scan run, which clears the markers. results.js only — no server change. Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 4 ++++ static/js/results.js | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6b7b44..a66503e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ Version numbers follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html - **AI-enhanced NER via Claude** — Named Entity Recognition (names, addresses, organisations) can now be powered by Claude Haiku instead of spaCy. Enable in **Settings → AI / NER**: paste an Anthropic API key, toggle on, click Test to confirm. When enabled, `document_scanner.py` calls the Claude API (`claude-haiku-4-5-20251001`) instead of spaCy for all three scan engines; results are cached in-memory per document (bounded at 2 000 entries) so repeated scans of the same file never re-charge the API. Falls back to spaCy automatically if the key is missing or the `anthropic` package is not installed. API key stored in `config.json` under `claude_api_key`; toggle stored under `claude_ner`. Routes: `GET/POST /api/settings/claude`, `POST /api/settings/claude/test`. +### Changed + +- **Redacted cards stay in the grid until the next scan** — previously redacting a card (✏) removed it from the grid and from `S.flaggedData`/`S.filteredData` immediately. Now the item is kept and marked redacted: the card is greyed (`card-resolved` styling), shows a `✏ Redacted` badge, and its delete/redact action buttons are hidden so it can't be re-processed. The operator can see what was handled during the session; the grid is rebuilt on the next scan run, which clears the redacted markers. Implemented with a `_redacted` flag in `results.js` (`appendCard` + `redactItem`); no server change. + ### Fixed - **Cards not shown after browser refresh** — when the browser reconnected to the SSE stream after a completed scan, the `scan_phase` events in the replay buffer temporarily set `S._m365ScanRunning = true` (all running flags start at `false` after a page reload). The watchdog's `loadHistorySession` call fired in this window and bailed on the stale flag; once `scan_done` cleared the flag, `_initialStatusChecked` was already `true` so `loadHistorySession` was never retried. Fixed by having the `sse_replay_done` handler retry `loadHistorySession(null)` when no scan is running and `S._historyRefScanId` is still `null` after replay. diff --git a/static/js/results.js b/static/js/results.js index d3bcdf2..f45da36 100644 --- a/static/js/results.js +++ b/static/js/results.js @@ -38,7 +38,7 @@ function appendCard(f) { : '/api/thumb?name=' + encodeURIComponent(f.name) + '&type=' + encodeURIComponent(f.source_type); const card = document.createElement('div'); - card.className = 'card' + (S.isListView ? ' list-view' : '') + (S._selectedIds.has(f.id) ? ' card-selected-bulk' : '') + (f._resolved ? ' card-resolved' : ''); + card.className = 'card' + (S.isListView ? ' list-view' : '') + (S._selectedIds.has(f.id) ? ' card-selected-bulk' : '') + ((f._resolved || f._redacted) ? ' card-resolved' : ''); card.dataset.id = f.id; card.onclick = (e) => { if (S._selectMode) { toggleCardSelect(f.id, e); } else { openPreview(f); } }; @@ -49,12 +49,12 @@ function appendCard(f) { cb.onclick = (e) => { e.stopPropagation(); toggleCardSelect(f.id, e); }; card.appendChild(cb); - const delBtn = (window.VIEWER_MODE || f._resolved) ? '' : ``; + const delBtn = (window.VIEWER_MODE || f._resolved || f._redacted) ? '' : ``; const _redactExts = new Set(['.docx', '.xlsx', '.txt', '.csv', '.pdf']); const _cloudRedactExts = new Set(['.docx', '.xlsx', '.pdf']); const _m365Types = new Set(['onedrive', 'sharepoint', 'teams']); const _fileExt = (f.name || '').substring((f.name || '').lastIndexOf('.')).toLowerCase(); - const _redactable = !window.VIEWER_MODE && !f._resolved && f.cpr_count > 0 && ( + const _redactable = !window.VIEWER_MODE && !f._resolved && !f._redacted && f.cpr_count > 0 && ( f.source_type === 'local' ? _redactExts.has(_fileExt) : _m365Types.has(f.source_type) ? _cloudRedactExts.has(_fileExt) : f.source_type === 'gdrive' ? _cloudRedactExts.has(_fileExt) : @@ -75,7 +75,7 @@ function appendCard(f) { ${f.phone_count > 0 ? '' + f.phone_count + ' ' + t('m365_badge_phones', 'tlf.') + ' ' : ''} ${f.face_count > 0 ? '' + f.face_count + ' ' + t('m365_badge_faces', f.face_count === 1 ? 'face' : 'faces') + ' ' : ''} ${f.exif && f.exif.gps ? '🌍 GPS ' : ''} - ${f.special_category && f.special_category.length ? '⚠ Art.9 — ' + f.special_category.filter(function(s){return s !== 'gps_location' && s !== 'exif_pii';}).join(', ') + ' ' : ''}${f._resolved ? '✓ ' + t('history_resolved_badge', 'Resolved') + ' ' : ''}${f.overdue ? '🗓 Overdue' : ''} + ${f.special_category && f.special_category.length ? '⚠ Art.9 — ' + f.special_category.filter(function(s){return s !== 'gps_location' && s !== 'exif_pii';}).join(', ') + ' ' : ''}${f._redacted ? '✏ ' + t('redact_badge', 'Redacted') + ' ' : ''}${f._resolved ? '✓ ' + t('history_resolved_badge', 'Resolved') + ' ' : ''}${f.overdue ? '🗓 Overdue' : ''} ${delBtn}${redactBtn}`; } else { card.innerHTML = ` @@ -85,7 +85,7 @@ function appendCard(f) {
${f.size_kb} KB · ${esc(f.modified || '')}
${f.folder ? `
📂 ${esc(f.folder)}
` : ''}
${esc(label)}${f.account_name ? ' ' : ''}${f.transfer_risk === "external-recipient" ? ' ⚠ Ext.' : f.transfer_risk ? ' 🔗' : ''}
- ${f.cpr_count} CPR${f.email_count > 0 ? ' ' + f.email_count + ' ' + t('m365_badge_emails', 'e-mail') + '' : ''}${f.phone_count > 0 ? ' ' + f.phone_count + ' ' + t('m365_badge_phones', 'tlf.') + '' : ''}${f.face_count > 0 ? ' ' + f.face_count + ' ' + t('m365_badge_faces', f.face_count === 1 ? 'face' : 'faces') + '' : ''}${f.exif && f.exif.gps ? ' 🌍 GPS' : ''}${f._resolved ? ' ✓ ' + t('history_resolved_badge', 'Resolved') + '' : ''}${f.overdue ? ' 🗓 Overdue' : ''} + ${f.cpr_count} CPR${f.email_count > 0 ? ' ' + f.email_count + ' ' + t('m365_badge_emails', 'e-mail') + '' : ''}${f.phone_count > 0 ? ' ' + f.phone_count + ' ' + t('m365_badge_phones', 'tlf.') + '' : ''}${f.face_count > 0 ? ' ' + f.face_count + ' ' + t('m365_badge_faces', f.face_count === 1 ? 'face' : 'faces') + '' : ''}${f.exif && f.exif.gps ? ' 🌍 GPS' : ''}${f._redacted ? ' ✏ ' + t('redact_badge', 'Redacted') + '' : ''}${f._resolved ? ' ✓ ' + t('history_resolved_badge', 'Resolved') + '' : ''}${f.overdue ? ' 🗓 Overdue' : ''} ${delBtn}${redactBtn}`; } @@ -629,9 +629,13 @@ async function redactItem(f, cardEl) { }); const d = await r.json(); if (d.ok) { - S.flaggedData = S.flaggedData.filter(x => x.id !== f.id); - S.filteredData = S.filteredData.filter(x => x.id !== f.id); - if (cardEl) cardEl.remove(); + // Keep the redacted item in the grid (marked, greyed, action buttons + // hidden) until the next scan run, so the operator can see what was + // handled. The grid is rebuilt on the next scan, clearing these. + const _mark = (x) => { if (x.id === f.id) x._redacted = true; }; + S.flaggedData.forEach(_mark); + S.filteredData.forEach(_mark); + renderGrid(S.filteredData.length ? S.filteredData : S.flaggedData); updateStats(); log(t('redact_done', 'Redacted') + ' ' + f.name + ' (' + (d.redacted || 0) + ' ' + t('redact_spans', 'CPR spans') + ')', 'ok'); if (_previewItemId === f.id) closePreview();