Commit Graph

22 Commits

Author SHA1 Message Date
JasonFraser 8a99254d28 Add QBO/Xero/CSV exports, consolidated Download dropdown, per-row exclude checkbox
Three new export formats, all reusing this pipeline's existing
transactions data with no new extraction logic:
- QBO (QuickBooks Web Connect / Quicken): qbo_service.py writes OFX 1.x
  SGML directly, including <INTU.BID>3000 so it actually qualifies as a
  real QBO/QFX file (corrected same day from an initial build that
  produced plain generic OFX with a .qbo extension slapped on - see
  CLAUDE.md for the research trail). Needs a reusable, project-scoped
  bankAccountProfiles record (pb_migrations/14) so a user isn't re-typing
  routing/account numbers on every export of the same real account.
- Xero (import CSV): xero_csv_service.py, no bank-account concept at all
  (Xero's own CSV import has none) - genuinely simpler than QBO.
- A plain, generic transactions CSV (csv_service.py) - distinct from
  Xero's import-specific shape, writes every row regardless of a missing
  date/amount since a plain dump has no structural requirement to violate.

The three original separate download buttons were consolidated into one
Download trigger + hover dropdown (QuickBooks/Xero/CSV/Excel), reusing
the Results dropdown's own zero-dead-zone hover structure. Excel's and
the new CSV's single/all download logic was generalized behind one
DOWNLOAD_FORMATS lookup rather than duplicated.

Also adds a per-transaction "include in downloads" checkbox - a lighter,
reversible alternative to permanently deleting a row: excludedFromExport
lives on the document's own result, read only at download time, with
zero effect on the live review screen's own data/checks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-24 08:16:17 -04:00
JasonFraser 206f78979b Warn on low-resolution image upload before extraction
Probes a staged bare image's own naturalWidth (fired, not awaited, so
staging stays synchronous) and flags one below LOW_RESOLUTION_WIDTH_PX -
deliberately the same threshold raw_ocr_extract._MIN_OCR_WIDTH_PX uses
server-side to decide whether to upscale before OCR, kept in sync rather
than two independently-chosen numbers. Inline warning under the staged
file's name, not a blocking modal - both real choices (pick a different
file, or proceed anyway) are already on screen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-24 08:15:51 -04:00
JasonFraser 99dc3d8bb4 Per-document mapping queue + persisted pending-mapping statements
A needs-mapping statement in a multi-file batch used to live in a
single global slot (layoutMapperStore), so mapping the first of several
such statements silently lost the rest. Each one is now a placeholder
document in extractionStore's own documents list (with a pendingMapping
field carrying its file/fingerprint/candidate data), reachable via
DocumentNavBar and a per-document "Map now" reminder in TransactionsTable,
with a clickable notice banner linking straight to each queued statement.

Also makes this survive a reload: a needs-mapping placeholder is now
saved to PocketBase (documentsService.savePendingMappingDocument,
pb_migrations/12 relaxes documents.result to optional and adds the
pending* fields) instead of living only in memory, and useDocuments.js
reconstructs it as a placeholder on load. Includes the confirm-before-
remapping step for correcting an already-successful document, and the
delete-flow guard for a placeholder with no PocketBase id yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-24 08:15:45 -04:00
JasonFraser 0c66edf48b Add transaction categorization (project-scoped, client-side rules)
A deliberate scope expansion past this product's original "does not
categorize transactions" boundary: project-scoped categorizationRules
(PocketBase), pure-JS matching (longest-pattern-wins, case-insensitive
substring), a Categorization tab beside Transactions, and an optional
"Categorized Summary" sheet in the Excel export. Categorization is
computed live from current rules and never persisted on the document
itself - only the rules persist.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-24 08:15:20 -04:00
JasonFraser 620944373a Value-pattern mapping (frontend half): confirm-a-value UI, no region-drawing needed
useBatchExtraction.js gets an else-if branch for needs_value_confirmation,
parallel to the existing needs_mapping one - reuses resolveNeedsMapping()
as-is (it's already fingerprint-only, agnostic to why resolution was
needed) and routes 'no_match' to a new layoutMapperStore.setPendingValueConfirmation()
instead of setPending().

ManualMappingView.vue gains a second mode (told apart by whether
pendingCandidateRow is set): a "Confirm values" card replacing region-
drawing - one row per field, raw text as read, an editable correction,
validated inline (empty-value and non-substring rejection, per explicit
requirement). The derived {stripPrefix?, stripSuffix?} per field is the
only thing sent as forcedMapping - no columnMap, letting auto-detection
resolve everything else.

