The camera stopped after decoding one code (by design, one scan at a time) but was only ever started on mount, so it stayed dead until staff navigated away and back. The parent now owns the lifecycle via a paused prop: Scan pauses while busy or any sheet is open (camera re-arms when the sheet closes), Login pauses while busy (re-arms after a failed scan). scannedRef guards duplicate callbacks between decode and stop.
162 lines
7.3 KiB
Markdown
162 lines
7.3 KiB
Markdown
# Welcome Check-In Confirmation (2026-10-19)
|
||
|
||
## Symptom
|
||
|
||
At the welcome desk, a staff member scanned an attendee's lanyard in the Convivo
|
||
app and the attendee was checked in — but **no badge printed**. Reported against
|
||
production.
|
||
|
||
## Root cause
|
||
|
||
Two things, one a genuine bug and one a UX gap:
|
||
|
||
1. **The scanner defaults to *session* check-in.** The staff Scan screen has a
|
||
"Check-in type" toggle. In the default **session** mode it calls
|
||
`checkin_attendee`, which records session attendance and points but — by
|
||
design — never enqueues a badge. Only **welcome** check-in (`welcome_checkin`)
|
||
enqueues a print. A scan left in session mode therefore checks the person in
|
||
without printing.
|
||
2. **Welcome check-in fired silently.** Even in welcome mode the scan checked the
|
||
person in and queued a print with no confirmation, so staff had no idea a
|
||
label was about to come out (or that the wrong mode was selected).
|
||
|
||
## Fix
|
||
|
||
A confirmation step on the **welcome** path only (session check-in is unchanged
|
||
and still never prints, per the product decision):
|
||
|
||
- New read-only RPC `preview_welcome_checkin(p_attendee_qr)`
|
||
(`20261019090000_welcome_checkin_preview.sql`) resolves the scanned token to
|
||
the attendee and reports `already` + `will_print`. `will_print` mirrors the
|
||
exact enqueue condition in `welcome_checkin` (a genuine first check-in **and**
|
||
the event has a badge layout), so the popup never promises a print that won't
|
||
happen. It checks nobody in and enqueues nothing. Staff/admin only.
|
||
- The attendee app (`apps/convivo/src/screens/Scan.tsx`) now previews first and
|
||
shows a sheet: **"You are checking in [Name]. By confirming, you will print
|
||
this person's label."** with **Yes / No**. Only **Yes** runs `welcome_checkin`.
|
||
When `will_print` is `false` (already checked in, or no layout) the copy drops
|
||
the print sentence.
|
||
|
||
## Tests
|
||
|
||
- `supabase/tests/badge_print_tests.sql`: **+8 assertions** (109 total) — preview
|
||
resolves the name, reports `will_print` for an unchecked attendee, enqueues
|
||
nothing, checks nobody in, reports no print for a checked-in attendee or a
|
||
layout-less event, and is staff/admin-only (non-staff + anon rejected).
|
||
- `e2e/src/pages/ScanPage.ts` + welcome specs drive the new confirm step; added
|
||
`CONV-CHECKIN-003` (popup shows the name + print copy; **No** leaves the
|
||
attendee unchecked; **Yes** checks in).
|
||
- Real-browser smoke against a local build: **No** → not checked in, queue empty;
|
||
**Yes** → checked in and one `badge_print` job queued with the right name.
|
||
|
||
## Deployment
|
||
|
||
**Deployed to production 2026-10-19** (attendee app + DB migration).
|
||
|
||
- Migration `20261019090000_welcome_checkin_preview.sql` applied to prod in one
|
||
transaction with `ON_ERROR_STOP=1` and recorded in the ledger (39 → 40).
|
||
Backup `/home/APPE/convivo-backups/wprev-…` (counts before/after). Counts and
|
||
the print queue unchanged; `preview_welcome_checkin` present.
|
||
- `convivo-app` rebuilt from HEAD behind a baseline drift guard (the three
|
||
changed files — `api.ts`, `types.ts`, `Scan.tsx` — were byte-identical to the
|
||
deployed baseline, so whole-file copy was safe). Only `convivo-app` recreated;
|
||
admin, sidecar and every unrelated container ID preserved.
|
||
|
||
---
|
||
|
||
# Follow-up: camera scans ignored Welcome mode + un-check-in removes points (2026-10-19)
|
||
|
||
## Symptoms (reported from production)
|
||
|
||
1. With the "Check-in type" toggle switched to **Welcome**, a camera scan still
|
||
produced the *session* result sheet ("Already checked in / No extra points")
|
||
and no confirmation popup.
|
||
2. Feature request: when an admin flips the **checked-in** toggle OFF in the
|
||
admin Registrations view, the points that person earned from check-ins
|
||
should be removed too.
|
||
|
||
## Root cause of (1)
|
||
|
||
`Scanner` (`apps/convivo/src/components/ui.tsx`) registers the html5-qrcode
|
||
success callback once in a `useEffect(…, [])`. That callback captured the
|
||
`onResult` prop **from the first render**, so it kept calling a `handleScan`
|
||
closure in which `welcomeMode` was still `false` (and the session selector
|
||
still empty). Toggling Welcome afterwards had no effect on camera scans — every
|
||
scan ran the session branch. The manual-entry field called the *current* prop,
|
||
which is why keyboard-driven tests and the earlier smoke test passed.
|
||
|
||
**Fix:** keep `onResult` in a ref refreshed on every render and invoke
|
||
`onResultRef.current(text)` from the camera callback.
|
||
|
||
## Design of (2)
|
||
|
||
New admin RPC `set_registration_checked_in(p_registration_id, p_checked_in)`
|
||
(`20261019100000_set_registration_checked_in.sql`), the single admin path for
|
||
the toggle:
|
||
|
||
- admin-only (`is_admin()`), locks the registration row;
|
||
- sets `checked_in` to the requested value;
|
||
- when turning it **off**, sums the attendee's `points_log` rows of category
|
||
`checkin` for that event, deletes them, and applies the negative delta
|
||
through `_award_points(…, 'admin')` — so the leaderboard mirror and the audit
|
||
trail stay consistent (the reversal itself is logged as an `admin` row);
|
||
- returns `points_removed`. Re-checking in does **not** re-award points (no
|
||
point farming by toggling); the admin `points` column refreshes after the
|
||
call and a toast reports the removal.
|
||
|
||
## Tests
|
||
|
||
- `supabase/tests/set_registration_checked_in_tests.sql`: **15 assertions** —
|
||
un-check removes exactly the checkin points (40 → 10, other categories
|
||
untouched), leaderboard syncs, reversal logged once as −30 `admin`,
|
||
no-checkin-points un-check is a no-op, re-check awards nothing, unknown id
|
||
rejected, non-admin and anon rejected.
|
||
- Existing suites re-run clean: leaderboard 46, badge_print 109, rpc_tests.
|
||
|
||
## Deployment
|
||
|
||
**Deployed to production 2026-10-19**: migration applied + ledger (40 → 41);
|
||
`convivo-app` and `convivo-admin` rebuilt from HEAD behind the drift guard (all
|
||
three changed files byte-identical to the deployed baseline).
|
||
|
||
---
|
||
|
||
# Follow-up: camera stays dead after a scan (2026-10-19)
|
||
|
||
## Symptom (reported from production)
|
||
|
||
After a successful scan the camera stopped working — staff had to navigate to
|
||
another tab and back to re-activate it before scanning the next lanyard.
|
||
|
||
## Cause
|
||
|
||
`Scanner` deliberately stops the camera after decoding one code (so the same
|
||
lanyard cannot fire twice), but it only ever started the camera once, on mount.
|
||
Nothing restarted it afterwards.
|
||
|
||
## Fix
|
||
|
||
The camera lifecycle is now driven by a `paused` prop owned by the parent:
|
||
|
||
- `Scan.tsx` passes `paused = busy || a sheet is open` (connect, session
|
||
result, welcome confirm, welcome result). The camera stops while a sheet is
|
||
up and **restarts automatically the moment the sheet closes** — "Scan next"
|
||
or ✕ is all it takes now.
|
||
- `Login.tsx` passes `paused = busy` so a failed scan (e.g. unknown code)
|
||
re-arms the camera immediately instead of leaving it dead.
|
||
- A `scannedRef` guard ignores duplicate callbacks in the frames between the
|
||
decode and the camera actually stopping.
|
||
|
||
## Tests
|
||
|
||
Real-browser smoke against a local build: staff login → Welcome mode → scan →
|
||
confirm popup → **Yes** → result sheet → **Scan next** → sheet closes and the
|
||
camera effect re-runs (fresh `Html5Qrcode` instance starts; the library clears
|
||
the element in its constructor, so re-attaching to the same div is safe).
|
||
Badge queued correctly; test data cleaned afterwards.
|
||
|
||
## Deployment
|
||
|
||
**Deployed to production 2026-10-19**: attendee app only (`convivo-app`
|
||
rebuilt; no migration, admin/sidecar untouched).
|