feat(terminal): kitchen display on paired screens, live without polling (platform-v2 3.2b)

Port of the manager's KdsPage.jsx into terminal/src/apps/kds, split into pure logic
(layout packing, age, buckets, rounds, totals, status cycle, settings; unit-tested) and
components (card, item, action bars, dialogs, item totals, rails, settings panel).
- Settings are the device's config; the settings panel saves them (managers only),
  zoom changes the size for the session.
- Orders reload on live events and every reconnect; polling only while the live
  connection is down (DeviceProvider exposes liveUp; useLiveEvents helper).
- "Tap to start" unlocks sound; venue clock via useFormat; English-first texts.
- Undo of an item recomputes the order status at once; undo/redo clear the selection.
- Tests: terminal unit +15, terminal.mjs +12 KDS checks (no polling, live order + chime,
  item/undo/prepare/decline, settings permission, change made elsewhere), backend
  regression for an item back to pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 19:27:11 +02:00
co-authored by Claude Opus 5.5
parent d5c4400fde
commit 5f6d4ab428
24 changed files with 2550 additions and 12 deletions
+52
View File
@@ -0,0 +1,52 @@
// The kitchen screen's settings (plan steps 3.2a, 3.2b): device config (GET /api/devices/me →
// config, the same as GET /api/kds/context → settings; modules/kds/manifest.py) → what the
// board uses. Pure.
export const FONT_SCALE_MIN = 60
export const FONT_SCALE_MAX = 200
export const FONT_SCALE_STEP = 10
export const DEFAULT_CONFIG = {
prep_zone_id: null, card_width: 272, font_scale: 100, font_weight: 600, batch_mode: 'merged',
group_items: 'off', group_by_course: false, combine_modifiers: false, categories_as_filters: true,
age_warning_minutes: 5, age_late_minutes: 10, age_flash_minutes: 15, flash_late: true,
colour_fresh: '#34b56a', colour_warning: '#f0a52a', colour_late: '#e8513f', colour_done: '#3d4757',
triple_state: false, sound: true, notify_order_complete: false, notify_item_complete: false,
refresh_seconds: 30, auto_sign_out_minutes: 0,
}
/** Device config → board settings. `fontScale` (percent) overrides font_scale for this
* session (the top bar's zoom buttons). */
export function boardSettings(config, fontScale = null) {
const c = { ...DEFAULT_CONFIG, ...(config || {}) }
return {
zoneId: c.prep_zone_id,
colW: c.card_width,
fontScale: (fontScale ?? c.font_scale) / 100,
fontWeight: c.font_weight,
batchMode: c.batch_mode,
groupItems: c.group_items,
groupByCourse: c.group_by_course,
combineModifiers: c.combine_modifiers,
categoriesAsFilters: c.categories_as_filters,
thresholds: { warning: c.age_warning_minutes, late: c.age_late_minutes, flash: c.age_flash_minutes },
flashLate: c.flash_late,
colours: { fresh: c.colour_fresh, warning: c.colour_warning, late: c.colour_late, done: c.colour_done },
tripleState: c.triple_state,
sound: c.sound,
notifyOrderComplete: c.notify_order_complete,
notifyItemComplete: c.notify_item_complete,
refreshSeconds: c.refresh_seconds,
}
}
/** The zoom buttons: one step, kept within the allowed range. */
export function zoomStep(percent, dir) {
return Math.min(FONT_SCALE_MAX, Math.max(FONT_SCALE_MIN, percent + dir * FONT_SCALE_STEP))
}
/** How the screen signs its calls to waiters (the backend does the same, routers/kds.py). */
export function senderName(context) {
const z = context?.zone
return (z && (z.notification_name || z.name)) || context?.device?.name || ''
}