Two real bugs from the first real test of R.1's pdf.js viewer:
1. getDocument(url) was called with a bare string. The installed
pdfjs-dist (6.4.299) requires an object - getDocument(src = {})
only ever reads src.url/src.data/src.range, so src.url ended up
undefined and pdf.js threw its own "expected either data, range, or
url parameter" error, exactly what was reported. Fixed:
getDocument({ url }).
2. Found while fixing #1: cleanup called pdfDoc.value.destroy(), but
destroy() lives on the loading task (getDocument()'s own synchronous
return value), not the resolved PDFDocumentProxy, which has no
destroy of its own - confirmed via the package's own type
definitions and a real Node script throwing "doc.destroy is not a
function" otherwise. Fixed by keeping the loading task and calling
loadingTask.destroy() instead.
Verified for real via pdf.js's own Node support, not just re-reading
the code: the buggy call shape reproduced the exact reported error
first, the fix loaded both the HSBC and RBC fixtures correctly, and
loading a second document after destroying the first (the real
document-switching scenario) succeeded cleanly.
Traced but could not find a code path connecting this to the separately
reported empty transactions table - that computed has no dependency on
the source panel's state. Fixed the confirmed bug; did not claim that
symptom is resolved.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
R.1 (frontend half) of the staged review-screen plan. An <iframe> has
no overlay hook, so drawing a highlight box on a flagged row's own
printed position (source_page/source_bbox, shipped in the previous
commit) needed real rendering control.
New usePdfViewer.js (installs pdfjs-dist) renders each page to its own
canvas, stacked in one scrollable column - the closest behavioral match
to the iframe's own scrollable multi-page view. The browser's native
PDF toolbar goes away as a direct consequence; zoom is rebuilt to match
useImageZoom.js's own -/+/Fit pattern. The coordinate mapping (bbox
value * zoom, no axis flip) is the exact one already verified correct
against real rendered fixtures in the backend half of this work, reused
here rather than re-derived.
useImageZoom.js gained the same highlight/highlightStyle/showHighlight/
clearHighlight shape for an image upload, reusing its own existing zoom
math. SourceDocumentPanel.vue exposes one unified showHighlight(page,
bbox)/clearHighlight() routing to whichever viewer is active - not
called from anywhere yet, since R.2 (the flagged-row UI that would
trigger it) isn't built. R.1 only builds the capability.
Verified: npm run build passes, the pdf.js worker bundles and serves
correctly (curl'd directly, 200). The app container rebuilt and the
served bundle confirmed to contain the new class/function names.
measure.py unaffected (no backend touched this half). Not
machine-verified, more consequential than usual to leave that way:
canvas rendering, worker loading, zoom, and scroll all depend on real
browser behavior a bundle check can't confirm - Claude-in-Chrome did
not connect this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
R.1 (backend half) of the staged review-screen plan (Phase 2). Every
transaction now carries source_page/source_bbox - purely additive, so
the frontend's upcoming pdf.js viewer can box the exact printed row a
flagged transaction came from.
Traced extraction_service.py first: the canonical transactions list for
a normal text PDF always comes from pdfplumber (table_extract.py);
Docling's own extract_transactions() only feeds the cross-check
confidence signal, never the returned data. So this only needed to
touch table_extract.py and raw_ocr_extract.py (the OCR pixel-position
fallback), zero changes to engine-selection/cross-check logic.
One shared helper, table_extract._line_bbox(), used by both files
(mirrors how raw_ocr_extract.py already reuses _classify_money/_REF_RE
rather than re-implementing them) instead of two separate
implementations that could drift apart. A new _union_bbox() grows a
transaction's box as narrative lines merge into it, both the trailing
direction (HSBC) and leading direction (RBC).
Docling's own OCR-table-structure path doesn't get a real bbox (a
synthetic row-index, not a pixel position) - those transactions get
source_bbox: null, a graceful no-highlight rather than an error.
Verified: measure.py run before/after, byte-identical pass rate and
field accuracy on all three fixtures. A real /api/process call against
both HSBC and RBC fixtures confirmed every existing field unchanged.
Then the check measure.py can't make at all: rendered both fixtures'
pages for real and drew the reported source_bbox on the actual page
image - every box landed on exactly the right printed row, including
HSBC's trailing-narrative merge correctly widening the box.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ProjectSidebar: each project now expands (chevron toggle) into its own
lazy-loaded document list - click a document to open it in the main
view, or delete it via the same two-step ConfirmModal pattern already
used elsewhere (Move to project, DocumentNavBar's own delete). Deleting
from here keeps both the sidebar's cached list and the main workspace
(extractionStore) in sync.
Also fixes a real reported bug: the Results dropdown closed when the
mouse moved slowly from the toggle down to the checks list, but stayed
open on a fast drag. Root cause: the panel's 8px gap was a `top`
positioning offset, which doesn't extend its relatively-positioned
parent's own hoverable box - that gap sat outside the hover zone
entirely, so crossing it slowly let a genuine mouseleave fire first.
Fixed by moving the gap into padding on an invisible wrapper instead of
a positioning offset, so the whole hover path - button, gap, and panel
- is one continuous box with no dead zone.
Verified: npm run build passes; the served bundle contains the new
class names. The two new Vue reactivity patterns (a reactive Set via
ref(new Set()), and dynamic keys on a reactive({}) object) were each
executed directly against real Vue reactivity, not assumed - both
correct. measure.py unaffected. Not machine-verified: the actual
interactive behavior - Claude-in-Chrome did not connect this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Five related UX fixes from one request:
- DocumentNavBar's filename is now clickable (hover state + a trailing
ellipsis-icon hint) and renders for any loaded document, not just
once there's more than one - opens DocumentOptionsModal to rename, or
hands off to a ConfirmModal to delete (now with danger/busy props:
red confirm button, stays open with a spinner mid-request). Lets a
user delete a document they don't want before downloading.
- Every .btn-toggle button (Hide/Show, Recheck, Download, Results) is a
consistent 36px tall by construction now, not by each call site
matching a number.
- The separate "Download All" button is gone - the single Download
button opens DownloadChoiceModal (current vs. all) once more than one
document is loaded, same as before with exactly one.
- ResultCard.vue is deleted; its content (status banner, checks list,
Download) merges into TransactionsTable's own top bar: a Results
toggle (left) opens a hover-sticky dropdown - stays open while the
mouse is over the trigger or panel, closes the moment it leaves both,
via one shared @mouseleave rather than separate hover-tracking state
- DocumentNavBar sits truly centered (CSS Grid, not flex
space-between) in the middle, Download on the right.
- New shared useModalFocus composable, factored out once three modals
needed the same "focus on open so Esc works" logic.
Verified: npm run build passes; every new icon class confirmed against
the installed FontAwesome CSS; the app container rebuilt and the served
bundle confirmed to contain the new component/class names.
extractionStore.removeDocument/setActiveDocumentFileName executed
directly against a real Pinia instance across five scenarios (earlier
removal, active-document removal mid-list and as the last entry,
emptying to zero, a plain rename) - all correct.
documentsService.updateDocument(id,{fileName})/deleteDocument executed
directly against the real running PocketBase container - rename
persisted and re-fetched correctly, delete correctly 404s afterward.
measure.py re-run, unaffected. Not machine-verified: the actual
interactive behavior - Claude-in-Chrome did not connect this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The dropdown worked but gave zero feedback - no confirmation, nothing
visibly changed - so a successful move looked identical to a no-op
(reported directly by the user). Adds a generic ConfirmModal.vue
(reusable beyond this one call site) triggered on select instead of a
second button next to the dropdown, per request. Switches the select
from a bare :value binding to its own v-model so a cancelled move can
actually revert the visible selection (a plain :value can't re-sync a
<select>'s displayed option). Adds a transient "Moved to {project}"
note and clarifies the label from "Project" to "Move to project".
Verified: npm run build passes; the built bundle contains the new
modal/label/note strings; the app container rebuilt and serves 200.
measure.py unaffected. Not machine-verified: the actual modal
interaction - Claude-in-Chrome still isn't connected this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The project sidebar was "not impressive" per direct feedback, pointed
at docs/sample_ui.png (a Cloudflare R2 dashboard) as the reference.
Adds AppHeader (brand + breadcrumb + account menu) and AppFooter, and
rebuilds ProjectSidebar into the reference's own left-nav pattern
(search box, icon-led list, bottom-anchored collapse-to-rail toggle).
ProjectSidebar moves from ExtractorView into App.vue's shell, since
it's account-wide chrome, not page-specific - same reasoning as the
new header/footer.
Every unicode-entity icon left over from the original vanilla-JS build
is replaced with a FontAwesome solid icon (installed as a real npm
dependency, not a CDN link, to keep the Docker build offline-
reproducible) - not just in the sidebar, across every button site-wide,
per the explicit ask. Color theme is untouched.
Verified: npm run build passes with the fonts bundled correctly; every
icon class used was grepped against the installed FontAwesome CSS and
confirmed to exist; the app container was rebuilt and curl-checked
end-to-end (bundle, CSS, and font asset all serve correctly, and the
new component/icon class names are present in the built JS). measure.py
re-run, unaffected. Not machine-verified: the actual rendered page -
Claude-in-Chrome did not connect this session, same as every prior UI
change in this project.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Completes the three-stage PocketBase plan: project CRUD with delete
guard rails (refuses the default project and any non-empty project),
a collapsible sidebar to select/filter/rename/create/delete projects,
and a "Move to project" control on the transactions table. useFileUpload
is split back into a pure staging concern; loadDocuments moves out to
a new useDocuments composable shared by the sidebar and the initial
page load.
Verified at both the service layer and the Pinia store layer against
the real running PocketBase + app stack (signup, every delete guard,
move-to-project, filtered listing, store state sync) - all correct.
measure.py re-run, unaffected. Caught and fixed one binding bug before
any build/test: the "Move to project" select was reading result.project
(the raw backend blob, no such field) instead of the store's own
activeDocument.project.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The actual request was simple (store exports in R2 like source files,
pending a retention-duration decision), but investigating where
exports were written surfaced something worse: /api/process built and
saved a full workbook to disk on EVERY extraction, and nothing in the
frontend ever called /api/download/<filename> to retrieve it (confirmed
by grep - no reference anywhere). Every extraction was silently
orphaning an .xlsx file for no reason; 91 had already accumulated
locally from this session's own testing alone.
Removed the dead work entirely: /api/process no longer builds or saves
a workbook at all. /api/download/<filename>, file_repository.
save_workbook/resolve_output_path, and OUTPUT_FOLDER (env var, volume,
directory) are all gone - confirmed nothing else referenced any of
them before removing. outputs/ deleted, including its 91 accumulated
files.
/api/export (the only path actually used - Download Excel/All) now
builds the workbook into an in-memory BytesIO and streams it straight
from there - never touches disk, not even temporarily. The frontend
persists it long-term instead: documentsService.saveExportFile uploads
the same Blob the browser download already used to a new exportFile
field (pb_migrations/3_add_export_file.js), stored in R2 same as
sourceFile. Overwrites the previous export rather than keeping a
history - no retention policy has been decided yet, and keeping every
version would just relocate the same unbounded-growth problem from the
VPS to R2 instead of fixing it. Best-effort from ResultCard.vue - a
save failure is reported but never blocks the browser download itself.
Verified for real: /api/process's response no longer has `filename`
(title still does); /api/export still streams a valid, correctly-typed
.xlsx; /app/outputs no longer exists in the rebuilt container; the old
/api/download URL now falls through to the ordinary SPA catch-all, not
a leftover route. documentsService.saveExportFile run against the REAL
bytes /api/export produced, fetched back through the R2-backed URL,
confirmed byte-for-byte - and confirmed a second export overwrites
rather than creating a second record. measure.py unaffected; npm run
build passes.
New documentsService.js (saveDocument/updateDocument/listDocuments/
deleteDocument/sourceFileUrl) and a minimal projectsService.js
(getDefaultProject/listProjects, extended in B.3) replace
extractionService.js's old localStorage-backed persistResult/
restoreResult/lastBatchKeys/appendToLastBatch/startNewBatch/
discardPersisted - deleted outright, not kept alongside.
extractionStore's document entries gained a pbId field (the PocketBase
record id), set from saveDocument's create response or a listed
record's own id - needed so useRowEditing's saveEdit() knows which
record to PATCH.
RestoreBanner.vue and uiStore's restoreBannerVisible/Text/show/hide
deleted outright (not repurposed) - the banner existed because a
localStorage cache's presence was ambiguous ("did a crash happen?");
PocketBase being the real backend means a logged-in user's documents
just load, same as any other app showing your own data.
useFileUpload.restoreOnLoad() renamed loadDocuments(), simplified from
the plan's own "needs a watcher" - unnecessary, since App.vue's auth
gate already means ExtractorView can't mount before authenticated.
Two real bugs caught by executing the actual services against the live
PocketBase, not just reading them: an empty-string filter is rejected
outright rather than treated as "no filter" (fixed by omitting the key
entirely); sort:'-created' referenced a field that didn't exist -
projects/documents came out of migration 1 with no created/updated
fields at all, unlike the built-in users auth collection. Fixed with a
new migration (2_add_timestamps.js, not editing the one that already
ran) adding autodate created/updated to both, field shape copied from
users' own via the REST API.
Verified end-to-end with the real, committed services run from a
plain Node script against the live container: signup -> default
project resolves -> saveDocument with a real File -> listDocuments
finds it -> sourceFileUrl fetched for real returns the exact original
bytes -> updateDocument (simulating a row edit) -> re-listDocuments
confirms the change actually persisted. npm run build passes.
measure.py unaffected; R2/Google settings confirmed to survive the
PocketBase container rebuild.
Same official 4-color "G" logomark PocketBase itself serves (the exact
SVG confirmed from the live /api/collections/users/auth-methods
response while verifying the OAuth2 setup) - same button on both the
sign-in and sign-up views, since they're the same form with a mode
toggle, not separate pages.
configure-secrets.sh run for real against the user's actual R2 bucket
and Google OAuth client, confirmed via /api/settings, /api/collections/
users, and /api/collections/users/auth-methods (the exact endpoint the
frontend SDK calls). Round-tripped an actual file through R2 end to
end - created a document with a real multipart upload, fetched it back
via PocketBase's own file URL, confirmed the exact bytes.
Caught before any of this ran: the superuser email/password in .env
were still .env.example's literal placeholders even after R2/Google
values were filled in - flagged and confirmed with the user before
upserting a well-known default credential on an account with full
admin access to every user's data.
.fields > div's flex:1 1 180px is a WIDTH basis meant for the
horizontal balance-fields row - in LoginView's column layout that same
180px became a HEIGHT basis instead, stretching each email/password
wrapper to ~180px tall. Not padding/margin, a flex-basis axis mismatch.
New third service alongside app/docling - a deliberate, revisited
decision from the documented "no DB" architecture, not an oversight.
pocketbase/Dockerfile - official minimal pattern (no official image
exists), pinned binary, migrations+hooks copied in and run on startup.
pb_migrations/1_create_collections.js - schema as code: users (auth,
self-registration open), projects (owner-scoped), documents (owner-
AND project-scoped - project is REQUIRED, not optional, since a
planned future per-project category-mapping feature needs every
document scoped from day one), with a sourceFile field for the
original PDF/image (stored in R2 once configured).
pb_hooks/ensure_default_project.pb.js - auto-creates each new user's
"General" project (isDefault:true) the moment their account exists -
covers password and Google signup uniformly, guarantees the required
documents.project relation always has somewhere to point.
configure-secrets.sh - the only place R2/Google secrets are handled,
reading from a gitignored .env and PATCHing PocketBase's own REST API.
Never in a migration (those are committed to git).
Frontend: pocketbaseRepository.js (the one SDK instance),
authService.js (login/signup/Google/logout), authStore.js (Pinia,
synced to the SDK's own authStore), LoginView.vue, and App.vue's new
auth gate - talks to PocketBase directly, not proxied through Flask.
Verified via real REST API calls against the running container (not
just read): migrations create the expected collections/rules; a fresh
signup gets exactly one auto-created "General" project; a second
user's token can't see the first user's data; a document created with
no project correctly fails validation (confirming the frontend must
resolve one itself); authService's actual functions exercised via a
live Node script against the real container (signup, hook-created
project visible, logout, re-login). npm run build passes. measure.py
unaffected (no backend code touched).
Not yet verified - needs real R2/Google credentials this session
doesn't have: configure-secrets.sh itself, and the Google OAuth popup
flow (needs a real browser + real Google Cloud OAuth client, both
outside this repo's control - documented as setup prerequisites in
README.md).
This is Stage B.1 of 3 (schema + auth gate). B.2 (document persistence
moves from localStorage to PocketBase) and B.3 (the project sidebar
UI) are not started yet.
DocumentNavBar no longer sits in its own standalone div above both
panels - it's now rendered inside TransactionsTable.vue, across the
top of the transactions card, above the Hide/Show Source Doc row, with
no border/background box of its own (already inside the card's). Still
disappears via the same v-if once there's nothing to navigate between.
.pdf-col/.txn-col height raised from 82vh to 102.5vh (25% more), both
panels still matching each other exactly.
Picking/dropping a file replaced whatever was already staged (reported:
"I select one document and start again to select another, the first
one is replaced"). setFiles now appends instead, deduping exact
name+size repeats, so a batch can be built up across several separate
picks/drops, not just one multi-select dialog.
Each staged file gets an x to remove it before Extract is clicked.
The staging list is cleared the moment Extract runs (not after it
resolves), so an already-handed-off file can't linger and get
re-processed - and duplicated, since extractionStore.documents has no
dedup of its own - by a later click.
Also resets the native file input after each pick so re-selecting the
same file (e.g. after removing it) still fires a change event.
extractionStore restructured from a single currentResult into a list
of documents + activeIndex, so a batch of files can be extracted
sequentially (useBatchExtraction.js replaces useExtraction.js) with
"Extracting N/M: filename" progress, and browsed afterward via
DocumentNavBar's prev/next. currentResult/currentDocKey/
flaggedIndexes/effectiveOpeningBalance/effectiveClosingBalance stay
getters with their exact old names (now derived from activeDocument),
so ResultCard.vue and most of TransactionsTable.vue needed no changes
beyond the balance-input v-model bindings.
Two choices from the plan were revised after user review before any
code was written: focus never moves on its own except to show the
very first result (a later file finishing mid-batch never yanks the
user away from whatever they're reviewing or editing), and a Download
All button sits beside Download Excel, shown once a multi-file batch
has actually finished.
Restore-on-reload generalized from one document to a whole batch
(lastBatchKeys/appendToLastBatch replace lastDocKey; persistResult now
saves {fileName, result} with a backward-compatible fallback for the
old bare-result shape).
Two real bugs caught in review before ever reaching a browser:
TransactionRow was keyed only by row index (could reuse a stale
component's draft across documents sharing an index - fixed by keying
on docKey+index too), and addDocument called recomputeFlags() which
only ever targets the active document (a document added while focus
stayed elsewhere would never get its own flaggedIndexes computed -
fixed by computing flags directly for whichever document was just
added, not just the active one).
Verified: npm run build; every new/changed store action and getter
executed directly against real Pinia with synthetic multi-document
scenarios; the real Docker container rebuilt and hit with sequential
/api/process calls confirming identical results to the pre-change
baseline; measure.py unaffected (no backend code touched). No backend
changes anywhere - /api/process|recheck|export already each take
exactly one file/document per call.
Add README.md - what the product is, docker compose up, project
layout, measure.py usage, pointer to CLAUDE.md for the deeper record.
Delete fixtures/ground_truth_sep_reference.xlsx - a bank-description
to accounting-category mapping from the separate bank_statement_
categorizer tool, not this product's own extraction ground truth, and
referenced nowhere in this repo. Nothing to repurpose it into, since
this product deliberately doesn't categorize transactions at all.
Investigate HSBC-Aug's running_balance failure and both fixtures'
engine_agreement findings - confirmed not extraction bugs. Built and
hand-verified fixtures/HSBC-USD-August2026_ground_truth.xlsx (all 31
transactions checked against the rendered PDF, including the Cancelled
wire and its two blank-balance rows) to prove it: 1.0 field accuracy.
The running_balance break is the Cancelled wire's -22,386.00 genuinely
not applying to the real balance chain - the check correctly flagging
that, not smoothing it over. engine_agreement on both fixtures is
Docling missing a table and pdfplumber's result being used instead,
exactly as designed, correctly flagged for lower confidence rather
than silently trusted.
RBC prints "Account Fees: $48.75" directly under "Closing balance" on
the statement's last page - not a money token this module recognizes
("$48.75", not "48.75"), no reference-number prefix, no page-number
pattern, so it fell through to plain narrative text and landed on the
last real transaction's description via the trailing-leftover-buffer
rule (correct behavior for a GENUINE trailing narrative line, wrong
for this one).
Fixed by treating the closing-balance line as a position-based
boundary, the same way the header row already is: once extract_page()
recognizes it, every subsequent line on that page is skipped outright
rather than reaching money/narrative classification at all. A no-op
for HSBC, which never emits a closing_balance row in the first place.
measure.py: RBC field accuracy 0.9977 -> 1.0, HSBC unaffected. RBC's
overall status is still "Failed" after this - a separate, pre-existing
engine_agreement disagreement on page 4, not touched by this fix.
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>