fix(admin): per-row check-in toggle; feat(db): front-desk gate + badge copies
Registrations table felt buggy because both row actions did setBusy(true) -> write -> reloadRegistrations() -> setBusy(false): the list is sorted by points, so a reload made the row you just touched jump (or vanish under a Checked-in filter), and the single `busy` flag disabled every control in the table for the whole request. The fix is per-row in-flight state (busyIds + withRowBusy) and no reload at all: the toggle patches its own row's checked_in plus the points delta the RPC returns, the type change patches `type`; a rejected write rolls both back. Only the touched row is disabled, shows a "Saving…" pulse, and two rows can save at once. Toggle hit area is now 40x41 px with a focus-visible ring. Front-desk gate: checkin_attendee reads registrations.checked_in and raises "This attendee needs to be checked in at the front desk first." when it is not true, and no longer sets checked_in as a side effect. checkins has no INSERT policy, so the RPC is the only write path and the gate cannot be bypassed. The scanner shows a dedicated "Not checked in yet" sheet instead of a toast. Badge copies: events.badge_copies (1..4, default 1). welcome_checkin sends that many pgmq jobs in one transaction (the Pi prints one label per job, so N jobs = N labels; no worker change) and clamps the value again itself. preview_welcome_checkin gained a `copies` column (drop + recreate) so the popup states the real count. Manual reprint still prints exactly one. Set from Settings -> Badge printing (active event) and the Events form, always as a single-column update; the Settings badge section now renders even when the LLM settings call fails. Tests: badge_print 113 (+6), leaderboard 47 (+1), new registration-checkin-toggle (6), front-desk-gate (3), welcome-badge-copies (3); the stale registrations-PATCH mock in registration-ticket-merge now targets set_registration_checked_in, the ambiguous Save button is "Save copies", and the print-copy assertion tolerates the typographic apostrophe. Docs updated (rpcs, schema, printing, tests, admin-app, screens) with a release record; NOT deployed - see docs/releases/2026-10-19.md. Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
d3531e1fac
commit
17473916a6
27 files changed
+1378
-73
No files matched your search
@@ -99,7 +99,7 @@ cross-reference list.
|
||||
|
||||
| Function | Purpose |
|
||||
|---|---|
|
||||
| `enqueue_badge_print(p_registration_id)` | Manual reprint: queue the badge of one registration (`kind = reprint`); returns the queue msg id |
|
||||
| `enqueue_badge_print(p_registration_id)` | Manual reprint: queue the badge of one registration (`kind = reprint`); returns the queue msg id. Always **one** label — `events.badge_copies` belongs to the welcome check-in, so reprinting a lost badge never produces a stack |
|
||||
| `create_print_station(p_name)` | Register a station. Generates `cvp_<64 hex>` (32 random bytes), stores only its **SHA-256 hex digest**, returns the plaintext token **once** |
|
||||
| `rename_print_station(p_id, p_name)` | Rename (trimmed, required, ≤ 80 chars). Revoked stations stay renamable so history remains readable |
|
||||
| `revoke_print_station(p_id)` | Sets `revoked_at`; the token stops working immediately |
|
||||
@@ -125,15 +125,33 @@ worker) and stamps `last_seen_at`.
|
||||
behaviour, plus the `badge_print` enqueue for a **genuine first check-in** only,
|
||||
inside the same transaction (see [rpcs.md](./rpcs.md#welcome_checkinp_attendee_qr--attendee_email-attendee_name-already)).
|
||||
|
||||
### How many labels one welcome prints
|
||||
|
||||
`events.badge_copies` (`1..4`, default `1`, added in
|
||||
[`20261019110000_front_desk_gate_and_badge_copies.sql`](../../supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql))
|
||||
is the per-event copy count for the **front desk**. `welcome_checkin` builds the
|
||||
payload once and calls `pgmq.send` that many times in the same transaction; the
|
||||
worker already prints exactly one label per job, so **N jobs = N labels** and no
|
||||
worker, renderer or queue change was needed. The value is clamped with
|
||||
`greatest(1, least(4, …))` *inside* the function too, so a hand-edited row can
|
||||
never flood the queue, and the same clamp is used by
|
||||
`preview_welcome_checkin`'s `copies` column so the popup states the true number
|
||||
(*"you will print their badge 3 times"*). Re-welcoming an already-checked-in
|
||||
attendee prints nothing, copies included. Admins set it in **Settings → Badge
|
||||
printing** (the active event) or on the Events form; both write the single
|
||||
column, never the whole row.
|
||||
|
||||
The staff scanner (attendee app → Scan → Welcome check-in) does **not** fire
|
||||
`welcome_checkin` directly. It first calls the read-only
|
||||
`preview_welcome_checkin(qr)` and shows a confirmation — *"You are checking in
|
||||
[Name]. By confirming, you will print this person's label."* — with **Yes/No**.
|
||||
[Name]. By confirming, you will print this person's label"* (or *"…their badge 3
|
||||
times"*, from `copies`) — with **Yes/No**.
|
||||
Only **Yes** runs `welcome_checkin`. The preview's `will_print` mirrors the exact
|
||||
enqueue condition (first check-in **and** a layout exists), so the popup never
|
||||
promises a print that won't happen; when it is `false` the popup says the person
|
||||
is checked in without mentioning a label. Session check-in is unchanged and never
|
||||
prints. (Added in `20261019090000_welcome_checkin_preview.sql`.)
|
||||
prints. (Added in `20261019090000_welcome_checkin_preview.sql`, `copies` in
|
||||
`20261019110000_front_desk_gate_and_badge_copies.sql`.)
|
||||
|
||||
## 5. Station tokens & security model
|
||||
|
||||
@@ -280,7 +298,7 @@ and staged (`STAGE_APP` / `STAGE_WIFI_PORTAL` / `REBOOT`):
|
||||
## 12. Tests
|
||||
|
||||
- **SQL:** [`supabase/tests/badge_print_tests.sql`](../../supabase/tests/badge_print_tests.sql)
|
||||
— rollback-only, **101 assertions**; run it **combined with the migration**
|
||||
— rollback-only, **113 assertions**; run it **combined with the migration**
|
||||
(idempotent, works before and after apply):
|
||||
```sh
|
||||
(echo 'begin;'; \
|
||||
|
||||
+38
-2
@@ -124,6 +124,14 @@ Staff checks an attendee into a session.
|
||||
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
|
||||
`staff or admin only`.
|
||||
- Resolves the attendee by `qr_token`.
|
||||
- **Front-desk gate:** when the attendee's `registrations.checked_in` is not
|
||||
`true`, it raises `This attendee needs to be checked in at the front desk
|
||||
first.` Nobody can be checked into a session before the **welcome** check-in at
|
||||
the front desk has marked them present at the event. The scanner shows this as
|
||||
its own sheet instead of a generic error (see
|
||||
[../frontend/screens.md](../frontend/screens.md)). `checkin_attendee` also
|
||||
stopped setting `checked_in = true` as a side effect — the welcome check-in
|
||||
(or an admin's Registrations toggle) is now the only way to earn it.
|
||||
- **Service-session guard:** if the session's slot is a `service_session`, it
|
||||
raises `service sessions cannot be checked in` (there's nothing to check into —
|
||||
everyone is in the room).
|
||||
@@ -148,9 +156,13 @@ from `checkin_attendee`, which checks someone into a specific session).
|
||||
check-in's job).
|
||||
- `already` is `true` if the attendee was already checked in to the event.
|
||||
- On a **first** check-in (and only when the event has a badge layout), enqueues
|
||||
a `badge_print` job in the same transaction (see [printing.md](printing.md)).
|
||||
`events.badge_copies` identical `badge_print` jobs in the same transaction — the
|
||||
Pi worker prints exactly one label per job, so N jobs = N labels (see
|
||||
[printing.md](printing.md)). The value is clamped to `1..4` inside the function,
|
||||
so a bad row can never flood the queue. A re-check-in (`already`) enqueues
|
||||
nothing. Manual reprint (`enqueue_badge_print`) still prints **one** label.
|
||||
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print)`
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies)`
|
||||
Read-only preview shown by the staff scanner **before** a welcome check-in is
|
||||
committed, so the confirmation popup can name the attendee and be honest about
|
||||
printing.
|
||||
@@ -161,6 +173,10 @@ printing.
|
||||
- `will_print` is `true` only for a genuine first check-in **and** when the
|
||||
event has a badge layout with elements — exactly the condition under which
|
||||
`welcome_checkin` enqueues a job.
|
||||
- `copies` is the number of labels a confirm would queue — the same
|
||||
clamp `welcome_checkin` applies, and `0` when nothing would print. The popup
|
||||
uses it to say "print their badge 3 times" instead of a fixed "this person's
|
||||
label", so it can never over- or under-promise.
|
||||
- Checks nobody in and enqueues nothing; it is a pure lookup.
|
||||
|
||||
### `merge_tickets(p_source_id, p_target_id)` -> `jsonb`
|
||||
@@ -507,6 +523,26 @@ genuine **first** check-in it enqueues the badge job in the same transaction
|
||||
when the event has a layout with elements (see
|
||||
[welcome_checkin](#welcome_checkinp_attendee_qr--attendee_email-attendee_name-already).
|
||||
|
||||
## Front-desk gate and badge copies
|
||||
|
||||
Source of truth:
|
||||
[`supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql`](../../supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql)
|
||||
(see [release record](../releases/2026-10-19.md)).
|
||||
|
||||
- `events.badge_copies` — new `integer not null default 1` with
|
||||
`check (badge_copies between 1 and 4)`. Admins edit it from **Settings → Badge
|
||||
printing** for the active event, and when creating/editing an event (see
|
||||
[../frontend/admin-app.md](../frontend/admin-app.md)).
|
||||
- `checkin_attendee` re-creates: adds the **front-desk gate** and drops the
|
||||
`checked_in = true` side effect.
|
||||
- `welcome_checkin` re-creates: enqueues `badge_copies` jobs instead of one.
|
||||
- `preview_welcome_checkin` **drops and re-creates** (the return type gained
|
||||
`copies`, and Postgres cannot `create or replace` across a signature change);
|
||||
grants are re-applied in the same migration.
|
||||
|
||||
`checkins` has no `INSERT` policy, so `checkin_attendee` is the only write path
|
||||
for session check-ins — the gate cannot be bypassed from the API.
|
||||
|
||||
## Error handling
|
||||
|
||||
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
|
||||
|
||||
@@ -81,6 +81,7 @@ queries everything for the active event and handles "no active event" gracefully
|
||||
| `sessionize_endpoint` | `text` | nullable — the Sessionize API URL for this event (see [sidecar.md](./sidecar.md)) |
|
||||
| `use_realtime_clock` | `boolean` | default `false` — when `true`, the attendee app drives slot status (Live/Next/Done) from the real system clock; when `false` it uses the simulated mid-event clock (see [../frontend/app-structure.md](../frontend/app-structure.md)) |
|
||||
| `talk_networking_bonus` | `integer` | default `2` — bonus points awarded to **each** party when two people who were checked into the same session (talk) accept a connection. `0` disables the feature (the +5 connection award still applies). Awarded with the `talk_networking` points category (see [rpcs.md](./rpcs.md#accept_connectionp_connection_id-uuid)) |
|
||||
| `badge_copies` | `integer` | default `1`, `check (between 1 and 4)` — how many badge labels a **welcome (front-desk) check-in** prints. Enforced again inside `welcome_checkin`, so a hand-edited row cannot flood the queue. Manual reprint ignores it and always prints one. Set from **Settings → Badge printing** (see [printing.md](./printing.md)) |
|
||||
| `last_synced_at` | `timestamptz` | nullable — when the Sessionize sync last ran |
|
||||
| `created_at` | `timestamptz` | |
|
||||
|
||||
@@ -98,7 +99,7 @@ Points are scoped **per event** here (one row per contact per event).
|
||||
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
|
||||
| `contact_email` | `text` FK → `contacts` | `on delete cascade` |
|
||||
| `type` | `registration_type` (enum) | `attendee` \| `speaker` \| `staff` \| `sponsor` (default `attendee`) |
|
||||
| `checked_in` | `boolean` | default `false` |
|
||||
| `checked_in` | `boolean` | default `false` — **the front-desk flag.** Set by the welcome check-in (or an admin's Registrations toggle); it is what makes someone eligible for session check-ins. `checkin_attendee` refuses anyone with this flag `false` |
|
||||
| `points` | `integer` | `>= 0`, default 0 |
|
||||
| `qr_token` | `text` | nullable — the lanyard token; **doubles as the Auth password** (generated per event) |
|
||||
| `external_id` | `text` | nullable — reserved for an external system's id (currently unused) |
|
||||
|
||||
+49
-1
@@ -1,3 +1,50 @@
|
||||
# Front-Desk Gate + Badge Copies Regression
|
||||
|
||||
After applying `20261019110000_front_desk_gate_and_badge_copies.sql`, run the
|
||||
SQL suite **combined with the migration** in one transaction (the migration is
|
||||
`create or replace`, so the same stream also re-verifies an already-applied
|
||||
database):
|
||||
|
||||
```sh
|
||||
(echo 'begin;'; \
|
||||
cat supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql; \
|
||||
sed '/^begin;$/d' supabase/tests/badge_print_tests.sql) \
|
||||
| docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/set_registration_checked_in_tests.sql
|
||||
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- front-desk-gate.spec.ts --project=chromium
|
||||
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- welcome-badge-copies.spec.ts --project=chromium
|
||||
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts --project=chromium
|
||||
```
|
||||
|
||||
The SQL fixture is rollback-only: **113 assertions** — six of them added with the
|
||||
gate and the copies (the badge-print suite owns both functions) — cover the gate
|
||||
refusing a session check-in for an attendee with no front-desk check-in
|
||||
(`session check-in requires a front-desk check-in`), the copies loop
|
||||
(`badge_copies = 3` queues three more labels) and the savepoint that returns the
|
||||
queue to one so the rest of the run is unaffected, plus
|
||||
`preview_welcome_checkin`'s new `copies` column: `1` by default, `0` when nothing
|
||||
would print, `3` after the event is changed. The pre-existing "session check-in
|
||||
records / enqueues nothing" case now flips `checked_in` on first, because the
|
||||
gate makes it a precondition.
|
||||
`set_registration_checked_in_tests.sql` (**15 assertions**) covers the admin
|
||||
toggle that grants and revokes the same flag, with its points accounting.
|
||||
|
||||
`front-desk-gate.spec.ts` and `welcome-badge-copies.spec.ts` are real-browser
|
||||
suites against the local stack (real Auth + PostgREST + pgmq): they provision a
|
||||
disposable attendee, assert the scanner shows its **"Not checked in yet"** sheet
|
||||
while recording no check-in, that a session check-in no longer sets the
|
||||
front-desk flag by itself, that the same scan succeeds once the welcome check-in
|
||||
is done, that the queue grows by exactly `badge_copies` messages, and
|
||||
that a re-welcome prints nothing. They delete their own rows and restore
|
||||
`badge_copies = 1`. `registration-checkin-toggle.spec.ts` is API-mocked and
|
||||
covers the table behaviour the old build got wrong: no refetch on a toggle or a
|
||||
type change, row order preserved, only the touched row busy while its checkbox
|
||||
is disabled, other rows still usable, rollback on a rejected RPC, and the
|
||||
Settings copies picker saving and reloading.
|
||||
|
||||
See [release record](../releases/2026-10-19.md) for the bug this started with.
|
||||
|
||||
# Badge Print Queue Regression
|
||||
|
||||
After applying `20261018170000_badge_print_queue`, run the SQL suite **combined
|
||||
@@ -13,7 +60,8 @@ CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- printing.spec.t
|
||||
pytest apps/printer/tests # worker unit tests (no hardware, no browser)
|
||||
```
|
||||
|
||||
The SQL fixture is rollback-only: **101 assertions** cover queue creation and
|
||||
The SQL fixture is rollback-only: **113 assertions** (six of them the front-desk
|
||||
gate and badge copies, covered in the section above) cover queue creation and
|
||||
migration idempotency, pgmq/API isolation, the self-contained payload shape and
|
||||
layout resolution (default-with-elements, fallback, none → no job), first-scan
|
||||
enqueue inside `welcome_checkin` (re-scan enqueues nothing), station token
|
||||
|
||||
@@ -16,15 +16,15 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
|
||||
|---|---|
|
||||
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points + recent activity. |
|
||||
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`). Edit, toggle `is_admin`, set visibility, adjust points. (No QR token here — it lives on the registration.) A general search matches **first name, last name or email address**; the **LinkedIn**, **Visibility** and **Admin** columns each have an Excel-style **multi-select filter** with live counts. |
|
||||
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. |
|
||||
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. The **checked-in toggle is per-row and optimistic**: it patches that one row (and its points) in place — **no list reload**, so rows never jump or vanish mid-edit (the list is sorted by points) — while a small "Saving…" pulse marks the busy row and only that checkbox is disabled; other rows stay live and a second row can be toggled concurrently. A rejected write rolls the row back to the server's values. Changing the type behaves the same way. The toggle is what grants front-desk eligibility from the console (see [../backend/rpcs.md](../backend/rpcs.md)). |
|
||||
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). |
|
||||
| **Schedule** | Slots (with a **type optionset** — `Session` / `Service Session`) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state and `average_feedback`), plus an admin-only **Delete current schedule** action for the active event. |
|
||||
| **Activity** | Tables of check-ins, connections, and feedback (per active event), with manual **Generate AI Summary** controls for the event and individual sessions. |
|
||||
| **Raffle** | Draws eligible attendees one at a time for the active event. Configure the number of picks (default 5), then **Spin** a roulette that decelerates onto a server-chosen winner; repeat until the pick count is reached. Excludes staff/Admin and the leaderboard top 3, and no one can win twice in a run. **New run** clears the current winners. See [../backend/rpcs.md#raffle](../backend/rpcs.md#raffle). |
|
||||
| **Badges** | A **per-event WYSIWYG badge / PDF layout editor** (modelled on pretix's PDF Editor). Pick the event, then design one or more named **layouts** (a **Default** per event, switchable / creatable / deletable). Add **text boxes**, **QR codes** and **images** to a millimetre canvas; drag to move, use the 8 resize handles + rotation handle, **Shift-click to multi-select**, and **press `Del`** to remove. While dragging, **PowerPoint-style smart guides** appear — dashed alignment lines (edges / centres, page and neighbouring items) plus equal-spacing lines — and the element **snaps** to them. A **Word-style align** toolbar (left / center / right, top / middle / bottom) plus **PowerPoint-style** object alignment — align to the **page** or to the **selection**, and **distribute** horizontally / vertically — with the same controls in the properties panel. Text binds to attendee fields (name, email, ticket type, QR token, event name, **company / organizer**, or static) with font, size, line-height, colour, bold/italic, a labelled **Align text in box** section (horizontal left / center / right and vertical top / middle / bottom, inside the element's own frame) and case transform; QR binds to the token / check-in URL / email / name / static. **Undo/redo** (`Ctrl`+`Z` / `Ctrl`+`Y`, also `Ctrl`+`Shift`+`Z`), a **Preview** mode (no handles), a **JSON** view of the layout, and **Save**. Previewed against a real sample registration. See [../backend/rpcs.md#badge-editor](../backend/rpcs.md#badge-editor). |
|
||||
| **Printing** | Badge-print control center: printer stations (add / inline **rename** / **revoke**, the `cvp_…` token shown **once** on creation), live station cards with state + staff hints, queue counters (pending / in flight / dead letters / completed), the last completed jobs with **Reprint**, and dead letters with **Requeue** / **Discard**. Backed by `get_print_overview` (polled every 5 s) — see [../backend/printing.md](../backend/printing.md). |
|
||||
| **Settings** | Global LLM endpoint, model and optional API key for feedback summaries. |
|
||||
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
|
||||
| **Settings** | **Badge printing** section first: how many labels a front-desk (welcome) check-in prints for the **active event** — a 1–4 segmented picker (`events.badge_copies`), saving on its own single-column write with a "Copies saved" confirmation; it renders even when the LLM/sidecar call fails. Then the global LLM endpoint, model and optional API key for feedback summaries. See [../backend/printing.md](../backend/printing.md). |
|
||||
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default) + the **badge copies** picker (same 1–4 control as Settings). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
|
||||
| **Interfaces** | Manages the Sessionize sync **sidecar**: status (online / running / last run), a **Run sync** control (event picker + blocking run + result modal), an **Import Excel** control (upload the Sessionize "Sessions and speakers (advanced)" `.xlsx` + a "How to get this file" tooltip), and a **Recent runs** table from `sync_runs`. See [../backend/sidecar.md](../backend/sidecar.md). |
|
||||
|
||||
## Sessionize Source Editing
|
||||
@@ -129,12 +129,18 @@ apps/admin/src/
|
||||
├─ Sponsors.tsx # sponsor CRUD
|
||||
├─ Schedule.tsx # slots + sessions + speakers + material
|
||||
├─ Activity.tsx # check-ins / connections / feedback tables
|
||||
├─ Events.tsx # event management (+ sessionize_endpoint + per-row Sync + talk networking bonus)
|
||||
├─ Events.tsx # event management (+ sessionize_endpoint + per-row Sync + talk networking bonus + badge copies)
|
||||
├─ Interfaces.tsx # sidecar status / run / recent runs
|
||||
├─ Reports.tsx # post-event summary + CSV / Excel / PDF export (sidecar /export)
|
||||
└─ Settings.tsx # server-only LLM configuration (redacted key)
|
||||
└─ Settings.tsx # badge-print copies (active event) + server-only LLM configuration (redacted key)
|
||||
```
|
||||
|
||||
Shared component: `components/BadgeCopiesSetting.tsx` exports the presentational
|
||||
1–4 segmented picker (`BadgeCopiesPicker`), the clamping helper
|
||||
(`clampBadgeCopies`) and the self-saving Settings card (`BadgeCopiesSetting`,
|
||||
which writes `events.badge_copies` through `setBadgeCopies` — one column, so it
|
||||
can never clobber the rest of the row).
|
||||
|
||||
## Data access
|
||||
|
||||
The admin app uses the **anon key + the admin's session JWT** — no service-role
|
||||
|
||||
@@ -241,10 +241,22 @@ is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendee
|
||||
no extra points" (the `already` flag from the RPC). The `checkin_attendee`
|
||||
RPC also rejects a service session server-side ("service sessions cannot be
|
||||
checked in").
|
||||
**Front-desk gate:** if the lanyard belongs to someone the front desk has
|
||||
not welcomed yet, the RPC refuses and the screen shows its own sheet —
|
||||
**🛑 "Not checked in yet" / "…needs to be checked in at the front desk before
|
||||
they can be scanned into a session."** — instead of a generic error toast.
|
||||
Nothing is recorded and no points move; **OK** dismisses it and re-arms the
|
||||
camera. The gate is enforced in the database, not here (see
|
||||
[../backend/rpcs.md](../backend/rpcs.md)).
|
||||
- **Welcome check-in** — no session dropdown; scanning an attendee's lanyard →
|
||||
`welcomeCheckin(qr)` marks them present at the **event**
|
||||
(`registrations.checked_in = true`, no points). Result sheet: "👋 {name} —
|
||||
Welcome to the event! — ✓ Checked in" (or "Already checked in to the event").
|
||||
read-only `previewWelcomeCheckin(qr)` → a **confirm sheet** ("You are
|
||||
checking in {name}. By confirming, you will print their badge {N} times" /
|
||||
"…this person's label" when `copies` is 1; the print sentence is dropped when
|
||||
nothing would print) → **Yes** runs `welcomeCheckin(qr)`, which marks them
|
||||
present at the **event** (`registrations.checked_in = true`, no points) and
|
||||
queues `events.badge_copies` labels. Result sheet: "👋 {name} — Welcome to
|
||||
the event! — ✓ Checked in" (or "Already checked in to the event"). This is
|
||||
the scan that opens the session gate above.
|
||||
|
||||
Data: `useEvent()` (for the session list) + the RPCs above.
|
||||
|
||||
|
||||
@@ -159,3 +159,166 @@ Badge queued correctly; test data cleaned afterwards.
|
||||
|
||||
**Deployed to production 2026-10-19**: attendee app only (`convivo-app`
|
||||
rebuilt; no migration, admin/sidecar untouched).
|
||||
|
||||
---
|
||||
|
||||
# Follow-up: Registrations toggle feels buggy; front-desk gate; badge copies (2026-10-19)
|
||||
|
||||
## Symptoms (reported from production)
|
||||
|
||||
1. The admin **Registrations** table "feels buggy", especially when checking
|
||||
someone in or out.
|
||||
2. Request: nobody should be scannable into a **session** before the front desk
|
||||
has checked them in — and the app should say so.
|
||||
3. Request: an admin setting for **how many badge copies** a welcome check-in
|
||||
prints (default 1, up to 4).
|
||||
|
||||
## Root cause of (1)
|
||||
|
||||
Not a render bug — a regression the previous change introduced, **and it was
|
||||
never deployed**, which is why "it doesn't work" at all.
|
||||
|
||||
Commit `316f131` (un-check-in removes points) made both row actions do:
|
||||
|
||||
```
|
||||
setBusy(true) → write → await reloadRegistrations(event_id) → setBusy(false)
|
||||
```
|
||||
|
||||
Two things went wrong from there:
|
||||
|
||||
- The list is **sorted by points**. Reloading after a toggle re-sorts it, so the
|
||||
row you just clicked *moves*, and with a **Checked in** filter applied it
|
||||
disappears entirely. Clicking the same place again hits a different person.
|
||||
- `busy` was **one flag for the whole table**, so during every request the event
|
||||
selector, every type dropdown, every checkbox and the Merge buttons all went
|
||||
dead at once, with no indication of which row was working. A second click in
|
||||
that window either did nothing or fired a second write for the same row.
|
||||
|
||||
**Fix** (`apps/admin/src/views/Registrations.tsx`):
|
||||
|
||||
- `busyIds: Set<string>` + a `withRowBusy(id, run)` helper — **per-row** in
|
||||
flight state. Only the touched row's control is disabled; it gets a
|
||||
`.row-busy` background and a "Saving…" pulse (`data-testid="saving-<id>"`,
|
||||
motion-respecting). Other rows stay live, and two rows can be saved at the
|
||||
same time. A double click on the same row is ignored while its write runs.
|
||||
- **No reload.** The toggle patches its own row — `checked_in` plus the points
|
||||
delta the RPC itself returns (`points_removed`) — and the type change patches
|
||||
`type` (`set_registration_type` only mutates that column, and the sponsor
|
||||
lookup modal's `onSaved` now patches to `sponsor` instead of reloading). Rows
|
||||
therefore keep their place; the leaderboard and totals are untouched because
|
||||
the server is the source of truth either way.
|
||||
- Rollback on failure restores **both** `checked_in` and `points` from the row
|
||||
that was clicked, so the checkbox never lies.
|
||||
|
||||
Accessibility/ergonomics in the same pass (`apps/admin/src/styles.css`): the
|
||||
toggle's hit area is now 40×41 px (`padding: 9px 0; margin: -9px 0`) instead of
|
||||
the bare track, the hidden checkbox gets a `:focus-visible` ring on the track,
|
||||
and a disabled track reads as disabled.
|
||||
|
||||
## Design of (2) — the front-desk gate
|
||||
|
||||
`checkin_attendee` now reads the attendee's `registrations.checked_in` and
|
||||
raises **`This attendee needs to be checked in at the front desk first.`** when
|
||||
it is not `true`. It also **stopped setting `checked_in = true` as a side
|
||||
effect**, which is what let a session scan make someone "checked in to the
|
||||
event" without anyone welcoming them. The welcome check-in (and the admin
|
||||
Registrations toggle, i.e. the front desk acting from the console) are now the
|
||||
only ways to earn that flag.
|
||||
|
||||
Enforced in the database on purpose: `checkins` has **no INSERT policy**, so the
|
||||
RPC is the only write path and the gate cannot be bypassed from the API.
|
||||
|
||||
The scanner (`apps/convivo/src/screens/Scan.tsx`) treats this as a *state*, not
|
||||
a transient error: instead of a toast it opens its own sheet — **🛑 "Not checked
|
||||
in yet" / "This attendee needs to be checked in at the front desk before they
|
||||
can be scanned into a session."** with **OK** (`data-testid="front-desk-required"`
|
||||
/ `front-desk-ok`). The camera stays paused behind it and re-arms on **OK**.
|
||||
|
||||
## Design of (3) — badge copies
|
||||
|
||||
- New column `events.badge_copies` `integer not null default 1
|
||||
check (badge_copies between 1 and 4)`. Per-event is the right data model; the
|
||||
setting is surfaced in **Settings → Badge printing** for the active event
|
||||
because that is where admins expect one global knob, and also on the Events
|
||||
form.
|
||||
- `welcome_checkin` builds the payload once and calls `pgmq.send` **N times** in
|
||||
the same transaction. The Pi worker prints exactly one label per job, so
|
||||
**N jobs = N labels** and nothing in `apps/printer` changed. The value is
|
||||
clamped again inside the function (`greatest(1, least(4, …))`) so a
|
||||
hand-edited row cannot flood the queue.
|
||||
- `preview_welcome_checkin` gained a **`copies`** column (drop + recreate — the
|
||||
return type changed, and Postgres refuses `create or replace` across that), so
|
||||
the confirmation popup tells the truth: *"you will print their badge 3 times"*
|
||||
instead of a fixed *"this person's label"*. `copies` is `0` when nothing would
|
||||
print.
|
||||
- **Manual reprint (`enqueue_badge_print`) still prints exactly one label** —
|
||||
reprinting a lost badge must not produce a stack.
|
||||
- Saving uses `setBadgeCopies(eventId, copies)`, a **single-column** update, so
|
||||
it can never clobber the rest of the event row. The picker is
|
||||
`components/BadgeCopiesSetting.tsx` (shared segmented 1–4 control + the
|
||||
self-saving card with a "Copies saved" confirmation). The Settings view loads
|
||||
the active event **independently of** `getLlmSettings()`, so the badge section
|
||||
still renders when the LLM/sidecar call fails.
|
||||
|
||||
## Tests
|
||||
|
||||
- `supabase/tests/badge_print_tests.sql`: **+6 assertions → 113** — gate refuses
|
||||
an un-welcomed session scan; `badge_copies = 3` queues three more labels; the
|
||||
savepoint restores the queue to one; `preview.copies` = `1` / `0` / `3`. The
|
||||
pre-existing session-check-in case now sets `checked_in` first, since the gate
|
||||
made it a precondition.
|
||||
- `supabase/tests/leaderboard_tests.sql`: **+1 assertion → 47**, fixtures
|
||||
checked-in (plus a fresh, un-checked-in attendee to drive the gate).
|
||||
- `supabase/tests/rpc_tests.sql`: fixtures checked-in so the session path is
|
||||
reachable.
|
||||
- New `e2e/tests/registration-checkin-toggle.spec.ts` — **6** mocked-admin tests:
|
||||
toggle fires exactly one request and **zero refetches**, row order unchanged,
|
||||
the busy row shows "Saving…" with its checkbox disabled while other rows stay
|
||||
enabled, a second row saves concurrently, un-check reports `−30`, a rejected
|
||||
write rolls back, type change without refetch, and the Settings picker
|
||||
persisting 1–4.
|
||||
- New `e2e/tests/front-desk-gate.spec.ts` — **3** real-browser tests
|
||||
(CONV-GATE-001..003): the refusal sheet with **no check-in recorded**, the same
|
||||
scan succeeding after the welcome, and a session check-in not setting the
|
||||
event flag by itself.
|
||||
- New `e2e/tests/welcome-badge-copies.spec.ts` — **3** real-browser tests
|
||||
(CONV-COPIES-001..003): `badge_copies = 3` → exactly 3 queue messages for that
|
||||
attendee, `1` → 1 with the singular wording, re-welcome → **+0**.
|
||||
- `e2e/tests/registration-ticket-merge.spec.ts` (pre-existing, **broken by
|
||||
`316f131`**): its rollback test mocked a `registrations` PATCH the toggle
|
||||
stopped using when it moved to `set_registration_checked_in`; the mock now
|
||||
targets the RPC, so the test exercises what the UI actually calls.
|
||||
- Also fixed by this work: `feedback-ai-summary.spec.ts` was picking up an
|
||||
ambiguous `Save` button once the badge card added one — the card's button is
|
||||
labelled **"Save copies" / "Copies saved"**, which resolves the collision for
|
||||
both screen-reader users and the test. `checkin-attendee.spec.ts`'s print-copy
|
||||
assertion now tolerates the typographic apostrophe in the popup text.
|
||||
- Pre-existing, **not** caused by this change set: `session-checkin.spec.ts`,
|
||||
`checkin-attendee.spec.ts` and `rpc_tests.sql` still fail locally because the
|
||||
seeded demo identities (`CVV-ATT-1000`…`CVV-ATT-1005`, the `37ab7060-…`
|
||||
session) no longer exist — pretix-imported data replaced them. The identical 8
|
||||
`rpc_tests` failures occur at HEAD, and the same specs failed with everything
|
||||
stashed. The new specs deliberately provision their own fixtures so they do
|
||||
not depend on that drift; the fixtures should be re-seeded separately.
|
||||
- Both apps typecheck clean and build (`admin` `index-DSNhW0mZ.js`,
|
||||
`convivo` `index-CXd2kxEv.js`, print `print-CaBuVVFf.js`).
|
||||
|
||||
## Deployment
|
||||
|
||||
**Not deployed.** Production is still missing everything from this change set:
|
||||
`events.badge_copies` does not exist, `checkin_attendee` has no gate,
|
||||
`welcome_checkin` prints one label, and `admin.appe.at` serves the pre-fix
|
||||
bundle `index-Czkxg0C-.js` (which is exactly the reload-everything behaviour
|
||||
described above). `set_registration_checked_in` already exists there with the
|
||||
same signature, so the migration will not conflict.
|
||||
|
||||
**One data consequence to decide on before shipping:** in production 2 people
|
||||
already have session check-ins without `checked_in = true`, so the gate would
|
||||
lock 1 of them out of further session scans until the front desk welcomes them.
|
||||
Either backfill `checked_in = true` for anyone with an existing check-in as part
|
||||
of the rollout, or accept that the front desk re-welcomes them (they print a
|
||||
badge on the way back through).
|
||||
|
||||
To ship: apply `20261019110000_front_desk_gate_and_badge_copies.sql` (records
|
||||
41 → 42), rebuild `convivo-app` **and** `convivo-admin`, then re-run the suites
|
||||
above against prod.
|
||||
Reference in new issue
Block a user