Two real bugs caught by this stage's own testing: hasRequiredShape (the
region-drawing mode's Preview gate) stays permanently false in the new
mode since columnMap never populates there - fixed with a new canPreview
that branches per mode. The validation/diff logic's own substring check
didn't separate a leading "-" before comparing, so correcting a negative
value like "-CAD50.00" to "-50.00" failed validation outright (not a
contiguous substring) - the same bug already fixed on the backend earlier
the same day, reintroduced independently since the logic isn't shared.

LayoutsView.vue's own separate forcedMappingFor() (used by "Test") gets
the same valuePatterns key; Inspect gains a note for an empty columnMap
and a new card showing the saved cleanup rule itself.

Verified end to end against the real stack (19 assertions, actual
service/composable files): upload triggers needs_value_confirmation,
the derived pattern previews and saves correctly with no columnMap, the
real PocketBase superuser approves it via the existing L.8 review screen
unmodified, and a completely independent third-party user auto-applies
it via exact fingerprint match. measure.py byte-identical to baseline.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 19:28:54 -04:00
JasonFraser 292c13e819 Add the Layouts page, drift detection on every recheck, and fix two real persistence bugs (L.7)
New /layouts route (LayoutsView.vue, linked from AppHeader.vue): List (own + shared
mappings with usage/failure stats), Inspect (source document with each column drawn
as a labeled vertical strip), Test (an unsaved dry run against any of the user's own
documents), Version history + Roll back (append-only - a rollback creates a new
version rather than editing history), and Retire. The plan's own "Edit" (reopening
ManualMappingView pre-populated) was deliberately dropped - columnMap never persists
page/vertical position, so there's no real data to re-populate a visual editor with.

Drift detection now runs on every recheck, not just the original extraction -
useRowEditing.js and TransactionRow.vue both call the same recordUsage() useBatchExtraction.js
already used, via a newly shared layoutMappingsService.checksPassed(). Required
threading layoutMappingUsed/layoutMappingVersionUsed onto the in-memory document
object too (extractionStore/useDocuments/useBatchExtraction), not just the PocketBase
record.

Found and fixed two real bugs via this stage's own end-to-end testing, both in the
same "computed correctly this session, never persisted" category as L.6's zone-padding
fix: startPage itself was never saved, so every future auto-apply of a saved mapping
would have silently reset to page 1, reintroducing the cover-page bug L.2 already
fixed once. Worse: startPage alone only skips whole pages - it does nothing about the
real header row text still sitting on the start page itself, which would have
corrupted essentially every real manually-mapped statement. Fixed with two new
persisted fields (startPage, headerBottom) and a new header_bottom parameter in
table_extract.py, using the same zone-padding margin as a safety buffer.

Verified against the real rebuilt container: a 2-page synthetic statement confirmed
both bugs real before their fixes and confirmed both fixed together; a second,
independent upload auto-applies the saved mapping with both fields carried through;
sourceDocument backfill, version history/rollback, retire, and real three-user
promotion all confirmed against the real PocketBase; a separate test confirmed the
recheck-triggered drift detection itself, flipping a real mapping to stale after a
deliberately broken running-balance edit. measure.py byte-identical throughout; npm
run build passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-15 05:03:20 -04:00
JasonFraser 4764023d87 Add the manual layout mapping screen - the core deliverable of the layout mapper (L.6)
New /map-layout route (ManualMappingView.vue): draw a box over each column on the
source document, assign it a role, set date format/sign convention/ignored rows,
Preview (required before Save) runs the real forced-mapping extraction and shows
the first ten rows plus the balance check outcome, Save Mapping persists the
mapping + an initial version + the document. A real File can't survive a router
navigation, so a new layoutMapperStore holds the one pending file + fingerprint in
memory; ExtractorView.vue shows a banner linking to the mapper while one is set.

