"use client"; import Link from "next/link"; import { useCallback, useEffect, useState } from "react"; import { Button, buttonVariants } from "@/components/ui/button"; import { hasRunPage, runHref } from "@/lib/research/runs-hrefs"; import { projectHref } from "@/lib/hrefs"; import { badgeVariants } from "@/components/ui/badge"; import ChainPanel from "@/components/articles/ChainPanel"; import { ITERATIONS_CHANGED } from "@/components/articles/HandTools"; 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 ModelLog from "@/components/model-log/ModelLog"; import DeletePlan from "@/components/DeletePlan"; import { usd, type Today } from "@/components/articles/PolicyPanel"; import type { ArticleIterations, DraftJobView, IterationRow, PolicyView } from "@/lib/articles/generation"; // AN ARTICLE'S ITERATIONS (release 27 S8): every generation of its report or // its video, newest first — what made it (kind, model, parent, copy), how it // went (status, cost per model, minutes, ops applied and refused, checks), and // which is the article and which its video. Each action asks the editor (a // `report-draft` job) or the registry (use this iteration) through umtool's // routes; nothing here writes a file. While anything is queued or running the // list is re-read every 3 s, and a running job's log every 2.5 s. const field = "rounded border border-[var(--color-line)] bg-[var(--color-ink)] px-1.5 py-0.5 text-[12px] text-[var(--color-text)]"; const STATUS_VARIANT: Record = { done: "on", failed: "blocking", running: "state", queued: "state", cancelled: "info", }; // The report-draft task that made an iteration of this kind (a copy re-runs it). const TASK_OF: Record = { sweep: "sweep", "revise-report": "revise-report", "revise-video": "revise-video", research: "research" }; const fmtTokens = (n: number) => (n >= 10_000 ? `${Math.round(n / 1000)}k` : n.toLocaleString()); type Ctx = { article: string; policy: PolicyView | null; allModels: string[]; /** Start a report-draft job (the editor makes the iteration). */ post: (body: Record) => Promise; /** Make an iteration the article's (the registry's makeCurrent). */ use: (n: number) => Promise; refresh: () => void; /** An iteration was deleted (the registry's delete, through /api/articles/delete). */ deleted: (n: number) => void; }; function ModelSelect({ value, onChange, label, models }: { value: string; onChange: (v: string) => void; label: string; models: string[] }) { return ( ); } /** The editor job behind a queued or running iteration (or step): its place, its log, cancel (the ONE JobProgress). */ function JobProgress({ jobId, label, onEnd }: { jobId: string; label: string; onEnd: () => void }) { return ( onEnd()} className="mt-2 rounded-[3px] border border-seam bg-ground p-2" /> ); } function NewIterationForm({ it, ctx, onDone }: { it: IterationRow; ctx: Ctx; onDone: () => void }) { const [target, setTarget] = useState<"report" | "video">("report"); const g = ctx.policy?.generation; const route = g?.routes[target === "report" ? "revise-report" : "revise-video"]; const [model, setModel] = useState(route === "local" ? (g?.models.local ?? "") : (g?.models.api ?? "")); const [feedback, setFeedback] = useState(""); const capDefault = g?.caps.revision ?? 2; const [cap, setCap] = useState(String(capDefault)); const claude = model.startsWith("claude-"); return (
{ e.preventDefault(); const ok = await ctx.post({ task: target === "report" ? "revise-report" : "revise-video", article: ctx.article, iteration: it.n, model, feedback, ...(claude ? { maxUsd: Number(cap) } : {}), }); if (ok) onDone(); }} >
what to change
{claude && ( )}