"use client"; import { useState } from "react"; import CitedClip from "@/components/clips/CitedClip"; import { buttonVariants } from "@/components/ui/button"; import type { QuoteChecks, ReportCheck } from "@/lib/articles/checks"; import type { CitedTarget } from "@/lib/clips/types"; import { cn } from "@/lib/utils"; // VERIFY QUOTES and CHECK REPORT (release 32 R1): the CLI's `reports // verify-quotes --article` and `reports check --article`, as two buttons on // the article page (lib/articles/checks.ts runs the same functions). Every // quote's status, score and track, every problem in its own sentence -- and a // Play beside each, so the person rules by ear. No model. const WARN = new Set(["inexact", "fragment"]); const tone = (status: string) => status === "ok" || status === "pass" ? "text-meter" : WARN.has(status) ? "text-doubt-text" : "text-reject-text"; function Play({ target, why }: { target: CitedTarget; why: string }) { const [open, setOpen] = useState(false); return open ? ( ) : ( ); } export default function ArticleChecks({ site, report }: { site: string; report: string }) { const [busy, setBusy] = useState(null); const [result, setResult] = useState(null); const [error, setError] = useState(null); const [allowMissing, setAllowMissing] = useState(false); const run = async (what: "quotes" | "check") => { setBusy(what); setError(null); try { const r = await fetch("/api/articles/checks", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ site, report, what, allowMissingMedia: allowMissing }), cache: "no-store", }); const j = await r.json(); if (!r.ok) throw new Error(j.error ?? `HTTP ${r.status}`); setResult(j); } catch (e) { setError(e instanceof Error ? e.message : String(e)); } finally { setBusy(null); } }; return (
{result && ( )} {error && ( {error} )} {result?.what === "quotes" && (
{result.rows.length} quote(s): {Object.entries(result.counts).map(([s, n]) => `${n} ${s}`).join(", ") || "none"}
    {result.rows.map((r) => (
  • {r.status} {r.citation} {!r.cited && not cited} {r.score !== undefined && {r.score.toFixed(2)}} {r.track && {r.track}} {r.enOrig !== undefined && r.track !== "transcript.en-orig.vtt" && ( en-orig {r.enOrig.toFixed(2)} )} {r.channel}/{r.id} {r.start !== undefined ? ` @ ${r.start}–${r.end} s` : ""}

    “{r.quote}”

    {r.message &&

    {r.message}

    } {r.target && }
  • ))}
)} {result?.what === "check" && (
{result.summary}
{[...result.allowed.map((a) => `allowed (missing media): ${a}`), ...result.warnings.map((w) => `warning: ${w}`)].map((l) => (
{l}
))}
    {result.problems.map((p, i) => (
  • {p.kind} {p.where}

    {p.message}

    {p.quote &&

    “{p.quote}”

    } {p.target && }
  • ))}
)}
); }