Bug 1 (malformed/truncated JSON crashed the route with SyntaxError):
- Raise extraction max_tokens 4000 -> 8000 and ask the model for compact, complete JSON
- Parse tolerantly: extractJson() for fences/prose, plus a repair pass that closes
open strings/brackets and drops a trailing partial entry for token-truncated output
- Wrap JSON.parse; on failure return a friendly code (parse_failed, or output_truncated
when stop_reason was max_tokens) instead of a raw 500
Bug 2 (40MB PDF -> Anthropic 413):
- Validate visual file size BEFORE calling the API (max 4.5MB raw; base64 inflates ~33%)
- Return 413 {error:file_too_large, maxMb} so the UI shows 'max X MB, compress or use text/link'
i18n: file_too_large (with {mb}), parse_failed, output_truncated (es/en); ImportModal
interpolates the size limit.
Verified: build passes; repair recovers mid-string/mid-property/fenced/prose JSON;
oversized upload returns 413 with the limit; text path fails gracefully (no crash).
Editor QR tab now generates a styled, scannable QR with live preview and clean
PNG/SVG export (no frame or text — the owner lays it out).
- Restaurant.qrConfig JSON persists the styling (migration 0003)
- qr-code-styling (MIT) runs client-side in QrTab: preview + WYSIWYG PNG (2048px)
and vector SVG export, avoiding native canvas deps in the alpine image
- Controls: dots color/gradient, background (incl. transparent), corners color,
dot & corner shapes, optional center logo (uploaded via /upload, capped at 20%)
- Scannability: error correction forced to 'H' whenever there's a logo or color;
WCAG contrast check warns on low contrast; persistent 'verify before printing' notice
- Templates inherit the menu palette but every value is independently editable
- QR always targets {APP_BASE_URL}/{slug}
- PATCH /api/[slug]/qr saves config; GET stays as a config-aware server fallback
- i18n (es/en) for the qr namespace; glassmorphism, mobile-first
Verified: build passes; migration 0003 applies; PATCH persists qrConfig; GET
honors saved colors/ECC (png + colored svg); auth guard returns 401.
ProductEditor and CatalogTab use t('save'/'edit'/'delete') from the editor
namespace, but those keys only existed in the common namespace, so the UI showed
raw keys (editor.save, editor.delete). Add them to messages/es.json and en.json.
Audited every useTranslations call across src/ against both catalogs: no other
unresolved keys, and es/en are at full key parity.
Import a menu from PDF, photo, Excel/CSV, web link, or pasted text and turn it
into draft sections + products with Claude.
- Product.aiEstimated JSON flags AI-inferred macros/allergens (migration 0002)
- POST /api/[slug]/import: resolves the source (vision via Sonnet for PDF/photo,
Haiku for text/CSV/XLSX/web), extracts structured JSON for review only
- POST /api/[slug]/import/apply: writes to the draft in add or replace mode,
preserving aiEstimated flags; replace wipes the draft first
- Editor: 'Cargar menú' button + glass ImportModal (method -> review -> add/replace),
'Estimado por IA — verifica' badges, verification disclaimer; ProductEditor shows
the badge and clears the flag when the value is edited
- Reuses anthropic.ts, upload/guard, shared extractJson (moved to lib/json.ts)
- i18n labels (es/en); adds xlsx dependency for spreadsheet parsing
Verified: build passes; migration applies; apply add/replace persist correctly
with aiEstimated; extract validation + auth guard behave as expected.
Multi-tenant digital menu platform (Collina Systems): public QR menu with
glassmorphism + 3D macro flip cards, mobile-first editor with draft/publish
versioning (5-version history + restore), AI consultant & translation (Claude
Haiku), realtime orders via SSE, configurable palette, QR generation, superadmin
panel, and Docker/Coolify infra.