Repository navigation
feat(frontend): bootstrap print locales before first print - #624
Merged
Merged
Conversation
Contributor
Greptile SummaryThe PR deterministically synchronizes tenant print-language policies and preloads selected locale bundles before authenticated bootstrap completes.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported stale-bootstrap overwrite is prevented by checking operation identity after locale loading and before applying either print policy.
|
| Filename | Overview |
|---|---|
| frontend/src/store/auth.ts | Coordinates login, restoration, and tenant selection with operation identities so stale asynchronous bootstrap work cannot overwrite current print policies. |
| frontend/src/lib/print-policy-bootstrap.ts | Resolves stored receipt and KOT policies, warms their selected locale bundles, and applies policies only while the originating auth operation remains current. |
| frontend/src/components/layout/AuthGuard.tsx | Surfaces print-locale bootstrap failures after restoration while retaining the existing authenticated routing behavior. |
| frontend/src/lib/printer/web-print.ts | Reports explicit locale-fallback warnings from browser receipt generation and printing. |
| frontend/src/lib/printer/warnings-toast.ts | Separates actionable locale-load notifications from skipped-content and financial print warnings. |
| tests/auth-print-bootstrap-race.test.ts | Verifies that a stale session restoration cannot replace a newer tenant selection or its receipt and KOT policies. |
| tests/phase6-locale-loading.test.ts | Covers policy bootstrap and browser/WebUSB receipt locale loading across all registered languages. |
Sequence Diagram
sequenceDiagram
participant User
participant Auth as Auth Store
participant API
participant Bootstrap as Print Policy Bootstrap
participant Locale as Locale Loader
participant Dashboard
User->>Auth: Login, restore session, or select tenant
Auth->>Auth: Increment operation identity
Auth->>API: Load tenant/session data
API-->>Auth: Tenant and print policies
Auth->>Bootstrap: Synchronize policies with identity guard
Bootstrap->>Locale: Load receipt and KOT locales
Locale-->>Bootstrap: Loaded locales or failures
Bootstrap->>Bootstrap: Verify operation is still current
alt Current operation
Bootstrap-->>Auth: Apply policies and report failures
Auth-->>Dashboard: Release authenticated state
else Stale operation
Bootstrap-->>Auth: Skip policy mutation
end
Reviews (2): Last reviewed commit: "no-mistakes(document): Documented print-..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Implement Phase 6 of the FloCafe internationalization and printing remediation plan: make locale and print-policy loading deterministic before the first print. Synchronize print-language policies at authentication/bootstrap time instead of only after visiting Settings. Surface browser locale-bundle failures instead of silently labeling English output as another locale. Add all-registered-locale browser and WebUSB loading tests. The selected print language must be available at authentication/bootstrap time and before the first print. Browser locale-bundle loading failures must be visible and actionable, never silently treated as another locale English output. Browser and WebUSB loading tests must cover every registered locale. Existing active UI-language behavior, print semantics, timezone behavior, financial values, and thermal safety must remain unchanged. Keep this as a deterministic locale-loading and print-policy bootstrap change. Do not change translation wording or setup/demo seed quality, country defaults, timezone behavior, currency precision, tax or service-charge policy, country-pack templates, printer capability architecture, raster output, broad routing, or unrelated UI. Start from the current FloCafe default branch after merged PR #620. Phase 5A country-pack charge-row parity remains separately deferred until its output-contract compatibility decision is settled. Use the full no-mistakes delivery path; after this phase lands, continue only with the next planned phase and preserve the one-worker-at-a-time sequence.
What Changed
Risk Assessment
✅ Low: The change is bounded to deterministic print-policy/locale bootstrap and warning propagation, with stale-auth operation guards and coverage for the selected browser/WebUSB locale paths; no concrete source risk was substantiated.
Testing
After installing the locked dependencies, focused bootstrap, race, browser/WebUSB locale, KOT, printer, compatibility, build, and packaged locale-chunk checks completed without actionable failures. The simulated bundle failure produced a visible reload instruction. Receipt HTML/PNG evidence was captured; the toast failure path used a synthetic browser harness rather than a screenshot because the dashboard was not rendered. No linters or static analysis were run per the assigned test-phase boundary.
Evidence: All locale loading evidence
Evidence: Locale failure visibility evidence
~/.no-mistakes/evidence/01M1K152VD2H33T9003Q4478X8/01_persian_receipt_rial_persian_digits.png)Evidence: Rendered receipt HTML
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
frontend/src/lib/printer/web-print.ts:160- Locale-load warnings omitkind, soshowPrintWarningsToasttreats them as skipped receipt lines. Browser/KOT failures therefore show misleading text such as “1 line was not printed” and unsupported-character guidance, despite printing English labels. Add a distinct warning classification and render the locale-load message separately.🔧 Fix: Classified locale warnings and routed them to actionable toasts
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm ci --ignore-scriptsfrontend: npm ci --ignore-scriptsnpm run test:phase6-locale-loadingnpm run test:auth-print-bootstrap-racenpm run test:browser-receiptswith required evidence directorynpm run test:kot-locale-cold-startnpm run test:printernpm run build:frontendnpm run test:locale-chunksnpm run test:print-labelsnpm run test:auth-ui-deterministicSynthetic browser locale-bundle failure check with captured actionable toast textVisual inspection of the generated Persian receipt screenshotFinal clean-worktree and transient-artifact cleanup check✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
eslint: command not found).🔧 Fix: Lint and static analysis clean
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.