import Link from "next/link"; import { Suspense } from "react"; import NextCard, { NextCardShell } from "@/components/piece/NextCard"; import { IterationsSummary, ProjectDecisions } from "@/components/projects/report/OverviewTab"; import { hms, type ClipDetail } from "@/components/projects/report/shared"; import { readArticleIterations } from "@/lib/articles/generation"; import { readRefreshes } from "@/lib/articles/refresh"; import RefreshSummary from "./RefreshSummary"; import { ARTICLES_KEY } from "@/lib/articles/key.mjs"; import { projectHref } from "@/lib/hrefs"; import { decisionsForProject } from "@/lib/projects"; import type { ArticlePieceFrame, ArticleVideo } from "@/lib/pieces/article"; import type { ProjectRef } from "@/lib/project-types"; import { researchCaseHref } from "@/lib/research/hrefs"; // An ARTICLE PIECE's Overview (P4a-2; canvas "Piece · Overview"): the Next // card -- the top Inbox call across the article and its video project(s) -- // then the iterations (the article store's) and the video's decisions beside // the article's sections, the Cut on show, and the board that seeded it. // Each summary links the tab that holds the whole. type Href = (tab: string, q?: { project?: string }) => string; export default async function ArticleOverview({ site, title, sections, frame, video, videoRef, detail, tabHref, }: { site: string; title: string; /** The current report's section titles, or null when there is no report yet. */ sections: string[] | null; frame: ArticlePieceFrame; video: ArticleVideo | null; videoRef: ProjectRef | null; detail: ClipDetail | null; tabHref: Href; }) { const store = site === ARTICLES_KEY; const [iterations, decisions, refreshes] = await Promise.all([ store ? readArticleIterations(frame.report).catch(() => null) : Promise.resolve(null), videoRef ? decisionsForProject(videoRef).catch(() => []) : Promise.resolve([]), store ? readRefreshes(frame.report).catch(() => []) : Promise.resolve([]), ]); const rows = iterations?.iterations ?? []; const asked = rows.find((r) => r.currentReport && r.question) ?? rows.find((r) => r.question) ?? null; const clips = detail ? detail.entries.filter((e) => e.kind === "clip") : []; const runtime = clips.reduce((n, e) => n + Math.max(0, e.end - e.start), 0); const shown = video?.project ?? null; const madeBy = shown ? video?.iterationOf.get(shown.id) : undefined; return (
Reading the Inbox… } >
{store && (

Iterations

All iterations →
{rows.length > 0 ? ( ) : (

No iterations.

)} {asked && (

Question: {asked.question} {asked.scope?.channels?.length ? ` · scope ${asked.scope.channels.join(", ")}` : ""}

)}
)} {refreshes[0] && } {videoRef && }

{sections ? `Article · ${sections.length} section${sections.length === 1 ? "" : "s"}` : "Article"}

Read →
{sections ? (
    {sections.map((s, i) => (
  • {s}
  • ))}
) : (

No report yet.

)}

{shown ? `Cut · ${madeBy ? `i${madeBy}` : shown.id}` : "Cut"}

{shown && ( Open the cut → )}
{shown && detail && (
  • {detail.build.built ? "final video built" : "final video not built"} {detail.build.built ? `${detail.build.slug}.mp4${detail.build.stale ? " · out of date" : ""}` : ""}
  • cut {clips.length} clips · {hms(runtime)}
  • project {shown.id}
)} {shown && !detail && (

video.manifest.json could not be parsed.

)} {!shown && video?.unreachable && (

i{video.unreachable.n}'s project is not reachable here:{" "} {video.unreachable.dir}

)} {!shown && !video?.unreachable &&

No video project yet.

} {video && video.owned.length > 1 && (
    {video.owned .filter((p) => p.id !== shown?.id) .map((p) => (
  • {video.iterationOf.has(p.id) ? `i${video.iterationOf.get(p.id)}` : p.id} another cut · {p.id}
  • ))}
)}
{frame.board && (

Research board

{frame.board.title}

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

)} {(frame.piece?.possible.length ?? 0) > 0 && (

Possible videos

    {frame.piece!.possible.map((p) => (
  • {p.id} shares the slug; not linked
  • ))}
)}
); }