You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: distinguish disabled server bill printing and scope appended KOT items - #1461
Apply the 3 verified, minimal YAGNI follow-up fixes from the post-merge review before tagging 3.13.23:
Distinguish disabled Server App bill printing (BILL_PRINTING_DISABLED) from permission_denied (and other 403s) in main/server-app.ts, main/routes/printers.ts, and frontend/src/app/server-standalone/page.tsx (printOrderSlip) so status === 403 stays quiet only when errorCode === 'BILL_PRINTING_DISABLED' (matching KOT_PRINTING_DISABLED in printKotForOrder).
Make the new Server App HTTP 400 E2E regression test in frontend/e2e/server-app-ordering.spec.ts (does not open browser print popup when no hardware printer is configured (400)) strictly falsifiable and race-free by using { exact: true } for 'Order sent', awaiting both /api/printers/print-kot and /api/printers/print-bill 400 responses via page.waitForResponse, and asserting that neither localized print-error toast ("Order sent, but the kitchen ticket didn't print" / "Order sent, but the bill didn't print") appears.
In frontend/src/app/server-standalone/page.tsx (sendDraft append path), prefer data.added_items from POST /api/orders/:id/items when present (matching POSPage and OrdersPage) so concurrent appends from multiple waiters on the same table only print the items added by that call.
What Changed
Return code: 'BILL_PRINTING_DISABLED' on 403 responses from POST /api/printers/print-bill in main/routes/printers.ts and main/server-app.ts (and document the 403 error codes in docs/reference/api.md), and update printOrderSlip in frontend/src/app/server-standalone/page.tsx to suppress 403 errors only when code === 'BILL_PRINTING_DISABLED'.
Prefer data.added_items from POST /api/orders/:id/items in ServerStandalonePage.sendDraft when determining which newly appended items to print on KOT tickets, falling back to existingItemIds diffing only when absent.
Harden the Server App 400 printer E2E test in frontend/e2e/server-app-ordering.spec.ts to match the 'Order sent' toast with { exact: true }, await both /api/printers/print-kot and /api/printers/print-bill400 responses before checking state, and assert that neither print-failure toast appears.
Risk Assessment
✅ Low: The changes are minimal, targeted follow-ups that add an explicit BILL_PRINTING_DISABLED error code on 403 responses, prefer backend added_items on order appends, and harden the Server App E2E print test assertions without introducing behavioral regressions.
Testing
Built the backend and static frontend, ran the full Playwright e2e/server-app-ordering.spec.ts suite (9/9 passing, including the strengthened HTTP 400 regression test) and backend Server App test suites (test:server-app-server-role, test:server-app-station-routing), and drove all four end-to-end scenarios live against disposable Main API, KDS, and Server App instances with Chromium browser contexts, capturing screenshots and JSON transcripts in the evidence directory.
Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario
Result
Live
Evidence
Waiter sends an order when Server App bill printing is disabled: both Server App and Main API return HTTP 403 with code 'BILL_PRINTING_DISABLED' and the UI shows only 'Order sent' without any bill-pri…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-1-bill-printing-disabled-quiet.png and ~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/live-valid…
Adversarial: Waiter whose printing.execute permission is denied sends an order when Server App bill printing is enabled: /api/printers/print-bill returns HTTP 403 with code 'permission_denied' and the…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-2-permission-denied-403-toast.png and ~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/live-valida…
Waiter sends an order when no hardware printer is configured: both /api/printers/print-kot and /api/printers/print-bill return HTTP 400, no browser window.print() or window.open() popup is triggered,…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-3-no-hardware-printer-400.png and npx --prefix frontend playwright test e2e/server-app-ordering.spec.ts
Two waiters concurrently append items to the same table order without refreshing in between: the second waiter's /api/printers/print-kot request payload contains only the items from data.added_items a…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-4-concurrent-append-kot-items.png and ~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/live-valida…
Evidence: Live validation API & print payload transcript
{
"scenario1": {
"mainApiDirect403": {
"status": 403,
"body": {
"error": "Bill printing is disabled for the server role. An owner or manager can enable it in Settings.",
"code": "BILL_PRINTING_DISABLED"
}
},
"serverAppProxy403": {
"status": 403,
"body": {
"error": "Bill printing is disabled for the Server Companion App. An owner or manager can enable it in Settings.",
"code": "BILL_PRINTING_DISABLED"
}
},
"billErrorToastCount": 0,
"kotErrorToastCount": 0
},
"scenario2": {
"forwardedPrintBill403": {
"status": 403,
"body": {
"error": "Insufficient permissions",
"code": "permission_denied",
"permission": "printing.execute"
}
},
"billErrorToastVisible": true
},
"scenario3": {
"kot400": { "status": 400 },
"bill400": { "status": 400 },
"browserPrintCalls": 0,
"kotErrorToastCount": 0,
"billErrorToastCount": 0,
"rawErrorToastCount": 0
},
"scenario4": {
"orderId": 4,
"waiter1AppendAddedItems": [{ "id": 5, "product_name": "E2E Tea", "quantity": 1 }],
"waiter1KotPrintedItems": [{ "id": 5, "product_name": "E2E Tea", "quantity": 1 }],
"waiter2AppendOrderAllItemsCount": 3,
"waiter2AppendAddedItems": [{ "id": 6, "product_name": "E2E Croissant", "quantity": 2 }],
"waiter2KotPrintedItems": [{ "id": 6, "product_name": "E2E Croissant", "quantity": 2 }]
}
}
{
"scenario1": {
"mainApiDirect403": {
"status": 403,
"body": {
"error": "Bill printing is disabled for the server role. An owner or manager can enable it in Settings.",
"code": "BILL_PRINTING_DISABLED"
}
},
"serverAppProxy403": {
"status": 403,
"body": {
"error": "Bill printing is disabled for the Server Companion App. An owner or manager can enable it in Settings.",
"code": "BILL_PRINTING_DISABLED"
}
},
"kotResponse": {
"status": 403,
"body": {
"error": "KOT printing is disabled for this business",
"code": "KOT_PRINTING_DISABLED"
}
},
"billErrorToastCount": 0,
"kotErrorToastCount": 0,
"screenshot": "~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-1-bill-printing-disabled-quiet.png"
},
"scenario2": {
"forwardedPrintBill403": {
"status": 403,
"body": {
"error": "Insufficient permissions",
"code": "permission_denied",
"permission": "printing.execute"
}
},
"billErrorToastVisible": true,
"billErrorToastCount": 2,
"screenshot": "~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-2-permission-denied-403-toast.png"
},
"scenario3": {
"kot400": {
"status": 400,
"body": {
"error": "No default printer configured. Add a printer in Settings."
}
},
"bill400": {
"status": 400,
"body": {
"error": "No default printer configured. Add a printer in Settings."
}
},
"browserPrintCalls": 0,
"kotErrorToastCount": 0,
"billErrorToastCount": 0,
"rawErrorToastCount": 0,
"screenshot": "~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-3-no-hardware-printer-400.png"
},
"scenario4": {
"orderId": 4,
"waiter1AppendAddedItems": [
{
"id": 5,
"product_name": "E2E Tea",
"quantity": 1
}
],
"waiter1KotPrintedItems": [
{
"id": 5,
"product_name": "E2E Tea",
"quantity": 1
}
],
"waiter2AppendOrderAllItemsCount": 3,
"waiter2AppendAddedItems": [
{
"id": 6,
"product_name": "E2E Croissant",
"quantity": 2
}
],
"waiter2KotPrintedItems": [
{
"id": 6,
"product_name": "E2E Croissant",
"quantity": 2
}
],
"screenshot": "~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-4-concurrent-append-kot-items.png"
}
}
Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario
Result
Live
Evidence
Waiter sends an order when Server App bill printing is disabled: both Server App and Main API return HTTP 403 with code 'BILL_PRINTING_DISABLED' and the UI shows only 'Order sent' without any bill-pri…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-1-bill-printing-disabled-quiet.png and ~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/live-valid…
Adversarial: Waiter whose printing.execute permission is denied sends an order when Server App bill printing is enabled: /api/printers/print-bill returns HTTP 403 with code 'permission_denied' and the…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-2-permission-denied-403-toast.png and ~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/live-valida…
Waiter sends an order when no hardware printer is configured: both /api/printers/print-kot and /api/printers/print-bill return HTTP 400, no browser window.print() or window.open() popup is triggered,…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-3-no-hardware-printer-400.png and npx --prefix frontend playwright test e2e/server-app-ordering.spec.ts
Two waiters concurrently append items to the same table order without refreshing in between: the second waiter's /api/printers/print-kot request payload contains only the items from data.added_items a…
✅ pass
live
~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/scenario-4-concurrent-append-kot-items.png and ~/.no-mistakes/evidence/01M6JGMRAMHFM2HQM2FHY1D3FW/live-valida…
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
Distinguish disabled bill printing and scope appended KOT items
🐞 Bug fix🧪 Tests📝 Documentation🕐 20-40 Minutes
AI Description
• Identify disabled Server App bill printing explicitly so other 403 errors remain visible.
• Print only items added by the current order append when the API provides them.
• Make the no-printer E2E test wait for both responses and reject print-error toasts.
Use the API's added_items as the authoritative scope for an append, retain the existing fallback, and return a specific code from both bill-printing gates. This is more targeted than inferring concurrent additions from the full order or suppressing every 403.
Files changed (5) +31 / -10
Bug fix (3) +12 / -4
page.tsxScope appended KOT items and identify quiet bill failures+10/-4
Scope appended KOT items and identify quiet bill failures
• Prefers added_items from the order append response, falling back to the existing item-ID comparison. Suppresses a bill-printing 403 only when its code is BILL_PRINTING_DISABLED, leaving other 403 errors visible.
server-app-ordering.spec.tsStrengthen the no-printer Server App regression test+16/-3
Strengthen the no-printer Server App regression test
• Matches the success toast exactly, waits for both mocked 400 printer responses, and verifies that neither browser printing nor print-failure toasts occur.
api.mdDocument printer permission and disabled-printing responses+3/-3
Document printer permission and disabled-printing responses
• Corrects the print-bill permission listing and documents the BILL_PRINTING_DISABLED and KOT_PRINTING_DISABLED 403 codes, including the Server App forwarding route.
1. Print-failure toasts can escape the test 🐞 Bug☼ Reliability
Description
The new response waits resolve when Playwright receives the status and headers, while the single
zero-delay timer does not guarantee that Axios has handled the response and React has rendered a
toast. If either print path begins showing an error toast after that timer, the absence assertions
can pass before the toast appears.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
The test awaits the two 400 responses, then waits only one zero-delay timer before checking for
absent toasts. Playwright documents that its response event occurs when status and headers arrive,
before the response body finishes downloading; neither that event nor the timer establishes that the
frontend's catch handlers have run.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The test can check that print-failure toasts are absent before the frontend has handled both 400 responses.
## Fix Focus Areas
- frontend/e2e/server-app-ordering.spec.ts[124-146]
## Recommended Fix
Replace the zero-delay timer with a reliable signal that both frontend print handlers have completed before asserting toast absence. If no completion signal is available, observe for late toasts over an explicit bounded interval rather than relying on `toHaveCount(0)` immediately after the responses.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
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
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
Apply the 3 verified, minimal YAGNI follow-up fixes from the post-merge review before tagging 3.13.23:
What Changed
code: 'BILL_PRINTING_DISABLED'on403responses fromPOST /api/printers/print-billinmain/routes/printers.tsandmain/server-app.ts(and document the403error codes indocs/reference/api.md), and updateprintOrderSlipinfrontend/src/app/server-standalone/page.tsxto suppress403errors only whencode === 'BILL_PRINTING_DISABLED'.data.added_itemsfromPOST /api/orders/:id/itemsinServerStandalonePage.sendDraftwhen determining which newly appended items to print on KOT tickets, falling back toexistingItemIdsdiffing only when absent.frontend/e2e/server-app-ordering.spec.tsto match the'Order sent'toast with{ exact: true }, await both/api/printers/print-kotand/api/printers/print-bill400responses before checking state, and assert that neither print-failure toast appears.Risk Assessment
✅ Low: The changes are minimal, targeted follow-ups that add an explicit BILL_PRINTING_DISABLED error code on 403 responses, prefer backend added_items on order appends, and harden the Server App E2E print test assertions without introducing behavioral regressions.
Testing
Built the backend and static frontend, ran the full Playwright
e2e/server-app-ordering.spec.tssuite (9/9 passing, including the strengthened HTTP 400 regression test) and backend Server App test suites (test:server-app-server-role,test:server-app-station-routing), and drove all four end-to-end scenarios live against disposable Main API, KDS, and Server App instances with Chromium browser contexts, capturing screenshots and JSON transcripts in the evidence directory.Evidence: Live validation API & print payload transcript
{ "scenario1": { "mainApiDirect403": { "status": 403, "body": { "error": "Bill printing is disabled for the server role. An owner or manager can enable it in Settings.", "code": "BILL_PRINTING_DISABLED" } }, "serverAppProxy403": { "status": 403, "body": { "error": "Bill printing is disabled for the Server Companion App. An owner or manager can enable it in Settings.", "code": "BILL_PRINTING_DISABLED" } }, "billErrorToastCount": 0, "kotErrorToastCount": 0 }, "scenario2": { "forwardedPrintBill403": { "status": 403, "body": { "error": "Insufficient permissions", "code": "permission_denied", "permission": "printing.execute" } }, "billErrorToastVisible": true }, "scenario3": { "kot400": { "status": 400 }, "bill400": { "status": 400 }, "browserPrintCalls": 0, "kotErrorToastCount": 0, "billErrorToastCount": 0, "rawErrorToastCount": 0 }, "scenario4": { "orderId": 4, "waiter1AppendAddedItems": [{ "id": 5, "product_name": "E2E Tea", "quantity": 1 }], "waiter1KotPrintedItems": [{ "id": 5, "product_name": "E2E Tea", "quantity": 1 }], "waiter2AppendOrderAllItemsCount": 3, "waiter2AppendAddedItems": [{ "id": 6, "product_name": "E2E Croissant", "quantity": 2 }], "waiter2KotPrintedItems": [{ "id": 6, "product_name": "E2E Croissant", "quantity": 2 }] } }Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run build && npm run build:frontendE2E_BASE_URL=http://127.0.0.1:43001 E2E_KDS_BASE_URL=http://127.0.0.1:43002 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43003 CI=1 npx --prefix frontend playwright test e2e/server-app-ordering.spec.ts --config=frontend/playwright.config.ts --project=chromium --retries=0npm run test:server-app-server-rolenpm run test:server-app-station-routingNODE_PATH="$(pwd)/node_modules:$(pwd)/frontend/node_modules" node tests/run-electron-node-test.cjs ~/.gemini/antigravity-cli/brain/a742b408-11a6-4a22-bda3-72e9db16af93/scratch/live-verify.ts✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.