Both sticky rows kept their own border-bottom (inherited from the
base th rule), which read as a thin visible gap between them. The
header row no longer draws one - the filter row's own border is the
single line that should separate the whole sticky header block from
the scrolling data beneath it.
Dragging the resizer narrow on a wide screen never triggered the
existing @media(max-width:640px) stacked layout, since that only
watches the viewport, not the column itself - so the balance fields
and Recheck Balance button just overflowed the column's right edge
instead. Gave .txn-col container-type:inline-size and replaced that
media query with an equivalent @container rule, which also covers
the genuine-mobile case the old rule handled (the column is just as
narrow as the viewport there too).
Same root cause was squeezing the transactions table's Description
column unreadable: table-layout:fixed + width:100% shrinks every
column proportionally to fit, fixed-pixel ones included. Gave the
table a min-width (fixed columns' sum + a legible floor for
Description) so .table-wrap's overflow-x:auto takes over with a
horizontal scrollbar instead of compressing Description further.
Header row and filter row both stuck to top:0 via one shared rule,
so the filter row (later in the DOM) visually covered the header row
on scroll instead of stacking beneath it. Gave the header row an
explicit height and offset the filter row's own sticky top by that
amount so they stack correctly.
Also removed the now-empty <div class="note"> left over after its
instructional text was deleted - it was still taking up margin-bottom
space above the table for no reason.
Matching just the top edge (via the label-height spacer) wasn't
enough - the button's own padding made it naturally shorter than a
balance input, so the two boxes still looked slightly off-center
against each other. Both now get the same explicit height with the
button's text flex-centered inside it.
- Recheck Balance now lines up with the balance input fields on wide
viewports via an invisible label-height spacer, instead of the row's
top edge.
- Each transaction column gets its own up/down sort arrows, plus a
filter row beneath the header (Description doubles as search, Status
is a dropdown of values actually present). Sorting/filtering never
disturbs row identity - edits and flags still target the original
index, not the displayed position.
The mismatch note only handled outcome === 'fail'. A statement with no
typed or auto-detected balance at all returns "not_available" instead,
which was left just as silently grey as "fail" used to be before the
last fix.
Grey (vs green) on the calc-readouts said something was wrong but never
what - the actual explanation (the statement_balance check's own detail
text, with the full math and "off by \$X") only existed in the checks
list, which starts collapsed by default, with no visible link back to
the readouts near the balance fields.
Surfaces that same detail text directly under the balance fields/Recheck
button when the check outcome is "fail" - no new backend call or logic,
just showing what was already being computed and returned, in the place
the user is actually looking.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Typing opening/closing balance AFTER extraction (e.g. the user forgot to
fill it in before clicking Extract) never did anything on its own - the
fields were only ever read by some OTHER trigger (a row Save, or
Download). Confirmed this gap predates the Vue rewrite - the original
vanilla-JS version had the identical behavior.
Adds a "Recheck Balance" button (TransactionsTable.vue) that re-runs the
same recheck-only (no re-extraction) call a row Save already makes,
using whatever's currently in the balance fields - an explicit,
deliberate trigger rather than auto-firing on blur, matching the
existing per-row Save pattern (edits/entries only take effect when
confirmed). Positioned at the row's own right edge, aligned under the
Hide/Show Source Doc toggle above it; drops below the closing-balance
field at mobile widths (a new 640px breakpoint, separate from the
860px one the overall layout already used).
Verified end-to-end against the real backend: uploaded a statement with
no balance supplied (statement_balance: not_available), then called
/api/recheck with balances added afterward - the check correctly
recalculated and reported the result, the same request shape and
endpoint the new button uses.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The previous commit fixed .txn-col but missed the real asymmetry: only
.pdf-col's CHILD (iframe/img-preview-wrap/empty-panel-source) was pinned
to 82vh - the .pdf-col CARD itself had no height of its own, so its real
total height was 82vh plus pdf-col-head's own height plus the card's
padding, taller than .txn-col's flat 82vh. Visually this is exactly
"transactions panel is shorter."
Applied the identical fixed-height-flex-column pattern to .pdf-col that
.txn-col already had: height:82vh on the card itself, pdf-col-head
flex-shrink:0, and the child (iframe/img-preview-wrap/empty-panel-source)
changed from height:82vh to flex:1 1 auto; min-height:0 so it fills
whatever space remains under the head - both columns are now driven by
the same fixed value through the same structural pattern, which is what
actually guarantees matching heights (one side being content-driven and
the other fixed can't reliably match, regardless of what the fixed value is).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
.pdf-col's height came from its child (iframe/img-preview-wrap/
empty-panel-source, all fixed at 82vh); .txn-col had no height of its
own, just whatever its header+fields+notes+table content needed - the
two columns drifted apart whenever txn-col's content was taller than
82vh on its own.
.txn-col is now flex-column with a fixed height:82vh, matching its
sibling exactly; the table area (table-wrap, or empty-panel-table when
there's no result yet) is the one piece that absorbs whatever space is
left after the header/fields/notes above it (flex:1, min-height:0 so its
own overflow-y:auto scroll still works within that constrained space),
rather than the whole column growing taller than 82vh.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The opening/closing balance fields live in TransactionsTable, which was
only rendered after a successful extraction - so there was no way to
type a balance before clicking Extract, even though both fields are
submitted as part of that same request. Confirmed this wasn't introduced
by the Vue rewrite - the original vanilla-JS version had the identical
behavior (#resultSection stayed display:none until renderResult ran).
Both panels are now always visible. Each shows an empty-state message
("No Source Document to Display..."/"No Transactions to Display...")
until there's something real to show instead - SourceDocumentPanel until
a file is chosen, TransactionsTable's table (not the balance fields
above it) until an extraction result exists.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Rebuilds templates/index.html (896 lines of vanilla JS, no framework, no
build step) as frontend/, a Vue 3 app per ENTERPRISE_STANDARDS.md's
frontend layering (views -> components -> composables -> services ->
repositories, Pinia for stores) - same agreed scope as Stage 1 (backend):
structure + commenting, not the full SaaS-shaped doc.
The full original file was read in full before starting (every function
enumerated against the plan, not re-derived from memory) to make sure
nothing documented in CLAUDE.md's "Frontend / UI state" section got
simplified away: sticky side-by-side layout with a draggable resizer,
Hide/Show Source Doc, collapsible Result card, per-row pencil-to-edit,
comma-formatted numbers, localStorage persistence with a restore banner,
image zoom controls, the pencil-icon-color and description-autogrow
fixes from earlier this session.
The original ask that started this whole detour - processing-phase text
with an animated ellipsis during /api/process - lands here as the one
genuinely new feature (useProcessingPhases.js + ProcessingIndicator.vue),
honestly simulated rather than claiming real progress (the backend is
one synchronous request with no streaming signal).
backend/app.py now serves frontend/dist (built via a new Dockerfile
multi-stage build: a node stage runs npm ci && npm run build, the Python
stage copies backend/ + that dist/ output) instead of rendering a Jinja
template - a manual SPA-fallback route serves a real static asset if one
exists at the requested path, else index.html. One real bug caught and
fixed before this ever ran: the first version also left Flask's own
automatic static route enabled, registering a duplicate/conflicting rule
against the same /<path:...> pattern as the manual catch-all - fixed by
disabling Flask's own static handling (static_folder=None) entirely.
Verified without a browser (the extension could not connect, tried
repeatedly): npm run build succeeds, formatService.js's pure functions
tested directly in Node, every prop/emit/store reference cross-checked
by hand across all ~20 new files, and full regression through the real
Docker container (SPA serving, static assets, /health, /api/* routing,
dual-engine extraction, measure.py - all unaffected or identical to
baseline). Actual interactive behavior - upload, drag/drop, the
processing-phase animation, editing, zoom, the resizer, persistence/
restore, download - was verified by the user in their own browser, not
by Claude. templates/index.html was kept in place as a fallback until
that confirmation came back, then deleted.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ocr_only detection only matched page_reports status "ocr_only", not
"ocr_raw_words" - if every page of a recheck needed the per-page
raw-OCR-words fallback (Docling failed on all of them), this incorrectly
treated the recheck as non-OCR-sourced, letting it reach "Verified" when
there was no second engine to earn that on. Now checks membership in
("ocr_only", "ocr_raw_words").
Verified directly (not just via measure.py, which never exercises
recheck()): an all-ocr_raw_words page_reports now correctly surfaces the
ocr_source check and stays below Verified; a mixed ocr_only/ocr_raw_words
case does the same; a normal dual-engine case is unaffected - confirmed
both as a direct function call and through /api/recheck on the real
running app. measure.py confirms zero regression elsewhere.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Three small UI fixes from earlier testing, never committed:
- Pencil edit icon now uses the same blue accent token the Save button
already does (.row-btn.edit), instead of the default muted gray.
- Description textarea boxes left stale blank space after hiding the
Source Document panel - the drag-resizer already re-measures box
height on resize (autoGrowAll()), but the Hide/Show toggle never did,
so widening the transactions column left every description box at its
old height until something else happened to trigger a re-measure.
Added the missing call.
- Images shown in the Source Document panel had no zoom controls at all
(unlike PDFs, which get the browser's native viewer toolbar for free).
Added a dedicated zoomable/scrollable image panel with -/+/Fit
controls, width-based zoom (not CSS transform, so the panel's
overflow:auto actually produces real scrollbars when zoomed in),
opening at fit-width by default.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Docling's own OCR engine swaps (tesseract, rapidocr) and table_mode
(fast vs accurate) were all benchmarked against the same problem page
and made no difference - confirmed the table-structure model itself
(TableFormer), not the OCR engine, is the bottleneck (see CLAUDE.md).
app/raw_ocr_extract.py sidesteps TableFormer entirely: runs OCR
directly (tesserocr) for raw per-word text+position, then reuses
table_extract.py's own column-geometry logic (_find_zones/_classify_
money/etc) to derive columns from word positions, the same way it
already does for native PDFs. Two real adaptations: pixel-to-point
scaling (exact for a scanned PDF via its own known point dimensions,
heuristic for a bare photo), and cross-page zone sharing (a page with
one-sided data, e.g. zero debits, can't reliably resolve its own
columns alone - confirmed for real on HSBC page 1 - so zones resolve
from whichever page is most complete and apply across the whole
document, deterministically fixing the sign-assignment bug a single
page alone can't).
Wired into reconcile._run_ocr_only as a PER-PAGE fallback, not
document-level - confirmed necessary for real: Docling succeeded on
one page and silently missed another's table in the same conversion
call, which a document-level "did any page work" check would have
missed entirely (10 real transactions, including debits, would have
vanished with no error).
Verified end-to-end through the real running app on a genuine 2-page
scanned test file (docs/scanned_statement_2page.pdf, built from real
HSBC pages 1+2): 17/17 transactions, correct signs and balances,
date_sanity correctly flagged the one real OCR misread. measure.py
confirms zero regression on the existing text-PDF corpus.
New dependencies: tesserocr, pypdfium2, pillow (Python) plus
tesseract-ocr/libtesseract-dev/libleptonica-dev (OS, Dockerfile).
TESSDATA_PREFIX must be set explicitly - tesserocr doesn't reliably
auto-discover Debian's tessdata path on its own.
Known limitation, documented not hidden: the one-sided-data edge case
is only reliably fixed with a second page to borrow zones from - a
true single-page photo upload has no such fallback and stays a close
geometric call.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PaddleOCR (PP-StructureV3) performed worse than Docling on the same test
image - see the prior commit's findings, condensed into a short historical
note in CLAUDE.md rather than kept as unused code. Also removed the local
.venv_paddle environment (1.1GB, was gitignored, never tracked).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
app/paddleocr_client.py is a self-contained adapter (own column-resolution
logic, not imported from docling_client.py) that reshapes PP-StructureV3's
table output into the same canonical row format Docling's OCR path uses,
so it plugs into the real table_extract.rows_to_transactions/checks.run_all
pipeline unchanged - not just a raw-OCR-text comparison. Not wired into
reconcile.py or added to requirements.txt/Dockerfile; needs its own Python
3.11 venv (paddlepaddle has no wheel for the main app's Python version).
Run against docs/scan_test_page-1.png - the exact image Docling struggled
with - PP-StructureV3 did worse: its table HTML was more severely corrupted
(mismatched colspans, cell content from different rows jumbled together),
and while its best header-row candidate recovered status/date/credit/debit
correctly, the "Balance" column header was lost entirely with no recoverable
cell anywhere, one field short of usable. 0 transactions extracted, verified
through the real pipeline functions. See CLAUDE.md's "OCR / scanned
statements" section for full detail.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The pipeline previously had no OCR path at all - pdfplumber has zero OCR
capability (confirmed by building an image-only PDF from a real statement
page and watching extract_text() return nothing), and the only guard
against that case raised a misleading error ("could not recognize this
statement's column layout") written for a different problem entirely.
reconcile._needs_ocr() now distinguishes "no text layer at all" (a scan
or phone photo - routes to _run_ocr_only(), Docling's OCR as the sole
canonical source) from "has text, but this extractor doesn't recognize
the bank's layout" (unchanged, same error as before). docling_client's
new ocr_table_to_rows()/ocr_extract_pdf() reshape Docling's OCR'd table
into the identical row format table_extract.extract_page() produces, so
rows_to_transactions/extract_statement_facts run completely unchanged on
OCR'd data rather than duplicating that logic for a second engine.
Column-role resolution (_resolve_columns, shared with the existing
cross-check path) is now collision-aware instead of first-match-wins:
excludes a field when a header cell's text genuinely contains vocabulary
from two different fields at once (caught a real Docling mis-segmentation
bug this way, on an RBC page), while still correctly resolving two
separately-clean columns that both legitimately match the same field
(HSBC has two real date columns) and not confusing "amount" nested inside
"credit amount" for contamination. Took two iterations against the real
fixture corpus to get both cases right at once.
An OCR-sourced extraction can never reach "Verified" (checks.py's new
check_ocr_source, always needs_review) - there's no second engine to
cross-check Docling's OCR against, so the safety property every other
check rests on doesn't hold here.
The upload UI now accepts .jpg/.png in addition to .pdf.
Real-world reliability is honestly unresolved, not assumed solved - see
CLAUDE.md's new "OCR / scanned statements" section for four real test
renders this session and exactly what did and didn't work. The routing
and reshaping logic itself is verified correct (confirmed through the
real running app, both a text-PDF upload and a raw-image upload); whether
a given scan or photo actually extracts anything depends on Docling's
own, inconsistent table-structure recognition on that specific image.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Marks the three items done in the previous commit as complete in the
outstanding checklist, with detail on what was verified and how; flags
the two things that surfaced in the process but are still open: the
mismatched (categorization, not extraction) ground_truth_sep_reference.xlsx,
and the pre-existing HSBC-Aug/RBC check failures measure.py now makes visible.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Bettersight Statement Extractor as of Phase 1 build: bank-agnostic pdfplumber
extraction, Docling cross-check, the 6+1 checks, Excel export, and the
minimal web UI - all built and working.
Adds the measurement harness (measure.py) from the plan's step 10: runs
every fixtures/*.pdf with a matching *_ground_truth.xlsx against the real
pipeline, diffs date/description/amount/balance per transaction, and logs
a dated JSON result under results/. Also adds hand-verified ground truth
for the HSBC Sep statement and a new RBC fixture (RBC-CAD-Aug26.pdf, sourced
from docs/) with its own hand-verified ground truth - RBC extraction now has
regression coverage it previously lacked.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>