import { readFile } from "node:fs/promises"; import { postItemSeconds } from "umtool-report-to-video/post-item"; import path from "node:path"; import Link from "next/link"; import { Suspense } from "react"; import NextCard, { NextCardShell } from "@/components/piece/NextCard"; import { badgeVariants } from "@/components/ui/badge"; import { Table, TD, TH } from "@/components/ui/table"; import { ARTICLES_KEY } from "@/lib/articles/key.mjs"; import { readArticleIterations, type IterationRow } from "@/lib/articles/generation"; import { articleHref } from "@/lib/hrefs"; import { researchCaseHref } from "@/lib/research/hrefs"; import { Markdown } from "@/lib/markdown"; import { decisionsForProject } from "@/lib/projects"; import type { Decision } from "@/lib/decisions"; import type { PieceFrame } from "@/lib/pieces/frame"; import { TONE, hms, type ReportTabProps } from "./shared"; import DecisionSettle from "./DecisionSettle"; import SourceBacklog from "./SourceBacklog"; import ProjectSites from "./ProjectSites"; import LinkPolicyPanel from "./LinkPolicyPanel"; import { manifestToken } from "@/lib/report/manifest.mjs"; import { Options } from "@/components/ui/disclosure"; // The Overview tab (canvas "Piece · Overview"): the Next card, then the // piece's decisions and -- when it is an article's video -- the article and // its iterations beside the stats, then the author's README. The decisions and // the README are ReportProject's sections, unchanged (P4a-1). const VIA: Record = { iteration: "made by its iteration", manifest: "named by the manifest", slug: "matched by name", }; export default async function OverviewTab({ project, detail, frame }: ReportTabProps & { frame: PieceFrame }) { const { manifest: m, build, entries } = detail; const decisions = await decisionsForProject(project); // The settles beside the rows write through the window writer with the // manifest's token, as every other manifest write does. const token = await manifestToken(project.dir).catch(() => null); const readme = await readFile(path.join(project.dir, "README.md"), "utf8").catch(() => null); const p = (m.provenance ?? {}) as Record; const clips = entries.filter((e) => e.kind === "clip"); // Post items (report-to-video/post-item.mjs) are counted on their own, and play their rule's seconds. const posts = entries.filter((e) => e.kind === "post"); const nonClips = entries.filter((e) => e.kind !== "clip" && e.kind !== "post"); const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0) + posts.reduce((n, e) => n + postItemSeconds(e), 0); const article = frame.article; const iterations = article && article.site === ARTICLES_KEY ? await readArticleIterations(article.report).catch(() => null) : null; return ( <> Reading the Inbox… } >
{/* --- what is wrong, first ------------------------------------- */} {iterations && iterations.iterations.length > 0 && article && (

Iterations

All iterations →
)}

This video

{m.subtitle &&

{m.subtitle}

}
  • cut {clips.length} clips{posts.length ? ` · ${posts.length} posts` : ""}{nonClips.length ? ` · ${nonClips.length} other` : ""} · {hms(runtime)}
  • final video {build.built ? `${build.slug}.mp4${build.stale ? " · out of date" : ""}` : "not built"}
  • {typeof p.channel === "string" && p.channel && (
  • channel{p.channel}
  • )} {m.generatedOn && (
  • generated{m.generatedOn}
  • )} {typeof p.videosCited === "number" && (
  • videos cited{p.videosCited}
  • )} {typeof p.enumeratedMatches === "number" && (
  • enumerated matches{p.enumeratedMatches}
  • )}
{/* How much of each cited channel the archive holds and has transcribed (UI notes item 16). */} {clips.length > 0 && } {frame.board && (

Research board

{frame.board.title}

its quotes made this cut{frame.board.at ? ` · ${frame.board.at.slice(0, 10)}` : ""}

)} {article && (

Article

{article.title}

{article.site === ARTICLES_KEY ? "the article store" : article.site} · {VIA[article.via] ?? article.via} {article.cut ? " · its Cut" : ""}

)}
{/* --- the author's own account of the cut ------------------------- */} {readme && (
)} ); } /** A project's decisions, what is waiting first (ReportProject's section, unchanged). */ export function ProjectDecisions({ project, decisions, token = null }: { project: string; decisions: Decision[]; token?: string | null }) { return ( <> {decisions.length > 0 && (

{decisions.filter((d) => d.severity !== "info").length} waiting of {decisions.length}

{/* A kind with many rows (68 clips with no cues): its first five, the rest folded (lane/ui-simplify). */} {(() => { const row = (d: Decision, i: number) => (
  • {d.severity} {d.target} {d.why} {/* The one-press settle, when the row knows one; `fix` is its terminal twin. */} {d.settle && } {d.kind}
  • ); const byKind = new Map(); for (const d of decisions) byKind.set(d.kind, [...(byKind.get(d.kind) ?? []), d]); const folded = new Set(); for (const list of byKind.values()) if (list.length > 8) list.slice(5).forEach((d) => folded.add(d)); return ( <>
      {decisions.filter((d) => !folded.has(d)).map(row)}
    {[...byKind.entries()] .filter(([, list]) => list.length > 8) .map(([kind, list]) => (
      {list.slice(5).map(row)}
    ))} ); })()}
    )} {decisions.length === 0 && (

    No decisions on this project.

    )} ); } /** The article's newest iterations (canvas `.itab`): number, kind, model, spend, time, checks, current. On a phone each row is a stacked line (`.stack-rows`). */ export function IterationsSummary({ rows }: { rows: IterationRow[] }) { return ( {rows.map((r) => ( ))}
    # Kind Model Spend Time Checks
    {r.n} {r.kind} {r.model} {r.usd > 0 ? `$${r.usd.toFixed(2)}` : "—"} {r.minutes != null ? `${r.minutes.toFixed(1)} min` : "—"} {r.checks.length === 0 ? "—" : r.checks.map((c) => ( {c.ok ? "✓" : "✕"} {c.name} ))} {r.currentVideo || r.currentReport ? "current" : r.status}
    ); }