Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit b1629e893454b79b847653451449f8ccaaccdb62
parent 0d83a7f5e69294db504e6e98f6e25573715824b9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 12:13:47 -0400

umtool: the Iterations tab's Refresh… and a refresh's outcome on its card; common: a refresh reads a cited recording's tracks without importing publish/

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/controller/reportRefresh.ts | 49++++++++++++++++++++++++++++++++++++++-----------
Mumtool/components/articles/IterationsTab.tsx | 11+++++++++++
Mumtool/components/articles/RefreshDialog.tsx | 16++++++++++++++++
Mumtool/e2e/refresh.spec.ts | 9+++++++++
Mumtool/lib/articles/generation.ts | 9+++++++++
5 files changed, 83 insertions(+), 11 deletions(-)

diff --git a/common/controller/reportRefresh.ts b/common/controller/reportRefresh.ts @@ -21,7 +21,7 @@ // The iteration refreshed: `iteration` when given, else the current report's // (current.json), else the newest done iteration that carries a report. -import { access } from "node:fs/promises"; +import { access, readdir, readFile } from "node:fs/promises"; import path from "node:path"; import { runManagedFunction, type StreamActionResult } from "../jobs/streamCommand"; import type { JobProgress } from "../jobs/registry"; @@ -36,7 +36,10 @@ import { stateFromAvailability } from "../lib/availability"; import { resolveEffectiveAvailability } from "../lib/availability-server"; import { resolveVideoDir } from "../lib/videoDir-server.mjs"; import { detectPlatform } from "../lib/detectPlatform.mjs"; -import { readCitedRecord } from "../publish/composeReports"; +import { WHISPER_FILENAME, englishVttsByPreference } from "../lib/videoStatus"; +import { parseVtt } from "../lib/vtt"; +import { parseTranscriptJson } from "../lib/whisper"; +import { isCuesJsonFresh, readNormalizedTranscript } from "./normalizeTranscript"; import { diskPostChannelOf } from "../lib/report/convert-server"; import { readAllPosts } from "../lib/posts-server"; import { @@ -53,6 +56,7 @@ import type { CorpusToolsLike, TaskDeps } from "../lib/report/draft/tasks/types" import { refresh as refreshTask, type RefreshHooks } from "../lib/report/draft/refresh/task"; import { fetchAndBuild, type FetchAndBuild, type FetchHooks } from "../lib/report/draft/refresh/fetch"; import { NothingToRefreshError, refreshBasis } from "../lib/report/draft/refresh/basis"; +import type { RecordRead } from "../lib/report/draft/refresh/delta"; import { DEFAULT_REVISION_USD, DEFAULT_USD_PER_RECORDING } from "../lib/report/draft/refresh/task"; import { REFRESH_FORMAT, outcomeOf, type RefreshFile, type RefreshPlan, type RefreshPlanChannel } from "../lib/report/draft/refresh/types"; import type { ResearchEditor } from "../lib/report/draft/research/tools"; @@ -390,15 +394,10 @@ async function runRefreshJob( return { source, origin, ...(b ? { build: b.build } : {}) }; }, recordOf: async (channel, id) => { - const rec = await readCitedRecord(disk, channel, id).catch(() => null); - if (!rec) { - const cues = await cuesOf(channel, id); - return cues ? { cues } : null; - } - const dir = await resolveVideoDir(disk, channel, id).catch(() => null); - const avail = dir ? await resolveEffectiveAvailability(dir).catch(() => null) : null; - const state = stateFromAvailability(avail); - return { cues: rec.cues, tracks: rec.tracks, ...(state !== "available" ? { state } : {}) }; + const rec = await diskRecordOf(disk, channel, id).catch(() => null); + if (rec) return rec; + const cues = await cuesOf(channel, id); + return cues ? { cues } : null; }, capRefusal: async (usd) => { if (provider !== "api") return null; @@ -463,6 +462,34 @@ async function runRefreshJob( if (result.status === "failed") throw new Error(result.summary); } +// A cited recording on disk, as a refresh reads it: every transcript track it +// has (the normalized cues, our transcription, each English caption track, +// en-orig first) and its platform state when it is not available; null when the +// archive holds no directory for it. (publish/composeReports' readCitedRecord +// reads the same files; a controller may not import publish.) +export async function diskRecordOf(channelsDir: string, slug: string, id: string): Promise<RecordRead | null> { + const dir = await resolveVideoDir(channelsDir, slug, id).catch(() => null); + if (!dir) return null; + const entries = await readdir(dir).catch(() => [] as string[]); + if (!entries.length) return null; + const tracks: { name: string; cues: { start: number; end: number; text: string }[] }[] = []; + const fresh = await isCuesJsonFresh(dir).catch(() => ({ fresh: false as const })); + if (fresh.fresh && "cuesPath" in fresh) { + const n = await readNormalizedTranscript(fresh.cuesPath).catch(() => null); + if (n?.cues?.length) tracks.push({ name: path.basename(fresh.cuesPath), cues: n.cues }); + } + if (entries.includes(WHISPER_FILENAME)) { + const w = await readFile(path.join(dir, WHISPER_FILENAME), "utf8").then((t) => parseTranscriptJson(t), () => []); + if (w.length) tracks.push({ name: WHISPER_FILENAME, cues: w }); + } + for (const name of englishVttsByPreference(entries)) { + const v = await readFile(path.join(dir, name), "utf8").then((t) => parseVtt(t), () => []); + if (v.length) tracks.push({ name, cues: v }); + } + const state = stateFromAvailability(await resolveEffectiveAvailability(dir).catch(() => null)); + return { cues: tracks[0]?.cues ?? [], tracks, ...(state !== "available" ? { state } : {}) }; +} + /** A refresh iteration's refresh.json, or null. */ export async function readRefreshFile(article: string, n: number, paths: ReportDraftDeps["paths"]): Promise<RefreshFile | null> { const text = await readIterationFile(article, n, "refresh.json", paths).catch(() => null); diff --git a/umtool/components/articles/IterationsTab.tsx b/umtool/components/articles/IterationsTab.tsx @@ -9,6 +9,7 @@ import { badgeVariants } from "@/components/ui/badge"; import ChainPanel from "@/components/articles/ChainPanel"; import { EditorJobProgress } from "@/components/ui/job-progress"; import ResearchSlot from "@/components/articles/ResearchSlot"; +import { RefreshButton } from "@/components/articles/RefreshDialog"; import ExtractorSelect, { extractorBody } from "@/components/articles/ExtractorSelect"; import DeletePlan from "@/components/DeletePlan"; import { usd, type Today } from "@/components/articles/PolicyPanel"; @@ -197,6 +198,11 @@ function IterationCard({ </span> </header> + {it.refresh && ( + <p className="mt-1 text-[13px]" data-refresh-outcome={it.refresh.status}> + {it.refresh.summary} + </p> + )} {(it.feedback ?? it.question) && <p className="mt-1 text-[13px]">{it.feedback ? `“${it.feedback}”` : it.question}</p>} {it.scope?.channels && ( <p className="font-mono text-[11px] text-[var(--color-dim)]"> @@ -439,6 +445,11 @@ export default function IterationsTab({ {today.daily > 0 ? ` of ${usd(today.daily)}` : ""} </span> )} + {data.current.report !== null && !data.busy && ( + <span className="ml-auto"> + <RefreshButton article={article} /> + </span> + )} {compare.length === 2 && ( <Link href={`/articles/${article}/compare?a=${Math.min(...compare)}&b=${Math.max(...compare)}`} diff --git a/umtool/components/articles/RefreshDialog.tsx b/umtool/components/articles/RefreshDialog.tsx @@ -198,6 +198,22 @@ export function RefreshMenuItem({ article }: { article: string }) { ); } +/** The Iterations tab's Refresh: the same dialog, from the tab's own line. */ +export function RefreshButton({ article }: { article: string }) { + const hydrated = useHydrated(); + return ( + <button + type="button" + disabled={!hydrated} + data-refresh-open="iterations" + className={buttonVariants({ variant: "outline", size: "sm" })} + onClick={() => window.dispatchEvent(new CustomEvent(OPEN_EVENT, { detail: { article } }))} + > + Refresh… + </button> + ); +} + /** The page's Refresh dialog: opened by the menu item, or on arrival with `?refresh=1` (the Next card's action). */ export function RefreshHost({ article, initialOpen = false, href }: { article: string; initialOpen?: boolean; href: string }) { const router = useRouter(); diff --git a/umtool/e2e/refresh.spec.ts b/umtool/e2e/refresh.spec.ts @@ -115,6 +115,15 @@ test("Refresh: one editor job, then the Overview says what it found — the new await expect(page.locator(`[data-lit-line][data-piece='${PIECE}'][data-card='refresh-available']`)).toHaveCount(0); }); +test("the Iterations tab: the refresh's outcome on its card, and Refresh… opens the plan", async ({ page }) => { + await page.goto(urls.articleHref({ site: "articles", id: REFRESH_ARTICLE }, { tab: "iterations" })); + await expect(page.locator("[data-iteration='2'][data-kind='refresh'] [data-refresh-outcome='updated']")).toContainText("1 new recording matches · 1 quote changed"); + await page.locator("[data-refresh-open='iterations']").click(); + await expect(dialog(page).locator("[data-refresh-plan]")).toBeVisible(); + await dialog(page).getByRole("button", { name: "Cancel" }).click(); + await expect(dialog(page)).toBeHidden(); +}); + test("1366×768: the plan fits without scrolling the page", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); await page.goto(urls.articleHref({ site: "articles", id: REFRESH_ARTICLE }, { refresh: true })); diff --git a/umtool/lib/articles/generation.ts b/umtool/lib/articles/generation.ts @@ -347,6 +347,8 @@ export type IterationRow = { hasManifest: boolean; currentReport: boolean; currentVideo: boolean; + /** A refresh's outcome (R4: iteration.json's `refresh`), else null. */ + refresh: { status: string; summary: string } | null; }; /** A project directory's id: its path under REPORTS_ROOT, posix, or null outside it. */ @@ -385,6 +387,12 @@ const exists = (p: string) => { } }; +// A refresh iteration's outcome as iteration.json keeps it (common's RefreshOutcome), or null. +function refreshOutcomeOf(it: Iteration): IterationRow["refresh"] { + const r = (it as { refresh?: { status?: unknown; summary?: unknown } }).refresh; + return r && typeof r.status === "string" ? { status: r.status, summary: typeof r.summary === "string" ? r.summary : "" } : null; +} + function rowOf(it: Iteration, hasReport: Map<number, boolean>, byN: Map<number, Iteration>, current: IterationsCurrent): IterationRow { let reportFrom: number | null = null; for (let at: number | null = it.n; at !== null; at = byN.get(at)?.parent ?? null) { @@ -431,6 +439,7 @@ function rowOf(it: Iteration, hasReport: Map<number, boolean>, byN: Map<number, hasManifest: projectDir ? exists(path.join(/* turbopackIgnore: true */ projectDir, "video.manifest.json")) : false, currentReport: current.report === it.n, currentVideo: current.video === it.n, + refresh: refreshOutcomeOf(it), }; }