From 65fa93bb28c127f21ea5fee6f7a89ecc130a3896 Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Tue, 13 Oct 2026 15:47:36 -0400 Subject: [PATCH] Add plain-language flags, source highlighting, and flag navigation (R.2) The piece that gives R.1's highlighting infrastructure something to do, and the first genuinely new review-screen UI (R.1 was all plumbing - same page, same components, just a different PDF renderer underneath). New flagCatalogService.js translates each check's own raw mismatch/ issue data into a four-part plain-language flag (what/where/why/what to do). Only running_balance/date_sanity/structure_sanity/ narrative_direction ever carry row-level data - the other three checks are whole-statement, confirmed by reading checks_service.py directly. date_sanity/structure_sanity return a free-text issue string, not a structured type - pattern-matched against the backend's own known message shapes, with a fallback that always shows the raw text rather than silently dropping it if that text ever changes. TransactionRow.vue gained a flag-icon toggle opening a second with every flag's own explanation (Vue 3 supports multi-root components, so this is a real sibling row, not a wrapped div that would break the table's HTML) and a "Show on source" button. The real design question: how does a flagged row (deep inside TransactionsTable) tell the source panel (a sibling three levels up, no direct prop/event path) to highlight itself? Solved with uiStore.highlightRequest as the bridge - TransactionRow sets it, ExtractorView (which holds the actual ref to SourceDocumentPanel) watches it and calls the panel's own showHighlight(), built in R.1 but unused until now. SourceDocumentPanel also clears both the request and its own highlight state whenever the active document changes, so a stale box never lingers over a different document. useTransactionFilters.js gained a flaggedOnly toggle; TransactionsTable added "Flagged only"/"Next flagged" buttons (shown only when something is actually flagged) - the latter cycles through flagged rows via scrollIntoView on each row's own id, wrapping after the last. Verified: flagsForIndex executed directly against real backend output (a live /api/process call against the HSBC-Aug fixture, which has a real documented running_balance mismatch) plus synthetic data covering every builder's own branches, including two checks flagging the same row and confirming whole-statement checks never contribute a row flag. npm run build passes, the app container rebuilt, measure.py unaffected (pure frontend presentation, no backend touched). Not machine-verified: the actual click-through - Claude-in-Chrome did not connect this session. Co-Authored-By: Claude Sonnet 5 --- CLAUDE.md | 87 +++++++++++- frontend/src/assets/main.css | 21 ++- .../src/components/SourceDocumentPanel.vue | 19 ++- frontend/src/components/TransactionRow.vue | 58 +++++++- frontend/src/components/TransactionsTable.vue | 51 ++++++- .../src/composables/useTransactionFilters.js | 29 +++- frontend/src/services/flagCatalogService.js | 128 ++++++++++++++++++ frontend/src/stores/uiStore.js | 19 +++ frontend/src/views/ExtractorView.vue | 18 ++- 9 files changed, 407 insertions(+), 23 deletions(-) create mode 100644 frontend/src/services/flagCatalogService.js diff --git a/CLAUDE.md b/CLAUDE.md index 4de2778..3034b9f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -30,7 +30,7 @@ to rough effort: | Phase | Contains | Status here | |---|---|---| | **1** | Extraction + 6 checks + Excel export, dual-engine, measurement harness | **In progress — see gaps below** | -| 2 | Review screen, suggested-fix patterns, OCR, 2nd+ bank support | OCR routing + working Docling-fallback (`raw_ocr_extract.py`) built and verified against a real multi-page scan 2026-10-11 — one known single-page edge case remains unreliable, see "OCR / scanned statements" below — review screen **in progress, staged R.1-R.5** (see "Review screen" under Key decisions & lessons) — R.1's backend half (per-row source-position capture) shipped 2026-10-13; the pdf.js highlighting viewer, R.2's plain-language flags, and R.3's suggested-fix engine are not started yet | +| 2 | Review screen, suggested-fix patterns, OCR, 2nd+ bank support | OCR routing + working Docling-fallback (`raw_ocr_extract.py`) built and verified against a real multi-page scan 2026-10-11 — one known single-page edge case remains unreliable, see "OCR / scanned statements" below — review screen **in progress, staged R.1-R.5** (see "Review screen"/"R.2" under Key decisions & lessons) — R.1 (source-position capture + the pdf.js highlighting viewer) and R.2 (plain-language flags + jump-to-flagged navigation) both shipped 2026-10-13; R.3's suggested-fix engine, R.4's structural row edits, and R.5's accept/acknowledge + edit log are not started yet | | 3 | Layout mapper (fingerprinting, versioning, drift detection) | Not started | | 4 | Multi-tenant practice/client accounts, Frappe data model | Not started | | 5 | Free front door, public accuracy page | Not started | @@ -347,6 +347,13 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co `pdfColHidden`). `restoreBannerVisible` etc. were removed along with `RestoreBanner.vue` in Stage B.2 - see "PocketBase Stage B.2" under Key decisions & lessons. + `highlightRequest`/`requestHighlight()`/ + `clearHighlightRequest()` (NEW 2026-10-13, review screen + R.2) - the bridge between `TransactionRow`'s "Show on + source" and `SourceDocumentPanel`'s exposed + `showHighlight()`, siblings three levels apart with no + direct prop/event path between them - see "R.2" under Key + decisions & lessons. authStore.js — `user` (mirrors `pb.authStore.record`), `isAuthenticated` getter, `syncWithAuthStore()` (registered once in `App.vue`'s `onMounted`, keeps the store in sync @@ -383,7 +390,13 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co were removed outright in Stage B.2, replaced by documentsService.js below). formatService.js (fmtMoney/fmtNum/parseNum - escapeHtml dropped, redundant - once Vue's own {{ }} auto-escapes). authService.js (login/ + once Vue's own {{ }} auto-escapes). flagCatalogService.js + (NEW 2026-10-13, review screen R.2 - translates each + check's raw mismatch/issue data into the spec's + four-part plain-language flag; only + running_balance/date_sanity/structure_sanity/ + narrative_direction ever carry row-level data, see + "R.2" under Key decisions & lessons). authService.js (login/ signup/loginWithGoogle/logout, thin wrappers over the PocketBase SDK — the SDK itself persists/restores the auth token). documentsService.js (`saveDocument`/ @@ -451,7 +464,8 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co via pdf.js/usePdfViewer as of 2026-10-13, not the browser's native `