Repository navigation
fix(frontend): hydrate receipt display settings on layout load - #1202
Merged
Merged
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 17, 2026
Frontend browser-print receipt settings remain stale until Settings page is opened (ARCH-011b)
#1188
Closed
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
Fix issue #1188: Frontend browser-print receipt settings remain stale until Settings page is opened (ARCH-011b)
What Changed
useReceiptSettingsSynchook to the dashboard layout to hydrate receipt display and business settings intousePosSettingsStoreon initial load and window focus.hydrateReceiptSettingstousePosSettingsStoresupporting camelCase and snake_case properties, refactored settings page hydration to use it, and eliminated redundant settings fetching in sidebar navigation.bill_footer_messageandbill_templatein backend/api/settings/businessresponse shape, with test coverage for store hydration and receipt print HTML generation.Risk Assessment
✅ Low: The changes cleanly hydrate receipt display settings and layout state on initial load without touching terminal-local hardware printer settings or extending route mutation contracts.
Testing
Exercised backend build, frontend static build, focused test:receipt-settings-hydration unit/integration suite, and 6 live Playwright end-to-end browser scenarios against the running product (ports 3001, 3002, 3003). Verified cold-start POS layout hydration, receipt generation with custom address, phone, tax ID, and footer note without navigating to Settings, dynamic window-focus sync, terminal-local hardware printer preference preservation, permission boundary gating without 403 errors, single-request GET /api/settings/business payload contract, and adversarial empty-string boundary normalization. Visual screenshots and HTML artifacts were generated directly in the evidence directory. All checks passed with verdict 'go'.
Evidence: receipt-cold-start-hydrated.png
Evidence: receipt-cold-start-hydrated.html
Complete emitted HTML document for browser-print receipt with hydrated store headers and footer.Evidence: receipt-partial-boundary.png
Evidence: receipt-partial-boundary.html
Rendered HTML document for receipt with empty/partial backend settings.Evidence: pos-dynamic-focus-synced.png
Evidence: dynamic-focus-sync-state.json
Client Zustand store snapshot after window focus event dynamically updated the footer note and address.Evidence: terminal-printer-settings-preserved.json
Verified JSON state demonstrating terminal-local hardware printer settings (paper size 'thermal58', printerUseUnicode true, autoPrintBill false) remain preserved during layout receipt hydration.Evidence: staff-no-settings-permission.png
Evidence: backend-settings-business.json
GET /api/settings/business response payload verifying unified return of bill_footer_message, bill_template, and business details.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
frontend/src/hooks/useReceiptSettingsSync.ts:12- frontend/src/hooks/useReceiptSettingsSync.ts:12 exports an uncalled standalone async function syncReceiptSettings() that duplicates the hook's fetching logic but has 0 call sites across the codebase. No requirement in User Intent (issue Frontend browser-print receipt settings remain stale until Settings page is opened (ARCH-011b) #1188) requires this extra export. Recommend removing syncReceiptSettings as an unrequired component.frontend/src/store/pos-settings.ts:131- frontend/src/store/pos-settings.ts:131-148 and 299-317 define multi-tier fallback aliases (taxRegistrationNumber and billTaxRegistrationNumber at line 300; billAddress and businessAddress at line 306; billPhone and businessPhone at line 310; billFooterMessage at line 314) that are neither returned by the backend GET /api/settings/business endpoint nor passed by settings forms. No requirement in User Intent (issue Frontend browser-print receipt settings remain stale until Settings page is opened (ARCH-011b) #1188) requires supporting these uncalled alias chains. Recommend narrowing ReceiptSettingsHydrationData and hydrateReceiptSettings to the canonical backend keys.main/routes/settings.ts:310- main/routes/settings.ts:310 and 459-460 introduce a second acceptance path for updating bill_footer_message via PUT /api/settings/business in addition to the existing PUT /api/settings/bill_footer_message endpoint used by the settings page. No requirement in User Intent (issue Frontend browser-print receipt settings remain stale until Settings page is opened (ARCH-011b) #1188, which is about layout hydration) needs an additional write path on the business settings route. Recommend removing bill_footer_message from PUT /api/settings/business to keep the route mutation contract strictly minimal.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run buildnpm run build:frontendnpm run test:receipt-settings-hydrationnpx playwright test e2e/receipt-settings-hydration.spec.ts (6 live end-to-end scenarios)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.