Two real bugs found by actually wiring this up and testing it end to end:
useBatchExtraction.js was reading fingerprintHash from the wrong (post-reassignment)
response, which never carries that field - would have silently left
documents.layoutFingerprintHash unset for every mapping-applied extraction. More
consequential: forced-mapping column zones were completely unpadded, so a word
landing a fraction of a point past a raw boundary (or a human's own imprecise drag)
could silently exclude a whole transaction with no error - fixed with a new
_FORCED_ZONE_PADDING in table_extract.py, the same discipline the auto-detected
path's own zones already use.

Verified end to end against a hand-built synthetic statement (unmatchable gibberish
headers, 3 real transaction rows at known coordinates) through the real rebuilt
container: Preview correctly extracts all 3 transactions with a passing balance
check; Save persists correctly (confirmed on the re-fetched document record, not
the create response); a second, independent upload of the identical file then
silently auto-applies the saved mapping with zero further input, producing
byte-identical results to the manual Preview - the actual proof this feature
exists for. measure.py byte-identical throughout; a regression re-run of the
earlier Equals Money forced-mapping test confirmed the zone-padding fix changed
nothing there. npm run build passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-14 21:48:20 -04:00
JasonFraser 6e0d33510d Add multi-highlight source panel + click-and-drag region tool (L.5)
usePdfViewer.js/useImageZoom.js gain a parallel highlights/showHighlights/
clearHighlights (several labeled boxes at once) alongside the existing single
highlight/showHighlight/clearHighlight the review screen already depends on -
that call site needed zero changes. SourceDocumentPanel.vue exposes both and
renders the plural boxes via a new v-for. New useRegionDraw.js composable adds
the click-and-drag-to-define-a-region interaction the manual mapping screen
(L.6) will use, wired in via a new regionDrawMode prop + region-drawn emit, a
no-op everywhere today. Both viewers now also expose their own raw zoom ref
(previously only a formatted display string was public) so the region tool can
convert a drawn pixel rectangle back into PDF-point/image-pixel space.

Verified: 21 assertions against the real composables (a fake window.addEventListener
is the only browser API useRegionDraw touches, so no real DOM was needed) - drag
math divides correctly by zoom, an up-left drag still normalizes to a positive box,
a sub-threshold drag never fires, and the new multi-highlight state never disturbs
the existing single-highlight state. npm run build passes; the app container
rebuilt and confirmed serving the new bundle. measure.py unaffected (no backend
touched). Not machine-verified: actual on-screen rendering and a real mouse drag,
same standing limitation as every other frontend-only change this session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-14 20:34:17 -04:00
JasonFraser 92ba5f4386 Wire frontend fingerprint-lookup orchestration for the layout mapper (L.4)
useBatchExtraction.js now reacts to a needs_mapping:true response: looks up an
exact or near-match layout mapping (layoutMappingsService.js), applies it silently
on an exact match, asks for confirmation on a stale exact match or a near match via
a real ConfirmModal wired through ExtractorView.vue (not a placeholder), and falls
through to reason:'no_match' when nothing matches (the manual mapping screen's own
entry point, not built yet). A used mapping's usage is recorded for drift detection
and persisted onto the saved document record.

Found and fixed two real bugs in the near-match comparator by testing it against
the spec's own documented example (Debit/Credit renamed to Withdrawals/Deposits):
compute_fingerprint was building header_labels from whole header LINES instead of
per-field label text, making a two-word rename indistinguishable from a totally
different layout; added a field_labels map so the comparison is per-field. Even
after that, the first 70% overlap threshold still failed the documented example
itself (a 4-field rename of 2 fields is exactly 50%) - corrected to 50%, derived
from the example's own real numbers.

Verified: 18 assertions against the real layoutMappingsService/useLayoutMapping
(hard gates, the corrected per-field overlap, real PocketBase ownership/sharing
rules, stale-mapping decline/accept, no-match reporting); the real rebuilt
container's /api/process response now carries the fixed field_labels shape;
measure.py byte-identical throughout; npm run build passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-14 19:51:42 -04:00
JasonFraser 6913d45d20 Add review screen R.5: edit log, acknowledge/accept workflow, Excel Edits sheet
Completes the R.1-R.5 review screen plan. editLog/acknowledgedFlags/accepted all
live on the existing result JSON blob, no new PocketBase migration needed. Every
row mutation (manual edit, suggested-fix apply, structural edits) now logs a
field-level edit log entry; flags can be individually acknowledged; a document
can be Accepted once Verified or fully acknowledged; exports gain an optional
Edits sheet when edit_log is non-empty.

Verified: measure.py byte-identical to the pre-R.5 baseline, real curl round trip
through the rebuilt container confirming the Edits sheet appears/omits correctly,
extractionStore's new getters/actions run directly against real Pinia, and
useRowEditing's edit-log capture confirmed against a document actually persisted
on the live PocketBase container.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 20:41:13 -04:00
JasonFraser 65fa93bb28 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 <tr> 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 <noreply@anthropic.com>
2026-10-13 15:47:36 -04:00
JasonFraser deee78a6c1 Keep the sidebar's per-project document list live across the app
Reported: a newly loaded document didn't show up under its project in
the sidebar, with the same gap correctly anticipated for a document
moved from the transactions view.

Root cause: ProjectSidebar.vue's own per-project document list was a
reactive({}) local to that one component, lazy-loaded once per project
on first expand and cached indefinitely - nothing else in the app had
any way to tell it something changed.

Moved the cache into projectsStore.js (documentsByProject, keyed by
project id) - the natural shared owner. Four new actions:
loadProjectDocuments (the same lazy-fetch-once behavior, just
relocated), addDocumentToCache/removeDocumentFromCache/
moveDocumentInCache, each a no-op if that project was never expanded
so call sites don't need to know or care. All three real mutation
sites now call the relevant action right after their own successful
backend call: useBatchExtraction.js (new document), TransactionsTable's
"Move to project" (called before the document's own project field is
mutated, so the old project id is still readable), and
DocumentNavBar's delete (which didn't even import projectsStore
before). ProjectSidebar's own per-document delete now calls the same
shared action instead of mutating local state.

