import { useState } from 'react' // #798: a quiet "how this summary was made" line at the bottom of the decision page. Click opens a // panel of recorded facts only. A fact the run did not record is left out, never filled in. export interface Provenance { model?: string | null generated_at?: string | null tier?: string | null prompt_name?: string | null prompt_version?: string | null transcript_source?: string | null video_url?: string | null analyses_for_meeting?: number | null } export interface ProvenanceFact { label: string value: string } const TIER_LABEL: Record = { light: 'Light (fast, shorter analysis)', full: 'Full (deeper analysis)', } /** The facts to list, in order, skipping every one that was not recorded. */ export function provenanceFacts(p: Provenance | null | undefined): ProvenanceFact[] { if (!p) return [] const out: ProvenanceFact[] = [] if (p.model) out.push({ label: 'Model', value: p.model }) if (p.generated_at) { const d = new Date(p.generated_at) if (!Number.isNaN(d.getTime())) out.push({ label: 'Generated', value: d.toLocaleString() }) } if (p.tier && TIER_LABEL[p.tier]) out.push({ label: 'Analysis', value: TIER_LABEL[p.tier] }) if (p.prompt_name) out.push({ label: 'Prompt', value: p.prompt_version ? `${p.prompt_name} (version ${p.prompt_version})` : p.prompt_name, }) if (p.transcript_source) out.push({ label: 'Transcript source', value: p.transcript_source }) return out } /** Set when the preferred-analysis step chose between several analyses of this meeting. */ export function chosenAmongNote(p: Provenance | null | undefined): string | null { const n = p?.analyses_for_meeting if (!n || n < 2) return null return `This meeting has ${n} analyses. This is the one shown, chosen by the site's model preference.` } export default function AnalysisProvenance({ provenance }: { provenance?: Provenance | null }) { const [open, setOpen] = useState(false) const facts = provenanceFacts(provenance) const note = chosenAmongNote(provenance) const video = provenance?.video_url || null if (!facts.length && !video) return null return (
{open ? (

This summary is machine-generated from the meeting transcript. It can contain mistakes: check it against the recording.

{facts.length ? (
{facts.map((f) => (
{f.label}
{f.value}
))}
) : null} {note ?

{note}

: null} {video ? (

Watch the source recording

) : null}
) : null}
) }