Skip to content

Add in-browser OCR support with TXT/CSV/XLSX export#1

Merged
JerrettDavis merged 8 commits into
mainfrom
feat/ocr
May 26, 2026
Merged

Add in-browser OCR support with TXT/CSV/XLSX export#1
JerrettDavis merged 8 commits into
mainfrom
feat/ocr

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Summary

  • New OCR mode alongside existing image conversion — extracts text from images entirely in-browser using Tesseract.js (lazy-loaded WASM, no server)
  • Receipt-aware parsing detects merchant, date, line items, subtotal, tax, total
  • Export results as plain TXT (one file or combined), CSV, or XLSX workbook (multi-sheet for multi-file)
  • Per-image editable text + confidence badge + progress bar
  • Bundle remains slim — tesseract.js and xlsx dynamic-import on demand

Test plan

  • 48 unit tests pass (receipt-parser, export, ocr wrapper, pre-existing formats/files/downloads)
  • Playwright E2E covers OCR flow end-to-end with __ocrTestMode hook (hermetic, no WASM download)
  • Convert mode unchanged — existing accessibility E2E still passes
  • GitHub Actions CI runs typecheck + build + unit + e2e on every push/PR

Files

  • New: src/lib/{ocr,ocr-types,receipt-parser,export}.ts (+ tests)
  • New: tests/ocr.spec.ts, src/test-setup.ts, .github/workflows/ci.yml
  • Modified: src/main.ts (mode toggle + OCR UI), src/style.css, package.json, vite.config.ts, playwright.config.ts

🤖 Generated with Claude Code

JerrettDavis and others added 8 commits May 26, 2026 12:38
Add skeleton modules (ocr, receipt-parser, export, ocr-types),
tesseract.js + xlsx + papaparse deps, jsdom test env, global
tesseract mock, and Playwright webServer config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Heuristic line-by-line parser detecting merchant, date,
currency, line items (with optional quantity), subtotal,
tax, and total. Pure function, fully unit tested.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pure transform from OcrResult[] to downloadable Blobs.
Supports combined or per-file output, free-form text, and
receipt mode with structured headers + line items. Lazy-loads
xlsx package to keep main bundle slim.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lazy-loaded singleton worker with progress callback and
clean termination. Pure interface over tesseract.js v5,
fully tested via a global module mock that simulates the
logger lifecycle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds Convert/OCR mode toggle, OCR control panel (format,
receipt mode, combined), per-item cards with editable text,
confidence badges, progress bars, and download single/all
via buildExport + JSZip for multi-file ZIPs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Runs typecheck, build, unit tests, and Playwright E2E on
every push and pull request. Caches npm + Playwright
browsers. Uploads dist artifact and playwright-report on
failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Allows Playwright tests to substitute a synthetic OCR result
instead of loading the 10 MB Tesseract WASM, keeping E2E
hermetic and fast.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hermetic test using __ocrTestMode hook to avoid loading the
real Tesseract WASM. Covers TXT export, CSV receipt-mode export,
and download verification. Also fixes playwright.config.ts webServer
to bind to 127.0.0.1 so Playwright's URL health-check resolves.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JerrettDavis JerrettDavis merged commit 6160fde into main May 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant