fix(points): welcome check-in awards +10; add Sessions view, AI connection test, silent reload

The front-desk check-in set checked_in and printed badges but awarded nothing,
so the +10 depended on which check-in a person happened to get. Every award
path was reviewed:

- welcome_checkin awards +10 (category checkin) on a genuine first check-in and
  returns points + points_awarded; checkin_attendee and preview_welcome_checkin
  return points_awarded too.
- set_registration_checked_in(false) deleted all checkin points while keeping
  the checkins rows, and switching back on awarded nothing -- one mistaken
  toggle destroyed those points permanently. ON now recomputes from the rows
  that still exist and awards only the shortfall: reversible, still unfarmable.
- The staff/Admin/@appe.at exclusion stays (product decision) but is no longer
  silent: three-way points sheets in the scanner, "no points" with a tooltip in
  Registrations, and the Contacts points modal refuses to apply rather than
  letting adjust_points (void) no-op quietly.

Also in this change:
- admin silent refresh (5s poll + 500ms after writes) across all data views;
  Registrations patches in place so rows never slide under the cursor
- Settings "Validate AI connection" via a new sidecar POST /llm-test verdict
  endpoint (never leaks the key, distinguishes "no usage block" from "off")
- new Sessions view between Schedule and Activity: speakers, attendance,
  ratings, attendee filter, and one button that summarises every session with
  feedback (one request each, concurrency 3, UI blocked until all settle)
- provider requests disable thinking through one shared body builder sending
  both reasoning_effort:"none" and chat_template_kwargs.enable_thinking

SQL: 113 / 57 / 24 assertions (set_registration_checked_in section 3 was
rewritten, it asserted the bug). Sidecar 34 unit tests. Full e2e 202 passed,
0 failed. Migration applied locally only -- not deployed.

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:
committed 2026-10-19 20:14:03 +02:00
1 parent cdb4793273
commit d3083b7940
35 files changed
+2778 -154

No files matched your search

+83 -6
View File
@@ -6,10 +6,8 @@ SQL suite **combined with the migration** in one transaction (the migration is
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/badge_print_tests.sql
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
@@ -17,6 +15,26 @@ CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- welcome-badge-co
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts --project=chromium
```
> **Replaying an older migration is no longer possible for these functions.**
> `20261019160000_welcome_points_and_toggle_restore.sql` **drops and re-creates**
> `checkin_attendee`, `welcome_checkin`, `set_registration_checked_in` and
> `preview_welcome_checkin` with wider return types, and Postgres refuses
> `create or replace` across a row-type change. So `cat`-ing the 20261019110000
> migration onto the suite now fails with
> `cannot change return type of existing function … Use DROP FUNCTION
> checkin_attendee(uuid,text) first` — that error is the guard working, not a
> broken suite. Run the suite against the live database (as above), or chain the
> **newest** migration instead:
>
> ```sh
> (echo 'begin;'; \
> cat supabase/migrations/20261019160000_welcome_points_and_toggle_restore.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
> ```
>
> That chain still reports **113 assertions**.
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
@@ -27,8 +45,10 @@ queue to one so the rest of the run is unaffected, plus
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.
`set_registration_checked_in_tests.sql` (**24 assertions**, was 15) covers the
admin toggle that grants and revokes the same flag, with its points accounting —
see [Points Correctness Regression](#points-correctness-regression) for what the
extra nine assert.
`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
@@ -45,6 +65,63 @@ Settings copies picker saving and reloading.
See [release record](../releases/2026-10-19.md) for the bug this started with.
# Points Correctness Regression
After applying `20261019160000_welcome_points_and_toggle_restore.sql`:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/leaderboard_tests.sql # 57 assertions
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 # 24
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/badge_print_tests.sql # 113
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- checkin-points.spec.ts --project=chromium
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts sessions-view.spec.ts --project=chromium
```
`leaderboard_tests.sql` grew from 47 to **57 assertions**: the front-desk
(welcome) check-in now awards **+10** like a session scan, so it asserts the
first welcome pays out and lands on the registration, a second welcome pays
nothing, welcome-then-session totals 20, and — for each excluded identity (staff
pass, Admin contact, `@appe.at`) — that a welcome still checks the person in while
awarding **nothing** (`points_awarded = false`, `points = 0`). The excluded-identity
loop ends on a non-admin JWT, so the suite restores the admin claims afterwards;
without that the tail assertions silently run as the wrong person.
`set_registration_checked_in_tests.sql` grew from 15 to **24 assertions**, and its
third section was **rewritten because it encoded the bug**: it used to assert
"points unchanged after re-check-in". It now seeds two real `checkins` rows and
asserts the toggle ON re-awards exactly what those rows justify (30), that a
second ON adds 0, that an off→on round trip restores 30 both times, and that a
staff contact's toggle removes 0 and adds 0.
`checkin-points.spec.ts` is the end-to-end proof against the **real** database,
which is what the original complaint needed (the scanner appeared not to award
the +10):
- **CONV-PTS-001** the welcome check-in pays +10, the confirm sheet promises it
*before* the write, the result sheet says `+10 pts · now 10`, the registration
reads 10, and `points_log` holds a `checkin=10` row.
- **CONV-PTS-002** a second welcome says "No extra points" and stays at 10; the
following session scan takes the total to 20.
- **CONV-PTS-003** a staff pass still checks in, but the sheets say "does not
earn points" / "staff earn no points", the score stays 0 and **no `points_log`
row is written** — the exclusion, made visible.
- **CONV-PTS-004** drives `set_registration_checked_in` through the real RPC
(psql has to supply `request.jwt.claims` because `is_admin()` reads
`auth.jwt()`): off removes 20, on restores 20, and a third click adds 0 — no
farming.
`sessions-view.spec.ts` (8 tests) covers the new Sessions view against mocked
APIs: nav order Schedule → **Sessions** → Activity, per-session speaker chips and
check-in counts, the attendee filter narrowing to that person's sessions and
highlighting them in the roster, **one request per session that has feedback**
(none for a session without any), the blocking overlay with its `done / total`
counter and disabled controls, a partial failure reporting which session failed
while the others still land, the stale-summary flag, and the disabled button when
the LLM is unconfigured or nothing has feedback.
# Badge Print Queue Regression
After applying `20261018170000_badge_print_queue`, run the SQL suite **combined