feat: sync GridSmart agendas and use event-relative demo time

Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage.
This commit is contained in:
Lago committed 2026-10-11 08:39:15 +02:00
1 parent 40f24cf5f7
commit c0fbf495dc
27 files changed
+1215 -60

No files matched your search

+47 -8
View File
@@ -2,16 +2,17 @@
The **sidecar** is a small Node HTTP service that syncs an event's agenda from
[Sessionize](https://sessionize.com) into Convivo. It is the only server-side
component that holds the **service-role key**, and it is driven entirely by the
APPE Admin **Interfaces** menu — it runs **on demand only** (no scheduling).
component that holds the **service-role key**. Sessionize runs on demand from
Admin and automatically for active configured events, initially at startup and
then every 15 minutes. Pretix retains its independent every-minute loop.
- Code: [`apps/sidecar/`](../../apps/sidecar/), HTTP service in
[`src/server.js`](../../apps/sidecar/src/server.js), pure Excel transform in
[`src/transform-excel.js`](../../apps/sidecar/src/transform-excel.js)
- Image: [`apps/sidecar/Dockerfile`](../../apps/sidecar/Dockerfile)
(`node:20-alpine`; runtime dependencies **`xlsx`** (parse the Sessionize Excel
export) and **`pdfkit`** (render the PDF report) — everything else is built-in
`http` + `fetch`)
export), **`cheerio`** (parse GridSmart HTML without executing scripts), and
**`pdfkit`** (render the PDF report in the repository's newer server baseline))
- Compose service: `convivo-sidecar` in the root
[`docker-compose.yml`](../../docker-compose.yml) (`:3002`)
- DB side: the `sync_sessionize_event` RPC + `sync_runs` audit table — see
@@ -19,15 +20,52 @@ APPE Admin **Interfaces** menu — it runs **on demand only** (no scheduling).
## What it does
There are **two import paths**, both on demand:
There are **two import paths**; the source/API path also runs automatically:
**A. API sync** (`POST /run`) — fetches the event's `sessionize_endpoint` and
imports, in order: (1) speakers as contacts (matched by **email**), (2) sessions
(upserted by `external_id`), (3) the agenda/schedule (slots find-or-created by
date/start/end + `session_speakers` links). The public `/view/` payload has no
date/start/end/type + `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).
### GridSmart Sources and Polling
The Admin event editor accepts either an HTTPS Sessionize `All` / `GridSmart`
URL or one `<script src="...">` embed. It extracts and stores the URL, never
executes the script, and reports invalid input without saving. The sidecar also
normalizes stored script tags for compatibility. Only the exact
`sessionize.com/api/v2/<id>/view/All` and `.../GridSmart` paths are accepted;
credentials, alternate hosts, ports and HTTP are rejected. Queries and fragments
are removed. Requests have a 30-second timeout and do not follow redirects.
JSON `All` feeds retain their existing transform. For embed responses, the source
reader loads GridSmart HTML using `under=True` and parses stable `data-sessionid`
values, titles, rooms, service/plenum classes and UTC timing attributes. The
loader's explicit event UTC offset converts those times to event-local date/time.
Duplicate rendered cards are deduplicated by ID; conflicting copies, malformed
timings, empty grids, unknown timezones and overnight sessions fail validation.
The grid does not supply email addresses. Existing speaker links, descriptions,
level/area and materials are retained rather than replaced with missing data.
New speaker contacts still require the email-bearing Excel import. Service
sessions receive all event staff. Concurrent service placeholders use separate
service slots instead of being typed as ordinary talks.
Polling selects only active events with a configured source, processes them
sequentially, skips overlapping imports and retries failed sources on the next
pass. Set `SESSIONIZE_SYNC_INTERVAL_MS` in the sidecar container environment to
override the default `900000`; positive values are clamped to at least `60000`,
and `0` disables automatic polling. `/status` reports `sessionizeIntervalMs` and
the last run, including `source_format`. The Admin description reflects the
default interval. Manual Sync remains available for inactive configured events.
Successful imports upsert stable Sessionize IDs; missing entries are not deleted.
Migration `20261011060534_gridsmart_service_identity` also adopts the four
supplemental `manual-service-*` IDs when exactly one service matches the event,
title, date and timing, preserving its session ID and existing links. See the
[deployment record](../releases/2026-10-11.md#gridsmart-automation).
> **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
@@ -137,7 +175,8 @@ flowchart LR
- **Supabase:** PostgREST at `supabase_kong_Convivo:8000` (Kong's internal port
on the shared network — see [supabase-core.md#ports](./supabase-core.md#ports)),
authenticated with the **service-role key**.
- **Sessionize:** the event's stored `sessionize_endpoint`, fetched **as-is**.
- **Sessionize:** the event's stored `sessionize_endpoint`, normalized and read
as JSON or a non-executed GridSmart embed.
The public `/view/` endpoint needs no key. If `SESSIONIZE_API_KEY` is set it
is sent as the `X-Sessionize-API-Key` header (harmless for `/view/`, required
for an `/api/` endpoint).
@@ -154,7 +193,7 @@ flowchart LR
| Method | Path | Body | Returns |
|---|---|---|---|
| `GET` | `/health` | — | `{ ok: true }` (compose healthcheck) |
| `GET` | `/status` | — | `{ ok, running, lastRun }` |
| `GET` | `/status` | — | `{ ok, running, lastRun, sessionizeIntervalMs, ... }` |
| `POST` | `/run` | `{ event_id }` | **blocking** — the API-sync result (summary + errors) |
| `POST` | `/import-excel` | `multipart/form-data` (`event_id` + `file` = the `.xlsx`) | **blocking** — the Excel-import result (summary + errors) |
| `POST` | `/export` | `{ event_id, format: 'csv' \| 'xlsx' \| 'pdf', tables? }` | **blocking** — `{ filename, mime, content_base64 }` (the event report) |
+47
View File
@@ -1,3 +1,50 @@
# Service Staff Regression
The attendee browser suite also covers demo clock dates for two different events
and real-time mode against a fixed system date:
```sh
CONVIVO_BASE_URL=https://convivo.appe.at npm test --prefix e2e -- convivo-admin-entry.spec.ts --project=chromium --grep 'Event demo clock'
```
These three checks fail if the demo clock falls back to the seed date. They assert
Done/Live/Up next at 10:20 on the event start date, and all Done for a later real
system date with real-time mode enabled.
GridSmart source and automatic-poll regressions:
```sh
npm test --prefix apps/sidecar
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/gridsmart_sync_tests.sql
CONVIVO_ADMIN_URL=https://admin.appe.at npm test --prefix e2e -- sessionize-source.spec.ts --project=chromium
```
Apply `20261011060534_gridsmart_service_identity` first. Seven rollback SQL
assertions cover manual service ID adoption, concurrent placeholder types,
staff assignment, omitted talks/metadata/speakers and repeat-poll idempotence.
Sidecar tests include five source-reader checks, two polling checks and the
existing nine Excel checks. Browser tests cover both input formats and invalid
host rejection without script execution. Actual live startup polling and a
second no-duplicate sync were also verified.
After applying `20261011054613_service_session_staff_assignment`, run:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/service_session_staff_tests.sql
CONVIVO_BASE_URL=https://convivo.appe.at npm test --prefix e2e -- convivo-admin-entry.spec.ts --project=chromium --grep 'Service agenda'
```
The SQL fixture rolls back and covers staff present before session creation,
later staff promotion, unchanged talk speakers, event isolation and idempotence.
Browser fixtures cover service ordering and staff names on mobile and desktop,
including active talk filters. They also cover Placeholder nesting within matching
talk blocks, corrected displayed block counts, filter-independent visibility and
retained no-pick/no-upload service behavior even for an assigned staff speaker.
A separate case checks exact date/time matching and keeps unrelated services
separate. See the [deployment record](../releases/2026-10-11.md).
# Session Persistence Regression
Run the rollback-only fixture after applying
+10
View File
@@ -23,6 +23,16 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| **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). |
## Sessionize Source Editing
The Events editor accepts a Sessionize `All` or `GridSmart` URL, or the full
Sessionize `<script src="...">` tag, in the same multiline source field. Save
extracts and validates the HTTPS Sessionize URL and stores it as
`sessionize_endpoint`; the script is never executed. Invalid sources produce an
in-place error and are not saved. Active configured events sync at startup and
every 15 minutes by default; the existing Sync button still runs immediately.
See [source parsing and polling](../backend/sidecar.md#gridsmart-sources-and-polling).
## Auth guard
Login uses **email-only magic links**, with no password field, sign-in method
+13 -12
View File
@@ -76,24 +76,26 @@ The app drives slot status (Live / Up next / Done) from a **"now"** that is
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:
clock, using the active event's first day at 10:20:
```ts
export const EVENT_DATE = '2026-02-20';
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
export function demoNow(eventDate: string): Date {
return new Date(`${eventDate}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).
`demoNow(event.start_date)` is frozen at **10:20 on the active event's start
date**, independent of the actual calendar date. Changing the active event or
its configured start date changes the simulated date after the event data loads.
There is no hardcoded seed date. The demo time remains intentionally fixed; an
event without a session at 10:20 may have no Live session.
`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;
const now = clockMode === 'simulated' && event ? demoNow(event.start_date) : new Date();
```
The Home header shows a **🎬 Demo clock** indicator only when the simulated
@@ -130,10 +132,9 @@ 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
that can carry a pending-feedback nudge.
> **Why a simulated clock by default?** 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.
> **Why a simulated clock by default?** Outside an event's dates, a real clock
> would show all slots as either future or past. The simulated clock lets the
> event be demonstrated at a predictable time on its configured first day.
> **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
+11
View File
@@ -138,6 +138,17 @@ from `slotStatus(slot, now)`
## Agenda
Demo status uses 10:20 on the active event's configured start date. Real-time mode
uses the system date/time instead; see [the event clock](./app-structure.md#the-event-clock-libtime-ts).
Service sessions named **Placeholder** (case-insensitive, trimmed) are displayed
inside an ordinary talk block when their date, start time and end time match
exactly. Other services, unmatched Placeholders and partial time overlaps retain
their own blocks. The displayed slot count reflects these merged blocks.
Grouping is presentation-only: original slot IDs and session types remain intact.
Merged Placeholders retain staff speakers, stay visible under level/area filters,
and have no pick control, speaker mic tag or pending-material requirement.
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
+153
View File
@@ -0,0 +1,153 @@
# Service Sessions Follow-up
## Diagnosis
The active Community Day 2026 event had 21 talks and no service slots or service
sessions. The configured Sessionize API returned the same 21 talks and no service
entries; the UI was not hiding existing services.
## Changes
Migration `20261011054613_service_session_staff_assignment` assigns existing event
staff when a service session is created, and assigns newly registered or promoted
staff to existing service sessions. Assignment is idempotent and event-scoped.
Ordinary talk speakers are unchanged. Internal helper execution is restricted.
Existing service sessions are backfilled when the migration is applied.
The attendee agenda now orders slots by date, start time, end time and ID rather
than insertion ID. Services remain visible when level/area filters are active.
The event-specific [supplemental schedule](../../supabase/supplemental/community_day_2026_services.sql)
restores only the four fully visible, named services from the supplied schedule
screenshot for October 23, 2026:
| Service | Time |
| --- | --- |
| Arrival & Coffee | 08:30-09:00 |
| Opening Keynote - TBC | 09:00-10:00 |
| Lunch | 12:00-13:00 |
| Coffee Break | 14:45-15:15 |
Times are the displayed local schedule times (W. Europe daylight time, UTC+02).
Rooms were not guessed. Unnamed breaks, placeholder blocks and cut-off schedule
entries were not reconstructed. A complete service export is still needed to
restore those entries. This supplemental SQL is opt-in, not a seed or schema
migration, and is safe to rerun for the exact matching active event. It does not
overwrite existing matching sessions. Later authoritative imports may require
reconciliation with its explicit `manual-service-*` external IDs.
## Production
Deployed the schema migration and supplemental schedule in one transaction, with
the migration ledger recorded. Preservation assertions confirmed that all 21
existing talk rows and their 21 speaker links remained unchanged. Rebuilt and
restarted only `convivo-app`, applying only the agenda ordering change to the
remote source baseline. No full reimport, reset, seed or email was performed.
Backup: `/home/APPE/convivo-backups/services-20261011T055100Z`, including the full
database dump, prior API source and rollback image tag. Earlier unsuccessful
deployment attempts did not commit database changes.
## Verification
- Five rollback-only staff-assignment assertions passed locally and in production.
- Supplemental schedule executed against a temporary matching event and rolled back locally.
- Local and production attendee builds passed; nginx configuration passed.
- Two API-mocked browser regressions against the production bundle passed at
360px and 1280px, covering order, staff names and filter-independent services.
- The complete 35-test attendee entry/profile/service browser suite passed;
test TypeScript and editor diagnostics passed. Both service screenshots were
inspected with no overlapping text or controls.
- Live agenda RPC verified 21 talks, four services and exactly all four current
event staff linked as speakers to each service.
- Public root returned HTTP 200 with rebuilt bundle `index-D8QKHrBx.js`.
The initial service deployment preceded repository delivery; the consolidated
follow-up commit includes these source changes and the later fixes below.
## GridSmart Automation
The later supplied GridSmart embed exposes ten services, including the breaks,
both placeholders and Closing at 16:55-17:10. This supersedes the initial
four-entry screenshot-only restoration above.
Admin now accepts either the complete script tag or its URL and saves the
normalized source. The sidecar parses JSON or GridSmart HTML without executing
embed JavaScript. It polls active configured events immediately at startup and
every 15 minutes, without overlapping imports. Source validation restricts
requests to HTTPS Sessionize API views; fetches have timeouts and reject redirects.
Migration `20261011060534_gridsmart_service_identity` separates concurrent talk
and service slots and adopts uniquely matched supplemental service IDs. Existing
speaker links and nonempty metadata are retained; absent grid entries are not
deleted. The published grid has 20 talks, so the omitted 21st talk remains intact.
Production was switched to the supplied GridSmart source. Only Admin and the
sidecar were rebuilt/restarted. The VM's older sidecar source/manifests were
checksum-verified and patched locally in private staging; its lack of the newer
PDF/export code was preserved. Cheerio 1.0.0 was added, and the VM build now uses
its matching lockfile with `npm ci`. Repository and deployed sidecar baselines
remain different by design. The existing `xlsx` high-severity audit finding has
no reported automatic fix and was not changed by this task.
Backup: `/home/APPE/convivo-backups/gridsmart-20261011T061247Z`, including full
database/source archives, original session/link snapshots and rollback image tags.
The initial incompatible patch preflight stopped before writes.
Verified locally and against deployed code:
- 16 sidecar tests passed locally and in the isolated production image.
- Seven rollback SQL assertions passed locally and in production.
- Three API-mocked Admin browser tests passed locally and against the public bundle.
- The combined 42-test deployed Admin/attendee suite passed, covering source
editing, ticket merging, QR/admin entry, profile artwork and service visibility.
Both source-input screenshots were inspected; test TypeScript passed.
- The first automatic poll succeeded with all ten service sessions and four staff
speakers each; all 21 talks, 25 original session IDs and 37 original speaker
links were retained, along with existing nonempty metadata/material paths.
- A second live sync created zero sessions and zero slots.
- Admin builds and nginx validation passed; editor diagnostics were clean.
The consolidated follow-up commit includes the GridSmart automation changes.
## Placeholder Display Grouping
The attendee Agenda now nests service sessions named Placeholder inside a talk
block with exactly matching date/start/end times. This does not merge database
slots: each session retains its slot ID and service type, staff assignments and
no-pick/no-check-in/material rules. Per-session service type controls row rendering
and filters, while the original slot controls detail-sheet behavior. Unmatched
Placeholders and unrelated services remain separate.
Only `Agenda.tsx` and the new pure `agendaBlocks.ts` helper were deployed to the
attendee app. No database migration, import, source reconfiguration, Admin/sidecar
restart or dependency change was made. All other container IDs were verified
unchanged. Backup: `/home/APPE/convivo-backups/placeholder-20261011T062823Z`, with
the previous Agenda source and rollback attendee image.
Local and production builds/nginx checks passed. Three focused browser tests
passed locally and against the production bundle at 360px and 1280px; the full
36-test attendee suite also passed. Tests cover nesting, block counts, staff names,
filter behavior, preserved no-pick/no-upload rules, and nonmatching dates/times.
Both screenshots were inspected with no overlapping controls or text.
Live data confirmed two matching Placeholders (11:15-12:00 and 16:15-17:00), giving
14 displayed blocks from 16 stored slots. Public root returned HTTP 200 with
bundle `index-Dq5rJz3h.js`. Existing tabs need a page reload to load this version.
## Event-relative Demo Date
The demo clock was using the seed's hardcoded February 20, 2026 date. It now uses
the active event's `start_date` at the intentionally fixed demo time of 10:20.
Real-time mode still uses the system date/time. This remains a frontend display
clock; database timestamps and backend time-based enforcement are not mocked.
Deployed only the attendee clock modules, with source and rollback-image backup
at `/home/APPE/convivo-backups/demo-date-20261011T063601Z`. Local and production
builds/nginx checks passed. Three new clock regressions passed locally and against
the public app, using two event dates and a distinct fixed system date. The full
combined deployed Admin/attendee suite passed all 46 tests; editor checks passed.
Production attendee bundle: `index-DbYmWAlL.js`.
All October 11 follow-up source changes, migrations, tests and documentation are
included together in the requested commit on `main`.