From 35b898af504389ff9fa5bfc53a1c26090d2cca95 Mon Sep 17 00:00:00 2001 From: Alex-Gilbert Date: Mon, 16 Feb 2026 18:02:54 -0600 Subject: [PATCH] fix: remove unused import, add duplicate redaction detection - Remove unused detect_redactions import from app.py - Add de-duplication check in dblclick handler to prevent creating duplicate redaction entries for the same dark region Co-Authored-By: Claude Opus 4.6 --- unredact/app.py | 2 +- unredact/static/app.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/unredact/app.py b/unredact/app.py index 6b6c3b9..012a717 100644 --- a/unredact/app.py +++ b/unredact/app.py @@ -17,7 +17,7 @@ from PIL import Image, ImageFont from sse_starlette.sse import EventSourceResponse from unredact.pipeline.rasterize import rasterize_pdf -from unredact.pipeline.detect_redactions import detect_redactions, spot_redaction +from unredact.pipeline.detect_redactions import spot_redaction from unredact.pipeline.ocr import ocr_page from unredact.pipeline.font_detect import detect_font_for_line, CANDIDATE_FONTS, _find_font_path from unredact.pipeline.solver import build_constraint, SolveResult diff --git a/unredact/static/app.js b/unredact/static/app.js index 7dedc60..4d24206 100644 --- a/unredact/static/app.js +++ b/unredact/static/app.js @@ -915,6 +915,18 @@ rightPanel.addEventListener("dblclick", async (e) => { const data = await resp.json(); const box = data.box; + + // De-duplicate: if a redaction with the same box already exists, just activate it + const existingDup = Object.values(state.redactions).find(r => + r.page === state.currentPage && + Math.abs(r.x - box.x) < 3 && Math.abs(r.y - box.y) < 3 && + Math.abs(r.w - box.w) < 3 && Math.abs(r.h - box.h) < 3 + ); + if (existingDup) { + activateRedaction(existingDup.id); + return; + } + const id = "m" + Date.now().toString(36); state.redactions[id] = {