fix(points): welcome check-in awards +10; add Sessions view, AI connection test, silent reload
The front-desk check-in set checked_in and printed badges but awarded nothing, so the +10 depended on which check-in a person happened to get. Every award path was reviewed: - welcome_checkin awards +10 (category checkin) on a genuine first check-in and returns points + points_awarded; checkin_attendee and preview_welcome_checkin return points_awarded too. - set_registration_checked_in(false) deleted all checkin points while keeping the checkins rows, and switching back on awarded nothing -- one mistaken toggle destroyed those points permanently. ON now recomputes from the rows that still exist and awards only the shortfall: reversible, still unfarmable. - The staff/Admin/@appe.at exclusion stays (product decision) but is no longer silent: three-way points sheets in the scanner, "no points" with a tooltip in Registrations, and the Contacts points modal refuses to apply rather than letting adjust_points (void) no-op quietly. Also in this change: - admin silent refresh (5s poll + 500ms after writes) across all data views; Registrations patches in place so rows never slide under the cursor - Settings "Validate AI connection" via a new sidecar POST /llm-test verdict endpoint (never leaks the key, distinguishes "no usage block" from "off") - new Sessions view between Schedule and Activity: speakers, attendance, ratings, attendee filter, and one button that summarises every session with feedback (one request each, concurrency 3, UI blocked until all settle) - provider requests disable thinking through one shared body builder sending both reasoning_effort:"none" and chat_template_kwargs.enable_thinking SQL: 113 / 57 / 24 assertions (set_registration_checked_in section 3 was rewritten, it asserted the bug). Sidecar 34 unit tests. Full e2e 202 passed, 0 failed. Migration applied locally only -- not deployed.
This commit is contained in:
1 parent
96e4e6a6ea
commit
fdb6045966
35 files changed
+2778
-154
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
getAllCheckins,
|
||||
getAllConnections,
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from '../lib/api';
|
||||
import type { Checkin, Connection, Contact, Event, Feedback, LeaderboardRow } from '../lib/types';
|
||||
import { Avatar, Empty, Spinner } from '../components/ui';
|
||||
import { useSilentRefresh } from '../lib/useSilentRefresh';
|
||||
import type { View } from '../App';
|
||||
|
||||
export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
@@ -21,40 +22,51 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
const [lb, setLb] = useState<LeaderboardRow[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
try {
|
||||
const ev = await getActiveEvent();
|
||||
if (cancelled) return;
|
||||
setEvent(ev);
|
||||
if (!ev) {
|
||||
setLoaded(true);
|
||||
return;
|
||||
}
|
||||
const [c, ck, conn, f, l] = await Promise.all([
|
||||
getAllContacts(),
|
||||
getAllCheckins(),
|
||||
getAllConnections(),
|
||||
getAllFeedback(),
|
||||
getLeaderboard(),
|
||||
]);
|
||||
if (cancelled) return;
|
||||
setContacts(c);
|
||||
setCheckins(ck.filter((x) => x.event_id === ev.id));
|
||||
setConnections(conn.filter((x) => x.event_id === ev.id));
|
||||
setFeedback(f.filter((x) => x.event_id === ev.id));
|
||||
setLb(l.filter((x) => x.event_id === ev.id));
|
||||
const cancelledRef = useRef(false);
|
||||
|
||||
async function load(silent = false) {
|
||||
try {
|
||||
const ev = await getActiveEvent();
|
||||
if (cancelledRef.current) return;
|
||||
setEvent(ev);
|
||||
if (!ev) {
|
||||
setLoaded(true);
|
||||
} catch (e) {
|
||||
if (!cancelled) setError(e instanceof Error ? e.message : 'Failed to load');
|
||||
return;
|
||||
}
|
||||
})();
|
||||
const [c, ck, conn, f, l] = await Promise.all([
|
||||
getAllContacts(),
|
||||
getAllCheckins(),
|
||||
getAllConnections(),
|
||||
getAllFeedback(),
|
||||
getLeaderboard(),
|
||||
]);
|
||||
if (cancelledRef.current) return;
|
||||
setContacts(c);
|
||||
setCheckins(ck.filter((x) => x.event_id === ev.id));
|
||||
setConnections(conn.filter((x) => x.event_id === ev.id));
|
||||
setFeedback(f.filter((x) => x.event_id === ev.id));
|
||||
setLb(l.filter((x) => x.event_id === ev.id));
|
||||
setLoaded(true);
|
||||
} catch (e) {
|
||||
// A failed background tick must not replace a good dashboard with the error
|
||||
// screen — this view renders `if (error) return <Empty/>`.
|
||||
if (!silent && !cancelledRef.current) setError(e instanceof Error ? e.message : 'Failed to load');
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
cancelledRef.current = false;
|
||||
void load();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
cancelledRef.current = true;
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Live counters: arrivals, connections and the leaderboard move as the event
|
||||
// runs, without anyone pressing reload.
|
||||
useSilentRefresh(() => load(true), { enabled: loaded });
|
||||
|
||||
const nameOf = useMemo(() => {
|
||||
const m = new Map(contacts.map((c) => [c.email, c.full_name]));
|
||||
return (email: string) => m.get(email) ?? email;
|
||||
|
||||
Reference in new issue
Block a user