import Link from "next/link"; import { badgeVariants } from "@/components/ui/badge"; import { Card } from "@/components/ui/panel"; import type { RefreshRow } from "@/lib/articles/refresh"; import RefreshWatch from "./RefreshWatch"; // --------------------------------------------------------------------------- // The newest REFRESH on an article's Overview (plans/umtool-redesign.md, R4): // what its refresh.json kept, in one line — "4 new recordings match · 2 quotes // changed · 1 source deleted", or "Nothing new since " — then the new // recordings, the quotes that changed and what was fetched and built; the // update's spend, or the cap that held it. While it runs, the page reads // again every few seconds (RefreshWatch). // --------------------------------------------------------------------------- const STATUS: Record = { running: { label: "running", variant: "meter" }, "no-change": { label: "no change", variant: "info" }, // R6.1: the search again was capped and found nothing — not "no change". partial: { label: "partial", variant: "state" }, updated: { label: "updated", variant: "on" }, "held-by-cap": { label: "held by the cap", variant: "state" }, failed: { label: "failed", variant: "blocking" }, cancelled: { label: "cancelled", variant: "info" }, }; const usd = (n: number) => `$${n.toFixed(2)}`; export default function RefreshSummary({ row, iterationsHref }: { row: RefreshRow; iterationsHref: string }) { const live = row.status === "queued" || row.status === "running"; const state = live ? "running" : (row.refresh ?? (row.status === "failed" ? "failed" : row.status === "cancelled" ? "cancelled" : "running")); const s = STATUS[state] ?? STATUS.running!; const fetched = row.fetch.filter((f) => f.status === "done").length; const skipped = row.fetch.filter((f) => f.status === "skipped" || f.status === "refused"); return (

Refresh · i{row.n}

{s.label} {row.hasReport ? "Review in Iterations →" : "Iterations →"}

{live ? "Fetching and searching again…" : row.summary.split(" — ")[0]}

{!live && row.summary.includes(" — ") &&

{row.summary.split(" — ").slice(1).join(" — ")}

} {row.news.length > 0 && (
    {row.news.map((r) => (
  • {r.date ?? ""} {r.title ?? r.id}
  • ))} {row.counts.newIds > row.news.length &&
  • and {row.counts.newIds - row.news.length} more
  • }
)} {row.drifted.length > 0 && (
    {row.drifted.map((d) => (
  • {d.citation} “{d.quote}” {d.now !== null && now: “{d.now.slice(0, 200)}”}
  • ))}
)} {row.deleted.length > 0 && (

{row.gone.join(" · ")}: {row.deleted.join(", ")}

)} {row.counts.changed === null && (

{row.warnings.find((w) => w.startsWith("changed recordings are not tracked")) ?? "changed recordings are not tracked for this iteration"}

)}

{row.fetch.length ? `${fetched} fetch${fetched === 1 ? "" : "es"} done` : "no fetch"} {skipped.length ? ` · skipped: ${skipped.map((f) => `${f.channel} ${f.action} (${f.reason ?? f.status})`).join("; ")}` : ""} {row.build ? ` · build ${row.build.site ?? "none"} ${row.build.status}${row.build.reason ? ` (${row.build.reason})` : ""}` : ""} {row.update?.usd ? ` · ${usd(row.update.usd)} spent` : !live && (row.refresh === "no-change" || row.refresh === "partial") && !row.update ? " · $0" : ""} {row.update?.refusal ? ` · about ${usd(row.update.estimateUsd)} to update` : ""}

{live && }
); }