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

No files matched your search

+49
View File
@@ -45,6 +45,55 @@ an existing `@appe.at` contact). They return `Cache-Control: no-store`.
| `GET /sidecar/llm-settings` | Read redacted configuration. |
| `PUT /sidecar/llm-settings` | Save `{ endpoint, model, api_key? }`. |
| `POST /sidecar/feedback-summary` | Generate `{ scope: "event", event_id }` or `{ scope: "session", event_id, session_id }`. |
| `POST /sidecar/llm-test` | Make one real chat request with the **stored** settings and return a verdict. |
### Connection validation (`POST /sidecar/llm-test`)
Always answers **`200 OK` with a verdict** (only the auth layer returns 401/403,
and 405 for `GET`), because the reason a connection fails is the useful part:
```json
{"ok":true,"model":"Qwen3.8","endpoint":"https://ai.lago.dev/v1/chat/completions",
"latency_ms":412,"reasoning_disabled":true,"reasoning_tokens":0,"content":"OK",
"warning":null,"error":null}
```
- `reasoning_tokens` is the provider's own
`usage.completion_tokens_details.reasoning_tokens`, or **`null` when the
provider sent no `usage` block**. `null` is not "off"; `reasoning_disabled` is
`true` only when it is exactly `0`.
- `ok` answers "would generating a summary work?" — transport, auth and parsing
all fine. A working connection whose provider still reports reasoning tokens is
therefore `ok: true` with `reasoning_disabled: false` and a `warning`, so the
honest signal about cost stays separate from the pass/fail answer. The Admin UI
colours that case amber, not green.
- It never writes to the database, and the API key never appears in any field:
provider error text is flattened, truncated to 300 characters and the stored key
is replaced with `[redacted]` (a provider that echoes the Authorization header
in its own error body is covered by a test).
- An endpoint that fails the SSRF/DNS guard is reported **without ever contacting
it**.
### Disabling model thinking
Both requests (summaries and the test) are built by one helper,
`buildChatCompletionsBody`, so they cannot drift apart. It sends
`stream: false`, `reasoning_effort: "none"` **and**
`chat_template_kwargs: { enable_thinking: false }`. Measured against the
`ai.lago.dev` gateway (Bifrost → vLLM) serving `Qwen3.8`:
- Either field alone takes reasoning tokens from ~235 to `0`, about **3.5×
faster**. Both are sent because they cover different OpenAI-compatible
gateways and each silently drops the other; they agree, so the precedence rule
never matters.
- `thinking: { type: "disabled" }` (the Anthropic-style spelling) is **silently
ignored** by this endpoint and still cost ~235 reasoning tokens, so it is
deliberately not used.
- `max_tokens` is accepted and ignored, so it is not sent.
- **A `200 OK` proves nothing**: this endpoint ignores unknown fields entirely.
Only `usage.completion_tokens_details.reasoning_tokens === 0` is evidence.
Reasoning *levels* are validated though — `reasoning_effort: "banana"` is an
HTTP 400 `unsupported_value`, which is how the field was confirmed to be live.
The sidecar checks that the event exists and that a selected session belongs to
it. It reads all feedback in ordered 500-row pages, selecting only `rating` and
+46 -7
View File
@@ -26,6 +26,7 @@ Source of truth:
| Action | Points | Awarded to |
|---|---|---|
| **Welcome (front-desk) check-in**, first time only | **+10** | the attendee |
| Checked into a session (by staff) | **+10** | the attendee |
| Connection accepted | **+5 each** | both people |
| Connection accepted **with a shared talk** | **+`talk_networking_bonus` each** (per event, default 2, `0` = off) | both people (category `talk_networking`) |
@@ -38,8 +39,31 @@ contacts (`is_admin` or `@appe.at`) always have zero points and never rank,
including when checked in, leaving feedback, accepting connections or receiving
manual adjustments. Existing audit history is retained when a role changes.
**That exclusion is deliberate and stays — but it is no longer silent.** It used
to be invisible: a staff test check-in produced a bare `0` and looked like a
broken feature. `_points_eligible` is now consulted by the callers that report
outcomes, so every surface says why:
- `checkin_attendee` / `welcome_checkin` / `preview_welcome_checkin` return
`points_awarded`, and the scanner renders "Checked in · staff earn no points"
instead of claiming "+10 pts · now 0".
- The admin Registrations table shows "— no points" with a tooltip on the rows
the predicate excludes (`canEarnPoints` in
[../frontend/admin-app.md](../frontend/admin-app.md) mirrors the SQL exactly),
and the Contacts points modal refuses to apply an adjustment to such a contact
rather than letting `adjust_points` (which returns `void`) no-op quietly.
## Internal helpers
### `_points_eligible(p_event_id, p_contact_email)` → `boolean`
The single source of truth for "may this person earn points": the contact must
have a registration in **that event**, with `registrations.type <> 'staff'`,
`contacts.is_admin = false` and an email not ending in `@appe.at`. `_award_points`
uses it as a gate, and the outcome-reporting RPCs use it to tell the UI whether an
award actually happened — both halves read the same predicate, so a screen can
never promise points the database would refuse. There is no second copy of the
rule anywhere else; the admin app's client-side mirror is commented to that effect.
### `_award_points(p_event_id, p_contact_email, p_delta, p_category)`
The shared award path first locks the registration and checks eligibility. Missing
registrations, staff and Admin contacts receive no award or new audit entry.
@@ -119,7 +143,7 @@ Accepts an **incoming** request.
### `reject_connection(p_connection_id)` → `connections`
Same guards as accept, but sets `status = 'rejected'`. No points.
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already)`
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already, points_awarded)`
Staff checks an attendee into a session.
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
`staff or admin only`.
@@ -139,7 +163,10 @@ Staff checks an attendee into a session.
nothing returning id` — if no row was inserted, the attendee was **already
checked in**: sets `already = true` and awards **no points**.
- Otherwise awards **+10** to the attendee (category `checkin`).
- Returns the attendee's current total points.
- Returns the attendee's current total points, and `points_awarded` — whether
that +10 actually landed. It is `false` for someone `_points_eligible`
excludes, which is the only reason a fresh check-in pays nothing. Without it
the scanner had to render "+10 pts · now 0" for a staff badge scan.
> **Implementation note:** the "already checked in" case is detected via the
> `ON CONFLICT ... DO NOTHING returning id` (a `NULL` id means no-op), and the
@@ -147,14 +174,22 @@ Staff checks an attendee into a session.
> `return query` inside an `if` block would *not* terminate the function and would
> double-award.
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already)`
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, points, points_awarded)`
Staff **welcome** check-in: marks an attendee present at the **event** (distinct
from `checkin_attendee`, which checks someone into a specific session).
- **Role check:** `is_staff_or_admin()` or it raises `staff or admin only`.
- Resolves the attendee by `qr_token` for the active event.
- Sets `registrations.checked_in = true` (no points — that's the session
check-in's job).
- `already` is `true` if the attendee was already checked in to the event.
- Sets `registrations.checked_in = true` and, on a **first** check-in, awards
**+10** (category `checkin`) through `_points_eligible` + `_award_points`. The
front desk is a real check-in, so it pays the same as a session scan; before
this it paid nothing, which made "check me in" award different amounts
depending on *which* check-in a person got. It is once-per-person because the
`checked_in` flag already is, so repeating a welcome cannot farm points.
- `already` is `true` if the attendee was already checked in to the event; in
that case nothing is awarded and `points` is the unchanged total.
- `points_awarded` says whether the +10 landed (false for excluded staff/Admin),
so the result sheet can say "Checked in · staff earn no points" rather than
claiming points that were never written.
- On a **first** check-in (and only when the event has a badge layout), enqueues
`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
@@ -162,7 +197,7 @@ from `checkin_attendee`, which checks someone into a specific session).
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, copies)`
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies, points_awarded)`
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.
@@ -178,6 +213,10 @@ printing.
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.
- `points_awarded` predicts the confirm's outcome — `true` only for a genuine
first check-in by someone `_points_eligible`. The popup uses it to promise
"Checking in awards +10 points" only when it is true, and to say "This person
does not earn points (staff or organiser)" otherwise.
### `merge_tickets(p_source_id, p_target_id)` -> `jsonb`
+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
+98 -1
View File
@@ -19,11 +19,12 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| **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. |
| **Sessions** | Everything about the **active event's sessions** in one place (nav sits between Schedule and Activity): one row per session with its slot date/time, room / level / area, **speakers**, **check-in count** (with capacity when set), **average rating and response count**, and whether an AI summary is stored, **out of date**, or impossible. Click a row to expand it: description, the full **speaker list**, the **roster of who checked in** (with time and which staff member scanned them), and the stored **AI summary**. A **search** box matches title, room, level, area or speaker, and the **attendee filter** answers "which sessions did this person actually attend?" — the list narrows to those sessions, the header states the count, and the expanded roster highlights that person. **Generate AI Feedback Summary** (see below) summarises every session with feedback in one click. Data comes from `sessions` ⨝ `slots` ⨝ `session_speakers` ⨝ `checkins` ⨝ `feedback`, joined in the client so the numbers match the other views exactly and no new RLS policy is needed. |
| **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** | **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). |
| **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, plus **Validate AI connection** — one real chat request against the stored settings, with the verdict left on the page (latency, the model's reply, and whether the provider reported **reasoning tokens**, i.e. whether thinking is actually off). See [../backend/printing.md](../backend/printing.md) and [../backend/feedback-ai.md](../backend/feedback-ai.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). |
@@ -111,6 +112,7 @@ apps/admin/src/
├─ lib/
│ ├─ supabase.ts # createClient (same-origin)
│ ├─ api.ts # typed wrapper: reads + writes (contacts, registrations, sponsors, schedule, points, printing)
│ ├─ useSilentRefresh.ts # background poll + 500 ms-after-write debounce (see "Staying fresh")
│ ├─ printStatus.tsx # PrintStatusProvider (5 s get_print_overview poll) + pill/hint helpers
│ └─ types.ts # TS types mirroring the DB (incl. BadgePrintPayload, PrintOverview)
├─ components/
@@ -128,6 +130,7 @@ apps/admin/src/
├─ Registrations.tsx# per-event list + type / QR token (view) / badge preview / checked-in + sponsor lookup
├─ Sponsors.tsx # sponsor CRUD
├─ Schedule.tsx # slots + sessions + speakers + material
├─ Sessions.tsx # per-session speakers / attendance / feedback + attendee filter + bulk AI summaries
├─ Activity.tsx # check-ins / connections / feedback tables
├─ Events.tsx # event management (+ sessionize_endpoint + per-row Sync + talk networking bonus + badge copies)
├─ Interfaces.tsx # sidecar status / run / recent runs
@@ -287,6 +290,100 @@ The obsolete Schedule evaluation stub has been removed and its RPC is no longer
client-callable. See the [backend contract](../backend/feedback-ai.md) for provider
compatibility, data privacy, permissions and deployment requirements.
### Validating the AI connection
**Settings → Feedback AI → Validate AI connection** calls the sidecar
(`POST /sidecar/llm-test`), which reads the **stored** settings, resolves the
endpoint through the same SSRF guard, and makes **one** real chat request
("Reply with OK") with the same body shape a summary uses. It always answers with
a verdict rather than an exception, so the UI can name the reason:
| What you see | Meaning |
|---|---|
| "Connection works — replied in 412 ms" | Endpoint, key and response parsing are all fine, and the provider reported **0 reasoning tokens**. |
| "Connection works, but the model is still thinking" | The transport is fine but reasoning tokens came back, so summaries will be slow and costly. The endpoint is ignoring the thinking-off fields. |
| "Connection failed" + one line of detail | No settings saved yet, a non-2xx from the provider (a wrong key reads as `HTTP 401: …`), an endpoint that failed validation, a timeout, or a reply with no content. |
Three things are deliberate here:
- The button is **disabled while the form has unsaved changes**. The key never
reaches the browser, so a test can only ever exercise what is stored — being
able to press it against half-typed values would report on the wrong endpoint.
- `reasoning_tokens: null` means the provider sent no `usage` block at all. It is
shown as "not reported by this endpoint", never as zero: **only `0` proves
thinking is off**, since these gateways answer `200 OK` while silently ignoring
fields they do not implement.
- The verdict is rendered on the page, not as a toast — the latency and the
reasoning line are worth reading twice, and a toast expires.
### Generate AI Feedback Summary (all sessions at once)
The **Sessions** view has one button that summarises every session with at least
one feedback response — one request per session, issued from the browser against
the existing `POST /sidecar/feedback-summary` route (no new backend endpoint, and
the per-target `409` guard in the sidecar still applies).
- Concurrency is capped at **3**. The gateway behind `ai.lago.dev` is a single
vLLM worker, so firing N requests at once only makes each one slower.
- The page is **blocked until every request has settled**: a full-screen overlay
with a spinner and a `done / total` counter, the button disabled, the filters
disabled, and the background poll paused so it cannot race the writes.
- Each result is stored as it arrives (`feedback_summaries`, keyed by
`(scope, target_id)`), so a run that dies halfway keeps what it finished, and a
re-run only has to redo the rest.
- One failing session does not stop the others. The summary line reports
`2 session summaries stored · 1 failed: Power Apps Deep Dive: <reason>`.
- A **Stop** button ends the loop after the in-flight requests return; stored
results stay stored.
- Summaries are **flagged as stale** in the table when the session's response
count has moved since they were generated, so nobody quotes an old digest.
Provider requests disable model thinking with both `reasoning_effort: "none"` and
`chat_template_kwargs: { enable_thinking: false }` — see
[../backend/feedback-ai.md](../backend/feedback-ai.md) for why both, and why a
`200` proves nothing on its own.
### Staying fresh (silent reload)
Every data view keeps itself current without a reload, through
[`lib/useSilentRefresh.ts`](../../apps/admin/src/lib/useSilentRefresh.ts):
- a background poll every **5 s** (15 s for **Reports**, which pulls nine tables
at once), and a debounced pull **500 ms** after any write, so a burst of edits
settles on the server before it is read back;
- **silent** has teeth: no spinner, no scroll jump, no `setLoaded(false)`, and
background errors are swallowed — these views render `if (error) return <Empty/>`,
so one failed poll would otherwise replace a good table with an error screen;
- never fires on mount (the view's own `load()` owns the first fetch), drops
overlapping ticks instead of queueing them, and pauses while the tab is hidden,
refreshing the moment it becomes visible again;
- **Registrations** patches in place: the current row order is preserved (the list
is sorted by points, so a naive reload slid the row you had just toggled
somewhere else), rows with a write in flight are left alone so an optimistic
checkbox cannot flicker back, new rows append at the end and removed rows
disappear. **Schedule** and **Contacts** pause while a modal is open; **Raffle**
never refreshes mid-spin, because the animation reads the pool.
This is what makes a phone scan by a colleague on the other side of the room show
up on the console within a few seconds.
### Points, and who does not earn them
The Registrations table shows a plain number for anyone who can earn points, and
for everyone else `— no points` in a tooltip that explains the rule: staff passes,
Admin contacts and `@appe.at` addresses are excluded by `_points_eligible` on
purpose, so a `0` there is not a broken check-in. The client-side mirror
(`canEarnPoints`) is commented to stay in step with the SQL predicate. The Contacts
points modal applies the same rule before the write: the **Apply** button is
disabled with an explanation, because `adjust_points` returns `void` and would
otherwise report success while having changed nothing.
`set_registration_checked_in` reports both halves of its work
(`points_removed`, `points_added`), and the toggle's toast says which happened —
`+20 check-in pts restored` when switching a pass back on tops the score up from
the check-in rows that still exist. See
[../backend/rpcs.md](../backend/rpcs.md#points-rules).
### Registration Tickets
Registration totals and check-in totals exclude blank/missing QR tokens. Unticketed
+3 -2
View File
@@ -50,8 +50,9 @@ These map 1:1 to the Postgres RPCs documented in
| `createConnectionRequest(targetQr)` | `create_connection_request` | Send a connection request |
| `acceptConnection(id)` | `accept_connection` | Accept (+5 to both) |
| `rejectConnection(id)` | `reject_connection` | Decline |
| `checkinAttendee(sessionId, attendeeQr)` | `checkin_attendee` | Staff session check-in (+10) |
| `welcomeCheckin(attendeeQr)` | `welcome_checkin` | Staff welcome check-in (marks present at event, no points) |
| `checkinAttendee(sessionId, attendeeQr)` | `checkin_attendee` | Staff session check-in (+10, or nothing for excluded staff — `points_awarded` says which) |
| `welcomeCheckin(attendeeQr)` | `welcome_checkin` | Staff welcome check-in (marks present at the event **and awards +10**, first time only; `points` + `points_awarded` report what happened) |
| `previewWelcomeCheckin(attendeeQr)` | `preview_welcome_checkin` | Read-only pre-confirm lookup: `{ already, will_print, copies, points_awarded }` |
| `submitFeedback(sessionId, rating, comment)` | `submit_feedback` | Rate a session (+5/+10) |
| `getLeaderboard()` | `get_leaderboard` | Active-event leaderboard |
| `uploadSessionMaterial(sessionId, file)` | `set_session_material` | Upload to `materials` bucket + set `material_path` |
+19 -7
View File
@@ -236,9 +236,15 @@ is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendee
between two sub-modes:
- **Session check-in** (default) — pick a session (dropdown grouped by slot,
**service sessions excluded** — they can't be checked into), then scan an
attendee's lanyard → `checkinAttendee(sessionId, qr)`. Shows a result sheet:
"✓ {name} — Checked in — +10 pts · now {total}" or "⚠️ Already checked in —
no extra points" (the `already` flag from the RPC). The `checkin_attendee`
attendee's lanyard → `checkinAttendee(sessionId, qr)`. The result sheet's
points line is **three-way**, because `points_awarded` says whether the award
actually landed:
- "⚠️ Already checked in — **No extra points**" (the `already` flag),
- "✓ {name} — Checked in — **+10 pts · now {total}**",
- "✓ {name} — Checked in — **Checked in · staff earn no points**" for the
people `_points_eligible` excludes. Before that flag existed the sheet
claimed "+10 pts · now 0", which read like a broken scanner.
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
@@ -252,10 +258,16 @@ is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendee
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
nothing would print). The sheet also states the points honestly:
**"Checking in awards +10 points."** when `points_awarded`, or **"This person
does not earn points (staff or organiser)."** when it does not — so the
promise is made before the write, not after. **Yes** runs `welcomeCheckin(qr)`,
which marks them present at the **event** (`registrations.checked_in = true`),
awards **+10** (category `checkin`, first check-in only — the same amount a
session scan pays) and queues `events.badge_copies` labels. Result sheet:
"👋 {name} — Welcome to the event!" with the same three-way points line as
the session sheet (`+10 pts · now {points}` / "No extra points" /
"Checked in · staff earn no points"). This is
the scan that opens the session gate above.
Data: `useEvent()` (for the session list) + the RPCs above.
+140
View File
@@ -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.