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.

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-10-11 08:39:15 +02:00
1 parent f32289f583
commit 84691de6ee
27 files changed
+1215 -60

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
export function normalizeSessionizeSource(value: string): string | null {
let source = value.trim();
if (!source) return null;
if (source.startsWith('<')) {
const document = new DOMParser().parseFromString(source, 'text/html');
const scripts = document.querySelectorAll('script[src]');
if (scripts.length !== 1) throw new Error('Paste one Sessionize script tag or URL');
source = scripts[0].getAttribute('src') || '';
}
let url: URL;
try { url = new URL(source); } catch { throw new Error('Enter a valid Sessionize URL or script tag'); }
if (url.protocol !== 'https:' || url.hostname !== 'sessionize.com' || url.port
|| url.username || url.password || !/^\/api\/v2\/[a-z0-9]+\/view\/(All|GridSmart)$/i.test(url.pathname)) {
throw new Error('Use a Sessionize HTTPS All or GridSmart endpoint');
}
url.search = '';
url.hash = '';
return url.href;
}
+21 -7
View File
@@ -11,6 +11,7 @@ import {
import type { Event, PretixOptions, PretixSyncResult, SyncResult } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Empty, Modal, Spinner, Toggle } from '../components/ui';
import { normalizeSessionizeSource } from '../lib/sessionizeSource';
export function Events() {
const { push } = useToast();
@@ -286,6 +287,7 @@ function EventModal({
const [endDate, setEndDate] = useState(event ? event.end_date.slice(0, 10) : '');
const [location, setLocation] = useState(event?.location ?? '');
const [endpoint, setEndpoint] = useState(event?.sessionize_endpoint ?? '');
const [endpointError, setEndpointError] = useState<string | null>(null);
const [pretixApiKey, setPretixApiKey] = useState(event?.pretix_api_key ?? '');
const [pretixOrganizer, setPretixOrganizer] = useState(event?.pretix_organizer ?? '');
const [pretixEventSlug, setPretixEventSlug] = useState(event?.pretix_event_slug ?? '');
@@ -328,6 +330,14 @@ function EventModal({
async function save() {
if (!name.trim() || !startDate || !endDate) return;
let source: string | null;
try {
source = normalizeSessionizeSource(endpoint);
setEndpointError(null);
} catch (error) {
setEndpointError(error instanceof Error ? error.message : 'Invalid Sessionize source');
return;
}
setBusy(true);
try {
await upsertEvent(event?.id ?? null, {
@@ -335,7 +345,7 @@ function EventModal({
start_date: startDate,
end_date: endDate,
location: location.trim() || null,
sessionize_endpoint: endpoint.trim() || null,
sessionize_endpoint: source,
pretix_organizer: pretixOrganizer.trim() || null,
pretix_event_slug: pretixEventSlug.trim() || null,
pretix_api_key: pretixApiKey.trim() || null,
@@ -391,16 +401,20 @@ function EventModal({
{endpoint.trim() ? <span className="pill green">configured</span> : <span className="pill">not set</span>}
</div>
<div className="field">
<label>Sessionize endpoint</label>
<input
<label htmlFor="sessionize-source">Sessionize endpoint</label>
<textarea
id="sessionize-source"
className="input"
rows={3}
value={endpoint}
onChange={(e) => setEndpoint(e.target.value)}
placeholder="https://sessionize.com/api/v2/<id>/view/All"
onChange={(e) => { setEndpoint(e.target.value); setEndpointError(null); }}
aria-invalid={!!endpointError}
aria-describedby={endpointError ? 'sessionize-source-error' : undefined}
placeholder="https://sessionize.com/api/v2/<id>/view/GridSmart"
/>
{endpointError && <div id="sessionize-source-error" role="alert" className="error">{endpointError}</div>}
<div className="muted small" style={{ marginTop: 4 }}>
The Sessionize API URL (e.g. <code>…/api/v2/&lt;id&gt;/view/All</code>). Used by the
“Run sync” button. You can also import the .xlsx export in the Interfaces menu.
All / GridSmart URL or Sessionize script tag. Active events sync automatically every 15 minutes.
</div>
</div>
</div>
+24
View File
@@ -0,0 +1,24 @@
import type { Session, Slot } from './types';
type AgendaBlock = { slot: Slot; sessions: Session[] };
export function mergeAgendaPlaceholders(slots: AgendaBlock[]): AgendaBlock[] {
const blocks = slots.map(block => ({ slot: block.slot, sessions: [...block.sessions] }));
const merged = new Set<number>();
for (const block of blocks) {
if (block.slot.type !== 'service_session') continue;
const target = blocks.find(candidate => candidate.slot.type === 'session'
&& candidate.slot.slot_date === block.slot.slot_date
&& candidate.slot.start_time === block.slot.start_time
&& candidate.slot.end_time === block.slot.end_time);
if (!target) continue;
const placeholders = block.sessions.filter(session => session.slot_type === 'service_session'
&& session.title.trim().toLowerCase() === 'placeholder');
if (!placeholders.length) continue;
target.sessions.push(...placeholders);
const transferred = new Set(placeholders.map(session => session.id));
block.sessions = block.sessions.filter(session => !transferred.has(session.id));
if (!block.sessions.length) merged.add(block.slot.id);
}
return blocks.filter(block => !merged.has(block.slot.id));
}
+5 -1
View File
@@ -83,7 +83,11 @@ export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[
});
}
}
return [...map.values()].sort((a, b) => a.slot.id - b.slot.id);
return [...map.values()].sort((first, second) =>
first.slot.slot_date.localeCompare(second.slot.slot_date)
|| first.slot.start_time.localeCompare(second.slot.start_time)
|| first.slot.end_time.localeCompare(second.slot.end_time)
|| first.slot.id - second.slot.id);
}
/** Submit (or update) the current user's event-level feedback. */
+3 -6
View File
@@ -1,11 +1,8 @@
import type { Slot } from './types';
/** The event day (from the seed). All slot times are on this date. */
export const EVENT_DATE = '2026-02-20';
/** Simulated "now" used for the demo (10:20 on event day → Slot 2 is live,
* Slot 3 is next). Matches the mockup's "Good morning" greeting. */
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
export function demoNow(eventDate: string): Date {
return new Date(`${eventDate}T10:20:00`);
}
export type SlotStatus = 'done' | 'now' | 'next';
+2 -2
View File
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { getActiveEvent, getAgenda, groupAgenda } from './api';
import { DEFAULT_NOW } from './time';
import { demoNow } from './time';
import type { Event, Session, Slot } from './types';
export interface EventData {
@@ -53,7 +53,7 @@ export function useEvent(): EventData {
// 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;
const now = clockMode === 'simulated' && event ? demoNow(event.start_date) : new Date();
return {
event,
+6 -6
View File
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { mergeAgendaPlaceholders } from '../lib/agendaBlocks';
import {
clearPreference,
getMyCheckins,
@@ -48,6 +49,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
const matchesFilter = (s: Session) =>
(!levelFilter || s.level === levelFilter) && (!areaFilter || s.area === areaFilter);
const displayBlocks = mergeAgendaPlaceholders(slots);
useEffect(() => {
let active = true;
@@ -159,7 +161,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
<div className="h1">Agenda</div>
<div className="muted small">{event.name}</div>
</div>
<span className="pill violet">{slots.length} slots</span>
<span className="pill violet">{displayBlocks.length} slots</span>
</div>
<div className="muted small" style={{ marginTop: -4 }}>
Pick <b>one session per slot</b> — you can change until the slot starts.
@@ -209,14 +211,12 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
)}
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{slots.map(({ slot, sessions }) => {
{displayBlocks.map(({ slot, sessions }) => {
const status = slotStatus(slot, now);
const isServiceSlot = slot.type === 'service_session';
// Apply the level/area filter to non-service sessions only (service
// sessions have no level/area and are always shown).
const visibleSessions = isServiceSlot
? sessions
: sessions.filter(matchesFilter);
const visibleSessions = sessions.filter(session => session.slot_type === 'service_session' || matchesFilter(session));
// Skip the slot if it's a talk slot and all its sessions are filtered out.
if (!isServiceSlot && visibleSessions.length === 0) return null;
return (
@@ -235,7 +235,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
{visibleSessions.map((s) => {
const picked = pickFor(slot.id) === s.id;
const isMySession = mySpeakerSessions.includes(s.id);
const isService = slot.type === 'service_session';
const isService = s.slot_type === 'service_session';
return (
<button key={s.id} className={`sess ${picked ? 'picked' : ''}`} onClick={() => setSelected(s)}>
<div className="grow">
+286
View File
@@ -8,6 +8,7 @@
"name": "convivo-sidecar",
"version": "0.1.0",
"dependencies": {
"cheerio": "1.0.0",
"pdfkit": "^0.15.0",
"xlsx": "^0.18.5"
}
@@ -81,6 +82,12 @@
],
"license": "MIT"
},
"node_modules/boolbase": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
"license": "ISC"
},
"node_modules/brotli": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/brotli/-/brotli-1.3.3.tgz",
@@ -159,6 +166,48 @@
"node": ">=0.8"
}
},
"node_modules/cheerio": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0.tgz",
"integrity": "sha512-quS9HgjQpdaXOvsZz82Oz7uxtXiy6UIsIQcpBj7HRw2M63Skasm9qlDocAM7jNuaxdhpPU7c4kJN+gA5MCu4ww==",
"license": "MIT",
"dependencies": {
"cheerio-select": "^2.1.0",
"dom-serializer": "^2.0.0",
"domhandler": "^5.0.3",
"domutils": "^3.1.0",
"encoding-sniffer": "^0.2.0",
"htmlparser2": "^9.1.0",
"parse5": "^7.1.2",
"parse5-htmlparser2-tree-adapter": "^7.0.0",
"parse5-parser-stream": "^7.1.2",
"undici": "^6.19.5",
"whatwg-mimetype": "^4.0.0"
},
"engines": {
"node": ">=18.17"
},
"funding": {
"url": "https://github.com/cheeriojs/cheerio?sponsor=1"
}
},
"node_modules/cheerio-select": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz",
"integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==",
"license": "BSD-2-Clause",
"dependencies": {
"boolbase": "^1.0.0",
"css-select": "^5.1.0",
"css-what": "^6.1.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3",
"domutils": "^3.0.1"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/clone": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
@@ -196,6 +245,34 @@
"deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.",
"license": "MIT"
},
"node_modules/css-select": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz",
"integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==",
"license": "BSD-2-Clause",
"dependencies": {
"boolbase": "^1.0.0",
"css-what": "^6.1.0",
"domhandler": "^5.0.2",
"domutils": "^3.0.1",
"nth-check": "^2.0.1"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/css-what": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz",
"integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==",
"license": "BSD-2-Clause",
"engines": {
"node": ">= 6"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/deep-equal": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz",
@@ -268,6 +345,61 @@
"integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
"license": "MIT"
},
"node_modules/dom-serializer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
"license": "MIT",
"dependencies": {
"domelementtype": "^2.3.0",
"domhandler": "^5.0.2",
"entities": "^4.2.0"
},
"funding": {
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
}
},
"node_modules/domelementtype": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fb55"
}
],
"license": "BSD-2-Clause"
},
"node_modules/domhandler": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
"license": "BSD-2-Clause",
"dependencies": {
"domelementtype": "^2.3.0"
},
"engines": {
"node": ">= 4"
},
"funding": {
"url": "https://github.com/fb55/domhandler?sponsor=1"
}
},
"node_modules/domutils": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
"integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
"license": "BSD-2-Clause",
"dependencies": {
"dom-serializer": "^2.0.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3"
},
"funding": {
"url": "https://github.com/fb55/domutils?sponsor=1"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -282,6 +414,31 @@
"node": ">= 0.4"
}
},
"node_modules/encoding-sniffer": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz",
"integrity": "sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==",
"license": "MIT",
"dependencies": {
"iconv-lite": "^0.6.3",
"whatwg-encoding": "^3.1.1"
},
"funding": {
"url": "https://github.com/fb55/encoding-sniffer?sponsor=1"
}
},
"node_modules/entities": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
@@ -503,6 +660,37 @@
"node": ">= 0.4"
}
},
"node_modules/htmlparser2": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz",
"integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==",
"funding": [
"https://github.com/fb55/htmlparser2?sponsor=1",
{
"type": "github",
"url": "https://github.com/sponsors/fb55"
}
],
"license": "MIT",
"dependencies": {
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3",
"domutils": "^3.1.0",
"entities": "^4.5.0"
}
},
"node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/internal-slot": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",
@@ -784,6 +972,18 @@
"node": ">= 0.4"
}
},
"node_modules/nth-check": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
"integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
"license": "BSD-2-Clause",
"dependencies": {
"boolbase": "^1.0.0"
},
"funding": {
"url": "https://github.com/fb55/nth-check?sponsor=1"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
@@ -847,6 +1047,55 @@
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
"license": "(MIT AND Zlib)"
},
"node_modules/parse5": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
"integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
"license": "MIT",
"dependencies": {
"entities": "^6.0.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parse5-htmlparser2-tree-adapter": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.1.0.tgz",
"integrity": "sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==",
"license": "MIT",
"dependencies": {
"domhandler": "^5.0.3",
"parse5": "^7.0.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parse5-parser-stream": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz",
"integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==",
"license": "MIT",
"dependencies": {
"parse5": "^7.0.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parse5/node_modules/entities": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz",
"integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/pdfkit": {
"version": "0.15.2",
"resolved": "https://registry.npmjs.org/pdfkit/-/pdfkit-0.15.2.tgz",
@@ -920,6 +1169,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/set-function-length": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
@@ -1061,6 +1316,15 @@
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/undici": {
"version": "6.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz",
"integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/unicode-properties": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/unicode-properties/-/unicode-properties-1.4.1.tgz",
@@ -1087,6 +1351,28 @@
"integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==",
"license": "MIT"
},
"node_modules/whatwg-encoding": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",
"integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==",
"deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation",
"license": "MIT",
"dependencies": {
"iconv-lite": "0.6.3"
},
"engines": {
"node": ">=18"
}
},
"node_modules/whatwg-mimetype": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/which-boxed-primitive": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz",
+2 -1
View File
@@ -6,9 +6,10 @@
"main": "src/server.js",
"scripts": {
"start": "node src/server.js",
"test": "node --test tests/transform-excel.test.js"
"test": "node --test tests/*.test.js"
},
"dependencies": {
"cheerio": "1.0.0",
"pdfkit": "^0.15.0",
"xlsx": "^0.18.5"
}
+25 -15
View File
@@ -42,6 +42,8 @@
const http = require('http');
const XLSX = require('xlsx');
const { transformExcel } = require('./transform-excel');
const { readSessionizeSource } = require('./sessionize-source');
const { createSessionizePoller } = require('./sessionize-poller');
const PDFDocument = require('pdfkit');
const SUPABASE_URL = (process.env.SUPABASE_URL || 'http://supabase_kong_Convivo:8000').replace(/\/$/, '');
@@ -52,6 +54,9 @@ const SESSIONIZE_API_KEY = process.env.SESSIONIZE_API_KEY || '';
const PRETIX_API_KEY = process.env.PRETIX_API_KEY || '';
const PRETIX_BASE = (process.env.PRETIX_BASE || 'https://pretix.eu/api/v1').replace(/\/$/, '');
const PRETIX_SYNC_INTERVAL_MS = parseInt(process.env.PRETIX_SYNC_INTERVAL_MS || '60000', 10);
const configuredSessionizeInterval = Number(process.env.SESSIONIZE_SYNC_INTERVAL_MS || 900000);
const SESSIONIZE_SYNC_INTERVAL_MS = configuredSessionizeInterval === 0 ? 0
: Number.isFinite(configuredSessionizeInterval) ? Math.max(60000, configuredSessionizeInterval) : 900000;
const PORT = parseInt(process.env.PORT || '3002', 10);
// In-memory last-run state (the sidecar is otherwise stateless).
@@ -305,21 +310,11 @@ async function runSync(eventId) {
throw new Error(`event "${event.name}" has no sessionize_endpoint set`);
}
// 2. Fetch the Sessionize data. The public /view/ endpoint needs no key;
// if a key is configured we send it (required for /api/ endpoints).
const szUrl = event.sessionize_endpoint.trim();
log('run: fetching Sessionize', { szUrl, hasKey: Boolean(SESSIONIZE_API_KEY) });
const szHeaders = {};
if (SESSIONIZE_API_KEY) szHeaders['X-Sessionize-API-Key'] = SESSIONIZE_API_KEY;
const szRes = await fetch(szUrl, { headers: szHeaders });
if (!szRes.ok) {
const t = await szRes.text();
throw new Error(`Sessionize ${szRes.status}: ${t.slice(0, 200)}`);
}
const szData = await szRes.json();
// 3. Transform.
const { payload, skippedSpeakers } = transform(szData);
const source = await readSessionizeSource(event.sessionize_endpoint, { apiKey: SESSIONIZE_API_KEY });
const { payload, skippedSpeakers } = source.payload
? { payload: source.payload, skippedSpeakers: [] }
: transform(source.data);
if (!payload.sessions.length) throw new Error('Sessionize contains no scheduled sessions; existing agenda retained');
log('run: transformed', {
speakers: payload.speakers.length,
sessions: payload.sessions.length,
@@ -331,6 +326,7 @@ async function runSync(eventId) {
method: 'POST',
body: { p_event_id: event.id, p_payload: payload },
});
if (summary.errors?.length) throw new Error(`Sessionize import reported ${summary.errors.length} error(s)`);
const finishedAt = new Date().toISOString();
const result = {
@@ -339,6 +335,7 @@ async function runSync(eventId) {
started_at: startedAt,
finished_at: finishedAt,
status: 'success',
source_format: source.format,
summary,
skipped_speakers: skippedSpeakers,
};
@@ -810,6 +807,13 @@ async function handleExport(body) {
};
}
const pollSessionize = createSessionizePoller({
listEvents: () => supabaseFetch('/rest/v1/events?is_active=eq.true&sessionize_endpoint=not.is.null&select=id'),
syncEvent: runSync,
isBusy: () => running,
onError: (error, eventId) => log('sessionize poll error', { eventId, error: error.message }),
});
const server = http.createServer(async (req, res) => {
const url = new URL(req.url, `http://${req.headers.host || 'localhost'}`);
const path = url.pathname;
@@ -822,6 +826,7 @@ const server = http.createServer(async (req, res) => {
ok: true,
running,
lastRun,
sessionizeIntervalMs: SESSIONIZE_SYNC_INTERVAL_MS,
pretixRunning,
lastPretixRun,
pretixIntervalMs: PRETIX_SYNC_INTERVAL_MS,
@@ -870,6 +875,11 @@ const server = http.createServer(async (req, res) => {
});
server.listen(PORT, () => {
if (SESSIONIZE_SYNC_INTERVAL_MS > 0) {
log('sessionize auto-sync scheduled', { intervalMs: SESSIONIZE_SYNC_INTERVAL_MS });
setInterval(pollSessionize, SESSIONIZE_SYNC_INTERVAL_MS);
void pollSessionize();
}
log('sidecar listening', {
port: PORT,
supabase: SUPABASE_URL,
+21
View File
@@ -0,0 +1,21 @@
function createSessionizePoller({ listEvents, syncEvent, isBusy, onError }) {
let polling = false;
return async function pollSessionize() {
if (polling || isBusy()) return;
polling = true;
try {
const events = await listEvents();
for (const event of events) {
if (isBusy()) break;
try { await syncEvent(event.id); }
catch (error) { onError(error, event.id); }
}
} catch (error) {
onError(error);
} finally {
polling = false;
}
};
}
module.exports = { createSessionizePoller };
+85
View File
@@ -0,0 +1,85 @@
const { load } = require('cheerio');
function normalizeSessionizeSource(value) {
let source = String(value || '').trim();
if (source.startsWith('<')) {
const document = load(source);
const scripts = document('script[src]');
if (scripts.length !== 1) throw new Error('Paste one Sessionize script tag or URL');
source = scripts.attr('src');
}
let url;
try { url = new URL(source); } catch { throw new Error('Enter a valid Sessionize URL or script tag'); }
if (url.protocol !== 'https:' || url.hostname !== 'sessionize.com' || url.port
|| url.username || url.password || !/^\/api\/v2\/[a-z0-9]+\/view\/(All|GridSmart)$/i.test(url.pathname)) {
throw new Error('Use a Sessionize HTTPS All or GridSmart endpoint');
}
url.search = '';
url.hash = '';
return url.href;
}
function parseGridSmart(html, offsetMinutes) {
if (!Number.isInteger(offsetMinutes) || offsetMinutes < -720 || offsetMinutes > 840) {
throw new Error('Sessionize event timezone is missing or invalid');
}
const document = load(html);
const sessions = new Map();
document('.sz-session[data-sessionid]').each((index, element) => {
const card = document(element);
const id = card.attr('data-sessionid');
const title = card.find('.sz-session__title').text().trim();
const timing = card.find('.sz-session__time[data-sztz]').attr('data-sztz')?.split('|');
const start = new Date(timing?.[2]);
const end = new Date(timing?.[3]);
if (!id || !title || !Number.isFinite(start.getTime()) || !Number.isFinite(end.getTime()) || end <= start) {
throw new Error('GridSmart contains a session with incomplete identity or timing');
}
const localStart = new Date(start.getTime() + offsetMinutes * 60000).toISOString();
const localEnd = new Date(end.getTime() + offsetMinutes * 60000).toISOString();
if (localStart.slice(0, 10) !== localEnd.slice(0, 10)) throw new Error('Overnight sessions are not supported');
const session = {
external_id: id, title, description: null,
room: card.find('.sz-session__room').text().trim() || null,
date: localStart.slice(0, 10), start_time: localStart.slice(11, 19), end_time: localEnd.slice(11, 19),
is_service_session: card.hasClass('sz-session--service') || card.hasClass('sz-session--plenum'),
speakers: [], level: null, area: null,
};
if (sessions.has(id) && JSON.stringify(sessions.get(id)) !== JSON.stringify(session)) {
throw new Error('GridSmart contains conflicting copies of a session');
}
sessions.set(id, session);
});
if (!sessions.size) throw new Error('GridSmart contains no scheduled sessions');
return { speakers: [], sessions: [...sessions.values()] };
}
async function readSessionizeSource(value, { fetchImpl = fetch, apiKey = '' } = {}) {
const source = normalizeSessionizeSource(value);
const headers = apiKey ? { 'X-Sessionize-API-Key': apiKey } : {};
async function request(url) {
const response = await fetchImpl(url, { headers, redirect: 'error', signal: AbortSignal.timeout(30000) });
if (!response.ok) throw new Error(`Sessionize HTTP ${response.status}`);
const text = await response.text();
if (text.length > 5_000_000) throw new Error('Sessionize response exceeds size limit');
return text;
}
const body = await request(source);
try {
const data = JSON.parse(body);
if (!Array.isArray(data.sessions)) throw new Error('Sessionize JSON must contain sessions');
return { format: 'json', data };
} catch (error) {
if (!(error instanceof SyntaxError)) throw error;
}
const grid = new URL(source);
grid.pathname = grid.pathname.replace(/\/(All|GridSmart)$/i, '/GridSmart');
const loader = /\/GridSmart$/i.test(new URL(source).pathname) ? body : await request(grid.href);
const zone = loader.match(/sessionize\.eventTimezone\s*=\s*['"]UTC([+-])(\d{2})(?::?(\d{2}))?['"]/);
if (!zone) throw new Error('Sessionize embed does not expose an event timezone');
const offset = (Number(zone[2]) * 60 + Number(zone[3] || 0)) * (zone[1] === '-' ? -1 : 1);
grid.searchParams.set('under', 'True');
return { format: 'gridsmart', payload: parseGridSmart(await request(grid.href), offset) };
}
module.exports = { normalizeSessionizeSource, parseGridSmart, readSessionizeSource };
@@ -0,0 +1,32 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { createSessionizePoller } = require('../src/sessionize-poller');
test('polls events sequentially and isolates upstream failures', async () => {
const calls = [];
const failures = [];
const poll = createSessionizePoller({ listEvents: async () => [{ id: 'first' }, { id: 'second' }],
isBusy: () => false, syncEvent: async id => { calls.push(id); if (id === 'first') throw new Error('unavailable'); },
onError: (error, id) => failures.push(id) });
await poll();
assert.deepEqual(calls, ['first', 'second']);
assert.deepEqual(failures, ['first']);
});
test('does not overlap manual imports or another polling pass', async () => {
let finish;
let reads = 0;
let busy = true;
const pending = new Promise(resolve => { finish = resolve; });
const poll = createSessionizePoller({ listEvents: async () => { reads++; await pending; return []; },
isBusy: () => busy, syncEvent: async () => {}, onError: () => {} });
await poll();
assert.equal(reads, 0);
busy = false;
const first = poll();
await poll();
assert.equal(reads, 1);
finish();
await first;
await poll();
assert.equal(reads, 2);
});
@@ -0,0 +1,46 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { normalizeSessionizeSource, parseGridSmart, readSessionizeSource } = require('../src/sessionize-source');
const url = 'https://sessionize.com/api/v2/z0s5f2j2/view/GridSmart';
const card = (id, title, classes = '') => `<div class="sz-session ${classes}" data-sessionid="${id}">
<div class="sz-session__room">Main Stage</div>
<div class="sz-session__time" data-sztz="TimeWithDuration|en-US|2026-10-23T06:30:00.0000000Z|2026-10-23T07:00:00.0000000Z"></div>
<h3 class="sz-session__title">${title}</h3></div>`;
test('normalizes URL and script tag without executing code', () => {
assert.equal(normalizeSessionizeSource(url), url);
assert.equal(normalizeSessionizeSource(`<script type="text/javascript" src='${url}'></script>`), url);
for (const input of ['https://example.org/a', 'http://sessionize.com/api/v2/test/view/All',
'https://sessionize.com@localhost/api/v2/test/view/All', '<script>alert(1)</script>',
'https://sessionize.com:4430/api/v2/test/view/All']) assert.throws(() => normalizeSessionizeSource(input));
});
test('extracts service identity, entities, room, local time and deduplicates cards', () => {
const html = card('service-id', 'Arrival &amp; Coffee', 'sz-session--service') + card('service-id', 'Arrival &amp; Coffee', 'sz-session--service') + card('talk-id', 'Talk');
const result = parseGridSmart(html, 120);
assert.equal(result.sessions.length, 2);
assert.deepEqual(result.sessions[0], { external_id: 'service-id', title: 'Arrival & Coffee', description: null,
room: 'Main Stage', date: '2026-10-23', start_time: '08:30:00', end_time: '09:00:00',
is_service_session: true, speakers: [], level: null, area: null });
assert.equal(result.sessions[1].is_service_session, false);
});
test('rejects empty, malformed and conflicting schedules', () => {
assert.throws(() => parseGridSmart('', 120));
assert.throws(() => parseGridSmart(card('id', 'Talk').replace('2026-10-23T06:30:00.0000000Z', 'bad'), 120));
assert.throws(() => parseGridSmart(card('id', 'Talk') + card('id', 'Different'), 120));
assert.throws(() => parseGridSmart(card('id', 'Talk')));
});
test('reads loader and HTML without executing embed JavaScript', async () => {
const calls = [];
const result = await readSessionizeSource(`<script src="${url}"></script>`, { fetchImpl: async source => {
calls.push(source);
return { ok: true, text: async () => source.includes('under=True') ? card('id', 'Lunch', 'sz-session--plenum') : "sessionize.eventTimezone = 'UTC+02';" };
} });
assert.equal(result.format, 'gridsmart');
assert.equal(result.payload.sessions[0].is_service_session, true);
assert.deepEqual(calls, [url, `${url}?under=True`]);
});
test('retains JSON API compatibility and fails on upstream errors', async () => {
const result = await readSessionizeSource(url.replace('GridSmart', 'All'), { fetchImpl: async () => ({ ok: true, text: async () => '{"sessions":[]}' }) });
assert.equal(result.format, 'json');
await assert.rejects(readSessionizeSource(url, { fetchImpl: async () => ({ ok: false, status: 503 }) }), /503/);
});
+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`.
+95 -2
View File
@@ -4,6 +4,99 @@ const appUrl = process.env.CONVIVO_BASE_URL || 'http://localhost:3000';
const notice = 'If this email belongs to an eligible admin account, a sign-in link has been sent.';
const invalidLink = 'This sign-in link is invalid or expired. Please request a new link.';
test.describe('Service agenda', () => {
for (const width of [360, 1280]) {
test(`orders supplemental services and retains staff names through filters at ${width}px`, async ({ page }, testInfo) => {
await page.setViewportSize({ width, height: 900 });
const { session } = await mockApi(page, { registered: true, checkedIn: true });
const staffNames = 'Staff One, Staff Two, Staff Three, Staff Four';
const rows = [
{ slot_id: 1, start_time: '10:15:00', end_time: '11:00:00', title: 'Advanced Talk', slot_type: 'session', level: 'Advanced', speakers: 'Talk Speaker' },
{ slot_id: 2, start_time: '11:15:00', end_time: '12:00:00', title: 'Beginner Talk', slot_type: 'session', level: 'Beginner', speakers: 'Talk Speaker' },
{ slot_id: 902, start_time: '11:15:00', end_time: '12:00:00', title: 'Placeholder', slot_type: 'service_session', level: null, speakers: staffNames },
{ slot_id: 901, start_time: '12:00:00', end_time: '13:00:00', title: 'Lunch', slot_type: 'service_session', level: null, speakers: staffNames },
{ slot_id: 900, start_time: '08:30:00', end_time: '09:00:00', title: 'Arrival & Coffee', slot_type: 'service_session', level: null, speakers: staffNames },
].map(row => ({ ...row, session_id: `session-${row.slot_id}`, slot_name: row.title,
slot_date: '2026-02-20', room: '', description: '', material_path: null, capacity: null,
average_feedback: null, ai_generated_feedback: null, area: null }));
await page.route('**/rest/v1/rpc/get_agenda', route => route.fulfill({ json: rows }));
await page.route('**/rest/v1/session_speakers**', route => route.fulfill({ json: [{ session_id: 'session-902' }] }));
await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
await page.getByTestId('tab-agenda').click();
await expect(page.locator('.sess .title')).toHaveText(['Arrival & Coffee', 'Advanced Talk', 'Beginner Talk', 'Placeholder', 'Lunch']);
await expect(page.locator('.slot-card')).toHaveCount(4);
await expect(page.getByText('4 slots', { exact: true })).toBeVisible();
const talkBlock = page.locator('.slot-card').filter({ has: page.locator('.sess .title', { hasText: 'Beginner Talk' }) });
await expect(talkBlock.locator('.sess .title')).toHaveText(['Beginner Talk', 'Placeholder']);
const placeholder = page.locator('.sess').filter({ has: page.locator('.title', { hasText: 'Placeholder' }) });
await expect(placeholder.locator('.check')).toHaveCount(0);
await expect(page.locator('.sess .meta').filter({ hasText: staffNames })).toHaveCount(3);
await page.getByLabel('Filter by level').selectOption('Beginner');
await expect(page.locator('.sess .title')).toHaveText(['Arrival & Coffee', 'Beginner Talk', 'Placeholder', 'Lunch']);
await expect(page.locator('.sess .meta').filter({ hasText: staffNames })).toHaveCount(3);
await page.locator('.screen').evaluate(screen => { screen.scrollTop = 0; });
await page.screenshot({ path: testInfo.outputPath(`service-agenda-${width}.png`), fullPage: true });
await page.getByLabel('Filter by level').selectOption('Advanced');
await expect(page.locator('.sess .title')).toHaveText(['Arrival & Coffee', 'Advanced Talk', 'Placeholder', 'Lunch']);
await placeholder.click();
await expect(page.getByText('No pick needed for this slot.', { exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'Pick this session', exact: true })).toHaveCount(0);
await expect(page.getByTestId('material-upload-notice')).toHaveCount(0);
});
}
test('merges only Placeholders with the exact same date and start/end times', async ({ page }) => {
const { session } = await mockApi(page, { registered: true, checkedIn: true });
const rows = [
{ slot_id: 1, title: 'Talk', slot_type: 'session', room: 'Talk room', slot_date: '2026-02-20', end_time: '12:00:00' },
{ slot_id: 2, title: 'Placeholder', slot_type: 'service_session', room: 'Matching room', slot_date: '2026-02-20', end_time: '12:00:00' },
{ slot_id: 3, title: 'Placeholder', slot_type: 'service_session', room: 'Next day room', slot_date: '2026-02-21', end_time: '12:00:00' },
{ slot_id: 4, title: 'Placeholder', slot_type: 'service_session', room: 'Different end room', slot_date: '2026-02-20', end_time: '12:30:00' },
{ slot_id: 5, title: 'Lunch', slot_type: 'service_session', room: 'Lunch room', slot_date: '2026-02-20', end_time: '12:00:00' },
].map(row => ({ ...row, session_id: `session-${row.slot_id}`, slot_name: row.title, start_time: '11:15:00',
speakers: 'Staff', description: '', material_path: null, capacity: null, average_feedback: null,
ai_generated_feedback: null, level: null, area: null }));
await page.route('**/rest/v1/rpc/get_agenda', route => route.fulfill({ json: rows }));
await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
await page.getByTestId('tab-agenda').click();
await expect(page.locator('.slot-card')).toHaveCount(4);
const talkBlock = page.locator('.slot-card').filter({ has: page.locator('.sess .title', { hasText: /^Talk$/ }) });
await expect(talkBlock.locator('.sess .title')).toHaveText(['Talk', 'Placeholder']);
await expect(talkBlock.getByText('Matching room', { exact: false })).toBeVisible();
await expect(talkBlock.getByText('Next day room', { exact: false })).toHaveCount(0);
await expect(talkBlock.getByText('Different end room', { exact: false })).toHaveCount(0);
await expect(talkBlock.getByText('Lunch room', { exact: false })).toHaveCount(0);
});
});
test.describe('Event demo clock', () => {
for (const scenario of [
{ eventDate: '2026-10-23', realtimeClock: false },
{ eventDate: '2027-05-10', realtimeClock: false },
{ eventDate: '2026-10-23', realtimeClock: true },
]) {
test(`uses ${scenario.realtimeClock ? 'system' : 'event'} date for ${scenario.eventDate}`, async ({ page }) => {
await page.clock.setFixedTime(new Date('2028-01-01T10:20:00'));
const { session } = await mockApi(page, { registered: true, checkedIn: true, ...scenario });
const rows = [
{ slot_id: 1, title: 'Morning service', start_time: '08:30:00', end_time: '09:00:00', slot_type: 'service_session' },
{ slot_id: 2, title: 'Current talk', start_time: '10:15:00', end_time: '11:00:00', slot_type: 'session' },
{ slot_id: 3, title: 'Later talk', start_time: '11:15:00', end_time: '12:00:00', slot_type: 'session' },
].map(row => ({ ...row, session_id: `clock-${row.slot_id}`, slot_name: row.title, slot_date: scenario.eventDate,
room: '', speakers: 'Staff', description: '', material_path: null, capacity: null,
average_feedback: null, ai_generated_feedback: null, level: null, area: null }));
await page.route('**/rest/v1/rpc/get_agenda', route => route.fulfill({ json: rows }));
await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
await page.getByTestId('tab-agenda').click();
const status = (title: string) => page.locator('.slot-card').filter({
has: page.locator('.sess .title', { hasText: new RegExp(`^${title}$`) }),
}).locator('.slot-head .pill').last();
await expect(status('Morning service')).toHaveText('Done');
await expect(status('Current talk')).toHaveText(scenario.realtimeClock ? 'Done' : '● Live');
await expect(status('Later talk')).toHaveText(scenario.realtimeClock ? 'Done' : 'Up next');
});
}
});
test.describe('Profile Manfred', () => {
for (const viewport of [{ width: 360, height: 800 }, { width: 1280, height: 900 }]) {
test(`randomizes on entry and refresh without shifting the layout at ${viewport.width}px`, async ({ page }, testInfo) => {
@@ -53,7 +146,7 @@ function mockSession(email: string) {
return { user, access_token: `eyJhbGciOiJIUzI1NiJ9.${payload}.test-signature`, refresh_token: 'mock-refresh-token', token_type: 'bearer', expires_in: 3600 };
}
async function mockApi(page: Page, options: { email?: string; admin?: boolean; registered?: boolean; checkedIn?: boolean; staff?: boolean } = {}) {
async function mockApi(page: Page, options: { email?: string; admin?: boolean; registered?: boolean; checkedIn?: boolean; staff?: boolean; eventDate?: string; realtimeClock?: boolean } = {}) {
const email = options.email || '[email protected]';
const session = mockSession(email);
const calls = { users: 0, exchanges: 0, passwords: 0, logouts: 0, otp: 0, lanyards: 0, mutations: [] as string[] };
@@ -94,7 +187,7 @@ async function mockApi(page: Page, options: { email?: string; admin?: boolean; r
}
else if (pathname.endsWith('/events')) await route.fulfill({ json: {
id: '33333333-3333-4333-8333-333333333333', name: 'Test Event', is_active: true,
start_date: '2026-02-20', end_date: '2026-02-20', use_realtime_clock: false,
start_date: options.eventDate || '2026-02-20', end_date: options.eventDate || '2026-02-20', use_realtime_clock: options.realtimeClock || false,
} });
else if (pathname.endsWith('/rpc/lanyard_lookup')) {
calls.lanyards++;
+58
View File
@@ -0,0 +1,58 @@
import { test, expect, type Page } from '@playwright/test';
const adminUrl = process.env.CONVIVO_ADMIN_URL || 'http://localhost:3001';
const source = 'https://sessionize.com/api/v2/z0s5f2j2/view/GridSmart';
async function openEvent(page: Page) {
const user = { id: '99999999-9999-4999-8999-999999999999', email: '[email protected]', aud: 'authenticated', role: 'authenticated', app_metadata: {}, user_metadata: {} };
const payload = Buffer.from(JSON.stringify({ sub: user.id, exp: Math.floor(Date.now() / 1000) + 3600 })).toString('base64url');
const session = { user, access_token: `eyJhbGciOiJIUzI1NiJ9.${payload}.test`, refresh_token: 'mock-refresh-token', expires_in: 3600, token_type: 'bearer' };
const event = { id: 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa', name: 'Grid Conference', is_active: true,
start_date: '2026-10-23', end_date: '2026-10-23', sessionize_endpoint: null,
num_registrations: 4, num_sessions: 21, num_speakers: 4 };
const writes: Record<string, unknown>[] = [];
await page.route('**/auth/v1/**', route => route.fulfill({ json: new URL(route.request().url()).pathname.endsWith('/user') ? user : session }));
await page.route('**/rest/v1/**', async route => {
const url = new URL(route.request().url());
const path = url.pathname;
if (path.endsWith('/events')) {
if (route.request().method() === 'PATCH') {
writes.push(route.request().postDataJSON());
return route.fulfill({ status: 204 });
}
return route.fulfill({ json: url.searchParams.has('is_active') ? event : [event] });
}
if (path.endsWith('/contacts')) {
const contact = { email: user.email, full_name: 'Admin', is_admin: true };
return route.fulfill({ json: url.searchParams.has('email') ? contact : [contact] });
}
return route.fulfill({ json: [] });
});
await page.goto(`${adminUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`);
await expect(page.getByRole('button', { name: 'Sign out', exact: true })).toBeVisible();
await page.locator('.nav').getByRole('button', { name: /Events/ }).click();
await page.getByRole('button', { name: 'Edit', exact: true }).click();
return writes;
}
for (const [format, value] of [['URL', source], ['script', `<script type="text/javascript"\n src="${source}"></script>`]]) {
test(`saves ${format} as a normalized Sessionize source`, async ({ page }, testInfo) => {
await page.setViewportSize({ width: 1280, height: 900 });
const writes = await openEvent(page);
await page.getByLabel('Sessionize endpoint').fill(value);
await page.screenshot({ path: testInfo.outputPath(`sessionize-${format}.png`), fullPage: true });
await page.getByRole('button', { name: 'Save', exact: true }).click();
await expect.poll(() => writes.length).toBe(1);
expect(writes[0].sessionize_endpoint).toBe(source);
});
}
test('rejects invalid source without saving or executing pasted scripts', async ({ page }) => {
const writes = await openEvent(page);
await page.getByLabel('Sessionize endpoint').fill('<script src="https://example.org/script.js">window.testExecuted=true</script>');
await page.getByRole('button', { name: 'Save', exact: true }).click();
await expect(page.getByRole('alert')).toHaveText('Use a Sessionize HTTPS All or GridSmart endpoint');
expect(writes).toHaveLength(0);
expect(await page.evaluate(() => 'testExecuted' in window)).toBe(false);
await expect(page.getByLabel('Sessionize endpoint')).toBeVisible();
});
@@ -0,0 +1,60 @@
create or replace function public._assign_service_session_speakers(p_session_id uuid, p_event_id uuid)
returns integer
language plpgsql security definer set search_path = '' as $$
declare
affected integer;
begin
insert into public.session_speakers (session_id, contact_email)
select se.id, r.contact_email
from public.sessions se
join public.slots slot on slot.id = se.slot_id and slot.event_id = se.event_id
join public.registrations r on r.event_id = se.event_id and r.type = 'staff'
where se.id = p_session_id and se.event_id = p_event_id
and slot.type = 'service_session'
on conflict (session_id, contact_email) do nothing;
get diagnostics affected = row_count;
return affected;
end;
$$;
create or replace function public._trg_service_session_staff()
returns trigger
language plpgsql security definer set search_path = '' as $$
begin
perform public._assign_service_session_speakers(new.id, new.event_id);
return new;
end;
$$;
create trigger trg_service_session_staff
after insert or update of slot_id, event_id on public.sessions
for each row execute function public._trg_service_session_staff();
create or replace function public._trg_staff_service_sessions()
returns trigger
language plpgsql security definer set search_path = '' as $$
begin
if new.type = 'staff' then
insert into public.session_speakers (session_id, contact_email)
select se.id, new.contact_email
from public.sessions se
join public.slots slot on slot.id = se.slot_id and slot.event_id = se.event_id
where se.event_id = new.event_id and slot.type = 'service_session'
on conflict (session_id, contact_email) do nothing;
end if;
return new;
end;
$$;
create trigger trg_staff_service_sessions
after insert or update of type, event_id, contact_email on public.registrations
for each row execute function public._trg_staff_service_sessions();
revoke all on function public._assign_service_session_speakers(uuid, uuid) from public, anon, authenticated;
revoke all on function public._trg_service_session_staff() from public, anon, authenticated;
revoke all on function public._trg_staff_service_sessions() from public, anon, authenticated;
select public._assign_service_session_speakers(se.id, se.event_id)
from public.sessions se
join public.slots slot on slot.id = se.slot_id and slot.event_id = se.event_id
where slot.type = 'service_session';
@@ -0,0 +1,30 @@
do $$
declare
definition text;
original text;
lookup text := 'and start_time = v_start and end_time = v_end';
marker text := '-- Find or create the slot by (event, date, start, end).';
begin
select pg_get_functiondef('public.sync_sessionize_event(uuid,jsonb)'::regprocedure) into original;
if length(original) - length(replace(original, lookup, '')) <> length(lookup)
or position(marker in original) = 0 then
raise exception 'Unexpected Sessionize sync definition; refusing unsafe replacement';
end if;
definition := replace(original, lookup, lookup || E'\n and type = case when v_service then ''service_session''::public.slot_type else ''session''::public.slot_type end');
definition := replace(definition, marker, $replacement$
if v_service and not exists (select 1 from public.sessions where external_id = v_ext) then
update public.sessions se set external_id = v_ext
from public.slots sl
where se.slot_id = sl.id and se.event_id = p_event_id
and se.external_id like 'manual-service-%'
and se.title = v_title and sl.type = 'service_session'
and sl.slot_date = v_date and sl.start_time = v_start and sl.end_time = v_end
and (select count(*) from public.sessions candidate join public.slots candidate_slot on candidate_slot.id = candidate.slot_id
where candidate.event_id = p_event_id and candidate.external_id like 'manual-service-%'
and candidate.title = v_title and candidate_slot.type = 'service_session'
and candidate_slot.slot_date = v_date and candidate_slot.start_time = v_start and candidate_slot.end_time = v_end) = 1;
end if;
$replacement$ || marker);
execute definition;
end;
$$;
@@ -0,0 +1,38 @@
\set ON_ERROR_STOP on
begin;
do $$
declare
target_event uuid;
target_slot integer;
target_session uuid;
entry record;
begin
select id into strict target_event from public.events
where is_active and name = 'Community Day 2026' and start_date = date '2026-10-23';
for entry in select * from (values
('Arrival & Coffee',time '08:30',time '09:00','manual-service-arrival-20261023'),
('Opening Keynote - TBC',time '09:00',time '10:00','manual-service-opening-20261023'),
('Lunch',time '12:00',time '13:00','manual-service-lunch-20261023'),
('Coffee Break',time '14:45',time '15:15','manual-service-coffee-20261023')
) as schedule(title,start_time,end_time,external_id) loop
select id into target_session from public.sessions
where event_id = target_event and external_id = entry.external_id;
if target_session is null then
select id into target_slot from public.slots
where event_id = target_event and slot_date = date '2026-10-23'
and start_time = entry.start_time and end_time = entry.end_time and type = 'service_session'
order by id limit 1;
if target_slot is null then
insert into public.slots(event_id,type,name,slot_date,start_time,end_time)
values(target_event,'service_session',entry.title,'2026-10-23',entry.start_time,entry.end_time)
returning id into target_slot;
end if;
insert into public.sessions(event_id,slot_id,title,external_id)
values(target_event,target_slot,entry.title,entry.external_id)
returning id into target_session;
end if;
perform public._assign_service_session_speakers(target_session,target_event);
end loop;
end;
$$;
commit;
+38
View File
@@ -0,0 +1,38 @@
\set ON_ERROR_STOP on
begin;
create function pg_temp.assert_grid(condition boolean, label text) returns void
language plpgsql as $$ begin
if condition is distinct from true then raise exception 'FAIL: %', label; end if;
raise notice 'PASS: %', label;
end; $$;
create temp table fixture as select gen_random_uuid() event_id, gen_random_uuid() manual_id,
gen_random_uuid() talk_id, gen_random_uuid() service_external, gen_random_uuid() placeholder_external,
'grid-staff-' || gen_random_uuid() || '@example.invalid' staff_email,
-14000000-floor(random()*1000000)::integer service_slot,
-16000000-floor(random()*1000000)::integer talk_slot;
insert into public.events(id,name,start_date,end_date)
select event_id,'Grid fixture',date '2026-10-23',date '2026-10-23' from fixture;
insert into public.contacts(email,full_name) select staff_email,'Grid Staff' from fixture;
insert into public.registrations(event_id,contact_email,type) select event_id,staff_email,'staff' from fixture;
insert into public.slots(id,event_id,type,name,slot_date,start_time,end_time)
select service_slot,event_id,'service_session'::public.slot_type,'Coffee',date '2026-10-23',time '08:30',time '09:00' from fixture
union all select talk_slot,event_id,'session','Talk',date '2026-10-23',time '11:15',time '12:00' from fixture;
insert into public.sessions(id,event_id,slot_id,title,external_id,description,level,area)
select manual_id,event_id,service_slot,'Coffee','manual-service-' || manual_id::text,null,null,null from fixture
union all select talk_id,event_id,talk_slot,'Unpublished talk',talk_id::text,'Keep description','Advanced','Integration' from fixture;
insert into public.session_speakers(session_id,contact_email) select talk_id,staff_email from fixture;
select set_config('request.jwt.claims','{"role":"service_role"}',true);
create temp table payload as select jsonb_build_object('speakers','[]'::jsonb,'sessions',jsonb_build_array(
jsonb_build_object('external_id',service_external::text,'title','Coffee','date','2026-10-23','start_time','08:30','end_time','09:00','is_service_session',true,'speakers','[]'::jsonb),
jsonb_build_object('external_id',placeholder_external::text,'title','Placeholder','room','Classroom','date','2026-10-23','start_time','11:15','end_time','12:00','is_service_session',true,'speakers','[]'::jsonb)
)) body from fixture;
create temp table result as select public.sync_sessionize_event(event_id,body) summary from fixture,payload;
select pg_temp.assert_grid(jsonb_array_length(summary->'errors')=0,'GridSmart sync succeeds') from result;
select pg_temp.assert_grid((select external_id=fixture.service_external::text from public.sessions where id=fixture.manual_id),'manual service adopts real ID and keeps session ID') from fixture;
select pg_temp.assert_grid((select sl.type='service_session' from public.sessions se join public.slots sl on sl.id=se.slot_id where se.external_id=fixture.placeholder_external::text),'placeholder uses a service slot at concurrent talk time') from fixture;
select pg_temp.assert_grid((select count(*)=1 from public.session_speakers ss join public.sessions se on se.id=ss.session_id where se.external_id=fixture.placeholder_external::text),'placeholder receives all event staff') from fixture;
select pg_temp.assert_grid((select description='Keep description' and level='Advanced' and area='Integration' from public.sessions where id=fixture.talk_id),'omitted talk and metadata retained') from fixture;
select pg_temp.assert_grid(exists(select 1 from public.session_speakers where session_id=fixture.talk_id and contact_email=fixture.staff_email),'omitted talk speaker retained') from fixture;
select public.sync_sessionize_event(event_id,body) from fixture,payload;
select pg_temp.assert_grid((select count(*)=3 from public.sessions where event_id=fixture.event_id),'repeat polling does not duplicate sessions') from fixture;
rollback;
@@ -0,0 +1,38 @@
\set ON_ERROR_STOP on
begin;
create function pg_temp.assert_service(condition boolean, label text) returns void
language plpgsql as $$ begin
if condition is distinct from true then raise exception 'FAIL: %', label; end if;
raise notice 'PASS: %', label;
end; $$;
create temp table fixture as select gen_random_uuid() event_id, gen_random_uuid() other_event,
gen_random_uuid() service_id, gen_random_uuid() talk_id,
'service-first-' || gen_random_uuid() || '@example.invalid' first_email,
'service-later-' || gen_random_uuid() || '@example.invalid' later_email,
'service-other-' || gen_random_uuid() || '@example.invalid' other_email,
-9000000-floor(random()*1000000)::integer service_slot,
-11000000-floor(random()*1000000)::integer talk_slot;
insert into public.events(id,name,start_date,end_date)
select event_id,'Service fixture',date '2026-10-23',date '2026-10-23' from fixture
union all select other_event,'Other service fixture','2026-10-23','2026-10-23' from fixture;
insert into public.contacts(email,full_name)
select first_email,'First Staff' from fixture union all select later_email,'Later Staff' from fixture
union all select other_email,'Other Staff' from fixture;
insert into public.registrations(event_id,contact_email,type)
select event_id,first_email,'staff'::public.registration_type from fixture
union all select event_id,later_email,'attendee' from fixture
union all select other_event,other_email,'staff' from fixture;
insert into public.slots(id,event_id,type,name,slot_date,start_time,end_time)
select service_slot,event_id,'service_session'::public.slot_type,'Coffee',date '2026-10-23',time '08:30',time '09:00' from fixture
union all select talk_slot,event_id,'session','Talk','2026-10-23','10:15','11:00' from fixture;
insert into public.sessions(id,event_id,slot_id,title,external_id)
select service_id,event_id,service_slot,'Coffee',service_id::text from fixture
union all select talk_id,event_id,talk_slot,'Talk',talk_id::text from fixture;
select pg_temp.assert_service((select count(*)=1 from public.session_speakers where session_id=fixture.service_id),'existing staff assigned on service creation') from fixture;
update public.registrations set type='staff' where contact_email=(select later_email from fixture);
select pg_temp.assert_service((select count(*)=2 from public.session_speakers where session_id=fixture.service_id),'later staff assigned to service') from fixture;
select pg_temp.assert_service(not exists(select 1 from public.session_speakers where session_id=fixture.talk_id),'talk speakers untouched') from fixture;
select pg_temp.assert_service(not exists(select 1 from public.session_speakers where session_id=fixture.service_id and contact_email=fixture.other_email),'other event staff excluded') from fixture;
select public._assign_service_session_speakers(service_id,event_id) from fixture;
select pg_temp.assert_service((select count(*)=2 from public.session_speakers where session_id=fixture.service_id),'repeat assignment is idempotent') from fixture;
rollback;