import Link from "next/link"; import CheckSourcesButton from "@/components/system/CheckSourcesButton"; import { sourcesOf } from "@/lib/projects/report.mjs"; import { clipBenchHref } from "@/lib/hrefs"; import TagCitedButton from "../TagCitedButton"; import { Pill, type ReportTabProps } from "./shared"; // The Sources tab: every recording the cut cites, its cues and coverage, when // its availability was last checked, where its QR resolves, and tagging the // lot in the archive. Moved from ReportProject unchanged (P4a-1). export default async function SourcesTab({ project, detail }: ReportTabProps) { const { manifest: m, channelsDir, shadowExists } = detail; const p = (m.provenance ?? {}) as Record; const sources = await sourcesOf(project.dir, { manifest: m }); const days = (ms: number) => Math.floor((Date.now() - ms) / 86_400_000); return ( <> {/* --- the sources ---------------------------------------------- */}

sources — {sources.rows.length}

{sources.checkedAtMs ? `availability checked ${days(sources.checkedAtMs)} d ago` : "availability never checked"}
{/* Beside the sources, because these ARE the sources: tagging them in the archive is a statement about the recordings this table lists, and the count in the control is the count in its heading. */}
cues from {channelsDir} {shadowExists && ( (this project’s own shadow tree) )} {" · "}QR codes resolve to{" "} {String(p.siteOrigin ?? "") || "(nothing — siteOrigin is unset)"}
{sources.rows.length > 0 && (
{sources.rows.map((r) => { const a = r.availability; return ( ); })}
source clips cues coverage availability cite target
{r.key} {r.title &&
{r.title}
}
{r.clips.map((c, i) => ( {i > 0 && " "} {c} ))} {r.cues === "missing" ? ( missing ) : r.cues === "no-punctuation" ? ( no punctuation ) : ( present )} {r.coverageGap ? ( cues end {r.coverageGap.cuesEnd.toFixed(0)} s · {r.coverageGap.clip} needs {r.coverageGap.needs.toFixed(0)} s ) : r.cuesEnd != null ? ( cues to {r.cuesEnd.toFixed(0)} s ) : ( — )} {a ? ( {a.state === "held-locally" ? "held locally" : a.state === "unchecked" ? "not checked" : a.state} · {days(a.checkedAtMs)} d ago ) : ( never checked )} {r.cite.differs ? ( citeUrl{" "} override ) : ( derived )}
)}
); }