Service sessions + Home redesign + feedback loop

Service sessions (new slot semantics):
- Sidecar maps isServiceSession OR isPlenumSession -> service_session
  (Excel path also matches 'plenum' in Session Format).
- checkin_attendee rejects service sessions; Scan check-in dropdown
  excludes them.
- New _assign_service_session_speakers helper links every registered
  staff member as a speaker of a service session; both sync RPCs call
  it (and the API sync now actually types slots from is_service_session).
- No material requirement + no mic emoji for service sessions.

Home redesign:
- Now/Next cards show all concurrent sessions as sub-sections when
  there's no pick (1/2/3 sessions -> 1/2/3 sub-sections), with a
  "Nothing scheduled" fallback for empty slots.
- My picks today lists every pick (slot order) + empty state.
- Demo clock EVENT_DATE fixed to 2026-02-20 (matches seed) so a slot
  is live at 10:20.

Feedback loop:
- Attendee pending-feedback pill on Home (checked into an over session,
  not its speaker, no feedback yet); clears on submit.
- Speaker sees rating + AI summary for their own session in the Agenda
  sheet only after it's over.

Migration 20260833000000_service_sessions_feedback.sql. Docs updated.
This commit is contained in:
Lago committed 2026-08-25 08:58:16 +02:00
1 parent 2db22984fc
commit a5ad9795ee
15 files changed
+878 -105

No files matched your search

