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.
7.3 KiB
App Structure
Entry point, global state (contexts), the event hook, the tab shell, and the demo clock. For individual screens see screens.md; for the data layer see api-client.md.
Entry & providers (main.tsx, App.tsx)
App wraps everything in two providers, then renders the Shell:
<ToastProvider>
<AuthProvider>
<Shell />
</AuthProvider>
</ToastProvider>
ToastProvider— outermost, so any component (including auth) can show a toast.AuthProvider— holds the session + profile (below).Shell— decides what to render based on auth state (below).
AuthContext (context/AuthContext.tsx)
Holds the Supabase session, the current Contact, the current
Registration, and a loading flag.
- On mount, reads the persisted session (
supabase.auth.getSession()) and loads the contact + registration for that user's email. - Subscribes to
onAuthStateChangeso login/logout anywhere updates the context. loadContact(email)fetchescontactswhereemail = email(RLS returns only the caller's own row — see ../backend/rls.md);loadRegistration(email)fetches the caller'sregistrationsrow for the active event.- Exposes:
session,user,contact,registration,loading,refresh(),signOut().
The contact is the app's source of truth for the current user's
is_admin(staff powers); the registration holds the user'stype,points, andqr_token(the lanyard token, per event). After any points-changing action, screens re-fetch.
ToastContext (context/ToastContext.tsx)
Transient, auto-dismissing toasts. useToast().toast(message, 'ok' | 'err').
Used for login success, connection results, check-in results, and RPC errors.
The event hook (lib/useEvent.ts)
Loads the active event + agenda and exposes it in a convenient shape:
interface EventData {
event: Event | null; // the active event (name, dates, location)
slots: { slot: Slot; sessions: Session[] }[]; // grouped, ordered by slot id
sessionById: Map<string, Session>;
slotById: Map<number, Slot>;
now: Date; // the (simulated) event clock
loading: boolean;
error: string | null;
reload: () => void; // re-fetch (e.g. after a material upload)
}
- Calls
getAgenda()(theget_agenda()RPC) and groups the flat rows withgroupAgenda()(see api-client.md); also loads the active event viagetActiveEvent(). - Every screen that needs the schedule calls
useEvent()— the agenda is fetched per screen mount (cheap, and keeps each screen self-contained).
The event clock (lib/time.ts)
The app uses a simulated "now" so the demo always looks mid-event — it does not use the real system date:
export const EVENT_DATE = '2026-02-20';
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
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()):
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_NOWwithnew Date(). For a demo you'll show on arbitrary dates, a good middle ground is: usenew 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" |
The polling hook (lib/usePolling.ts)
usePolling(fn, ms, enabled) runs fn every ms milliseconds, but only while
the tab is visible (document.visibilityState === 'visible'), and re-runs
immediately when the tab becomes visible again. No background polling. Used by
the Connections screen (5s) and the Shell's pending-connection red dot (5s).
The Shell (App.tsx)
The Shell is the navigation container. Render logic, in order:
loading→ full-screen spinner.- No session / no profile →
<Login />(full screen, no tab bar). feedbackSessionset →<Feedback />full-screen takeover (no tab bar).- Otherwise → the active tab + the bottom tab bar.
Tabs
| Tab id | Label | Screen | Notes |
|---|---|---|---|
home |
🏠 Home | Home |
default tab |
agenda |
📅 Agenda | Agenda |
|
scan |
📷 Scan / Check-in | Scan |
label is role-aware (below) |
connections |
🤝 Connect | Connections |
red dot when there are pending incoming requests |
profile |
👤 Profile | Profile |
- Role-aware Scan tab: if
contact.is_adminis true, the tab label is "Check-in" and theScanscreen defaults to staff mode. Otherwise it's "Scan". - Leaderboard is not a tab — it's reached from the Home points pill and the
Home quick-actions. It renders as a tab in the shell but is opened via
go('leaderboard'). - Feedback is a full-screen takeover (no tab bar), opened from the Agenda
session sheet via
openFeedback(sessionId).
Shared UI components (components/ui.tsx)
| Component | Purpose |
|---|---|
Avatar |
Colored initials circle (color derived from a hash of the id) |
Spinner |
Loading indicator |
Empty |
Empty-state placeholder (icon + text) |
Sheet |
Bottom-sheet modal (backdrop + grab handle) |
QrImage |
Renders a string (e.g. a QR token) as a scannable QR (qrcode.react) |
Scanner |
Camera QR scanner (html5-qrcode) with a manual-entry fallback and a hasCamera guard (headless/no-camera environments fall back to typing the code) |