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.

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-19 20:14:03 +02:00
1 parent cdb4793273
commit d3083b7940
35 files changed
+2778 -154

No files matched your search

+83 -3
View File
@@ -16,13 +16,13 @@ function fixture(options = {}) {
assert.equal(init.headers.Authorization, 'Bearer user-token');
return new Response(JSON.stringify({ id: 'user-id', email: '[email protected]' }), { status: options.unauthorized ? 401 : 200 });
},
validateEndpoint: async () => {},
validateEndpoint: options.validateEndpoint || (async () => {}),
providerFetch: options.providerFetch || (async () => new Response(JSON.stringify({ choices: [{ message: { content: 'Helpful feedback summary' } }] }))),
supabaseFetch: async (path, init) => {
if (init) { writes.push({ path, ...init }); return null; }
reads.push(path);
if (path.includes('/contacts?')) return [{ is_admin: !options.notAdmin }];
if (path.includes('/llm_settings?')) return options.noSettings ? [] : [config];
if (path.includes('/llm_settings?')) return options.noSettings ? [] : (options.settingsRows || [config]);
if (path.includes('/events?')) return [{ id: eventId, name: 'Event' }];
if (path.includes('/sessions?')) return options.wrongSession ? [] : [{ id: sessionId, title: 'Session' }];
if (path.includes('/feedback?') || path.includes('/event_feedback?')) {
@@ -116,4 +116,84 @@ test('blocks private, loopback, metadata, mapped and reserved IP destinations',
await assert.rejects(resolveEndpoint(config.endpoint, async () => [{ address: '127.0.0.1', family: 4 }]), /public IP/);
const record = await resolveEndpoint(config.endpoint, async () => [{ address: '8.8.8.8', family: 4 }]);
assert.equal(record.address, '8.8.8.8');
});
});
const okReply = { choices: [{ message: { content: 'OK' } }], usage: { completion_tokens: 1, completion_tokens_details: { reasoning_tokens: 0 } } };
test('llm-test verifies the connection and sends thinking-disabled request', async () => {
const calls = [];
const { api, writes } = fixture({ providerFetch: async (url, options) => {
calls.push({ url, options, body: JSON.parse(options.body) });
return new Response(JSON.stringify(okReply));
} });
const verdict = await api.handle(request(), '/llm-test');
assert.equal(verdict.ok, true);
assert.equal(verdict.model, 'model');
assert.equal(verdict.endpoint, config.endpoint);
assert.equal(verdict.reasoning_disabled, true);
assert.equal(verdict.content, 'OK');
assert.equal(verdict.error, null);
assert.equal(typeof verdict.latency_ms, 'number');
assert.equal(writes.length, 0);
assert.equal(calls.length, 1);
assert.equal(calls[0].url, config.endpoint);
assert.equal(calls[0].options.headers.Authorization, 'Bearer secret');
// Same body shape as generateSummary, so the test really proves summaries work.
assert.equal(calls[0].body.model, 'model');
assert.equal(calls[0].body.stream, false);
assert.equal(calls[0].body.reasoning_effort, 'none');
assert.deepEqual(calls[0].body.chat_template_kwargs, { enable_thinking: false });
assert.equal(calls[0].body.thinking, undefined);
assert.ok(!JSON.stringify(verdict).includes('secret'));
});
test('llm-test reports thinking still on without calling it a clean pass', async () => {
const { api } = fixture({ providerFetch: async () => new Response(JSON.stringify({
choices: [{ message: { content: 'OK' } }],
usage: { completion_tokens: 236, completion_tokens_details: { reasoning_tokens: 235 } },
})) });
const verdict = await api.handle(request(), '/llm-test');
assert.equal(verdict.ok, true);
assert.equal(verdict.reasoning_disabled, false);
assert.equal(verdict.reasoning_tokens, 235);
assert.match(verdict.warning, /thinking is still enabled/);
});
test('llm-test answers ok:false for unconfigured settings, provider errors and blocked endpoints', async () => {
const cases = [
{ label: 'no settings stored', options: { noSettings: true }, match: /No LLM endpoint and model are configured/ },
{ label: 'endpoint stored without a model', options: { settingsRows: [{ ...config, model: '' }] }, match: /No LLM endpoint and model are configured/ },
{ label: 'provider 503', options: { providerFetch: async () => new Response(JSON.stringify({ error: { message: 'upstream unavailable' } }), { status: 503 }) }, match: /HTTP 503.*upstream unavailable/ },
{ label: 'provider network failure', options: { providerFetch: async () => { throw new Error('ECONNREFUSED'); } }, match: /failed or timed out/ },
{ label: 'endpoint fails SSRF validation', options: { validateEndpoint: async () => { throw new Error('LLM endpoint must resolve to a public IP address'); } }, match: /must resolve to a public IP/ },
];
for (const { label, options, match } of cases) {
const { api, writes } = fixture(options);
const verdict = await api.handle(request(), '/llm-test');
assert.equal(verdict.ok, false, label);
assert.match(verdict.error, match, label);
assert.equal(verdict.model, /no settings|endpoint stored/.test(label) ? '' : 'model', label);
assert.equal(writes.length, 0, label);
assert.ok(!JSON.stringify(verdict).includes('secret'), label);
}
// A blocked endpoint must never reach the provider.
let providerCalled = false;
const blocked = fixture({ validateEndpoint: async () => { throw new Error('private'); }, providerFetch: async () => { providerCalled = true; return new Response('{}'); } });
assert.equal((await blocked.api.handle(request(), '/llm-test')).ok, false);
assert.equal(providerCalled, false);
});
test('llm-test never leaks the stored key and rejects non-POST', async () => {
const { api } = fixture({ providerFetch: async () => new Response(JSON.stringify({ error: { message: `bad key: ${'secret'}` } }), { status: 401 }) });
const verdict = await api.handle(request(), '/llm-test');
assert.equal(verdict.ok, false);
assert.match(verdict.error, /HTTP 401/);
assert.ok(!verdict.error.includes('secret'));
assert.match(verdict.error, /\[redacted\]/);
await assert.rejects(api.handle(request('GET'), '/llm-test'), error => error.status === 405);
});
test('llm-test requires an authenticated admin', async () => {
const { api } = fixture({ unauthorized: true });
await assert.rejects(api.handle(request(), '/llm-test'), error => error.status === 401);
});