Commit Graph
100 Commits
Author SHA1 Message Date
bonaminandClaude Opus 5.5 15bd0f5b57 feat(waiter): keep the menu's photos for offline (platform-v2 step 5.2)
Right after the menu is read the phone downloads its photos (4 at a time,
services/photoCache.js). The library's year-long immutable headers keep them
in the browser cache; the installed PWA also caches /api/media/file/ cache-
first (workbox `xenia-media`). With no connection the menu still shows them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:57:51 +02:00
bonaminandClaude Opus 5.5 e09056a7a4 feat(manager): Media page, photo field for products and categories (platform-v2 step 5.2)
- Management → Media (src/pages/media/): every picture and video, search,
  pictures / videos, batch upload (many files or drop on the page) with a
  result per file, details (preview, display name, kind, resolution, length,
  file size, uploaded file, when / who, the sizes made, what uses it, delete
  off while used).
- MediaField: upload on the spot (into the library and set at once), pick
  from the library (MediaPicker, which can also upload), remove; after an
  upload on the spot "Name it after the product / category" renames it in
  Latin letters. Used by the product editor and the category dialog.
- nav: `anyPerm` (any of the keys that manage pictures); the route guard uses
  the same rule. Product rows have test ids.
- @xenia/i18n: latin() (Greek to Latin, the way venues write it) + tests.
- tests: manager media.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:57:50 +02:00
bonaminandClaude Opus 5.5 5ad4c4ef55 feat(backend): products and categories point at the media library (platform-v2 step 5.2)
- products.media_id / categories.media_id (Alembic 0027): the old
  /static/product_images photos are processed into the library (named after
  their product; missing or unreadable files logged and skipped; the old
  folder is left on disk) and products.image_url goes. The static mount is gone.
- APIs give `image` {id, name, thumb, card, full}; a product's image_url is its
  card size. media_id on create/update (null clears); media.not_a_picture for
  a video. POST /api/products/{id}/image is gone: uploads go to /api/media.
- Products and categories register their media usage: a photo in use can't
  be deleted.
- Media: AVIF pictures (Pillow 12.3), GET /api/media/{id} gives each stored
  size's bytes and resolution and the uploader's name; upload processing moved
  into services/media.ingest (also used by the data move).
- QR menu photo push (contract C-3): the library's card size, WebP.
- tests: test_product_photos.py (7, incl. the 0027 data move); 497 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:57:50 +02:00
bonaminandClaude Opus 5.5 238f8ec5a0 feat(backend): media library: files once by hash, WebP sizes, cached, protected while used (platform-v2 step 5.1)
- Table `media` (Alembic 0026): kind, name, original name, type, sha256
  (unique), bytes, width/height, video length, who and when.
- Files under /app/data/media/<sha[:2]>/<sha>/: the original, and for
  pictures thumb (200 px) / card (600) / full (1920) WebP, upright from
  EXIF, never enlarged, transparency kept. Videos (MP4, WebM) kept as
  uploaded; an MP4's length and size come from its header.
- GET/POST /api/media, GET/PATCH/DELETE /api/media/{id} for whoever manages
  the menu, customer display, signage or menu tablets. The same file again
  returns the existing item. The type comes from the bytes; 20 MB pictures,
  200 MB videos, 60 MP; refused uploads leave nothing behind.
- GET /api/media/file/<sha>/<variant>: public (LAN), Cache-Control
  public, max-age=1 year, immutable; byte ranges for video; a missing size
  is made again from the original.
- register_usage(kind, fn): what uses media (products, displays, signage
  from 5.2-5.4) declares it; delete is refused with media.in_use listing
  the users.
- tests: test_media.py (12); stack.mjs uploads 3 MB through both nginx hops
  and fetches a size with its cache headers (compose stack: all passed).
  Backend suite: 490 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 13:22:26 +02:00
bonaminandClaude Opus 5.5 24971533a0 fix(proxy): accept uploads up to 250 MB in every nginx hop
nginx's default client_max_body_size is 1 MB, so a phone photo (3-5 MB)
uploaded as a product image or customer-display image was refused with
413 before it reached the backend. The proxy (both copies, CS-5) and the
waiter, manager and terminal images now allow 250 MB; the backend checks
the real limits (media library: 20 MB pictures, 200 MB videos, step 5.1).
All five configs pass `nginx -t`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 13:22:26 +02:00
bonaminandClaude Opus 5.5 1fc34d6c9e docs+test: phase 4 wrap-up (platform-v2 step 4.99)
- Pack README: CS-3 now says orders are queued by id and priced on sync, refused lines
  are shown, and no request a screen waits for may hang; rows for the waiter's texts /
  colours guards and the table, ordering and bookings pages.
- run-all: the waiter suite's label lists what it covers.
- waiter.mjs: the language check waits for the profile save (the screen changes first).
- android.mjs: the "server really down" check accepts the offline screen in place of the
  app (the start-up data failing shows it there since the bootstrap time limit), not only
  on /offline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:09:18 +02:00
bonaminandClaude Opus 5.5 eba630e06e test(android): the sign-in screen check after pairing waits up to 15 s (a fresh install is slow to show it)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:29:21 +02:00
bonaminandClaude Opus 5.5 f57894dcb7 feat(waiter): table bookings on the phone; shared ReasonPicker (platform-v2 step 4.8c)
- Waiter: Bookings (side drawer, for whoever has connect_orders.manage or
  reservations.manage, with the online-orders app on): requests made online are
  confirmed or declined with a reason the guest sees; confirmed ones are seated at a free
  table (its seats shown, a warning mark when the party is bigger) or cancelled / marked
  as a no-show; the food ordered ahead and its kitchen time; live updates.
- Backend: the bookings routes take reservations.manage too (require_any).
- @xenia/ui ReasonPicker + reasonText (gallery, unit test), first piece moved from the
  terminal (4.6 → 4.8): the counter's online reject and booking decline dialogs use it;
  the waiter loads @xenia/ui styles.css (the .x-* components; tokens as before).
- Tests: waiter e2e +2 (request listed with the key, confirmed and seated from the phone);
  terminal.mjs and qr_table.mjs green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:10:14 +02:00
bonaminandClaude Opus 5.5 1e8271e370 feat(waiter): where each line came from; QR lines marked, the QR message opens the table (platform-v2 step 4.8b)
- order_items.source (Alembic 0025): waiter | counter | qr | online, set by the server
  (orders.add_priced_items: the phone / manager 'waiter', the counter 'counter'; the QR
  menu's lines 'qr', online orders 'online'; a split line keeps its source); lines of
  existing online orders backfilled 'online'; in the order's item output.
- Waiter: lines the guests sent from the QR menu (or an online order) carry a "📱 QR" /
  "🌐 Online" mark; the qr_order message's banner has "Open the table", and in the bell's
  list the message opens it.
- Tests: source per channel, migration 0025, QR placement marks 'qr'; waiter e2e +1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:59:57 +02:00
bonaminandClaude Opus 5.5 198f8ff571 feat(waiter): close with unpaid items as a setting, combine lines, seats (platform-v2 step 4.8a)
The owner's choices for 4.8 (2026-11-18), all configurable:
- Setting orders.close_with_unpaid (default off): when off, the server refuses to close
  an order with unpaid items (pos.order_unpaid) and the phone's CLOSE takes the payment
  first ("instant-pay close"); when on, CLOSE confirms and the items stay unpaid. Manager
  Settings → Operation, next to "auto-close after full payment" (unchanged).
- POST /api/orders/{id}/items/combine: unpaid lines of the same item (choices, note,
  price, course, kitchen state; no discount / deal / tab) become one line; the phone
  offers "Combine into one line" for selected lines or a grouped line. The grouping
  views (identical / same item) stay as they were.
- Seats: the table's seats next to its name on the cards (waiter Settings → Layout, on by
  default) and in the guests dialog, where more guests than seats only shows a hint.
- The table screen's last English-only labels (ADD, PAY, CLOSE, ACTIONS, SERVED, CLEAR,
  ALL) are keys too.
- Tests: test_close_and_combine.py (5), waiter e2e +5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:54:37 +02:00
bonaminandClaude Opus 5.5 beb53c65bb feat(waiter): the look on the shared tokens; the venue's colour (platform-v2 step 4.6)
- The waiter's --bg/--text/--accent… are made of @xenia/ui tokens: light / dark (user
  menu) and the venue's accent reach every screen; the 751 colour literals in
  waiter_pwa/src became tokens (by hue family and lightness), hex-alpha suffixes became
  fade() (color-mix), fixing 'var(--accent)18' tints that never showed.
- @xenia/ui: new `special` (violet: offers, discounts, deals; contrast-tested) and
  `on-colour` tokens.
- Setting venue.theme (teal | amber | blue | violet | rose, default amber), bootstrap
  venue.theme, manager Settings → Venue → Colour; the waiter sets data-venue-theme and
  the theme before the first render.
- Guard tests/no-colours.test.mjs; tests/e2e/waiter_look.mjs (every page light + dark,
  side-by-side compare page); waiter e2e +3; backend test_venue_theme.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:08:39 +02:00
bonaminandClaude Opus 5.5 d8c3a6c57c fix(access): the bootstrap request gets an 8 s time limit
A bootstrap request that never answered (seen on the Android emulator after a cold start
with the server down) left the app on its loading screen for good: no error, so no retry.
It now times out, counts as offline (cached bootstrap / offline screen) and is retried, so
the app comes back by itself when the server does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:08:38 +02:00
bonaminandClaude Opus 5.5 9e1912bce0 feat(waiter): a table's earlier orders (platform-v2 step 4.7)
- GET /api/tables/{id}/history: the table's closed / cancelled orders, newest first,
  for the waiters of its zone (ordering.orders.open), never older than the history
  module's history_days (free tier 31, D-6), module.disabled when history is off;
  each order with times, total (cancelled items left out), people and items.
- Waiter: a History tab on the table (and "This table's earlier orders" on a free
  table); orders expand to their items; the last answer is kept on the phone and
  shown offline, marked as saved; the plan's day limit is shown.
- Tests: test_table_history.py (4), waiter e2e +2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 04:45:31 +02:00
bonaminandClaude Opus 5.5 f8d91e7fae feat(waiter): English-first texts, part c: shift, log, chat, offline, notifications; language switch; guard (platform-v2 step 4.5c)
- Shift overview, order log, chat list / thread, offline + server search +
  rediscovery screens, notifications, the refused-lines sheet and the offline queue's
  reasons become keys; times and dates through useFormat() in the venue's clock.
- User menu: the other language(s) (data-testid menu-language-<lng>), saved to the
  person's profile (PATCH /api/auth/me) and the bootstrap reloaded (D-12).
- tests/no-greek.test.mjs: no Greek letter in waiter_pwa/src (the one Greek word the
  app recognises in staff messages is a \u escape).
- e2e: the test venue is English: waiter / browser / android use the English texts;
  waiter.mjs +3 (English by default, switch to Greek at once and saved, after reload);
  android bundle checks print what they saw when they fail.
- Pack README: the waiter texts rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 04:31:48 +02:00
bonaminandClaude Opus 5.5 2c4f78af47 feat(waiter): English-first texts, part b: table detail, ordering, options, payment (platform-v2 step 4.5b)
- Table detail (actions, item actions, split, price, discount, pay / revert / close,
  move / merge / transfer, guests, flags, assign, print), the order drawer (tabs,
  options, quick notes, price change, summary), add items (cart, totals, deals,
  search), the order summary and the summary before sending, the product picker.
- Money everywhere here in the language's format (`money()` in waiter i18n.js for
  helpers shared by several components, useFormat() elsewhere).
