fix(kds): reduce polling, reconnect, and database overhead - #323
Merged
Conversation
- Batch the standalone poll's per-order item and addon queries into single queries - Compute the global voided-item expiry marker once per broadcast and heartbeat - Use bounded exponential backoff for WebSocket reconnects - Isolate the 1s elapsed-time tick so the board/tabs don't rescan every second - Add a query-count regression check for the standalone poll Closes #226
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
Reduce FloCafe KDS polling, reconnect, and database overhead: batch the standalone poll item and addon queries, dedupe the global voided-item expiry marker query, bound WebSocket reconnect attempts with exponential backoff, isolate the elapsed-time clock tick, and add query-count regression coverage
What Changed
IN (...)lookup and deduped global voided-item expiry marker queries across clients during heartbeat ticks and broadcasts.ElapsedTimecomponent to eliminate 1-second full-board re-renders in Kanban and tabs views, and added query-count regression test coverage.Risk Assessment
✅ Low: The changes cleanly optimize KDS database queries, WebSocket reconnection backoff, and React component rendering without altering functional behavior or breaking existing invariants.
Testing
Executed targeted KDS test suites, Playwright E2E browser interactions, query-count regression checks, and performance verification scripts. Verified batched polling item queries (1 batched query vs N sequential queries), single global void marker computation across all connected clients, 1s-30s bounded exponential backoff on WebSocket reconnection, and clock tick isolation via the dedicated ElapsedTime component. All 12 automated test suites passed and captured UI screenshot evidence for both Kanban and Tabs views.
/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M04HC60QE719ZEWJP17HEP8P/kds-kanban-view.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M04HC60QE719ZEWJP17HEP8P/kds-tabs-view.png)Evidence: KDS Performance Optimization Verification Log
FloCafe KDS Optimization & Query Overhead Verification (Issue #226) --- VERIFICATION 1: Batched Standalone Poll Item & Addon Queries --- ✓ Total queries executed during /api/kds/orders poll for 5 orders: 12 ✓ Batched item queries executed: 1 (Expected: 1) ✓ Unbatched single-order item queries: 0 (Expected: 0) ✓ PASS: Standalone poll items and addons are batched into a single query pass across all active orders. --- VERIFICATION 2: Deduplicated Global Voided-Item Expiry Marker Query --- ✓ Heartbeat computes getExpiredVoidMarker() once globally per tick: true ✓ Broadcast computes getExpiredVoidMarker() once globally per broadcast: true ✓ PASS: Global voided-item expiry marker query is deduplicated across all connected WebSocket clients. --- VERIFICATION 3: Bounded WebSocket Reconnect Exponential Backoff --- Attempt 0: delay = 1000ms (expected: 1000ms) Attempt 1: delay = 2000ms (expected: 2000ms) Attempt 2: delay = 4000ms (expected: 4000ms) Attempt 3: delay = 8000ms (expected: 8000ms) Attempt 4: delay = 16000ms (expected: 16000ms) Attempt 5: delay = 30000ms (expected: 30000ms) Attempt 6: delay = 30000ms (expected: 30000ms) Attempt 10: delay = 30000ms (expected: 30000ms) ✓ PASS: WebSocket reconnect uses bounded exponential backoff (1s -> 30s max cap). --- VERIFICATION 4: Elapsed-Time Clock Tick Component Isolation --- ✓ KdsKanbanBoard root setClockTick removed: true ✓ KdsTabsView root setClockTick removed: true ✓ ElapsedTime component encapsulates isolated 1-second interval: true ✓ PASS: Elapsed-time clock ticks are isolated to individual card sub-components, preventing whole-board re-renders. ALL KDS PERFORMANCE OPTIMIZATION CHECKS VERIFIED SUCCESSFULLY!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 test:kds-integrationnpm run test:kds-contractnpm run test:kds-frontend-conflictnpm run test:kds-window-hardeningnode tests/run-electron-node-test.cjs tests/kds-websocket-revalidation.test.tsnode tests/run-electron-node-test.cjs tests/kitchen-addons-parsing.test.tsnode tests/run-electron-node-test.cjs tests/issue-125-addon-read-paths.test.tsnode tests/run-electron-node-test.cjs tests/issue-133-kds-kot-toggles.test.tsnode tests/run-electron-node-test.cjs tests/issue-134-station-routing.test.tsnode tests/run-electron-node-test.cjs tests/issue-134-station-management.test.tsnpx playwright test e2e/kds-kanban-skip-confirm.spec.tsnode tests/run-electron-node-test.cjs verify-kds-perf.cjs✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.