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>
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>
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>
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>
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>
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>
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>
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>
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.
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.