Real-time clock toggle: per-event use_realtime_clock flag

- Migration 20260834000000: events.use_realtime_clock (boolean, default false)
- Admin: Real-time clock toggle in the Events create/edit modal
- Convivo: useEvent picks new Date() vs simulated DEFAULT_NOW from the flag;
  Home shows a 'Demo clock' badge only in simulated mode
- Docs: app-structure, admin-app, schema, next-steps

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-08-25 09:22:28 +02:00
1 parent bd67debeef
commit f9a8513620
11 files changed
+113 -23

No files matched your search

+1
View File
@@ -152,6 +152,7 @@ export async function upsertEvent(
end_date: string; end_date: string;
location?: string | null; location?: string | null;
sessionize_endpoint?: string | null; sessionize_endpoint?: string | null;
use_realtime_clock?: boolean;
}, },
): Promise<void> { ): Promise<void> {
if (id) { if (id) {
+2
View File
@@ -31,6 +31,8 @@ export interface Event {
end_date: string; end_date: string;
location: string | null; location: string | null;
is_active: boolean; is_active: boolean;
/** When true, the Convivo app uses the real system clock for slot status. */
use_realtime_clock: boolean;
/** Sessionize API URL for this event (e.g. .../api/v2/<id>/view/All). */ /** Sessionize API URL for this event (e.g. .../api/v2/<id>/view/All). */
sessionize_endpoint: string | null; sessionize_endpoint: string | null;
/** When the Sessionize sync last ran for this event. */ /** When the Sessionize sync last ran for this event. */
+15
View File
@@ -174,6 +174,7 @@ function EventModal({
const [endDate, setEndDate] = useState(event ? event.end_date.slice(0, 10) : ''); const [endDate, setEndDate] = useState(event ? event.end_date.slice(0, 10) : '');
const [location, setLocation] = useState(event?.location ?? ''); const [location, setLocation] = useState(event?.location ?? '');
const [endpoint, setEndpoint] = useState(event?.sessionize_endpoint ?? ''); const [endpoint, setEndpoint] = useState(event?.sessionize_endpoint ?? '');
const [realtimeClock, setRealtimeClock] = useState(event?.use_realtime_clock ?? false);
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
async function save() { async function save() {
@@ -186,6 +187,7 @@ function EventModal({
end_date: endDate, end_date: endDate,
location: location.trim() || null, location: location.trim() || null,
sessionize_endpoint: endpoint.trim() || null, sessionize_endpoint: endpoint.trim() || null,
use_realtime_clock: realtimeClock,
}); });
onSaved(event ? 'Event updated' : 'Event created'); onSaved(event ? 'Event updated' : 'Event created');
} catch (e) { } catch (e) {
@@ -242,6 +244,19 @@ function EventModal({
“Run sync” button. You can also import the .xlsx export in the Interfaces menu. “Run sync” button. You can also import the .xlsx export in the Interfaces menu.
</div> </div>
</div> </div>
<div className="field">
<div className="row between" style={{ alignItems: 'center' }}>
<div>
<label>Real-time clock</label>
<div className="muted small" style={{ marginTop: 2 }}>
{realtimeClock
? 'The app uses the real system clock for Live/Next/Done.'
: 'The app uses a simulated mid-event clock (demo always looks live).'}
</div>
</div>
<Toggle checked={realtimeClock} onChange={setRealtimeClock} label={realtimeClock ? 'On' : 'Off'} />
</div>
</div>
</Modal> </Modal>
); );
} }
+2
View File
@@ -33,6 +33,8 @@ export interface Event {
end_date: string; end_date: string;
location: string | null; location: string | null;
is_active: boolean; is_active: boolean;
/** When true, the app uses the real system clock for slot status (Live/Next/Done). */
use_realtime_clock: boolean;
avg_feedback: number | null; avg_feedback: number | null;
num_sessions: number; num_sessions: number;
num_speakers: number; num_speakers: number;
+9 -1
View File
@@ -9,6 +9,8 @@ export interface EventData {
sessionById: Map<string, Session>; sessionById: Map<string, Session>;
slotById: Map<number, Slot>; slotById: Map<number, Slot>;
now: Date; now: Date;
/** Which clock drives slot status: the simulated mid-event clock or the real one. */
clockMode: 'simulated' | 'realtime';
loading: boolean; loading: boolean;
error: string | null; error: string | null;
reload: () => void; reload: () => void;
@@ -48,12 +50,18 @@ export function useEvent(): EventData {
for (const s of sessions) sessionById.set(s.id, s); for (const s of sessions) sessionById.set(s.id, s);
} }
// The event's `use_realtime_clock` flag decides the clock: the real system
// time, or the simulated mid-event clock (so the demo always looks live).
const clockMode: 'simulated' | 'realtime' = event?.use_realtime_clock ? 'realtime' : 'simulated';
const now = clockMode === 'realtime' ? new Date() : DEFAULT_NOW;
return { return {
event, event,
slots, slots,
sessionById, sessionById,
slotById, slotById,
now: DEFAULT_NOW, now,
clockMode,
loading, loading,
error, error,
reload: () => setNonce((n) => n + 1), reload: () => setNonce((n) => n + 1),
+6 -1
View File
@@ -44,7 +44,7 @@ function ConcurrentList({ sessions }: { sessions: Session[] }) {
export function Home({ go }: { go: (tab: string) => void }) { export function Home({ go }: { go: (tab: string) => void }) {
const { contact, registration } = useAuth(); const { contact, registration } = useAuth();
const { event, slots, sessionById, slotById, now, loading } = useEvent(); const { event, slots, sessionById, slotById, now, clockMode, loading } = useEvent();
const [prefs, setPrefs] = useState<Preference[]>([]); const [prefs, setPrefs] = useState<Preference[]>([]);
const [checkins, setCheckins] = useState<string[]>([]); const [checkins, setCheckins] = useState<string[]>([]);
const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]); const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]);
@@ -141,6 +141,11 @@ export function Home({ go }: { go: (tab: string) => void }) {
<div> <div>
<div className="h1">{greeting(now)}, {firstName} 👋</div> <div className="h1">{greeting(now)}, {firstName} 👋</div>
<div className="muted small">{event.name}</div> <div className="muted small">{event.name}</div>
{clockMode === 'simulated' && (
<div className="muted small" style={{ marginTop: 2 }}>
🎬 Demo clock
</div>
)}
</div> </div>
<div className="row" style={{ gap: 8 }}> <div className="row" style={{ gap: 8 }}>
{pendingMaterial.length > 0 && ( {pendingMaterial.length > 0 && (
+1
View File
@@ -78,6 +78,7 @@ queries everything for the active event and handles "no active event" gracefully
| `num_registrations` | `integer` | maintained aggregate | | `num_registrations` | `integer` | maintained aggregate |
| `num_checked_in_registrations` | `integer` | maintained aggregate | | `num_checked_in_registrations` | `integer` | maintained aggregate |
| `sessionize_endpoint` | `text` | nullable — the Sessionize API URL for this event (see [sidecar.md](./sidecar.md)) | | `sessionize_endpoint` | `text` | nullable — the Sessionize API URL for this event (see [sidecar.md](./sidecar.md)) |
| `use_realtime_clock` | `boolean` | default `false` — when `true`, the attendee app drives slot status (Live/Next/Done) from the real system clock; when `false` it uses the simulated mid-event clock (see [../frontend/app-structure.md](../frontend/app-structure.md)) |
| `last_synced_at` | `timestamptz` | nullable — when the Sessionize sync last ran | | `last_synced_at` | `timestamptz` | nullable — when the Sessionize sync last ran |
| `created_at` | `timestamptz` | | | `created_at` | `timestamptz` | |
+1 -1
View File
@@ -19,7 +19,7 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). | | **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, `average_feedback`, `ai_generated_feedback` + an **Evaluate** stub button). | | **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, `average_feedback`, `ai_generated_feedback` + an **Evaluate** stub button). |
| **Activity** | Tables of check-ins, connections, and feedback (per active event). | | **Activity** | Tables of check-ins, connections, and feedback (per active event). |
| **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**. Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. | | **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). 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). | | **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). |
## Auth guard ## Auth guard
+32 -14
View File
@@ -56,7 +56,8 @@ interface EventData {
slots: { slot: Slot; sessions: Session[] }[]; // grouped, ordered by slot id slots: { slot: Slot; sessions: Session[] }[]; // grouped, ordered by slot id
sessionById: Map<string, Session>; sessionById: Map<string, Session>;
slotById: Map<number, Slot>; slotById: Map<number, Slot>;
now: Date; // the (simulated) event clock now: Date; // the event clock (simulated or real, see below)
clockMode: 'simulated' | 'realtime'; // which clock `now` came from
loading: boolean; loading: boolean;
error: string | null; error: string | null;
reload: () => void; // re-fetch (e.g. after a material upload) reload: () => void; // re-fetch (e.g. after a material upload)
@@ -71,8 +72,11 @@ interface EventData {
## The event clock (`lib/time.ts`) ## The event clock (`lib/time.ts`)
The app uses a **simulated "now"** so the demo always looks mid-event — it does The app drives slot status (Live / Up next / Done) from a **"now"** that is
**not** use the real system date: either the **real system clock** or a **simulated mid-event clock**, decided per
event by the `events.use_realtime_clock` flag (see
[admin-app.md](./admin-app.md) for the toggle). By default it's the simulated
clock, so the demo always looks mid-event:
```ts ```ts
export const EVENT_DATE = '2026-02-20'; export const EVENT_DATE = '2026-02-20';
@@ -84,10 +88,23 @@ 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 calendar date is (open it on 25 Aug 2026 and it still looks like it's 10:20 on
20 Feb). 20 Feb).
`useEvent()` picks the clock from the flag and exposes both the resulting `now`
and which mode it used:
```ts
const clockMode: 'simulated' | 'realtime' = event?.use_realtime_clock ? 'realtime' : 'simulated';
const now = clockMode === 'realtime' ? new Date() : DEFAULT_NOW;
```
The Home header shows a **🎬 Demo clock** indicator only when the simulated
clock is active — when the real clock is on, nothing is shown (a real clock is
the expected state, so it needs no badge).
### How "Live" / "Up next" / "Done" is decided ### How "Live" / "Up next" / "Done" is decided
`slotStatus(slot, now)` compares the slot's start/end against `now` (the `slotStatus(slot, now)` compares the slot's start/end against `now` (the clock
simulated clock, **not** `new Date()`): chosen above — simulated by default, or `new Date()` when the event's
`use_realtime_clock` is on):
```ts ```ts
export function slotStatus(slot: Slot, now: Date): SlotStatus { export function slotStatus(slot: Slot, now: Date): SlotStatus {
@@ -97,7 +114,7 @@ export function slotStatus(slot: Slot, now: Date): SlotStatus {
} }
``` ```
`useEvent()` exposes `now: DEFAULT_NOW`, and the screens derive: `useEvent()` exposes `now` (the chosen clock), and the screens derive:
- **current** (the **Now** card) = the first slot where `slotStatus === 'now'` - **current** (the **Now** card) = the first slot where `slotStatus === 'now'`
- **next** (the **Next** card) = the first slot where `slotStatus === 'next'` - **next** (the **Next** card) = the first slot where `slotStatus === 'next'`
@@ -113,17 +130,18 @@ At the frozen `10:20`, the seed's slots resolve to:
So the Home screen shows a live Now card, an upcoming Next card, and a done slot So the Home screen shows a live Now card, an upcoming Next card, and a done slot
that can carry a pending-feedback nudge. that can carry a pending-feedback nudge.
> **Why a simulated clock?** The event day (20 Feb 2026) is in the past relative > **Why a simulated clock by default?** The event day (20 Feb 2026) is in the
> to "today", so a real clock would mark **every** slot `done` — there'd be no > past relative to "today", so a real clock would mark **every** slot `done` —
> Live or Next card, just a wall of "Done". The frozen clock is what keeps the > there'd be no Live or Next card, just a wall of "Done". The frozen clock is
> demo looking alive on any date. > what keeps the demo looking alive on any date.
> **Using the real clock.** This is a **frontend-only** concern — the database > **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 > 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 > display. Flip the event's **Real-time clock** toggle in the admin app
> `new Date()`. For a demo you'll show on arbitrary dates, a good middle ground > (Events → Edit) to switch an event to the real system clock. With it on,
> is: use `new Date()` when the event day is still in the future/present, and > `now` is `new Date()`, so a past event shows every slot as Done and no
> fall back to the simulated mid-event clock once the event day has passed. > Now/Next card; a live event tracks the actual time of day. Turn it back off
> to return to the simulated mid-event clock.
Helpers: Helpers:
+25 -6
View File
@@ -40,9 +40,13 @@ current phase.
> no pick; attendees who attended an over session (and aren't its speaker) get a > 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 > 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 > speaker can see the rating + AI summary for their own session only after it's
> over). > over), and
> Remaining work is cross-cutting (real event clock, deployment, testing, and the > **Real-time clock toggle** (a per-event `events.use_realtime_clock` flag,
> ticket/Pretix sync that will consume the speaker links by email). > toggled in the admin Events view, switches the attendee app between the real
> system clock and the simulated mid-event clock for Live/Next/Done status; the
> Home header shows a 🎬 Demo clock badge only in simulated mode).
> Remaining work is cross-cutting (deployment, testing, and the ticket/Pretix
> sync that will consume the speaker links by email).
## Done ## Done
@@ -472,11 +476,26 @@ slot is live.
adds `_assign_service_session_speakers`, re-creates `checkin_attendee` (service adds `_assign_service_session_speakers`, re-creates `checkin_attendee` (service
guard) and both sync RPCs (service-session typing + staff speakers). guard) and both sync RPCs (service-session typing + staff speakers).
## Real-time clock toggle — ✅ complete
A per-event flag lets the admin decide, in real time, whether the attendee app
drives slot status (Live/Next/Done) from the **real system clock** or the
**simulated mid-event clock** (the default, so the demo always looks live).
- **Schema:** `events.use_realtime_clock` (`boolean`, default `false`).
- **Admin:** a **Real-time clock** toggle in the Events create/edit modal
(on = real clock, off = simulated). Saved via `upsertEvent`.
- **App:** `useEvent()` picks `now` from the flag — `new Date()` when on,
`DEFAULT_NOW` when off — and exposes `clockMode` (`'realtime'` |
`'simulated'`). The Home header shows a **🎬 Demo clock** badge only in
simulated mode (nothing when the real clock is on). With the real clock on and
the event in the past, every slot is
`done` (no Now/Next card); with it off, the simulated clock restores the live
slot.
- **Migration:** [`20260834000000_event_realtime_clock.sql`](../../supabase/migrations/20260834000000_event_realtime_clock.sql).
## Cross-cutting / later ## Cross-cutting / later
- **Real event clock** — replace the simulated `DEFAULT_NOW`
([frontend/app-structure.md#the-event-clock](./frontend/app-structure.md#the-event-clock))
with `new Date()` for the live event.
- **Subdomains** — `convivo.appe.at`, `admin.appe.at`, `db.appe.at` don't exist - **Subdomains** — `convivo.appe.at`, `admin.appe.at`, `db.appe.at` don't exist
yet; everything is on localhost. DNS + TLS + a reverse proxy in front of the yet; everything is on localhost. DNS + TLS + a reverse proxy in front of the
Supabase core will be needed for a real deployment. Supabase core will be needed for a real deployment.
@@ -0,0 +1,19 @@
-- =============================================================================
-- Convivo — Per-event real-time clock toggle
--
-- Adds `events.use_realtime_clock` (boolean, default false). When false (the
-- default), the Convivo app uses its simulated mid-event clock so the demo
-- always looks "live" regardless of the real date. When true, the app uses the
-- real system clock (`new Date()`), so slot status reflects the actual time.
--
-- The admin toggles this per event in the Events view; the Convivo app reads it
-- from the active event and picks the clock accordingly.
-- =============================================================================
alter table public.events
add column if not exists use_realtime_clock boolean not null default false;
comment on column public.events.use_realtime_clock is
'When true, the Convivo app drives slot status (Live/Next/Done) from the real '
'system clock; when false (default) it uses the simulated mid-event clock so '
'the demo always looks live.';