Verified end-to-end against the real running PocketBase: created a
project, loaded its cache, created a document and confirmed it
appeared immediately, moved it to a second project and confirmed it
left the first project's cache and entered the second's, deleted it
and confirmed it cleared - then re-fetched directly from PocketBase
and confirmed server-side state matched the client cache exactly at
every step. measure.py unaffected (no backend touched). Not
machine-verified: the sidebar UI itself reflecting this without a
manual collapse/re-expand - Claude-in-Chrome did not connect this
session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 15:30:16 -04:00
JasonFraser 4c0973b6b5 Fix pdf.js pages staying blank until a zoom action
Reported: pages appeared blank/"a silhouette" on first load and
refresh, becoming visible only after hitting zoom.

Root cause: loadDocument() computed fitZoom/zoom correctly after
loading a PDF, but never actually called renderAllPages() - only
zoomIn/zoomOut/resetZoom do (via applyZoom), which is why touching zoom
"fixed" it. With nothing drawing into them, every <canvas> sat at the
browser's own unset-canvas default (300x150px), a small blank shadowed
rectangle. The render pipeline itself was never in question - already
proven correct by zoom successfully triggering it - this was purely a
sequencing bug.

Fixed with nextTick() before renderAllPages(): setting numPages only
queues the v-for's canvas elements, they don't exist in the DOM (so
canvasRefs stays empty) until Vue flushes that update, which nextTick
explicitly waits for.

Also investigated the separately reported "no longer see the other top
bar pdf options" - checked the zoom-controls row's own v-if and CSS,
found no second bug there. Most likely the same blank-canvas symptom
read as the whole panel looking broken; not confirmed as the same
issue, flagged to the user to check once this fix is live rather than
assumed resolved.

Verified: npm run build passes, the app container rebuilt. measure.py
unaffected. Not machine-verified - Claude-in-Chrome did not connect
this session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 15:05:46 -04:00
JasonFraser 42ff3e364f Fix pdf.js getDocument() call shape and document-switch cleanup
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>
2026-10-13 11:40:07 -04:00
JasonFraser cac895a11f Replace the native PDF iframe with a pdf.js viewer for row highlighting
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>
2026-10-13 11:26:48 -04:00
JasonFraser 461b399d74 Add document delete/rename, merge Result into the transactions top bar
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>
2026-10-13 09:13:17 -04:00
JasonFraser ae75c1ff11 Add the client-project sidebar UI (PocketBase Stage B.3)
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>
2026-10-13 07:32:08 -04:00
JasonFraser e59013cdcb Move document persistence from localStorage to PocketBase (Stage B.2)
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.
2026-10-13 06:41:51 -04:00
JasonFraser ec58a956e9 Accumulate staged files across picks instead of replacing them
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.
2026-10-12 21:06:53 -04:00
JasonFraser 2081bc574b Multi-file upload, sequential extraction, prev/next navigation, Download All
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.
2026-10-12 21:00:07 -04:00
JasonFraser 12e18ae235 Align Recheck button with balance inputs; add table sort/filter/search
- 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.
2026-10-12 07:53:36 -04:00
JasonFraser 6e4da3f385 Restructure frontend to Vue 3 + Vite (Stage 2 of 2)
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>
2026-10-12 06:32:49 -04:00