- The default quick notes are keys (the venue's own quick notes still win).
- Variables named `t` (tables, tabs, timers) renamed so they don't shadow t().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:59:12 +02:00
bonaminandClaude Opus 5.5 37155c0457 feat(waiter): English-first texts, part a: shell, sign-in, tables, settings, venues (platform-v2 step 4.5a)
- @xenia/i18n: new `waiter` namespace (en + el); the waiter's Greek texts become keys
  with English written fresh (Greek kept as the translation).
- App gates, side drawer / nav bars / notifications, user menu, login, table list and
  cards, settings, venues + pairing errors, install dialog, lock screen, update banners,
  QR scanner, favourites setup.
- Money and times through useFormat() (venue time, the language's number format):
  table cards, quick table view, user menu, notifications.
- waiter i18n.js: tw() for code outside components (pairing errors).
- The table-list's FavoritesSetupPage `.map(t => …)` renamed so it doesn't shadow t.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:50:33 +02:00
bonaminandClaude Opus 5.5 8e0a786bbc feat(ordering): orders priced by the server (platform-v2 step 4.4)
The waiter app (and the manager's ordering tab) send what was chosen, by id; the
server prices it with the counter's code. No app sends a price any more.

- POST /api/orders/{id}/items takes `lines` (pos_cart's line + course_id,
  price_adjustment, is_service_item): sales point checked first, refusals name the
  product and line (order.line.*, order.not_sold_here); prices or selected_options in a
  line -> order.line.client_price, the old `items` shape -> order.lines_required; a
  by-hand price change needs ordering.prices.modify or a manager's approval (audited
  PRICE_SET_BY_HAND). add_priced_items is the one writer of priced items (pos too).
- POST /api/orders/quote: the cart's total before sending; /api/pos/quote shares
  pos_cart.quote().
- pos_cart: a preference set left out takes its default; a set at its free default
  isn't stored; a default that costs is charged (the waiter never sent it: fixed);
  an extra's sub-choice is charged per extra (the counter charged it once: fixed).
- @xenia/api lines.js: lineFromOptions / wireLine / estimate / LineError.
- Waiter: lines on send; cart total from the quote ("≈ estimate" offline); summary
  shows the same prices; offline orders queued by id, priced on sync, refused lines
  shown on a "Δεν στάλθηκαν" sheet (no empty order opened); dead ItemOptionsModal gone.
- Tests: test_order_lines.py (14), lines.test.mjs, waiter e2e +6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:35:03 +02:00
bonaminandClaude Opus 5.5 bcf91bf6e9 test(android): self-healing WebView handle, fresh emulator, diagnostics (KI-015)
- lib/cdp.mjs: attach to the visible, non-empty page target (a replaced WebView can
  leave the old target listed first); a closed DevTools socket fails pending calls at
  once instead of hanging; every call has a timeout.
- lib/android.mjs: attach() follows the app's current process (socket named after its
  pid; an old one can linger) and re-attaches before a call when the process or the
  live page changed; a call cut off by the page going away is retried once.
  ensureDevice() reboots an emulator up longer than EMULATOR_MAX_UPTIME_MIN (30).
- android.mjs: switching venues waits until /venues lists them (the app may still be
  reloading into the last venue's bundle); a rediscovery timeout logs the page's DOM
  and console next to the screenshot.

Run alone: rediscovery 7/7, basics 3/3, stacks 21/21.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:35:02 +02:00
bonaminandClaude Opus 5.5 8abe4d92d3 feat(waiter): what a waiter may do comes from permission keys (platform-v2 step 4.3)
- Payments: ordering.orders.close checked on pay/close and the counter POS
  (waiters have it by default, owner decision); pay-offline always recorded.
- The venue switches waiter_cancellations / price_adjust / revert are gone:
  ordering.orders.cancel, ordering.prices.modify and the new
  ordering.payments.revert (overridable) decide; moves/split/transfer/merge
  need ordering.orders.open; discounts pricing.discounts.apply; chat chat.use.
- Venue role defaults: role_permissions (Alembic 0024), role_template(role, db),
  GET/PUT /api/waiters/roles/{role}/permissions applying the change to everyone
  with the role; manager Settings -> Operation -> "What each role may do".
  0024 also grants the new key to existing owners and store managers.
- Bootstrap `approvable`; @xenia/access useAllowed(key) -> yes/approve/no.
  The waiter shows each action by key, "with a manager's approval (PIN)" where
  allowed; GET /api/orders/cancel-permissions removed.
- Tests: test_waiter_keys.py (11), access allowed(), waiter.mjs +5, manager.mjs +3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 00:54:08 +02:00
bonaminandClaude Opus 5.5 a29a167977 fix(waiter): rediscovery probe timeout 1.5 s -> 3 s
A new plain-HTTP connection can take about a second on a busy network; inside
the 48-wide /24 scan the real server's answer then missed the 1.5 s limit and
the moved server was never found (seen on the Android emulator, 0.9 s first
connection). 3 s keeps a full scan under ~20 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 00:54:07 +02:00
bonaminandClaude Opus 5.5 8299184e3a feat(waiter): sign-in v2 on the phones (platform-v2 step 4.2)
- Login follows auth.waiter_login_mode / auth.waiter_require_username from the
  bootstrap: name + PIN, name + password, typed username, or a "paired screens
  only" message for tap mode. POST /api/auth/login {client: "waiter"}; a miss
  shows the translated error without a reload.
- POST /api/auth/login-by-id removed; bootstrap login carries waiter_mode and
  waiter_require_username.
- Sign-out ends the session on the server (POST /api/auth/logout), so
  single_session_waiter = refuse_new no longer strands a waiter.
- Lock on the phone: menu "Lock", automatic lock / sign-out after inactivity
  (security.auto_lock*, auto_logout*), unlock with the PIN in the same session,
  lock kept across app restarts (restore() no longer clears it).
- e2e: new waiter.mjs (22 checks) in run-all; android.mjs signs in for real and
  locks/unlocks on the emulator; TLS live check waits for the socket; the
  rediscovery helper re-attaches to a stale WebView handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:25:00 +02:00
bonaminandClaude Opus 5.5 9f5498332a feat(waiter): the waiter app on the shared foundations (api client, access, i18n), lint clean, starts offline
Plan step 4.1. No visible change to layout or flows.
- api/client.js on @xenia/api createApiClient (CS-8 baseURL, 401 → sign out, no answer →
  backend-offline, err.xenia, the manager-approval retry); the PIN login handles its own 401
  (before, a wrong PIN reloaded the page).
- <AccessProvider> at the root with an i18n instance: modules, permission keys, venue,
  language from bootstrap; who is signed in comes with it (no more /api/auth/me polling).
  packages/access: AccessProvider gains `cache` (the last bootstrap per session; used when
  the server can't be reached, `offline` in the context, keeps retrying) and `failed` (the
  app's own screen when there's nothing cached). The waiter caches per venue, shows its
  offline page (server search) on a first start without a server, retries every 5 s;
  ServerRediscovery and BundleSync run outside the bootstrap.
- Role names → keys: the shift gate and the user menu use core.dashboard.access.
- One shared, offline-cached read of the venue settings (api/venueSettings.js) instead of
  seven GET /api/settings/ calls; apiError() shows backend error codes in the user's
  language (17 places).
- Lint: 78 errors → 0 (unused code, empty catches, two duplicate style keys, a component
  created during render, refs read during render → state, hooks after an early return);
  set-state-in-effect is a warning like the manager/terminal; lint in run-all.
- Tests: tests/bootstrapCache.test.mjs; e2e browser: an offline restart stays signed in.
  Android rediscovery waits for what the screen shows instead of fixed sleeps: 10/10 three
  runs in a row (KI-009). Terminal 3.4 waits for both displays before the sale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 11:37:47 +02:00
bonaminandClaude Opus 5.5 f85894a72e refactor(connect): one live connection, no token in any address (SSE removed)
Plan step 4.0. Owner (2026-11-17): no phone in use needs to keep working, so no
compatibility path.
- Removed the SSE channel: routers/sse.py (/api/sse/stream, which still accepted a JWT whose
  session had ended — a signed-out phone could keep listening), services/sse_bus.py (every
  backend module now calls services/ws_bus.broadcast_sync directly), waiter useSSE.js.
- Credentials only in the first frame: the waiter's useWebSocket and the manager's
  LiveProvider send {token} there like the terminal; routers/ws.py no longer reads ?token=
  (a token in a URL ends up in proxy and server logs).
- Waiter: SSEContext → LiveContext (LiveProvider, useLiveContext, liveAlive, the
  'live-event' / 'live-reconnected' window events), dead SSE compat code removed.
- Tests: a token in the address is refused, /api/sse/stream is 404; e2e browser (3 delivery
  modes) and manager assert no token in the live connection's address. Android taps now
  wait for their element (the fixed sleeps made the suite flaky, KI-009).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:49:21 +02:00
bonaminandClaude Opus 5.5 d0c6a10e47 docs: CS-19 device apps (who hears what, scope patterns, replays) — platform-v2 phase 3 wrap-up
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:12:22 +02:00
bonaminandClaude Opus 5.5 dabe807ce0 feat(connect): caller ID as an integration: calls on the signed-in live connection, matched on the server
Plan step 3.5.
- The public /api/phone/ws socket is removed (anyone on the LAN could listen to every
  caller). GET /api/phone/call-event stays public for the Grandstream UCM but is LAN-only in
  the proxy (the 443 blocks' LAN-only location now covers it, in nginx-proxy/nginx.conf and
  install.sh), with an optional shared secret (setting caller_id.secret → &key=).
- Calls are logged (phone_calls, migration 0023), matched to a customer on the server
  (services/caller_id.py: Greek number rules moved from the manager) and published as
  `call_incoming` {call_id, at, number, ext, customer card: visits, spent, last 3 orders} to
  users with caller_id.use and to the counter POS screens. GET /api/phone/calls (the log),
  GET /api/customers/lookup?phone=. Calls older than a minute don't pop up (replays).
- Manager: PhoneListener on the live connection and the shared Dialog (no more downloading
  every customer to match); Integrations → Caller ID shows the server's log live and the UCM
  Action URL. Counter: CallPopup with "New takeaway sale".
- Tests: tests/test_caller_id.py (10), terminal unit test, e2e terminal and manager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:06:39 +02:00
bonaminandClaude Opus 5.5 88a9703902 feat(terminal): the customer display, with an idle screen each venue designs
Plan step 3.4. Owner (2026-11-16): the idle screen is configurable per venue.
- routers/customer_display.py (module customer_display, /api/display): the counter POS
  pushes its state (POST /api/display/state: idle | cart | paid with lines, total, paid,
  change); only the displays linked to that POS get `display.state`; the last state is kept
  in memory for a display that reconnects (GET /api/display/state). pos_counter's device
  scope includes customer_display.state.
- The idle screen: setting customer_display.idle (name, logo, logo + name, blank, one
  image, slideshow, QR code to the online ordering / QR menu / any link; a line of text;
  dark or light); images uploaded to /app/data/display_media (JPG/PNG/WebP/GIF ≤ 5 MB,
  random names, served publicly on the LAN); a change sends `display.settings` to every
  display. New key customer_display.manage (owners, store managers; migration 0022).
- Terminal: CustomerDisplayApp (cart with a large total, "Thank you" with the change for
  12 s, the venue's idle screen, its theme), logic.js (unit-tested); the POS pushes from the
  sale cart and the payment dialog (tables, online orders too) via useDisplay().
  qrcode.react added to the terminal (already in the workspace).
- Manager: Settings → Customer display (style cards, venue name, text, look, slide seconds,
  QR target/link/caption, image upload/pick/order/delete).
- Tests: tests/test_customer_display.py (3), terminal display.test.mjs (3); e2e terminal
  (linked vs unlinked display, < 1 s, paid, QR and slideshow idle screens), manager (the
  settings tab).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:34:05 +02:00
bonaminandClaude Opus 5.5 18d580d87c feat(manager): the venue's online ordering link and QR code on the Online ordering page
Plan phase 3S, step S.99.
- GET /api/connect/fees returns `links` {order, menu}: the ordering app and QR menu
  addresses, from the cloud's apps_url (heartbeat) and the site id.
- Manager: "Your ordering link" card (OrderingLink.jsx) on Online ordering: the address, its
  QR code, copy / open / print, to share or put on the website and window.
- Pack README: routers/fees.py row.
- Tests: the link (backend), the card (manager e2e).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 01:36:02 +02:00
bonaminandClaude Opus 5.5 652e6a26af feat(connect): the QR menu at the table: one code per table, orders straight onto the table
Plan phase 3S, step S.7.
- tables.qr_token (migration 0021): a random token per active table; services/table_qr.py
  (tokens, rotate, the snapshot's `qr` with the tokens' sha256 only, the code's link from the
  cloud's apps_url); setting connect_menu.table_ordering (read-only by default).
- /api/connect/qr (connect_menu.manage): the codes, ordering on/off, a new code per table or
  for all; table and QR changes push the menu at once (MENU_PATHS).
- Pull: a QR order with a table id goes onto the table's open order or a new one
  (services/qr_orders.py): items at the cloud's prices, kitchen tickets, KDS, order_updated
  (the waiters' phones and the counter), a `qr_order` message to the order's waiters or the
  table's zone waiters; audit QR_ORDER (a repeated pull adds nothing); the cloud is told
  "accepted" (the guest's page: in the kitchen). No usable table or no open day → the counter
  gets it as before. Waiter app: the message's look.
- Manager: Online → Table QR codes (/online/qr): ordering switch, the menu link, a QR card
  per table (print all), new code per table / for all.
- Heartbeat: apps_url kept in the license state.
- Tests: tests/test_qr_table.py (5); e2e qr_table.mjs (a real cloud and venue: table 5's
  code → two dishes on table 5's order, KDS, live event, the guest's page; a forged code
  refused; a new code kills the old one), in run-all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 01:26:55 +02:00
bonaminandClaude Opus 5.5 70c8f2bb57 feat(connect): table bookings from the online ordering app; food fired to the kitchen before arrival
Plan phase 3S, step S.6.
- Pull: "reservation" / "preorder" orders become Reservations waiting for an answer
  (status "requested"; services/online_reservations.py), with the food ordered ahead kept on
  the booking (items_json at the cloud's prices, the site's price check) — no order yet.
  Migration 0020 (reservations: online_order_cloud_id, online_ref, items_json, total,
  online_price_diff, fire_at, order_id, response_note).
- Confirm → the food's fire time = booking time − fire minutes (setting); the fire worker
  (connect_orders, every 20 s) turns the food into an order at that time (needs an open
  business day; waits otherwise): kitchen tickets, KDS (reference and time). Early arrival
  fires at once. Seating moves the order to the table (refused if the table has an open
  order). Decline / cancel / no-show with a reason. Every step mirrored to the cloud.
- Found: the KDS filter dropped every online order without an online status (SQL NULL in
  NOT(a AND b)) — made NULL-safe.
- Counter: Online → Bookings (requests first, then upcoming), BookingPanel (confirm,
  decline with reasons, food and when it goes to the kitchen, seat at a free table, cancel,
  no-show); the Online badge and chime count booking requests.
- Manager: Online ordering → Table bookings settings (on, food ahead, hours, slot, notice,
  days ahead, party size, fire minutes); the dashboard's reservations card confirms /
  declines online requests; the reservations router delegates online bookings' status steps.
- Tests: tests/test_online_bookings.py (8), unit tests (terminal, manager), e2e: order app
  (book with food → the venue confirms), terminal (request → confirm → the two dishes reach
  the KDS at the fire time, not before → seated), manager (booking settings).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:31:44 +02:00
bonaminandClaude Opus 5.5 0ca700279a feat(connect): the site side of online orders: fee line, customer's time, price check
Plan phase 3S, step S.5.
- Pull: an online order keeps the customer's time (orders.requested_for, None = as soon as
  possible) and delivery area; quick options are stored in the site's entry shape; items get
  their cost snapshot.
- The delivery fee is its own order line: a system product (products.system_key
  "delivery_fee", lifecycle "system", sold nowhere; services/system_products.py), created on
  first use in the venue's language with the VAT group most products use. Added printed and
  served, so kitchen tickets and the KDS never see it; paid at the counter with the items,
  counted in the shift, on the fiscal receipt with its VAT group. Never listed in the
  catalogue (products list, export, edit endpoints → 404) and never added by hand.
- Price check (services/online_check.py): each line priced as the snapshot prices it, at the
  order's time, and the fee through the same engine with the site's rules and the cloud's
  area id; differences kept on orders.online_price_diff and shown. The customer pays what
  the cloud charged.
- Counter: time chip (or as soon as possible), area, fee line, price warning; takeaway is
  its own kind (was shown as "at the venue") and finishes as "collected". KDS cards show the
  online reference and the time; kitchen tickets print the reference, the type and the time.
- Manager: Online ordering → "The fee on the receipt" (name, VAT group;
  PUT /api/connect/fees/fee-product, fees.vat_group_unknown); the online orders page shows
  the time, area and price warning.
- Migration 0019. Tests: tests/test_online_site_side.py (6), terminal unit test, e2e
  (terminal: fee, time, warning, paid in full; manager: fee line settings).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:38:25 +02:00
bonaminandClaude Opus 5.5 8ea44d71aa feat: online ordering settings (services, hours, preparation, slots) and the order app e2e (platform-v2 3S, S.4)
- connect_orders.ordering setting; GET/PUT /api/connect/fees/ordering (validated:
  services, hours per day incl. past midnight, preparation, slot minutes, days ahead,
  ASAP); pushed to the cloud with the menu (snapshot `ordering`).
- Manager: the Online ordering page gains "Services and hours" (OrderingSettings.jsx; logic
  in feesLogic.js, unit-tested); nav label "Online ordering".
- tests/e2e/order_app.mjs: a real cloud + the built order app in a phone-sized browser:
  takeaway and delivery placed, priced by the cloud (fee by area, minimum refused), the
  site moves the delivery to delivered and the page follows; a rejection with its reason;
  Greek. In run-all, with the order app's unit tests.
- Tests: backend +1 (406), manager unit +1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 13:39:13 +02:00
bonaminandClaude Opus 5.5 df27133af9 docs: fee engine has a byte-identical copy in the cloud (pack README)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 12:29:41 +02:00
bonaminandClaude Opus 5.5 9bfe54554d feat: delivery areas and fee rules with "test an order" (platform-v2 3S, S.3)
- models/fees.py + Alembic 0018: delivery_areas, fee_rules; key connect_orders.fees
  (owner, store manager; existing ones get it).
- services/fees.py: the pure engine (set / add / % / free / minimum, conditions: sales
  points, areas, products total, item count, days, time incl. past midnight, stop), the
  same file as the cloud's; tests/fixtures/fee_cases.json shared, plus a test that the
  cloud copy is identical.
- routers/fees.py at /api/connect/fees: areas and rules CRUD (validated), order, preview.
- Snapshot carries fees + the venue's time zone; a change to products, pricing or fees
  pushes the menu within ~5 s (middleware -> cloud_sync.request_menu_push).
- Manager: Online -> Delivery fees page (@xenia/ui): rules in order with words for each,
  areas with postcodes, "Test an order"; en/el texts; feesLogic.js unit-tested.
- Tests: test_fees.py (39), manager unit +5, manager.mjs +7 on the real page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 12:28:29 +02:00
bonaminandClaude Opus 5.5 ffeb2b45cb feat: the menu snapshot carries a price per sales point; pulled orders keep the cloud's sales point and table (platform-v2 3S, S.2)
- services/cloud_sync.menu_snapshot(db) (split out of the push, tested): sold_at + prices
  per customer-app sales point from the pricing engine; digital_price = the QR menu's.
- store_online_orders: sales_point from the cloud (older clouds: from the type), takeaway
  orders typed takeaway, the QR menu's table in front of the customer's note.
- manager e2e: waits for the live connection (html[data-live]) instead of a fixed 1.5 s,
  and for the server to record "read" (two timing races seen in a full run).
- Tests: +2 in test_sales_points.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:38:46 +02:00
bonaminandClaude Opus 5.5 1b468fe44b feat: sales points, offerings and prices per sales point (platform-v2 phase 3S, step S.1)
- core/sales_points.py: in_store, in_store_takeaway, qr_table, online_takeaway,
  online_delivery, online_preorder (+ old channel names mapped).
- Alembic 0017: orders.sales_point (backfilled), products.sold_at (from digital_visible),
  digital_price/digital_discount -> item price modifiers for the QR menu and online,
  order_channel conditions -> sales points; drops the three digital columns.
- Every order records its sales point; the pricing engine's channel is it; items not sold
  there are refused (order.not_sold_here, pos.line_invalid not_sold_here).
- POS menu: only what the counter sells, prices per counter sales point; the screen shows
  the order type's products and prices. Waiter app asks for in-person products.
- Cloud snapshot: products sold by the customer apps, priced by the engine.
- Manager: product "Where it's sold" tab; pricing condition shows sales points.
- Products API, catalogue export/import carry sold_at.
- Tests: test_sales_points.py (8, incl. the migration), access +1, terminal +1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:00:40 +02:00
bonaminandClaude Opus 5.5 f2182dcb37 feat(pos): refunds at the counter on a fiscal driver layer (platform-v2 3.3e)
- services/fiscal/: one driver interface (prepare_receipt / prepare_credit_note -> send,
  credit_notes flag, status); the dTEC100extra folder bridge moved into txt_file.py as the
  first driver, same command files. fiscal_service.py removed, callers moved.
- Refunds: models/refund.py + Alembic 0016 (refunds, refund_items; ordering.refunds for
  existing owners/managers). services/refunds.py: today's business day, the cashier's open
  shift, partial quantities, items from another shift need ordering.refunds or a manager's
  approval (check()/authorize() return the override row). Paid items are never edited.
- POS: GET /api/pos/receipts, GET /api/pos/receipts/{id}, POST /api/pos/orders/{id}/refund
  (cash opens the drawer; fiscal "manual" when the driver can't issue credit notes).
- Shift totals subtract refunds and now count discounts; day close and business-day
  reports carry refunds.
- Terminal: Receipts mode (ReceiptsView, ReceiptPanel, logic/refunds.js), en/el texts.
- Tests: test_pos_refunds.py (12), terminal unit +1, terminal.mjs +7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:44:17 +02:00
bonaminandClaude Opus 5.5 d542cf7d34 feat(backend,terminal): online orders on the counter POS (platform-v2 step 3.3d)
- Counter POS gets an "Online" mode (module on + connect_orders.manage): New / In
  progress / Finished, a chime on arrival (and every 30 s while one waits), badge,
  toast in any mode; the order panel offers only the next step: accept / reject with
  a reason, preparing, ready or out for delivery, then take the payment (shared
  PaymentDialog, drawer, shift) and mark delivered/served.
- connect_orders router on v2 conventions: require(connect_orders.manage), error
  codes online.not_found / online.status_changed, the cloud's step order enforced,
  audit rows, GET /api/connect/orders/board. POS device scope gains connect_orders.*;
  barista and barman get the key by default.
- Fixes: the KDS showed online orders before acceptance; accepting printed no
  kitchen tickets; a pull whose synced mark failed stored the order twice
  (store_online_orders skips known cloud ids); pulled orders lacked the business day
  and delivery type; rejected orders kept active items; delivered sets closed_at/by.
- Online orders belong to holders of connect_orders.manage (_can_access_order), so
  the counter pays them with POST /api/pos/orders/{id}/pay.
- Tests: test_pos_online.py (5), terminal unit +1, terminal.mjs +17 with a fake
  cloud (pull, synced, status mirror); fixed a timing race in a 3.3c check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:42:06 +02:00
bonaminandClaude Opus 5.5 988d413d8e feat(backend,terminal): tables at the counter, shared live with the waiter phones (platform-v2 3.3c)
- POS: GET /api/pos/tables (the cashier's zones as in the waiter app, each open order's
  totals, people, ready items, flags, reservation), POST /api/pos/tables/{id}/items (into
  the table's order or a new one via orders.open_order + add_items), POST
  /api/pos/orders/{id}/pay (chosen items, cash/card/split, drawer on cash), POST
  /api/pos/orders/{id}/close (only when nothing is unpaid). Quote takes order_id so the
  order's items count for cart conditions (shared pos_cart.order_cart, used by add_items).
- New codes pos.table_not_found, pos.table_not_yours, pos.items_changed, pos.order_unpaid.
- Fix: item cancels (DELETE item, cancel-items) now broadcast order_updated, so phones and
  kitchen screens see them at once.
- Terminal: Sale | Tables switch, zone list, table cards by zone, TablePanel (order lines,
  new lines, send, pay selected/all, cancel with approval, close), generic PaymentDialog.
- Tests: test_pos_tables.py (8), terminal unit, terminal.mjs +17 with a live phone socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:15:54 +02:00
bonaminandClaude Opus 5.5 bff82a332a feat(terminal): quick sale at the counter: cash/card/split, change, cash drawer, fiscal (platform-v2 3.3b)
- POST /api/pos/sales: all checks first (shift, lines, payment split, cash given,
  discount → ordering.prices.modify or manager approval, fiscal VAT groups), then the
  existing open_order / add_items / pay_items functions, so tickets, KDS, price events,
  shift totals and the fiscal receipt work as for any order.
- Cash drawer: printer_service.open_cash_drawer (ESC @ + ESC p 0 25 250) to the screen's
  receipt printer on cash, logged and audited (DRAWER_OPENED / DRAWER_FAILED).
- orders._can_access_order: the people assigned to an order may act on it (a cashier's
  own takeaway order); pos_cart prices a batch with the lines before it, as add_items does.
- Terminal: Charge → payment dialog (exact cash pre-selected, quick amounts, change,
  card, split by line), per-line discounts, sale summary and "Same again".
- Tests: backend +6 (socket printer receives the drawer kick, fiscal file in the bridge
  folder), terminal unit +1, terminal.mjs +9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 00:28:33 +02:00
bonaminandClaude Opus 5.5 17bee66df1 feat(terminal): counter POS screen with server-priced cart and shift gate (platform-v2 3.3a)
- Backend /api/pos (pos_counter): session (business day, the cashier's own shift,
  self-start, who can open the day), menu (sellable products with every kind of choice,
  no costs; price now from the pricing engine), quote (lines by id → the waiter's
  selected_options entries with DB prices → resolve_price as orders do; pos.line_invalid).
- POS device settings: default order type, start category, receipt printer (new ref
  sources categories / printers, also in the manager's Devices dialogs).
- Terminal apps/pos: shift gate (start shift with drawer cash), categories, search,
  product grid, price check, options dialog, cart priced by the backend.
- Tests: backend test_pos (13), terminal pos.test.mjs, manager refOptions,
  terminal.mjs +10 POS checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 21:55:30 +02:00
bonaminandClaude Opus 5.5 b1112b249e feat(manager): remove the KDS page; app cards lead to pairing a screen (platform-v2 3.2d)
- Deleted pages/KdsPage.jsx, its /kds route, nav entry and text: the kitchen display
  runs only on paired screens (D-25).
- Apps: cards of apps that run on a screen get "Set up a screen" (core.devices.manage)
  → /devices?pair=<app>, which opens the pair dialog on that app.
- manager.mjs: no "Open" on the KDS card, "Set up a screen" lands on the pair dialog,
  /kds is gone; the module-off rule stays covered by the Notes checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 20:46:50 +02:00
bonaminandClaude Opus 5.5 6b237fd169 feat(backend): KDS item claims across screens; zone screens only touch their own items (platform-v2 3.2c)
- order_items.claimed_by / claimed_at (Alembic 0015). POST/DELETE
  /api/kds/orders/{id}/items/{item}/claim (kds.bump): someone else's claim is refused
  (kds.item_claimed), letting go works for anyone with kds.bump; live kds_item_claimed.
  In progress claims for whoever did it; done/served/pending/declined clear the claim.
- Fix: order-level status and decline from a zone screen changed every zone's items;
  now only the screen's zone, and a zone screen sees the order status of its own items.
- Terminal: "I'm on it" / "Let go" on the selected card, the cook's name on claimed items.
- Tests: backend +6, terminal unit +1, terminal.mjs +6 with a second screen and cook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 20:25:34 +02:00
bonaminandClaude Opus 5.5 77e0adbe9c feat(ui): board design language as global tokens; KDS on tokens and shared components (platform-v2 3.2b-2)
- @xenia/ui: --x-board-* tokens (the kitchen display's look: dark board, light cards,
  status colours, card radius/shadows, number font), Tailwind board.* colours, contrast
  test for the board pairs; near-identical shades merged.
- New shared Stepper component (gallery + ui.mjs), labels ui.decrease / ui.increase.
- KDS: theme.js maps to the board tokens, no colour literals left (only stored setting
  values); decline / call waiter / settings use Dialog, Button, Switch, Select, Stepper;
  toasts are @xenia/ui toasts (ToastProvider at the terminal root).
- Terminal: apps can set their theme (APP_THEMES, KDS dark) while they run.
- CS-16: board screens and "no hard-coded colours in app code".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 20:02:35 +02:00
bonaminandClaude Opus 5.5 5f6d4ab428 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>
2026-11-14 19:27:11 +02:00
bonaminandClaude Opus 5.5 d5c4400fde feat(backend): KDS settings as device config, zone enforced for kitchen screens, KDS-only API (platform-v2 3.2a)
- KDS manifest: 23 typed settings (prep zone, board, waiting-time minutes and colours,
  behaviour) replacing the KDS page's localStorage settings.
- ConfigField: colour type, "after" ordering (warning < late < flash), groups for the
  manager's dialogs, ".none" text for an empty ref choice.
- routers/kds.py: a KDS device gets only its zone's orders, prints to its zone by default
  and signs waiter messages with its zone/name. New GET /api/kds/context and
  POST /api/kds/orders/{id}/retry-print so the screen never leaves its kds.* scope.
  Unused v1 /items and /items/{id}/status endpoints removed (D-21).
- PATCH /api/devices/me/config: a screen changes its own settings when the signed-in
  person holds core.devices.manage.
- Manager Devices dialogs: settings in sections, colour pickers, "All zones".
- Tests: test_kds_device.py, colour/ordered fields; terminal.mjs scope + zone checks;
  manager.mjs settings sections; stack.mjs detaches the non-LAN network before the
  restart check (one flaky 403).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 18:56:59 +02:00
bonaminandClaude Opus 5.5 c24cb72640 feat(terminal): pairing, sign-in per mode, device app router and live states (platform-v2 3.1c)
- Pairing screen: requests a code, shows it big, polls with the secret, new code on
  expiry, keeps the device token; "removed from the venue" notice after a revoke.
- Sign-in per device mode: PIN (name + PinPad), tap your name, password (name +
  password), none (straight into the app). Names = holders of <app>.access, refreshed
  every 30 s and on reconnect. Slim bar with screen, user and Sign out; idle sign-out
  after the device's auto_sign_out_minutes; hourly token refresh (same session).
- DeviceProvider: GET /api/devices/me (retried while unreachable), session, the live
  connection with credentials in the first frame (device.updated -> reload, app moved ->
  sign out, device.revoked -> forget, session.ended -> sign out), offline banner;
  useLiveEvent for apps. Screen choice is pure (device/flow.js, unit-tested).
- Blocked screen: app turned off / not licensed / device refused, recovers by itself.
- @xenia/access AccessProvider: autoRetryMs (retry bootstrap while unreachable).
- Tests: terminal unit tests (screen choice, live actions, idle, pairing polls), new
  tests/e2e/terminal.mjs (18 checks), manager.mjs owner flow now pairs and signs in on
  the real terminal screen; run-all runs terminal.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:29:18 +02:00
bonaminandClaude Opus 5.5 7ff3c3b48e feat(terminal): terminal app shell, pos-terminal image, LAN-only proxy port 8082 (platform-v2 3.1b)
- terminal/: new workspace app (Vite + React 19 + Router 7, Tailwind on the shared
  preset, @xenia/i18n namespace `terminal`, @xenia/api client sending X-Xenia-Device,
  @xenia/access bootstrap). Apps are lazy chunks by app_key (kds, pos_counter,
  customer_display placeholders); start screen; "unknown app" screen; dev-only
  /ui-gallery and /i18n-sample. Device + session tokens in a storage wrapper.
- Image pos-terminal (terminal/Dockerfile, context client-services/); every frontend
  Dockerfile copies terminal/package.json for npm ci.
- docker-compose(.dev).yml: service terminal; proxy publishes 8082.
- Proxy (nginx-proxy/nginx.conf == install.sh heredoc, CS-5): server :8082, LAN-only
  allow/deny, WebSocket upgrade; the terminal upstream is resolved per request so the
  proxy still starts on a stack without the terminal container.
- install.sh prints the screens address.
- Tests: terminal unit tests + lint in run-all; new tests/e2e/stack.mjs (release images
  on one compose stack: :8082 serves the app, /api + WebSocket through both hops,
  403 from a non-LAN docker network on 8082 and 8081, proxy up without terminal).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:02:20 +02:00
bonaminandClaude Opus 5.5 bda5cde92b feat(backend): live connection and per-device settings for paired screens (platform-v2 3.1a)
- WebSocket: credentials may come in the first frame ({cursor, token?, device?}).
  A device token alone connects a paired screen (login-none apps get every event, a
  sign-in app only events addressed to it); a terminal session's JWT needs its own
  device, as over HTTP. Refusals send {type: refused, data: {code}} + close 4001/4003.
- ws_bus: registry of open sockets by user, session and device. Ending a session
  closes its sockets (session.ended); revoke/reassign close the device's sockets
  (device.revoked / device.updated); edits and module on/off send device.updated.
  Events can target devices (device_ids=..., sync_events.target_device_ids, rev 0014).
  Pushes go through each socket's own loop (call_soon_threadsafe).
- Device config: DeviceApp.config = typed ConfigFields, validated on pair/edit/
  reassign (validation.device_config), effective values (defaults filled) in both
  device views and the module catalogue. First field: auto_sign_out_minutes (KDS, POS).
- Manager: DeviceConfigFields renders an app's fields in the pair and edit dialogs.
- @xenia/api createLiveClient: `credentials` and `onRefused` options.
- Tests: tests/test_live.py (11), module texts for config fields, live client,
  devices logic, manager.mjs device setting + live socket checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 16:31:59 +02:00
bonaminandClaude Opus 5.5 034426f870 fix: orders CSV export, Online Orders live refresh, starter flags and quick messages
Cleanup before platform-v2 phase 3 (owner-approved).
- KI-008: GET /api/reports/orders/export read order_history's dicts as ORM rows and
  always failed with 500; it also ignored business_day_id (the Today page sends it).
  Rebuilt on the dicts, header even when empty. tests/test_reports_export.py.
- KI-010: OnlineOrdersPage listened on /api/stream (never existed: no live refresh,
  a 404 every few seconds). It now refetches on the shared live connection
  (online_order_received / online_order_updated / ready); 20 s polling stays as a
  fallback. manager.mjs checks nothing asks for /api/stream.
- KI-007: the setup wizard seeds the 10 default table flags and 5 quick messages in
  the venue language (services/defaults.py), only when none exist. v1's seed never
  worked (NOT NULL columns missing). Managers edit them in Settings -> Operation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 14:08:54 +02:00
bonaminandClaude Opus 5.5 f1f20f7bba feat(backend): sign people out after N days without use (auth.idle_days, default 14)
Platform-v2 step 2.99d, owner decision 2026-11-14.
- New core setting auth.idle_days (int, default 14, 0 = never). A manager, waiter or
  paired-device session unused for that long ends with reason "idle" on its next
  request (sessions.validate) or when someone opens "Signed in now"
  (sessions.end_idle in GET /api/auth/sessions). Support keeps its own 4 h expiry.
- Manager: Settings -> Sign-in & security -> "Sign people out after" (7/14/30/60/90
  days / Never; a value set elsewhere is kept); "Signed in now" names the reason.
  Texts en/el.
- Tests: backend 284 (+ 14-day default, list drops idle ones, setting incl. 0);
  manager e2e checks the default and saving 30. The support-access check that
  failed once in ~8 runs now saves a screenshot and the page's alert text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:38:00 +02:00
bonaminandClaude Opus 5.5 cc4e76019b chore: deliberate dependency upgrades; drop legacy-peer-deps; Capacitor 8.6.2 (shell build 2)
Platform-v2 step 2.99c.
- Both apps on the same current versions: React 19.3.1, react-query 5.107.1,
  router 7.18.5, axios 1.21.1, zustand 5.1, vite 8.3.8, plugin-react 6.3; manager
  lucide-react 1.14 -> 1.73, recharts 3.8 -> 3.10.
- i18next 27.1.1 + react-i18next 18.0.1 (exact pins). Shared options moved to
  packages/i18n/src/options.js with returnEmptyString: true (27 shows the key for an
  empty text otherwise); tests/instance.test.mjs guards it, plus fallback, code
  casing and plurals.
- vite-plugin-pwa 2.0 lists Vite 8 as a peer: .npmrc (legacy-peer-deps) removed,
  `npm install` resolves without it.
- Native (CS-10): @capacitor/core/android/cli 8.6.2, @capacitor/app 8.1.2,
  @capgo/capacitor-updater 8.54.2; versionCode 2 / versionName 1.1.0 and
  MIN_SHELL_BUILD 2. capacitor-updater 8.54 refuses plain-HTTP downloads by
  default, which broke every bundle check in the stacks suite: httpsOnly: false in
  capacitor.config.json (venues have no domains; zips are sha256-checked).
- npm audit: 6 left, all in workbox-build 7.4.1 (build time).
Full run-all incl. Android passes (Android re-run after the httpsOnly fix).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:22:51 +02:00
bonaminandClaude Opus 5.5 e9b6ef57e0 chore: patch npm advisories in shipped and build code; add a manager ESLint config
Platform-v2 step 2.99b.
- npm update of the advised packages, within their ranges: what ships to browsers
  is axios 1.15.1 -> 1.21.1 and react-router(-dom) 7.14.1 -> 7.18.5 (both apps);
  build tools: vite 8.0.9 -> 8.3.8 (rolldown 1.2), postcss 8.5.33, babel 7.29.x,
  browserslist, js-yaml, zod, brace-expansion, nanoid, source-map-js... 30 -> 11
  advisories; the 11 left are build-time only (vite-plugin-pwa/workbox-build chain,
  @capacitor/cli -> xcode -> uuid) and move to 2.99c.
- manager_dashboard/eslint.config.js = the waiter's rules; `npm run lint -w
  manager-dashboard` checks the v2 code (file list in the script), in run-all.mjs.
  set-state-in-effect is a warning until phase 6 moves page loading to react-query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:35:50 +02:00
bonaminandClaude Opus 5.5 7cbd0325a4 refactor(backend): remove the v1 auth and permission leftovers no frontend uses
Platform-v2 step 2.99a. After 2.6 no frontend calls these any more:
- POST /api/auth/login needs `client` (manager/waiter/terminal); the no-`client`
  path with v1 rules and the `legacy_manager` single-session exception are gone.
- GET /api/setup/security-config (bootstrap's `login` replaced it in 2.6b).
- POST /api/recovery/use (a recovery code works in the normal login's
  password field).
- PUT /api/waiters/{id}/permission and /reset-permissions (the permission editor
  saves keys with PUT /{id}/permissions); staff create/update ignore perm_* fields.
- The v1 perm_* projection: core/access/legacy.py deleted, UserOut carries only
  `permissions` (no app reads the 13 booleans, waiter included).
e2e manager login sends client "manager"; smoke_routes too. Backend 281 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:08:01 +02:00
bonaminandClaude Opus 5.5 eb22997f8e test(e2e): owner flow end to end (platform-v2 2.6g)
manager.mjs: sign in -> KDS on from its Apps card -> pair a screen on the
Devices page (device side via the API) -> the chef is refused, then gets
kds.access + kds.bump in the permission editor -> signs in on that screen
with their PIN and reads /api/kds/orders -> listed under "Signed in now".
87 checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 10:04:43 +02:00
bonaminandClaude Opus 5.5 2426ffddad feat(manager): notification bell, sign-in/venue/print settings, log download (platform-v2 2.6f)
- Bell in the header: /api/platform/notifications with unread count, live via
  the new LiveProvider (one createLiveClient connection) on platform_notification
  and reconnect; mark read / all; warning+critical pop a toast.
- Settings: Sign-in card (manager/waiter/device modes, require username, one
  session per manager/waiter, username autofill) replaces the dead v1
  security.login_method card; new "Venue & language" tab (language, time zone);
  print alert threshold in Printing. Tab labels are i18n keys.
- Technical > Log files: list + download of the daily logs (owner-level).
  Backend: GET /api/system/logs, /api/system/logs/{date} (core.settings.manage),
  error system.log_not_found.
- Setup wizard asks staff language and time zone (setup/init stores them).
- @xenia/ui theme helpers (applyTheme, getStoredTheme); the manager stays light
  until phase 6 converts the older pages (owner decision 2026-11-14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 09:01:26 +02:00
bonaminandClaude Opus 5.5 92bc1b0113 feat(manager): staff permission editor, signed-in sessions, approvals log (platform-v2 2.6e)
- Staff: the 13 perm_* tick columns become one Permissions column (count,
  "changed from role") opening an editor grouped by module, from
  /api/waiters/permission-catalog: switches labelled per key, keys you don't
  hold are disabled with the reason, reset to role defaults (names what it
  can't give), save the whole set; access.cannot_grant explained by label.
- "Signed in now" (/management/sessions): who, where (app or device), since,
  last active, your own session marked; end session; show ended + reason.
- "Manager approvals" (/management/approvals): the override audit with
  action label, asked by, approved by, device, used/not used, order link.
- Backend: sessions list adds device_name/device_app/current/expires_at;
  overrides list adds device_name/expires_at.
- Permission labels for every key in modules.json (en/el), guarded by
  test_module_texts; manager unit tests for the editor logic; e2e 66 checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:10:57 +02:00
bonaminandClaude Opus 5.5 cc00ec39c7 feat(manager): Devices page — pair by code, app, name, sign-in mode, link, change app, remove
Platform-v2 step 2.6d:
- /devices (core.devices.manage, sidebar): devices from /api/devices with
  status (online / last seen / waiting for the device / app turned off /
  removed), app, sign-in mode (own or venue default), linked device; usage per
  device app against the license limit (devices)
- pair dialog: code as typed (normalized), app (only apps that are on, "all in
  use" when the limit is reached), name, sign-in mode for apps with a choice,
  optional linked device; license.limit_reached explained with the app's limit
- edit (name, sign-in mode, link), change app (signs out whoever is on it),
  remove with confirm (the device goes back to pairing), show removed
- manager_dashboard gets node --test (tests/platform.test.mjs: module states,
  dependents, device status/usage/room/links), added to run-all
- e2e manager.mjs: 54 checks (+ wrong code, normalized code, pair, the device
  picks up its token, online, rename, change app, remove → device.revoked)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:22:43 +02:00
bonaminandClaude Opus 5.5 1f28016122 docs(backend): CS-13 — a new module needs its staff texts in modules.json
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:34:32 +02:00
bonaminandClaude Opus 5.5 0d0b2d78e1 feat(manager): Apps, Integrations and License pages on the module catalogue
Platform-v2 step 2.6c:
- Apps (device apps, features, always-included core) and Integrations: module
  cards from GET /api/platform/modules with state (on / off / waiting for a
  dependency / not in your license / always on), dependencies, limits and an
  Open button where the manager has a page; core.modules.manage toggles them
  (PUT /api/platform/modules/{key}), with a confirm listing the modules that
  stop too; bootstrap reloads so the sidebar follows at once
- License page: licensed / free (with the reason) / development, site id,
  validity, last contact, "check the license now" (POST /api/system/sync-license),
  every module's entitlement and limits
- i18n: new `modules` namespace (names, descriptions, limit labels, en + el)
  kept complete against the registry by local_backend/tests/test_module_texts.py
- nav: Integrations and License in the sidebar; old AppsPage removed
- e2e manager.mjs: 43 checks (+ card states, toggle from the card, dependency
  warning, integrations, license page)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:33:54 +02:00
bonaminandClaude Opus 5.5 49a412d748 feat(manager): v2 sign-in (login modes, support access, license notice) and an unlock endpoint for the lock screen
Platform-v2 step 2.6b:
- backend: POST /api/auth/unlock {pin|password} checks the CURRENT session's
  user and keeps the session (no new login/token); 5 wrong tries end it
  (auth.wrong_pin with attempts_left, then auth.session_ended); bootstrap
  gains `login` (manager_mode, autofill_username, support)
- manager LoginPage rewritten on @xenia/ui + i18n: client "manager", password
  or PIN pad per setting, remembered/only account card, support access panel
  (challenge -> code -> 4 h session, not remembered as an account), notice
  when the license runs the free tier (expired/inactive/locked/clock/unverified)
- lock screen on /api/auth/unlock with the shared PinPad
- @xenia/ui PinPad: variable length (minLength/maxLength, OK key, Enter)
- e2e manager.mjs: 33 checks (+ lockout after 5 wrong PINs, PIN login mode,
  support access with a wrong then right code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:17:09 +02:00
bonaminandClaude Opus 5.5 df57fd1552 feat(manager): shell navigation from modules + permission keys; profile menu language
Platform-v2 step 2.6a:
- shell/nav.js: one nav definition (module + key per page) read by the sidebar,
  the page titles and a RouteGuard around the layout outlet (and /kds): a module
  that's off hides its items and its routes say "turned off"; a missing key
  hides the item and the route says "no access". Same keys as before (v1
  permission names mapped), plus the module check
- labels/breadcrumbs are keys in a new i18n namespace `manager` (en + el)
- removed the browser-only feature toggles (usePhase2Features, Settings ->
  Λειτουργίες, F-033), PermissionGuard and usePermissions
- profile menu: language, saved to the profile (PATCH /api/auth/me) and
  bootstrap reloaded
- e2e manager.mjs: module off/on, no-key user, language switch live + saved

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:48:08 +02:00
bonaminandClaude Opus 5.5 78c8824356 feat(api): @xenia/api + @xenia/access; the manager logs in and loads bootstrap through them
Platform-v2 step 2.5 (APPS_PLATFORM D-7, D-10, §9):
- @xenia/api: createApiClient (app passes its axios; session/device headers,
  err.xenia codes, 401/offline hooks, manager-override retry: ask PIN, grant,
  retry once with X-Xenia-Override); errorMessage; createLiveClient = the
  waiter's WebSocket logic (cursor replay, backoff, online) moved unchanged
- @xenia/access: AccessProvider (bootstrap per session token, language +
  venue formats, translated ui labels, approval dialog), useAccess/useCan/
  useModule, Can, RequireModule
- i18n: errors namespace for every backend code (en/el, test vs core/errors.py),
  override/access texts
- manager: client from createApiClient, AccessProvider in a layout route,
  /kds behind RequireModule, usePermissions from bootstrap keys; login and
  unlock no longer treat a wrong password/PIN as "session ended" (a wrong
  lock-screen PIN used to log the manager out)
- waiter: useWebSocket is a thin wrapper over createLiveClient
- tests: api/access unit tests; new e2e suite tests/e2e/manager.mjs; CS-18

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:38:31 +02:00
bonaminandClaude Opus 5.5 dbb8d5f0f4 feat(i18n): @xenia/i18n translations, language resolution and venue-time formatting
Platform-v2 step 2.4 (APPS_PLATFORM D-11, D-12, §7.2, §8):
- i18next 26.7.2 + react-i18next 17.1.13 (exact); en/el locale files
  (common, dev); createI18n, I18nProvider, useLanguage, setUserLanguage
  (screen first, then PATCH /api/auth/me through an app-provided save)
- resolveLanguage: user -> device -> venue -> en
- useFormat(): dates/times always in the venue zone from bootstrap (24 h,
  DST-safe, business dates never shifted), relative times, money and
  numbers per language; parseNumber accepts a comma or a dot
- scripts/check-i18n.mjs guard: keys missing in en, placeholder mismatches,
  dates formatted without the venue zone in new code (fails); missing el (warns)
- @xenia/ui components read their texts from UiLabelsProvider; useUiLabels()
  supplies the translated set
- dev-only /i18n-sample in the manager; ui.mjs e2e checks it with the browser
  in New York; unit tests in run-all; lockfile keeps both apps' versions
- new pack rule CS-17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:51:11 +02:00
bonaminandClaude Opus 5.5 3580f2815c feat(ui): @xenia/ui design tokens, Tailwind preset and base components
Platform-v2 step 2.3 (APPS_PLATFORM D-15 §9):
- tokens.css: --x- prefixed colours (light/dark/system + 5 venue accent themes),
  spacing, radius, type scale, shadows, motion, z-index; variables only
- components.css: .x-* classes only, no element selectors (new rule CS-16)
- Button, IconButton, Dialog, Sheet, Toast, PinPad, InfoTip, EmptyState,
  Spinner, Field/Input/Textarea/Select, Switch (accessible: focus trap and
  restore, ARIA wiring, 44px targets)
- tailwind-preset.js (adds names only); manager uses it + styles.css, the
  waiter imports tokens.css; existing screens unchanged
- dev-only /ui-gallery in the manager; e2e suite tests/e2e/ui.mjs; unit tests
  for PIN rules and WCAG AA contrast of every token pair, both in run-all

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:33:58 +02:00
bonaminandClaude Opus 5.5 c7102f1c89 feat(manager): upgrade to React 19, React Router 7 and Vite 8 (same versions as the waiter)
Platform-v2 step 2.2: react/react-dom 19.2.5, react-router-dom 7.14.1, vite 8.0.9,
@vitejs/plugin-react 6.0.1, and react-is 19.2.5 (recharts' peer dependency, no
longer installed implicitly). React and the router are now shared by both apps
at the workspace root; the waiter resolves exactly the versions it had.
- .npmrc legacy-peer-deps for the whole workspace (vite-plugin-pwa 1.2 does not
  list Vite 8 yet; the waiter always installed this way)
- manager Vite dev/preview proxies /api, /api/ws and /static to :8000 like the waiter
No code changes were needed: every route renders and the main flows work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:27:10 +02:00
bonaminandClaude Opus 5.5 17bef9915f chore(waiter): pin the Capacitor/Capgo native plugins to exact versions
A native plugin upgrade needs a versionCode + MIN_SHELL_BUILD bump (CS-10), so it
must never arrive as a side effect of npm install/update (it broke UI-bundle
updates during platform-v2 step 2.1). Versions unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:15:19 +02:00
bonaminandClaude Opus 5.5 905c2955b0 chore(build): frontends become one npm workspace; images build from client-services/
Platform-v2 step 2.1 (APPS_PLATFORM D-15):
- root package.json with workspaces (packages/*, waiter_pwa, manager_dashboard)
  and empty @xenia/{ui,i18n,api,access} skeletons (filled in 2.3-2.5)
- one root package-lock.json generated from the two old app locks, so every
  dependency keeps its exact version (a fresh resolve moved the Capacitor and
  Capgo native plugins and broke UI-bundle updates); apps keep nested trees
- waiter/manager Dockerfiles build with context client-services/ (npm ci per
  workspace), root .dockerignore replaces the per-app ones; manager on node 22
- Vite dedupes react/react-dom so source-imported packages share the app's React
- waiter eslint ignores build outputs and the Android project

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:47:29 +02:00
bonaminandClaude Opus 5.5 3699935347 fix(install): e2e compose stacks replace a data/pos.db left by a v1-era run
tests/e2e/lib/proc.mjs: composeStack() reuses out/<project>/data between runs; a database from before platform-v2 has no alembic_version, so the v2 backend refused it and the stack came up unhealthy (android.mjs stacks failed at docker compose up). The v1 check used for the seed template is now a shared isV1Database() and also applied to each stack's pos.db. android.mjs stacks: 21/21 after the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 13:09:42 +02:00
bonamin 6d42be95f8 feat(backend): a product can be listed in several categories, with one primary category
Platform v2 step 1.13 (APPS_PLATFORM D-23).
- product_categories(product_id, category_id, sort_order); products.category_id becomes
  products.primary_category_id (revision 0013 moves the data: one listing per product at its
  old position). services/catalog.py keeps the rule "the primary is one of its categories"
  and fixes up products when a category is deleted.
- Products API: category_ids + primary_category_id in and out, plus categories
  [{category_id, sort_order}]; GET /api/products/?category_id= lists a category's products in
  that category's order; PUT /reorder with category_id orders within a category. category_id
  stays as dev scaffolding (section 3.3): output = primary, input = "move the primary".
- Primary category: ticket grouping and prep-zone category order, the order-item category
  snapshot (1.12), report filters for waste-only rows and /meta/products.
- Every listing: price modifier / deal / min-quantity category targets, deal free choices,
  the QR menu snapshot (product in each category it's listed in; images pushed once).
- Catalogue export v2: each category lists all its products with "primary" and
  "category_sort_order"; import restores listings and order. v1 files are refused (D-21).
- New errors catalog.unknown_category, catalog.primary_not_listed.
2026-11-13 12:39:02 +02:00
bonaminandClaude Opus 5.5 3c5751025c refactor(backend): drop the legacy products.printer_zone_id and its print fallbacks
Routing has been by prep zone only since v1, which nulled this column on every start, so the four fallbacks in printer_service.py never ran. Revision 0012 drops the column (its unnamed FK goes with the batch rebuild). The unused legacy GET /api/kds/items keeps its single 'no zone' group. Product create/update/export/import no longer mention it. Scheduled in plan step 1.0 for the catalogue rework (1.13).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 12:28:13 +02:00
bonaminandClaude Opus 5.5 82c6ca4e0a feat(backend): order items keep the product and category they were sold under; reports use them
Platform v2 step 1.12 (APPS_PLATFORM D-18, CS-4).
- order_items.product_name (NOT NULL), category_id, category_name (revision 0011, back-filled from
  the current catalogue). A before_flush hook in models/order.py fills them for every new item,
  whoever creates it; an item created with product_name set is left alone (importer).
- Reports read the snapshots: order history, shift/printer/prep-zone breakdowns, cancellations,
  product and category performance (grouped by the category as sold, newest name in the period
  wins), and the printed product/category reports. Catalogue listings (unsold products in 'full'
  mode, meta endpoints, waste-only rows) keep live names on purpose.
- Order detail and OrderItemOut expose product_name/category_id/category_name next to the live
  .

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 11:33:55 +02:00
bonaminandClaude Opus 5.5 834fe6e250 feat(backend): alert managers while a ticket keeps failing to print (setting print.alert_after_failures, default 2)
Owner request after step 1.11: hear about a failing ticket during service, not only when it's abandoned.
- New notification print.failing (critical, all managers) when a print job's failed attempts reach
  print.alert_after_failures (ordering setting, default 2, 0 = never). Once per job; jobs on the same
  printer within an hour fold into one notification. print.failed_final (abandoned) stays.
- Both the first attempt (route-and-print, sent after its commit) and the retry sweep report it.
- Texts in en/el; tests for 1/2/3/0 and folding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 11:28:12 +02:00
bonaminandClaude Opus 5.5 5a21f67b42 feat(backend): platform notifications service with audiences, dedupe, read state and first producers
Platform v2 step 1.11 (APPS_PLATFORM section 10).
- notifications + notification_reads (revision 0010). Text = i18n key notification.<key> + params,
  rendered in the reader's language (en, el added).
- core/notifications.py: notify(key, severity, audience, params, dedupe_key, ttl/expires_at, fold)
  never raises; audience all_managers | perm:<key> | user:<id>; a live duplicate only bumps
  count/last_at (no unread reset, no event). New ones emit WS platform_notification {id} to the
  audience's users (current apps ignore it; phase 2 manager shows it).
- API (core, /api/platform/notifications; /api/notifications is chat's): list with unread count,
  POST /{id}/read, POST /read-all.
- Producers: license.limit_reached (device pairing/reassign/over-limit device, per module/limit/day,
  owners), license.expiring (14/7/3/1 days, from apply_license, owners), support.access_used (each
  use, core.settings.manage), print.failed_final (abandoned retry job, per printer/hour, managers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 11:13:37 +02:00
bonaminandClaude Opus 5.5 94a68b1c06 perf(backend): tests skip the event bus's sync_events write (5 s lock wait per broadcast)
services.ws_bus persists every broadcast through its own connection, which waited on the test transaction until SQLite's 5 s busy timeout and then failed quietly. An autouse fixture stubs _persist_event; no test uses the replay buffer. Full suite 61 s -> 17 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 11:13:37 +02:00
bonaminandClaude Opus 5.5 3a522e457d feat(backend): support access by offline challenge codes replaces the master account
Platform v2 step 1.10 (APPS_PLATFORM D-16, section 6.5).
- POST /api/auth/support/challenge (public): an 8-character challenge, stored 15 min
  (support_challenges, revision 0009; at most 5 open). POST /api/auth/support/verify
  {challenge, code}: code = base32(HMAC(SUPPORT_SECRET, site_id + challenge))[:10];
  single use, 5 wrong codes burn the challenge. Opens a 4 h support session
  (client=support, synthetic superadmin) with a hard end: sessions.expires_at.
- core/support_codes.py (stdlib only) is the derivation; tools/support_code.py
  (--init, --site-secret <SITE_ID>, <SITE_ID> <CHALLENGE>) uses it on the builder's
  machine with the master key in %USERPROFILE%/.xenia/support_master_key.txt.
- MASTER_USERNAME/MASTER_PASSWORD removed (config, login, docker-compose.yml,
  .env.example); SUPPORT_SECRET added; install.sh asks for it.
- e2e: backends get SUPPORT_SECRET from a test master key and log in with challenge
  codes (lib/support.mjs, license_e2e.py); install.mjs expects the new prompt.
- Pack rule CS-15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 10:52:16 +02:00
bonaminandClaude Opus 5.5 650fee7873 feat(backend): manager override with one-time PIN approval for cancel, price change, over-limit discount
Platform v2 step 1.9 (APPS_PLATFORM D-10).
- Perm(..., overridable=True). check() answers access.override_possible (not
  access.denied) for such keys, and consumes an X-Xenia-Override token for them.
- POST /api/access/override {key, username, pin}: the approver must hold the key
  (module effective); returns a token valid 60 s, once, for that key and the
  requesting session only (sha256 stored). Wrong PINs throttled per session.
  GET /api/access/overrides: audit list (core.staff.manage).
- access_overrides table (revision 0008): who asked, session, who approved, device,
  key, created/expires/used, target. The revision also grants core.devices.manage and
  the new pricing.discounts.over_limit to existing owners/store managers.
- Overridable: ordering.orders.cancel (the three cancel endpoints; the order audit log
  notes "override #n approved by user m"), ordering.prices.modify (price adjust), and
  new pricing.discounts.over_limit (waiter discounts beyond their limits; the reason
  goes in params). The venue switch discounts.enabled is never overridable.
- /orders/cancel-permissions adds override_possible; permission catalogues expose
  `overridable`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:57:37 +02:00
bonaminandClaude Opus 5.5 c699542565 fix(backend): waiter discounts crashed after order_discounts.price_before/after were dropped
Revision 0001_v2_baseline dropped order_discounts.price_before/price_after as unused,
but POST /api/orders/{id}/items/discount still passed them to OrderDiscount, so every
waiter discount failed with a 500 on platform-v2. Nothing reads them from
order_discounts: the before/after prices are recorded in price_event_log (CS-4).
Found while testing step 1.9 (manager override of discount limits).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:53:07 +02:00
bonaminandClaude Opus 5.5 91da3aeb27 feat(backend): paired devices with device tokens, scope, limits and terminal login
Platform v2 step 1.8 (APPS_PLATFORM D-8, section 6.3).
- devices + device_pair_requests tables (Alembic 0007_devices); sessions.device_id
  becomes a FK. Device tokens are stored as sha256 only; the plain token is generated
  when the device picks it up, once.
- /api/devices: pair-request (public, rate-limited, LAN-only in the proxy) + polling
  with a per-request secret; manager approve/list/rename/config/login mode/link/
  reassign/revoke (key core.devices.manage); the device's own /me and /me/users.
- Approving or reassigning checks the app's licence and its `devices` limit
  (license.limit_reached); after a downgrade the newest devices beyond the limit are
  refused, the oldest keep working.
- X-Xenia-Device: core/access/context.py loads the device (device.not_paired /
  device.revoked), tags logs with device=, throttles last_seen_at. check() and
  module_required() apply the app's scope (device.out_of_scope); require_device(app).
- POST /api/auth/login {client: "terminal"} uses the device's login mode (device ->
  auth.default_login_mode -> app's first mode); tap/none only here. The session is
  bound to the device (device.required without its header) and replaces the
  device's previous user. Revoke/reassign end the device's sessions.
- Registry: a device app with user logins must declare '<app>.access'.
- Proxy: location /api/devices/pair-request LAN-only on the :443 servers (both copies).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:44:40 +02:00
bonaminandClaude Opus 5.5 1d7a521e05 chore(backend): smoke_routes tool - GET every endpoint per role on a demo DB
The check used after each platform-v2 step (until now a scratch script): calls every parameterless GET endpoint as the demo manager and demo waiter, in dev mode or with licensing enforced (--free), and lists 5xx responses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:55:10 +02:00
bonaminandClaude Opus 5.5 e128cc37ec feat(backend): heartbeat v2 sends the module catalogue; license e2e on v2
Platform v2 step 1.7, site side (APPS_PLATFORM D-20, D-21; contract C-1 v2).
- cloud_sync heartbeat body is {version, local_ip, module_catalog}; the
  catalogue (key, kind, name, depends, limits) comes from the manifests and
  drives the sysadmin module editor
- license_e2e.py runs against the v2 cloud: free-tier checks use an ordering
  endpoint (the catalogue stays available), new section 8 edits the site's
  modules in the cloud and checks kds becomes module.not_licensed and
  reports.history_days = 30 after the next heartbeat (25/25 pass)
- e2e seed templates made by v1 code (no alembic_version) are detected and
  reseeded automatically (license_e2e.py and lib/proc.mjs)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:28:20 +02:00
bonaminandClaude Opus 5.5 9f1e12156e feat(backend): DB sessions, login modes, single-session rules
Platform v2 step 1.6 (APPS_PLATFORM D-8, D-9, §6.2, §6.4).
- sessions table (revision 0006); every JWT carries `sid` and is accepted
  only while its session is active (validated per request, 10 s cache that
  is dropped the moment a session ends); the in-memory blacklist is gone, so
  logout and "end session" survive restarts
- one login path, POST /api/auth/login {client, username?, user_id?, pin?,
  password?}: manager mode password|pin (username-only "none" removed, D-8),
  waiter mode pin|password|tap (tap answers auth.mode_needs_device until
  paired devices exist), optional "waiter must type username", and the app's
  access key (core.dashboard.access / waiter_app.access)
- auth.single_session_manager / _waiter: off | refuse_new | end_old
- /login without `client` = the current manager UI with v1 rules (pin or
  password; refuse_new treated as end_old because its lock screen re-logs-in);
  /login-by-id is a deprecated wrapper for the current waiter app;
  /login-no-auth removed
- GET /api/auth/sessions, POST /api/auth/sessions/{id}/end (core.staff.manage);
  blocking a user ends their sessions; refresh keeps the session; logout
  takes the bearer header (or ?token= as before)
- settings API validates enum/bool/int values from the manifests;
  security.login_method migrated to auth.manager_login_mode
- tests: modes, single-session rules, logout, refresh, forged token without
  session, manager session list/end

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:13:00 +02:00
bonaminandClaude Opus 5.5 3ede13e04a refactor(backend): platform API uses real permission keys
Bootstrap and /api/platform/modules now return the keys the user holds (user_permissions) instead of the role template, and enabling/disabling a module needs core.modules.manage instead of core.settings.manage (both were step 1.3 placeholders until keys existed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:51:41 +02:00
bonaminandClaude Opus 5.5 b7fda58af9 feat(backend): permission keys replace the 13 perm_* columns
Platform v2 step 1.5 (APPS_PLATFORM D-7, D-17, §3, §6.1).
- user_permissions(user_id, key); revision 0005 copies existing v1 flags into
  keys (frozen mapping) and drops the perm_* columns; can_cancel_orders gone
- core/access: check() = module effective + key held (superadmin implicit,
  override keys wired for 1.9); holds()/can(); markers require/require_any/
  public/require_device; role templates from manifests; queries.holders_filter
  replaces User.perm_x == True; legacy.py projects/accepts the v1 booleans
  for the current manager/waiter UIs only (§3.3, temporary)
- routers.deps: require_manager/... are now aliases of require("<key>");
  history endpoints use history.view; superadmin-only = core.system.admin;
  get_current_user carries the "signed_in" marker
- every inline perm_* read in routers/services converted to holds()
- staff API: permission catalogue by module with role templates, get/set a
  user's keys, reset to role template; legacy flag toggles still work; a
  non-superadmin can only grant keys they hold (access.cannot_grant)
- setup wizard creates the first account as owner (v1: store_manager, who
  couldn't change settings); demo/seed manager is owner
- roles.py keeps only the role list and labels
- guards: every route has an access marker (19 open routes marked public()
  on purpose; /waiters/roles now needs sign-in), no perm_* attribute reads
- tests: check matrix, templates, projection, staff permission API, grant
  guard, 0005 data copy; pack rule CS-14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:51:06 +02:00
bonaminandClaude Opus 5.5 0d43e6a111 feat(backend): license entitlements, enforced limits, free tier
Platform v2 step 1.4 (APPS_PLATFORM D-3..D-6, D-21, §5).
- core/modules/entitlements.py: compute() turns the evaluated license into
  per-module grants: the v2 token's `modules` map (own `exp` with the 5-day
  grace, never cut mid-service) + the free tier; no/invalid token, expired
  after grace, inactive, locked or clock tampering -> free tier only; core
  always. limit(module, name) with token value -> manifest licensed_default ->
  free value; None = unlimited. LICENSE_MODE=off (dev/test only) = everything
- module gating says why: module.not_licensed (402, the first unlicensed
  module in the dependency chain) before module.disabled (403)
- services/license.py accepts only v2 tokens with a modules map; the v1
  "legacy unsigned 72h" path is gone
- apply_license() always installs entitlements (startup before workers,
  every heartbeat, workday close); workers follow license changes
- the global license middleware is deleted (no more whole-API 402/423);
  license_state moved to services/license_state.py
- history_days enforced in every report/history endpoint: lower date bounds
  clamped (also when no "from" is given), and business days older than the
  limit refused by id (license.history_limited); data is never deleted
- bootstrap/modules API show license mode, entitlement source and limit values
- LICENSE_MODE=off in docker-compose.dev.yml and the e2e launchers; sites
  default to enforced
- tests: entitlement rules, limits, the three done-when checks, signed-token
  apply_license path; license tests moved to v2 tokens

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:32:57 +02:00
bonaminandClaude Opus 5.5 231a97c186 feat(backend): module registry, manifests, enable/disable without restart
Platform v2 step 1.3 (APPS_PLATFORM §4, §5.3, D-4, D-19).
- core/modules: Module/Perm/Limit/SettingDef/DeviceApp/Mount model; registry
  that discovers modules/<key>/manifest.py and validates it (keys, kinds,
  dependencies and cycles, permission prefixes and roles, unique settings,
  each router claimed once and importable, device_app only on apps, workers);
  free_tier.py (D-5 constant, used from 1.4)
- 25 manifests (the §4.2 map) with permission keys + default roles derived
  from today's perm_* meaning, limits, device apps and the 55 settings
- main.py mounts every router from the manifests; non-core routers carry
  Depends(module_required(key)) -> 403 module.disabled while off
- site_modules table (revision 0004), cached enablement; disabling a module
  also turns off modules that depend on it; core can't be disabled
- worker supervisor: connect_menu / connect_orders / connect_remote are now
  separate workers (v1's single _connect_loop split), started and stopped as
  their modules turn on and off; crashes are logged and restarted
- GET /api/platform/bootstrap (venue name/tz/language/currency, effective
  modules, user, language, role-template permission keys), GET /modules,
  PUT /modules/{key}
- settings API derives its key list and defaults from the manifests
- reports router split: history endpoints on history_router (`history`
  module, free tier later) under the same /api/reports prefix
- tests: registry validation, mount coverage, toggle round-trip, dependency
  propagation, bootstrap/catalogue shape, supervisor; pack rule CS-13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:46:52 +02:00
bonaminandClaude Opus 5.5 968b6c78fb feat(backend): error codes, backend i18n (en/el) and language fields
Platform v2 step 1.2 (APPS_PLATFORM D-12, §3.2, §8).
- core/errors.py: XeniaError + CODES registry; handlers give every error the
  {"error": {code, params, message}, "detail"} shape: XeniaError, wrapped
  HTTPException (http.<status>, detail untouched), validation.invalid (FastAPI
  detail list kept), and internal.error 500 with the request id (body, header
  and log line)
- orders: the 18 "Order not found" raises -> XeniaError("order.not_found")
- core/i18n: t(key, lang, **params) with en/el JSON (en fallback), venue/zone/
  user language resolution, normalize_language; 56 print keys
- printer_service: every printed label goes through keys. Kitchen,
  cancellation and service-item tickets print in the prep zone's language
  (-> venue.language); reports/receipts/synopsis in venue.language. Greek
  output is unchanged. Print retries now pass the job's zone (language and
  item grouping were lost on retries)
- users.language, prep_zones.language (revision 0003), setting venue.language
  (default en); editable via PATCH /auth/me, staff update, prep zones API;
  "" = inherit
- tests: error shapes, key/placeholder parity, fallback, kitchen ticket per
  zone/venue language, language APIs; pack rule CS-12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:29:31 +02:00
bonaminandClaude Opus 5.5 ab1e61a10f feat(backend): UTC time model - venue zone, business date, aware-only datetimes
Platform v2 step 1.1 (APPS_PLATFORM D-11, §7, D-24).
- core/timeutil.py: utcnow, venue_tz (venue.timezone, cached, invalidated on
  change - no restart), to_venue/venue_date/venue_strftime, parse_api_datetime
  (offset -> UTC; naive = venue-local; date = venue midnight), business_date_of
  /business_date_window (rollover hour, default 06:00), LocalClock + is_within,
  UTCDateTime column type (naive writes raise, reads are aware UTC), iso_z
- every model column is UTCDateTime; Pydantic UTCDatetime emits "...Z"
- business_days.business_date set at open; revision 0002 adds it (backfilled)
  and makes sync_events.created_at a UTCDateTime (AUTOINCREMENT restated)
- tz.py deleted; system.timezone setting replaced by venue.timezone (validated)
  + business_day.rollover_hour; manager timezone picker writes venue.timezone
- fixes: price-group schedules/time_range used the container's zone (happy
  hour bug); traffic report bucketed by UTC hour; reports' "date" meant the UTC
  calendar day, now the business date; reservations stored venue-local naive
  times (no-show check 2-3 h off) and listed by func.date; schedule week used
  UTC midnights; fiscal file names used container-local time
- seed.py/demo_seed.py create store_manager with role permissions (regression
  from step 1.0: v1's startup ALTER list used to rename/grant role 'manager')
- tzdata dependency; guard tests/guards/test_no_naive_time.py (AST scan);
  tests/test_timeutil.py covers the §7.3 DST cases and the API checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:12:35 +02:00
bonaminandClaude Opus 5.5 d3d328804e refactor(backend): Alembic owns the local schema; v1 ALTER list deleted
Platform v2 step 1.0 (APPS_PLATFORM D-13, D-17).
- migrations/ with env.py (render_as_batch, models/all.py metadata, no
  fileConfig) and baseline 0001_v2_baseline autogenerated from the models and
  reviewed; it also seeds the pos_settings rows a fresh v1 install got
- core/schema.py::upgrade_to_head() is the only way the schema is built:
  app startup, seed.py, demo_seed.py, wipe_database.py and the tests. It
  refuses v1 databases (tables without alembic_version) with a clear error
- main.py: _run_migrations() and create_all removed (723 lines)
- sync_events became a model (was raw DDL); price_event_log order indexes
  declared on the model; unused order_discounts.price_before/after dropped
- tests/guards: no-drift + idempotent upgrade + install defaults + v1 refusal
  + no create_all; placeholders for the time (1.1) and access (1.5) guards
- CS-1 rewritten for Alembic on this branch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:54:15 +02:00
bonaminandClaude Opus 5.5 980127379b chore(backend): DB-backed pytest harness (temp SQLite, real app, per-test rollback)
Platform v2 step 0.5. conftest.py now points DATABASE_URL/LOG_DIR/TLS_DIR at
a temp folder before anything imports config, builds the schema once per
session, and gives each test a connection-level transaction that is rolled
back (app commits become SAVEPOINT releases). Fixtures: db, client (TestClient
with get_db overridden, license open, no lifespan), make_user, login. Tests
using them are auto-marked `db`, so -m "not db" keeps the quick set.
test_harness.py proves login -> /api/auth/me and the rollback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:40:53 +02:00
bonaminandClaude Opus 5.5 9fa728c039 feat(backend): daily request-tagged log files + print job lifecycle logging
Platform v2 step 0.4 (APPS_PLATFORM §10). New core/logging.py:
- root logger -> stderr + <db dir>/logs/xenia-YYYY-MM-DD.log (UTC date,
  /app/data/logs in Docker, $LOG_DIR overrides); files older than the
  system.log_retention_days setting (default 30) are pruned
- line format: UTC ISO time, level, logger, [req= user= device=], message
- RequestContextMiddleware (pure ASGI): request id per request, X-Request-ID
  response header, one http line per request (DEBUG for plain reads)
- auth tags the user via set_log_context; uvicorn loggers routed through ours
Print jobs now log created / attempt / success / failed / abandoned with the
job id, so a missing ticket can be traced. Removed cloud_sync's basicConfig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:31:38 +02:00
bonaminandClaude Opus 5.5 e560d93cd5 chore(backend): v1 timestamp audit tool for the platform-v2 history import
Classifies every datetime column of a v1 pos.db as UTC or venue-local by
comparing it with server-written events (orders.opened_at, audit-log
PAYMENT/ORDER_CLOSED rows, business days). Read-only. Used by the importer
(platform-v2 plan step 7.1); results are recorded in plan step 0.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 12:37:23 +02:00
bonaminandClaude Opus 5.5 584dd1e510 test: end-to-end suites (install.sh, licensing, browser, Android emulator) + runner
tests/e2e (see its README):
- install.mjs: real install.sh in a Debian container - VPN-safe HOST_IP
  detection on simulated hosts, fresh/upgrade/re-run, and the proxy config
  byte-identical to nginx-proxy/nginx.conf (guards rule CS-5)
- license_e2e.py: real cloud + site processes with a throwaway signing key -
  400 days offline, tampered file, clock rollback, expiry deferred to workday
  close, renewal, remote lock
- browser.mjs: web delivery modes (same-origin, plain HTTP by LAN IP, venue
  mode) and the install dialog on Android/iPhone/desktop/no-APK
- android.mjs basics|rediscovery|stacks: pairing, venues, camera, back
  button, restart; IP change / server down / cold start; TLS pinning
  (wrong-key QR, impostor, upgrade, renewal, rediscovery) and UI bundles
  (apply, staged, tampered, APK too old, rollback, two venues) on isolated
  compose stacks built from the repo
- lib/: env (paths, LAN IP autodetect, settings), proc (seeded throwaway
  DBs via demo_seed.py, backends, nginx, Vite, compose stacks), android
  (adb + WebView DevTools, boots the AVD), cdp
- run-all.mjs runs everything fastest-first with a summary
Nothing machine-specific is hard-coded; developer stacks/DBs are never touched.
Results on this machine: install 9/9, license 17/17, browser 22/22,
android basics 19/19, rediscovery 10/10, stacks 21/21.

Pack README: Testing section + rule CS-11 (tests follow the code; run
run-all before a release).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 23:38:18 +03:00
bonaminandClaude Opus 5.5 f00c99fd36 test: unit tests for licensing, LAN IP, TLS identity and rediscovery
- local_backend/tests (pytest, 48 tests, <1s): license token verify/evaluate
  (tamper, other site/key, offline, grace, workday deferral, clock, transition),
  netinfo detection on fake sysfs (VPN/tunnel/WiFi/link-local), LAN-IP
  resolver priority + mismatch + staleness + override validation, TLS
  identity create/restart/renew-same-key/foreign cert (+ openssl pin check)
- waiter_pwa/tests (node --test, 7 tests): subnet candidates, scan picks only
  this venue, early stop, progress
- requirements-dev.txt (pytest), npm test, .pytest_cache ignored

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 23:33:16 +03:00
bonaminandClaude Opus 5.5 ffca0ace43 refactor: keep pure logic importable in tests on any OS
- netinfo_helper imports the Linux-only fcntl inside ipv4_of(), so detect()
  can be unit-tested on Windows/macOS
- SUPPORTED_API_VERSIONS moves to src/native/apiVersion.js (no Vite-only
  imports), so rediscovery.js runs under plain Node

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 23:33:16 +03:00
bonaminandClaude Opus 5.5 d80f53a31e fix(backend): licensing off when no CLOUD_URL is configured (pre-KI-006 parity)
Before KI-006 an install without CLOUD_URL (dev, demos, test stacks) was
simply licensed; after it, a SITE_ID without a cloud counted as
'unverified' and blocked everything. Real sites always have both set, and
blanking CLOUD_URL is no stronger than blanking SITE_ID (already possible).
verify_token() now reads the built-in public key at call time so the e2e
suite can swap it in-process for a throwaway key (never via configuration).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 23:33:16 +03:00
bonaminandClaude Opus 5.5 12fdea0914 fix(backend): demo_seed.py imports every model (crashed since pricing/deals)
order_items.deal_id references deals (models.pricing), which demo_seed never
imported, so create_all failed and the script could not seed a fresh DB.
Also registers prep_zone, chat and recovery_code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 23:33:16 +03:00
bonaminandClaude Opus 5.5 0ec3d4735b feat(manager): license banners for offline licensing (KI-006)
Expiry reminders from 14 days (was 5) with a 'connect the server to the
internet to renew' hint while offline; banners for a clock set back and for
a not-yet-verified license; a quiet note after 7+ days without cloud contact
stating the system keeps working until the license date. Grace period
banner respects grace_over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:16:32 +03:00
bonaminandClaude Opus 5.5 13a451a756 feat(backend): offline-capable signed licensing; fix expiry grace; state in data dir (KI-006)
- services/license.py: verifies the cloud's Ed25519-signed license token
  (public key built in) and decides purely: valid → licensed until expiry,
  then a 5-day grace, then blocked - never mid-service (deferred while a
  workday is open, applied at close). Works offline for as long as the
  license lasts: the "unlicensed after 72h without heartbeat" rule is gone.
- Tamper resistance: an edited token fails the signature ("unverified");
  a clock earlier than the latest provable time (token issued_at, newest
  order in the DB, stored high-water mark; 1 day tolerance) → "clock".
- apply_license() re-evaluates from the stored token at startup, after
  every heartbeat attempt and when a workday closes. Cloud lock/unlock from
  the token keeps the workday-deferred behaviour. Transition: a cloud
  without tokens is trusted 72h per successful heartbeat.
- FIX: the promised 5-day grace after expiry never happened - the cloud's
  licensed=false was applied immediately (402 on everything).
- FIX: license_state.json lived inside the container and was lost on every
  re-creation; it now lives in the data volume (old path read once).
- /api/system/status: offline_days, license_verified, license_problem,
  grace_over; lock_reason "clock"/"unverified"; grace days from the license
  module (rounded up).

Tests: 18 unit checks (signature, tamper, other site/key, 364 days
offline, grace ±workday, inactive, clock rollback, transition) + 17 E2E
checks with a real cloud + site process (400 days offline, tampered file →
402, clock behind newest order, expiry deferred until workday close,
renewal, remote lock/unlock).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:16:32 +03:00
bonaminandClaude Opus 5.5 a349043abb feat(waiter): install-app dialog (first visit) + "Εγκατάσταση εφαρμογής" in the side drawer
Replaces the thin bottom banner with a proper dialog (taller than wide):
app icon, four reasons to install (starts instantly, survives WiFi drops,
encrypted link, finds the server + updates itself), the three install
steps, "Λήψη εφαρμογής" and "Όχι τώρα". It opens by itself once, on the
first browser visit; closing it or tapping download marks it seen for good
(previously a 7-day dismissal, and once gone there was no way back).
Afterwards it is reachable from the side drawer, right above Settings.

Offered only where it makes sense: a browser on an Android phone (never in
the native app, on iPhones or desktops) and only if this venue's server
actually serves the APK (HEAD /downloads/xenia-waiter.apk, checked once).

Verified in Edge emulating Android / iPhone / desktop against the prod
build: auto-opens once, "Όχι τώρα" persists across reloads, drawer item
above Settings reopens it, not offered on iPhone/desktop or when the
server has no APK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:01:05 +03:00
bonaminandClaude Opus 5.5 251cac9807 chore: retire the per-client domain setup (plan step 9); addresses → bonamin.net
- remove setup-ssl.sh (mkcert IP certs) - superseded by install.sh's
  self-signed cert and the backend-managed TLS identity
- manager: "Waiter Domain (παλιό σύστημα)" - shown only for sites that
  still have one
- .env.example: REGISTRY=registry.bonamin.net and
  CLOUD_URL=https://xenia-api.bonamin.net (it pointed at the admin panel,
  xenia-admin, even before the domain move); install.sh points to the
  sysadmin panel at xenia-admin.bonamin.net
- pack README registry example updated
Proxy config unchanged (HTTPS domain blocks stay so not-yet-migrated sites
keep working until their visit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 19:06:45 +03:00