+23 -5
View File
@@ -99,6 +99,9 @@ Staff checks an attendee into a session.
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
`staff or admin only`.
- Resolves the attendee by `qr_token`.
- **Service-session guard:** if the session's slot is a `service_session`, it
raises `service sessions cannot be checked in` (there's nothing to check into —
everyone is in the room).
- `insert into checkins ... on conflict (event_id, contact_email, session_id) do
nothing returning id` — if no row was inserted, the attendee was **already
checked in**: sets `already = true` and awards **no points**.
@@ -208,13 +211,20 @@ Imports an event's Sessionize data in order: (1) speakers → contacts (matched
email), (2) sessions (upserted by `external_id`), (3) the agenda (slots
find-or-created by date/start/end + `session_speakers` links). `p_payload` is
`{ speakers: [{email, full_name, external_id?}], sessions: [{external_id, title,
description?, room?, date, start_time, end_time, speakers: [email,...]}] }`.
description?, room?, date, start_time, end_time, is_service_session?, speakers:
[email,...]}] }`.
- Guarded to the `service_role` caller (JWT role claim); granted to `service_role`
only — the apps cannot call it.
- **Slots are typed from `is_service_session`** (`service_session` for
breaks/lunch/closing/plenums, else `session`) with a matching name
("Service Session" vs "Slot HH:MM–HH:MM").
- **Idempotent:** re-running updates in place (contacts by email, sessions by
`external_id`, slots by date/start/end). Speaker links are **diffed** (insert the
new set, then delete only removed) so the `session_needs_speaker` trigger never
blocks a removal.
- **Service sessions:** every registered **staff** member is linked as a speaker
(via `_assign_service_session_speakers`) — a service session has no individual
speaker, so the whole staff team "owns" it.
- Linking a speaker fires `session_speakers_speaker_promote`, which promotes an
existing registration to `speaker`. **No registrations are created** — the ticket
sync does that (checking `session_speakers` by email).
@@ -233,8 +243,10 @@ extra step:
1. **Speakers → contacts** (matched by email; also sets `linkedin_url`).
2. **Sessions + agenda** — slots are typed from `is_service_session`
(`service_session` for breaks/lunch/closing, else `session`), sessions
upserted by `external_id`, speaker links diffed.
(`service_session` for breaks/lunch/closing/plenums, else `session`), sessions
upserted by `external_id`, speaker links diffed. **Service sessions** also get
every registered **staff** member linked as a speaker (via
`_assign_service_session_speakers`).
3. **Speaker registrations** — for every speaker, creates a `speaker`
registration or updates an existing `attendee` one to `speaker`
(`on conflict (event_id, contact_email)`). **Never overrides `staff` /
@@ -262,10 +274,16 @@ extra step:
All are `security definer` so they can read `contacts` / `registrations` /
`session_speakers` inside RLS checks and RPC guards.
## Internal helpers
| Function | Returns | Meaning |
|---|---|---|
| `_assign_service_session_speakers(p_session_id, p_event_id)` | `integer` | Links **every registered staff member** of the event as a speaker of the given session (`on conflict do nothing`). Returns the number of rows affected. Called by both Sessionize sync RPCs for `service_session` sessions — a service session has no individual speaker, so the whole staff team "owns" it. |
## Error handling
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
connect with yourself`, `staff or admin only`, `you must be checked in to this
session to give feedback`, `not a speaker of this session`). The frontend
surfaces these via toasts — see
session to give feedback`, `not a speaker of this session`, `service sessions
cannot be checked in`). The frontend surfaces these via toasts — see
[../frontend/api-client.md](../frontend/api-client.md).
+1 -1
View File
@@ -136,7 +136,7 @@ Unpaid sponsors are hidden from non-admins (RLS).
|---|---|---|
| `id` | `integer` PK | `nextval('slots_id_seq')` default — the UI/sidecar can create a slot **without** supplying an id (the seed inserts explicit ids and re-syncs the sequence) |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `type` | `slot_type` (enum) | **`session` \| `service_session`** (default `session`) — a true optionset, not freetext. `service_session` = breaks / lunch / closing (Sessionize's `isServiceSession`) |
| `type` | `slot_type` (enum) | **`session` \| `service_session`** (default `session`) — a true optionset, not freetext. `service_session` = breaks / lunch / closing / plenums (Sessionize's `isServiceSession` **or** `isPlenumSession`) |
| `name` | `text` | e.g. "Slot 09:00–09:45" / "Service Session" |
| `slot_date` | `date` | |
| `start_time` / `end_time` | `time` | |
+10 -2
View File
@@ -26,14 +26,22 @@ date/start/end + `session_speakers` links). The public `/view/` payload has no
speaker emails, so this path imports sessions + agenda but **skips speakers**
(unless an authenticated `/api/` endpoint + key is configured).
> **Service sessions.** A session is flagged `is_service_session` when
> Sessionize marks it `isServiceSession` **or** `isPlenumSession` (a plenum is a
> full-hall item — breaks, lunch, closing, or a plenary — with no individual
> speaker). The RPC then types its slot `service_session` and links every
> registered **staff** member as a speaker.
**B. Excel import** (`POST /import-excel`) — the admin uploads the Sessionize
**"Sessions and speakers (advanced)"** `.xlsx` export (generated on the fly by
any organizer with admin access to the event). The sidecar parses it (two sheets:
*Accepted sessions* + *Accepted speakers*) and calls the
`sync_sessionize_excel` RPC, which imports, in order: (1) speakers as contacts
(matched by **email** — the Excel carries emails, so this is reliable), (2)
sessions + agenda (slots typed `session` / `service_session` from
`isServiceSession` + `session_speakers` links), and (3) **a `speaker`
sessions + agenda (slots typed `session` / `service_session` from the
**Session Format** column — `service`/`break`/`lunch`/`closing`/`plenum` →
`service_session` — + `session_speakers` links, with every registered **staff**
member linked as a speaker of service sessions), and (3) **a `speaker`
registration for every speaker** (create, or update `attendee`→`speaker`; never
overrides `staff`/`sponsor`). This is the path that creates the missing speaker
contacts + registrations.
+51 -8
View File
@@ -71,27 +71,70 @@ interface EventData {
## The event clock (`lib/time.ts`)
The app uses a **simulated "now"** so the demo always looks mid-event:
The app uses a **simulated "now"** so the demo always looks mid-event — it does
**not** use the real system date:
```ts
export const EVENT_DATE = '2026-10-23';
export const EVENT_DATE = '2026-02-20';
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
```
At `10:20`, **Slot 1 (09:00–09:45) is `done`** and **Slot 2 (10:00–10:45) is
`now`** — matching the mockup. Helpers:
`EVENT_DATE` matches the seed's event day. `DEFAULT_NOW` is frozen at **10:20 on
the event day**, so the demo shows a live session no matter what the actual
calendar date is (open it on 25 Aug 2026 and it still looks like it's 10:20 on
20 Feb).
### How "Live" / "Up next" / "Done" is decided
`slotStatus(slot, now)` compares the slot's start/end against `now` (the
simulated clock, **not** `new Date()`):
```ts
export function slotStatus(slot: Slot, now: Date): SlotStatus {
if (now >= slotEnd(slot)) return 'done'; // slot ended before "now"
if (now >= slotStart(slot)) return 'now'; // "now" is inside the slot → Live
return 'next'; // slot starts after "now" → Up next
}
```
`useEvent()` exposes `now: DEFAULT_NOW`, and the screens derive:
- **current** (the **Now** card) = the first slot where `slotStatus === 'now'`
- **next** (the **Next** card) = the first slot where `slotStatus === 'next'`
At the frozen `10:20`, the seed's slots resolve to:
| Slot | Time | `slotStatus` at 10:20 |
|---|---|---|
| Slot 1 | 09:15–10:00 | `done` |
| Slot 2 | 10:15–11:00 | `now` → **● Live** |
| Slot 3 | 11:15–12:00 | `next` → **Up next** |
| Slot 4+ | … | `next` → **Up next** |
So the Home screen shows a live Now card, an upcoming Next card, and a done slot
that can carry a pending-feedback nudge.
> **Why a simulated clock?** The event day (20 Feb 2026) is in the past relative
> to "today", so a real clock would mark **every** slot `done` — there'd be no
> Live or Next card, just a wall of "Done". The frozen clock is what keeps the
> demo looking alive on any date.
> **Using the real clock.** This is a **frontend-only** concern — the database
> stores real slot times; the clock only decides which slot is "live" for
> display. To drive it off the real date, replace `DEFAULT_NOW` with
> `new Date()`. For a demo you'll show on arbitrary dates, a good middle ground
> is: use `new Date()` when the event day is still in the future/present, and
> fall back to the simulated mid-event clock once the event day has passed.
Helpers:
| Function | Returns |
|---|---|
| `slotStatus(slot, now)` | `'done'` \| `'now'` \| `'next'` |
| `slotStart(slot)` / `slotEnd(slot)` | `Date` for the slot's start / end |
| `fmtTime(time)` | `"09:00"` from `"09:00:00"` |
| `fmtRange(slot)` | `"09:00–09:45"` |
| `greeting(now)` | "Good morning" / "afternoon" / "evening" |
> This is a **frontend-only** concern. The database stores real slot times; the
> clock just decides which slot is "live" for display. To use the real clock,
> replace `DEFAULT_NOW` with `new Date()`.
## The polling hook (`lib/usePolling.ts`)
`usePolling(fn, ms, enabled)` runs `fn` every `ms` milliseconds, but **only while
+58 -27
View File
@@ -47,49 +47,77 @@ A 3-step flow: **splash → scan → confirm**.
The landing screen. Shows:
- **Greeting + pills** — "Good morning, Ana 👋" and, to the right, a **red
material pill** `📎 {n}` (only for speakers who have one or more of their
sessions without material — tapping it opens a popup listing the pending
sessions) and the **points pill** `⚡ {points}` (tapping opens the Leaderboard).
The event name (`event.name`) is shown under the greeting.
**non-service** sessions without material — tapping it opens a popup listing
the pending sessions) and the **points pill** `⚡ {points}` (tapping opens the
Leaderboard). The event name (`event.name`) is shown under the greeting.
- **Pending-feedback pill** — a full-width **"⭐ Rate your last session"** (or
"Rate N sessions") button, shown only when the user is checked into one or more
**over** sessions, is **not** the speaker of that session, and **hasn't**
submitted feedback for it yet. It stays while feedback is pending and disappears
once submitted. Tapping goes to the Agenda (where the "Give feedback ⭐" button
lives on the session sheet).
- **Now card** — **always shown** for the current slot. If the user has a pick,
the session title + a "✓ Checked in" / "Show your QR to staff to check in"
pill; otherwise a "No pick yet" placeholder (identical layout for every role).
- **Next card** — **always shown** for the next slot (pick or "No pick yet").
- **My picks today** — shows only **2 rows** (the current slot's pick + the next
slot's pick). "tap to change" is a **hyperlink** to the Agenda.
the picked session's title + room + speaker + a "✓ Checked in" / "Show your QR
to staff to check in" pill. **If there's no pick, the card still shows what's
running** — one clean sub-section per concurrent session (title + room +
speaker), so a slot with 1, 2, or 3 sessions renders 1, 2, or 3 sub-sections.
If the slot has no sessions at all, a "Nothing scheduled right now." line.
- **Next card** — **always shown** for the next slot (same pick / concurrent-list
logic as the Now card, without the check-in pill).
- **My picks today** — one row per pick the user has made **today** (in slot
order), each showing the slot time + session title + room. "tap to change" is a
**hyperlink** to the Agenda. With no picks, a "No picks yet" line.
- **Quick actions** — Scan & connect, Agenda, Connections, Leaderboard.
- **No active event** — a graceful empty state ("No active event right now.
Check back soon!").
> **Identical for every role.** The Home screen (and the tab bar) is the same for
> attendees and staff — no role badge, no "Check-in" relabel. The Now/Next cards
> always render (with a "No pick yet" placeholder when there's no pick), so the
> layout is identical whether or not the user has picks. Staff keep their check-in
> capability inside the **Scan** screen (Attendee/Staff mode toggle).
> always render (with a concurrent-session list or "Nothing scheduled" when there's
> no pick), so the layout is identical whether or not the user has picks. Staff
> keep their check-in capability inside the **Scan** screen (Attendee/Staff mode
> toggle).
Data: `useEvent()` (event + agenda + clock) + `getMyPreferences()` +
`getMyCheckins(email)` + `getMySpeakerSessions(email)` (for the pending-material
pill). Slot status comes from `slotStatus(slot, now)`
pill) + `getMyFeedback(email)` (for the pending-feedback pill). Slot status comes
from `slotStatus(slot, now)`
([app-structure.md#the-event-clock](./app-structure.md#the-event-clock)).
## Agenda
Lists all slots, each with its sessions, a **slot-type badge** (keynote / session
/ lunch break / coffee break / close up), and a status pill (**Done / ● Live /
Up next**). The user's pick per slot is highlighted (filled check). A session the
user speaks shows a **"🎤 you"** tag; a session with material shows a **📎**.
Lists all slots, each with its sessions, a **slot-type badge** (**Session** /
**Service Session** — the `slot_type` enum, capitalized), and a status pill
(**Done / ● Live / Up next**). The user's pick per slot is highlighted (filled
check). A session the user speaks shows a **"🎤 you"** tag; a session with
material shows a **📎**.
**Service sessions** (breaks / lunch / closing / plenums) are treated
differently:
- the **pick circle (✓) is hidden** — they can't be picked (the sheet shows
"No pick needed for this slot." instead of the pick button);
- the **🎤 mic emoji is never shown** (neither the "🎤 you" tag nor the mic in
the speaker pill) — service sessions have no individual speaker;
- they have **no material requirement** (the pending-material notice never
applies to them).
- **Tap a session** → opens a bottom **sheet** with details (description,
speakers, room, capacity, checked-in state) and actions:
- **Give feedback ⭐** — only when the session is *done* **and** the user is
checked in. Opens the Feedback takeover (`openFeedback(sessionId)`).
- **Speaker feedback review** — when the user is a **speaker** of the session
**and** the session is *done*, a **"⭐ Your session feedback"** block shows the
session's **average rating** (stars + number) and the **AI-generated summary**
(`ai_generated_feedback`). It is **never shown while the session is still
running** — only after it's over.
- **Pick / Remove my pick** — `setPreference(sessionId)` / `clearPreference(slotId)`.
- **Speaker material** — if the user is a speaker of the session and no material
is uploaded yet, a **non-dismissible** "📎 Upload your session material" notice
with a file input. Uploading stores the file in the `materials` bucket and
calls `set_session_material` (via `uploadSessionMaterial`). Once uploaded, the
notice is gone and a **📎 Download material** button appears (visible to **all**
attendees), pinned to the **bottom** of the sheet's button stack (below
"Pick this session").
- **Speaker material** — if the user is a speaker of a **non-service** session
and no material is uploaded yet, a **non-dismissible** "📎 Upload your session
material" notice with a file input. Uploading stores the file in the
`materials` bucket and calls `set_session_material` (via
`uploadSessionMaterial`). Once uploaded, the notice is gone and a **📎
Download material** button appears (visible to **all** attendees), pinned to
the **bottom** of the sheet's button stack (below "Pick this session").
- **Remove material** — a speaker of the session can also **🗑 Remove material**
(to re-upload). This deletes the storage object and clears `material_path` via
`set_session_material` (null) — `removeSessionMaterial`.
@@ -112,10 +140,13 @@ is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendee
yourself. Result toast reflects the connection status (sent / already connected).
- **Staff mode (check-in):** a **check-in type toggle** (uiverse switch) switches
between two sub-modes:
- **Session check-in** (default) — pick a session (dropdown grouped by slot),
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).
- **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`
RPC also rejects a service session server-side ("service sessions cannot be
checked in").
- **Welcome check-in** — no session dropdown; scanning an attendee's lanyard →
`welcomeCheckin(qr)` marks them present at the **event**
(`registrations.checked_in = true`, no points). Result sheet: "👋 {name} —
+44 -1
View File
@@ -31,7 +31,16 @@ current phase.
> speaker contacts, session links, and `speaker` registrations by email; `slots.type`
> is now a `session`/`service_session` enum; the seed uses the real Global Power
> Platform Bootcamp (Austria) agenda + 50 attendees + 4 staff, with the event's
> endpoint set and speakers added via the Excel import).
> endpoint set and speakers added via the Excel import), and
> **Service sessions + Home redesign + feedback loop** (a session is a
> `service_session` when Sessionize marks it `isServiceSession` **or**
> `isPlenumSession`; service sessions can't be checked in, have every registered
> staff member as their speaker, no material requirement, and no mic emoji; the
> Home Now/Next cards show **all concurrent sessions** as sub-sections when there's
> no pick; attendees who attended an over session (and aren't its speaker) get a
> pending-feedback pill on Home that clears once they rate it; and a session's
> speaker can see the rating + AI summary for their own session only after it's
> over).
> Remaining work is cross-cutting (real event clock, deployment, testing, and the
> ticket/Pretix sync that will consume the speaker links by email).
@@ -429,6 +438,40 @@ Migration `20260829000000_registration_type_optionset_speaker_promote_welcome_ch
- Bruno and Rita now have `contacts.password = 'appe-admin-2026'` so the Convivo
**staff QR login** (QR + staff password) works out of the box after a reset.
## Service sessions + Home redesign + feedback loop — ✅ complete
**Service sessions (new slot semantics).** A session is a `service_session` when
Sessionize marks it `isServiceSession` **or** `isPlenumSession` (the sidecar maps
both; the Excel path matches `service`/`break`/`lunch`/`closing`/`plenum` in the
Session Format column). Service sessions:
- **can't be checked in** — `checkin_attendee` raises `service sessions cannot be
checked in`, and the Scan check-in dropdown excludes them.
- **have every registered staff member as their speaker** — both sync RPCs call
the new `_assign_service_session_speakers` helper for service sessions.
- **have no material requirement** — excluded from the pending-material pill and
the Agenda upload notice.
- **never show the mic emoji** — no "🎤 you" tag and no mic in the speaker pill.
**Home redesign.** The **Now** and **Next** cards now show **all concurrent
sessions** as clean sub-sections (title + room + speaker) when the user has no
pick — so a slot with 1, 2, or 3 sessions renders 1, 2, or 3 sub-sections — and
fall back to "Nothing scheduled" when the slot is empty. **My picks today** lists
every pick the user has made (in slot order) with a "No picks yet" empty state.
The demo clock (`EVENT_DATE`) now matches the seed's event day (2026-02-20) so a
slot is live.
**Feedback loop.**
- **Attendee:** anyone checked into an **over** session (any registration type,
**except** the session's own speaker) sees a **"⭐ Rate your last session"** pill
on Home while feedback is pending; it disappears once they submit.
- **Speaker:** a session's speaker can see the **rating + AI summary** for their
own session in the Agenda sheet — **only after the session is over**, never
during.
**Migration:** [`20260833000000_service_sessions_feedback.sql`](../../supabase/migrations/20260833000000_service_sessions_feedback.sql)
adds `_assign_service_session_speakers`, re-creates `checkin_attendee` (service
guard) and both sync RPCs (service-session typing + staff speakers).
## Cross-cutting / later
- **Real event clock** — replace the simulated `DEFAULT_NOW`