From d0c6a10e47b5878c7cbc3839c00f4a8ab639a23b Mon Sep 17 00:00:00 2001 From: bonamin Date: Mon, 16 Nov 2026 09:12:22 +0200 Subject: [PATCH] =?UTF-8?q?docs:=20CS-19=20device=20apps=20(who=20hears=20?= =?UTF-8?q?what,=20scope=20patterns,=20replays)=20=E2=80=94=20platform-v2?= =?UTF-8?q?=20phase=203=20wrap-up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/README.md b/docs/README.md index 07c5b52..91fd5de 100644 --- a/docs/README.md +++ b/docs/README.md @@ -188,6 +188,12 @@ New UI text goes into `packages/i18n/locales/en/.json` first, then `el` (sam **CS-18. Frontends talk to the backend through `@xenia/api` and read access from bootstrap** (branch `platform-v2`, D-7, D-10, §9). An app makes one client with `createApiClient({ axios, baseURL, getToken, getDeviceToken, onUnauthorized })` (its own axios; the waiter passes `baseURL: () => apiBase()` when it moves, CS-8). Errors carry `err.xenia = { code, params, message, status, offline }`; show them with `errorMessage(err, t)` (texts in `packages/i18n/locales/*/errors.json`, which a test keeps complete against `core/errors.py`: a new backend code needs both texts). A 401 means "session ended" and logs out, so a form whose own wrong-credentials answer is a 401 (login, unlock, PIN checks) passes `{ xenia: { ignoreUnauthorized: true } }`. Lock screens never log in again: they call `POST /api/auth/unlock {pin}` with the current session (same token; 5 wrong PINs end the session); manager sign-in sends `client: "manager"` and reads its mode from bootstrap `login`. The app root is ``: it reloads bootstrap whenever the token changes and mounts the manager-approval dialog, so any request refused with `access.override_possible` is retried after a manager's PIN without extra code. Hide UI with `useCan(key)` / `` / `` (the backend still checks, CS-14). Live events: `createLiveClient` (one implementation; don't open sockets by hand). A paired device passes `credentials: () => ({ device, token })` (sent in the first frame, never in the URL) and `onRefused(code)`. In the manager there is one connection, `live/LiveProvider.jsx` (opened with the signed-in shell); components listen with `useLiveEvent(type, handler)` (`'ready'` fires after each reconnect: refetch then). +**CS-19. Device apps: who hears what, and replays** (branch `platform-v2`, phase 3). +- A screen with sign-in `none` (customer display) receives **every** broadcast event; send what is meant for one screen with `device_ids=[…]` (the customer display's `display.state` goes only to the displays linked to that POS) and what is meant for a role with `user_ids=[…]` plus the screens that need it (`call_incoming`: users with `caller_id.use` + the counter screens). +- A device app may only reach routes of modules in its `DeviceApp.scope`. When an app must call another module's route, add one pattern for it (the POS has `customer_display.state`), never a wildcard. +- Events are stored and **replayed on reconnect** (24 h). A screen that reacts with something visible must ignore stale ones: check the event's time (`call_incoming`: older than a minute → no popup) or let it expire (`display.state` "paid" → idle after 12 s); state a screen needs after a restart comes from a GET (`/api/display/state`, the KDS list), not from replay. +- What the device itself shows comes from its device config (`ConfigField`s) or a venue setting; the venue-wide look of a screen (the customer display's idle screen) is a setting with its own manager page, not free JSON in the device. + **CS-15. Support access is a challenge code, never a password** (branch `platform-v2`, D-16). There is no master account. A site's `SUPPORT_SECRET` (env only) comes from `tools/support_code.py --site-secret `, derived from the builder's master key in `%USERPROFILE%\.xenia\support_master_key.txt` (outside the repo, back it up). The derivation lives in `local_backend/core/support_codes.py` (stdlib only, the tool loads it by path) and is re-implemented for the e2e suites in `tests/e2e/lib/support.mjs`; `tests/test_support.py` pins a vector both must match. The e2e backends log in through support access (`login()` in `lib/proc.mjs`).