import { stat } from "node:fs/promises"; import { readLinkCheck } from "@/lib/report/linkCheck.mjs"; import { dayOf, projectSites, sitesByOrigin } from "@/lib/report/siteDeploys.mjs"; import { SITES_DIR } from "@/lib/paths.mjs"; import type { ProjectRef } from "@/lib/project-types"; import DecisionSettle from "./DecisionSettle"; import type { ClipDetail } from "./shared"; // THE SITES THIS CUT'S LINKS DEPEND ON (UI notes 2026-10-30, #9), on the // piece's Overview: each site a clip QR opens, named from its site.json, with // its deploy's date -- the corpus.json `generatedAt` the last link check read // (out/links.json; this never fetches) -- and the cited videos newer than that // deploy. "Publish " asks the editor to build and deploy it; "Check // links" reads every site again. The same answer is the check's // `site-deploy-behind` row (lib/report/siteDeploys.mjs). const STATE: Record = { ok: "", unreachable: "couldn't reach it at the last check", "no-corpus": "it publishes no corpus.json", unchecked: "not checked yet", }; export default async function ProjectSites({ project, detail }: { project: ProjectRef; detail: ClipDetail }) { const m = detail.manifest as Record; const doc = await readLinkCheck(project.dir); const records = new Map(); for (const e of detail.entries) { if (e.kind !== "clip") continue; const cueFile = (e as { cueFile?: string | null }).cueFile; const st = cueFile ? await stat(cueFile).catch(() => null) : null; records.set(e.id, { uploadDate: (e as { uploadDate?: string | null }).uploadDate ?? null, landedAt: st ? new Date(st.mtimeMs).toISOString() : null, }); } const sites = projectSites(m, doc, { sites: sitesByOrigin(SITES_DIR), recordOf: (id: string) => records.get(id) ?? null }); if (!sites.length) return null; return (

Sites the links depend on

    {sites.map((s) => (
  • {s.host} {s.siteId && {s.siteId}} {s.links} link{s.links === 1 ? "" : "s"} · {s.clips.length} clip{s.clips.length === 1 ? "" : "s"}

    {s.deployedAt ? `deployed ${dayOf(s.deployedAt)} (its corpus.json)` : "deploy date unknown"} {STATE[s.state] ? ` · ${STATE[s.state]}` : ""} {doc?.checkedAt ? ` · checked ${doc.checkedAt.slice(0, 16).replace("T", " ")}` : ""}

    {s.newer.length > 0 && (

    {s.newer.length} cited video{s.newer.length === 1 ? " is" : "s are"} newer than this deploy:{" "} {s.newer.slice(0, 6).map((n) => `${n.clip} (${n.why})`).join(", ")} {s.newer.length > 6 ? ` and ${s.newer.length - 6} more` : ""}

    )}
    {s.siteId && s.newer.length > 0 && ( )}
  • ))}
); }