WIP 2.0.0: AI buttons on the five screens, eval set, privacy notice

Describe your event (new event), Improve/Shorter/Fix mistakes (event
description, banner, email and WhatsApp boxes), Draft with AI (email and
WhatsApp attendees), Summarise this report (people-free reports) and
Summarise feedback (per event). Built-in privacy notice text for AI
(2.0.0 entry in BUILT_IN_UPDATES). npm run ai:eval runs the trial cases
through the Hub with fact checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls1vMeckMWrKPfc1MMyMJF
This commit is contained in:
2026-10-30 18:19:46 +02:00
co-authored by Claude Opus 5.5
parent d4f54f2cc8
commit 4924d1ed76
14 changed files with 620 additions and 1 deletions
@@ -14,6 +14,8 @@ import { MessageKindPicker, matchedText, type MessageKind } from "@/components/s
import { CampusAudiencePicker } from "@/components/shared/CampusAudiencePicker";
import { EventPicker } from "@/components/shared/EventPicker";
import { apiV2Data } from "@/lib/apiV2";
import { AiDraftMessage } from "@/components/shared/AiDraftMessage";
import { AiImprove } from "@/components/shared/AiImprove";
type Attendee = { id: string; name: string; email: string; pref: string };
type TemplateKey = 'custom'|'payment_reminder'|'event_reminder'|'tickets';
@@ -614,9 +616,13 @@ function EmailAttendeesPageInner() {
{templateKey !== 'tickets' ? (
<div>
<div className="mb-2">
<AiDraftMessage channel="email" eventId={eventId || undefined} onUse={d => { setSubject(d.subject); setSubjectDirty(true); setBody(d.body); setBodyDirty(true); }} />
</div>
<label className="block text-xs text-gray-600 mb-1">Message</label>
<textarea className="w-full border rounded px-3 py-2 text-sm" rows={8} value={body} onChange={e => { setBody(e.target.value); setBodyDirty(true); }} placeholder="Write your message to attendees..." />
<div className="text-[11px] text-gray-500 mt-1">Hint: Start with &lt;html&gt; or &lt;div&gt; to send HTML; otherwise plain text will be sent.</div>
{!/^\s*</.test(body) && <AiImprove text={body} onChange={t => { setBody(t); setBodyDirty(true); }} where="message" />}
</div>
) : (
<div className="p-3 border rounded bg-gray-50 text-sm text-gray-700">This will send each selected attendee their ticket(s) as attachments for this event.</div>
@@ -22,6 +22,8 @@ import {
} from "@/components/events/ScheduleEditor";
import { toSessionDraft, scheduleSummary } from "@/lib/sessions";
import { fetchApiFile, openBlob } from "@/lib/export";
import { AiEventDraft, type AiEventDraftFields } from "@/components/events/AiEventDraft";
import { AiImprove } from "@/components/shared/AiImprove";
import { apiV2, apiV2Data } from "@/lib/apiV2";
import { createTicketOption, updateTicketOption, listSections, createSection, updateSection, deleteSection, listAttachments, uploadAttachment, deleteAttachment, uploadImage } from "@/lib/eventSetup";
@@ -1127,6 +1129,33 @@ function EventModal({ mode, event: ev, source, onClose, onSuccess }: EventModalP
const upd = (patch: Partial<EventDraft>) => setDraft(d => ({ ...d, ...patch }));
// ── AI: "Describe your event" fills in the form (a person checks every step before saving) ──
const applyAiDraft = (a: AiEventDraftFields) => {
const at = (date: string, time: string, fallback: string) => (date ? `${date}T${time || fallback}` : "");
const asSessions = a.sessions.length > 1;
upd({
...(a.title ? { title: a.title } : {}),
...(a.description ? { description: a.description } : {}),
...(a.location ? { location: a.location } : {}),
requiresParentalConsent: a.needsParentalConsent,
scheduleType: asSessions ? "sessions" : "single",
...(asSessions ? {} : { startDate: at(a.startDate, a.startTime, "09:00"), endDate: at(a.endDate || a.startDate, a.endTime, "17:00") }),
...(a.ticketOptions[0] ? { price: String(a.ticketOptions[0].priceRand) } : {}),
});
if (asSessions) {
setSessions(a.sessions.map(s => keyed({ label: s.label, startsAt: at(s.date, s.startTime, "09:00"), endsAt: at(s.date, s.endTime || s.startTime, "17:00"), location: "", cancelled: false, capacity: "" })));
}
if (a.ticketOptions.length) {
setOptions(a.ticketOptions.map((t, i) => ({
name: t.name || "Ticket", price: String(t.priceRand), isMainTicket: i === 0,
// The event's places go on the main ticket; 0 means no limit.
stockLimit: i === 0 && a.capacity > 0 ? String(a.capacity) : "0",
earlyBirdTiers: t.earlyBirdPriceRand > 0 && t.earlyBirdUntil ? [{ deadline: `${t.earlyBirdUntil}T23:59`, price: String(t.earlyBirdPriceRand), stockLimit: "0" }] : [],
variants: [],
})));
}
};
// ── copy: move every date by the same amount (sessions, deadline, early birds, feedback) ──
const copyStart = multi ? scheduleBounds?.start || "" : draft.startDate;
const moveAllDates = (newStart: string) => {
@@ -1539,6 +1568,7 @@ function EventModal({ mode, event: ev, source, onClose, onSuccess }: EventModalP
{copyStart && new Date(copyStart) < new Date() && <p className="text-xs text-amber-700">This copy still starts in the past.</p>}
</div>
)}
{mode === "create" && !cloning && <AiEventDraft onApply={applyAiDraft} />}
<div>
<label className="block text-xs text-gray-600 mb-1">Title <span className="text-red-500">*</span></label>
<input className="w-full border rounded px-3 py-2 text-sm" value={draft.title} onChange={e => upd({ title: e.target.value })} placeholder="Event title" />
@@ -1546,6 +1576,7 @@ function EventModal({ mode, event: ev, source, onClose, onSuccess }: EventModalP
<div>
<label className="block text-xs text-gray-600 mb-1">Description</label>
<textarea className="w-full border rounded px-3 py-2 text-sm" rows={3} value={draft.description} onChange={e => upd({ description: e.target.value })} />
<AiImprove text={draft.description} onChange={description => upd({ description })} where="description" />
</div>
<div>
<div className="block text-xs text-gray-600 mb-1">When <span className="text-red-500">*</span></div>
@@ -14,6 +14,8 @@ import { MessageKindPicker, matchedText, type MessageKind } from "@/components/s
import { CampusAudiencePicker } from "@/components/shared/CampusAudiencePicker";
import { EventPicker } from "@/components/shared/EventPicker";
import { apiV2Data } from "@/lib/apiV2";
import { AiDraftMessage } from "@/components/shared/AiDraftMessage";
import { AiImprove } from "@/components/shared/AiImprove";
// Attendee with preference info
type Attendee = { id: string; name: string; phone: string; pref: string };
@@ -716,10 +718,14 @@ function WhatsAppAttendeesPageInner() {
{templateKey !== "tickets" ? (
<div>
<div className="mb-2">
<AiDraftMessage channel="whatsapp" eventId={eventId || undefined} onUse={d => { setMessage(d.body); messageDirtyRef.current = true; }} />
</div>
<label className="block text-xs text-gray-600 mb-1">Message</label>
<textarea className="w-full border rounded px-3 py-2 text-sm" rows={8} value={message}
onChange={(e) => { setMessage(e.target.value); messageDirtyRef.current = true; }}
placeholder="Write your WhatsApp message to attendees..." />
<AiImprove text={message} onChange={t => { setMessage(t); messageDirtyRef.current = true; }} where="message" />
</div>
) : (
<div className="p-3 border rounded bg-gray-50 text-sm text-gray-700">
@@ -6,6 +6,7 @@ import { useRouter } from "next/navigation";
import { Megaphone } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { AiImprove } from "@/components/shared/AiImprove";
type BannerType = "info" | "warning" | "success" | "danger";
@@ -124,6 +125,7 @@ export default function SetBannerPage() {
value={message}
onChange={e => setMessage(e.target.value)}
/>
<AiImprove text={message} onChange={setMessage} where="banner" />
</div>
<div>