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.
This commit is contained in:
1 parent
96e4e6a6ea
commit
fdb6045966
35 files changed
+2778
-154
No files matched your search
@@ -366,3 +366,143 @@ migration).
|
||||
admin flips the toggle before his next session scan. The print station
|
||||
`Welcome desk` had not heartbeated for ~77 minutes at deploy time, so any
|
||||
welcome before it comes back simply queues — jobs wait, nothing is lost.
|
||||
|
||||
# Follow-up: welcome check-in paid nothing; Sessions view; AI connection test (2026-10-19)
|
||||
|
||||
## Reported
|
||||
|
||||
1. "While checking in (either from admin or phone app) doesn't give the 10 +
|
||||
points. Review all the point logic to make sure it is correct."
|
||||
2. A silent reload on the admin site so it shows fresh data.
|
||||
3. A button in Settings to validate the AI connection.
|
||||
4. A new **Sessions** section (between Schedule and Activity) showing all
|
||||
sessions, their speakers, who checked in, a filter by attendee, and one
|
||||
button that generates an AI feedback summary per session with feedback —
|
||||
blocking until all requests finish, thinking disabled, results stored.
|
||||
|
||||
## Root cause of (1)
|
||||
|
||||
The **front-desk (welcome) check-in awarded nothing.** `welcome_checkin` set
|
||||
`checked_in = true` and enqueued badges, but never touched points — only
|
||||
`checkin_attendee` (+10 per session) did. So the first thing that happens to an
|
||||
attendee, the scan at the door, paid 0, and every later screen that promised
|
||||
"+10 pts" for a check-in was wrong for anyone whose only check-in was the welcome
|
||||
one. The scanner also rendered `+10 pts · now 0` for staff accounts, because
|
||||
`_points_eligible` silently no-ops for them and nothing reported the refusal.
|
||||
|
||||
Third defect found while reviewing every award path
|
||||
(`accept_connection`, `submit_feedback`, `adjust_points`, `welcome_checkin`,
|
||||
`checkin_attendee`, `set_registration_checked_in`): switching a registration's
|
||||
check-in **off** deleted all `checkin` points but kept the `checkins` rows, and
|
||||
switching it back on awarded **nothing** — documented as anti-farming. A single
|
||||
mistaken toggle therefore destroyed those points permanently, and the attendee
|
||||
could not earn them back by re-scanning ("already checked in, no extra points").
|
||||
|
||||
## Fix (1)
|
||||
|
||||
`supabase/migrations/20261019160000_welcome_points_and_toggle_restore.sql`:
|
||||
|
||||
- `welcome_checkin` awards **+10** (category `checkin`) on a genuine first
|
||||
check-in, once per person, and returns `points` + `points_awarded`.
|
||||
- `checkin_attendee` and `preview_welcome_checkin` return `points_awarded`.
|
||||
- `set_registration_checked_in` returns `points_added` and, going ON, recomputes
|
||||
what the **existing `checkins` rows** justify (10 × rows + 10 for the door) and
|
||||
awards only the shortfall — reversible in both directions, still unfarmable
|
||||
because the target comes from rows, never from click count.
|
||||
- Postgres cannot `create or replace` across a changed row type, so each function
|
||||
is `drop function`'d first; grants are re-applied per function.
|
||||
|
||||
**Staff / Admin / `@appe.at` exclusion stays** (product decision: they must not
|
||||
rank on the public leaderboard) but is **no longer silent** — three-way sheets in
|
||||
the scanner, `— no points` with a tooltip in Registrations, and the Contacts
|
||||
points modal disables **Apply** rather than letting `adjust_points` (returns
|
||||
`void`) no-op quietly.
|
||||
|
||||
## (2) Silent reload
|
||||
|
||||
`apps/admin/src/lib/useSilentRefresh.ts`: 5 s poll while visible + a debounced
|
||||
pull 500 ms after any write; never fires on mount, swallows background errors
|
||||
(these views render `if (error) return <Empty/>`), drops overlapping ticks,
|
||||
pauses when the tab is hidden. Registrations **patches in place** — current row
|
||||
order preserved, rows with a write in flight skipped, new rows appended, removed
|
||||
rows dropped — because the list is sorted by points and a naive reload slid the
|
||||
row you had just toggled across the table. Reports polls at 15 s (nine tables).
|
||||
Schedule/Contacts pause while a modal is open; Raffle never refreshes mid-spin.
|
||||
|
||||
## (3) Validate AI connection
|
||||
|
||||
Sidecar `POST /llm-test` (`feedback-api.js`): reads the **stored** settings, runs
|
||||
the SSRF guard, makes one `"Reply with OK"` chat request with the exact body a
|
||||
summary uses, and always answers `200` with a verdict
|
||||
(`ok, model, endpoint, latency_ms, reasoning_disabled, reasoning_tokens, content,
|
||||
warning, error`). Provider error text is flattened, truncated to 300 chars and
|
||||
key-redacted. `reasoning_tokens: null` means no `usage` block — it is shown as
|
||||
"not reported", never as zero, because **only `0` proves thinking is off**. A
|
||||
working endpoint that still reports reasoning tokens is `ok: true` + `warning`
|
||||
(the UI colours it amber). The button is disabled while the form has unsaved
|
||||
changes, since the key never reaches the browser and a test can only exercise
|
||||
what is stored.
|
||||
|
||||
## (4) Sessions view
|
||||
|
||||
`apps/admin/src/views/Sessions.tsx`, nav between Schedule and Activity. Rows join
|
||||
`sessions` ⨝ `slots` ⨝ `session_speakers` ⨝ `checkins` ⨝ `feedback` **in the
|
||||
client**, so the numbers match the other views exactly and no RLS policy changes.
|
||||
Search on title/room/level/area/speaker; the attendee filter narrows to that
|
||||
person's sessions and highlights them in the expanded roster.
|
||||
|
||||
**Generate AI Feedback Summary**: one `POST /sidecar/feedback-summary` per session
|
||||
that has ≥1 feedback (no new backend route), concurrency **3** (the gateway is a
|
||||
single vLLM worker), full-screen overlay with a `done / total` counter blocking
|
||||
the page until every request settles, each result stored as it arrives so a
|
||||
half-finished run keeps what it did, per-session failures reported without
|
||||
stopping the rest, a Stop button, and stored summaries flagged **stale** when the
|
||||
response count has moved. New API helpers `getEventCheckins`,
|
||||
`getEventSessionFeedback` (paged — PostgREST `max_rows = 1000` silently truncates)
|
||||
and `getEventSessionSpeakers` (filters through the session FK, since
|
||||
`session_speakers` has no `event_id`).
|
||||
|
||||
Thinking is disabled by one shared `buildChatCompletionsBody` sending **both**
|
||||
`reasoning_effort: "none"` and `chat_template_kwargs: { enable_thinking: false }`
|
||||
(measured on `ai.lago.dev` → vLLM: either alone takes reasoning tokens ~235 → 0,
|
||||
~3.5× faster; `thinking:{type:"disabled"}` is silently ignored, `max_tokens` is
|
||||
accepted but ignored, and the endpoint answers `200` while ignoring any unknown
|
||||
field).
|
||||
|
||||
## Tests
|
||||
|
||||
- `checkin-points.spec.ts` (**new, 4 tests, real DB**): welcome pays `+10 pts ·
|
||||
now 10` **and** writes `checkin=10`; second welcome adds nothing then a session
|
||||
scan totals 20; staff pass checks in with "staff earn no points", 0 points and
|
||||
**no `points_log` row**; toggle off removes 20, on restores 20, third click 0 —
|
||||
driven through the real RPC with `request.jwt.claims` set, since `is_admin()`
|
||||
reads `auth.jwt()`.
|
||||
- `sessions-view.spec.ts` (**new, 8 tests**): nav order, speaker chips + counts,
|
||||
attendee filter + roster highlight, **exactly one request per session with
|
||||
feedback** and none without, blocking overlay + disabled controls, partial
|
||||
failure reporting, stale flag, disabled button when unconfigured.
|
||||
- `registration-checkin-toggle.spec.ts` +3: the silent pull arrives after a write
|
||||
**and still does not reorder**, the staff row's `no points` marker, and a
|
||||
`+20 check-in pts restored` toast.
|
||||
- SQL: `badge_print_tests` **113**, `leaderboard_tests` **47 → 57** (welcome award
|
||||
+ excluded-identity welcomes; the loop restores admin claims afterwards or the
|
||||
tail runs as the wrong person), `set_registration_checked_in_tests` **15 → 24**
|
||||
— section 3 was **rewritten because it asserted the bug** ("points unchanged
|
||||
after re-check-in").
|
||||
- Sidecar **28 → 34** unit tests.
|
||||
- **Full e2e: 202 passed, 0 failed** (serial, 15.1 min). Note: three concurrent
|
||||
full runs against the one shared local DB produce phantom failures — run the
|
||||
suite serially and alone.
|
||||
- Builds: admin `index-CE_n-ZUs.js`, convivo `index-BE2x44BJ.js`; `tsc` clean in
|
||||
admin, convivo and e2e.
|
||||
|
||||
## Not deployed
|
||||
|
||||
Migration + all app changes are **local only**. `20261019160000` changes **four
|
||||
function signatures**, so production needs the usual backup + rollback tags, and
|
||||
the old `cat migration && tests` command in `tests.md` no longer works for the
|
||||
19110000 file (the newer one drops and re-creates those functions) — the doc now
|
||||
records that and the working alternative. **No backfill**: anyone whose points
|
||||
were erased by an off→on cycle before this stays low until an admin flips that
|
||||
toggle once — one OFF→ON now recomputes from the surviving `checkins` rows and
|
||||
puts them back, so the old damage is repairable from the UI.
|
||||
Reference in new issue
Block a user