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

+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