import Link from "next/link"; import { redirect } from "next/navigation"; import { UndoBar } from "@/components/piece/Lifecycle"; import LifecycleChip from "@/components/piece/LifecycleChip"; import LearnedSpellings from "@/components/series/LearnedSpellings"; import ScheduleControls from "@/components/series/ScheduleControls"; import TickProgress from "@/components/series/TickProgress"; import AppShell from "@/components/shell/AppShell"; import { badgeVariants } from "@/components/ui/badge"; import { EmptyState } from "@/components/ui/empty-state"; import { Panel } from "@/components/ui/panel"; import { Table, TD, TH } from "@/components/ui/table"; import { ARTICLES_KEY } from "@/lib/articles/key.mjs"; import { articleHref, triageHref, workHref } from "@/lib/hrefs"; import { readScheduleLearned } from "@/lib/research/learned"; import { readScheduleTriage, triageBoardId } from "@/lib/research/triage"; import { researchCaseHref } from "@/lib/research/hrefs"; import type { ScheduleTriage } from "@/lib/research/triage-types"; import { thresholdWords } from "yt-dlp-transcript-common/lib/report/draft/triage/types"; import { triagesFirst } from "yt-dlp-transcript-common/lib/report/schedule/types"; import { lifecycleOf, readLifecycle } from "@/lib/lifecycle"; import { readScheduleView } from "@/lib/schedules"; import type { Edition, ScheduleView, Tick } from "@/lib/schedule-types"; import { editionWindowAt, nothingToCover } from "yt-dlp-transcript-common/lib/report/schedule/types"; import { cn } from "@/lib/utils"; export const dynamic = "force-dynamic"; // --------------------------------------------------------------------------- // A SERIES (plans/umtool-redesign.md, R5): a recurring report's dated editions, // the piece `s:`. The head: its cadence chip ("weekly · next Mon 06:00"), // Pause/Resume, Tick now, Edit cadence, Delete (plan, then confirm). Then the // tick in flight, the editions newest first -- a quiet one dimmed, with its // window, no article -- each linking its article, and the tick log: status, // spend, reason. The editor keeps the schedule (its report-schedule lane); // this page reads it from the article store and writes through the editor. // // A WATCH (R6) has no editions: its page lists what its escalations FOUND // (each tick's article and board), and every schedule that triages shows its // triage runs (the tiers, each run's page), the precision of the flags the // operator marked and the threshold the marks suggest. R6.3: a schedule that // triages lists its LEARNED SPELLINGS (components/series/LearnedSpellings.tsx). // // A living report's schedule is its article's: /series/
goes there. // A static segment (`series`), so nothing else's catch-all takes it. // --------------------------------------------------------------------------- const usd = (n: number) => `$${n.toFixed(2)}`; const when = (iso: string) => iso.replace("T", " ").slice(0, 16); const EDITION_TONE: Record = { done: "on", quiet: "info", running: "neutral", failed: "blocking", cancelled: "info", "held-by-cap": "open", }; const TICK_TONE: Record = { done: "on", "no-change": "info", quiet: "info", // R6.1: a capped scan that found nothing — never quiet, the operator's call. partial: "open", "held-by-cap": "open", failed: "blocking", interrupted: "blocking", cancelled: "info", }; export default async function SeriesPage({ params }: { params: Promise<{ id: string }> }) { const { id: raw } = await params; const id = decodeURIComponent(raw); const read = await readScheduleView(id).catch((e: Error) => ({ problem: e.message })); if (read && "view" in read && read.view.shape === "living") redirect(read.view.href); const crumbs = [{ href: workHref({ recurring: "1" }), label: "Work" }]; if (!read || "problem" in read) { return (
{read && {read.problem}}{" "} Recurring reports
); } const v = read.view; const life = lifecycleOf(await readLifecycle(), v.piece); const editions = [...(v.editions ?? [])].sort((a, b) => b.n - a.n); // What the next tick's edition will cover: whole days, from the day after // the last edition through the day before the tick. const nextAt = v.nextTick ? Date.parse(v.nextTick) : NaN; const next = !v.paused && Number.isFinite(nextAt) ? editionWindowAt(v, nextAt) : null; const ticks = [...v.ticks].reverse(); const watch = v.shape === "watch"; const triage = triagesFirst(v) ? await readScheduleTriage(v).catch(() => null) : null; const found = watch ? ticks.filter((t) => t.article && t.triage?.escalated) : []; // R6.3: what the watch learned of how the transcripts mishear its names. const learned = triagesFirst(v) ? await readScheduleLearned(v).catch(() => null) : null; return (
{watch ? "watch" : "series"} {watch ? ( {found.length} found ) : ( {editions.length} edition{editions.length === 1 ? "" : "s"} )} {triage && !watch && triage first} {usd(v.spentUsd)} spent {v.piece} } actions={} below={