Deepen purchase draft save and confirmation
Before Current ownership
flowchart TB E["Four web draft editors"] --> I["Each owns identity + filtering"] I --> S["Pause and save"] I --> C["Page confirms stored draft ID"] S -. "caller must order" .-> C C -. "failure must resume" .-> S classDef node fill:#fff,stroke:#78716c,color:#292524; class E,I,S,C node; linkStyle 3,4 stroke:#b54736,stroke-width:2px;
After Proposed ownership
Problem Four editors repeat draft rules, while the save interface leaves confirmation ordering and recovery with callers.
Solution Give one purchase draft module ownership of editable state, persistence and confirmation; preserve each viewport's editing layout.
- Locality for draft invariants
- Leverage across four editors
- Interface tests include confirmation
Evidence
- Editors pause autosave, save, then call a page handler that confirms only the stored draft ID.
- Autosave resumes after a save failure, but the page catches a confirmation failure without resuming it.
- Duplicate-number correction updates React state just before saving the last-render ref; the confirmation handler ignores the supplied corrected draft.
Files
- W / ocr / ScanPage / desktop / DraftInvoiceDesktop.tsx:155
- W / ocr / ScanPage / small-screen / DraftInvoiceSmallScreen.tsx:221
- W / ocr / ManualEntryPage / desktop / DraftInvoiceDesktop.tsx:136
- W / ocr / ManualEntryPage / small-screen / DraftInvoiceSmallScreen.tsx:213
- W / ocr / hooks / useDraftAutoSave.ts:577
- W / ocr / ScanPage / shared / useScanPageState.ts:860
Tests at the interface
Current editor tests replace autosave. Test edit → save → confirm through the same interface, including failed confirmation, duplicate suffixes and deleted rows. Keep focused viewport interaction tests.
Deletion test
Keep the useful delta-saving implementation. Removing four copies of caller sequencing should concentrate it inside the deep module; a forwarding module would remain shallow.
Real seam
Use the owned persistence adapter and a delayed or failing test adapter. This seam tests the complete sequence, so depth increases without exposing more sequencing controls.