commit 2491edde9c835467f2eec0abe064599584f4b5ad
parent 44c127d0d85fd93def64549a4234cc0c13936fd5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 15:26:02 -0400
umtool: Settings · system in status lines — the old dashboard panels move to components/system and lose their paragraphs
- ToolsPanel, NowPanel (→ ActivityPanel), StateStrip (→ ProjectsPanel),
SourcesPanel and DeliverablesPanel leave components/dashboard (and its
Panel wrapper) for components/system/{ToolsPanel,Status,NowLive}.tsx on the
ui Panel; every data-* attribute kept.
- Copy: the index is said once (its panel: "N records · rebuilt …", "No index —
every read walks the disk."); Tools & disk says the free space and the tools;
roots "= reports · UMTOOL_MEDIA_DIR unset", an old cache "not read; safe to
delete"; sources one count line; Check / Check again; Nothing running.
- Order: tools, roots, index, activity, projects, deliverables, sources, then
storage (the long list) last. A source row opens its project's Sources tab.
- settings.spec: the index line, and no index on Tools & disk.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
13 files changed, 380 insertions(+), 469 deletions(-)
diff --git a/umtool/app/settings/system/page.tsx b/umtool/app/settings/system/page.tsx
@@ -1,29 +1,25 @@
import Link from "next/link";
-import DeliverablesPanel from "@/components/dashboard/DeliverablesPanel";
-import NowPanel from "@/components/dashboard/NowPanel";
-import SourcesPanel from "@/components/dashboard/SourcesPanel";
-import StateStrip from "@/components/dashboard/StateStrip";
-import ToolsPanel from "@/components/dashboard/ToolsPanel";
import AppShell from "@/components/shell/AppShell";
import { IndexPanel, RootsPanel, StoragePanel } from "@/components/system/Maintenance";
+import { ActivityPanel, DeliverablesPanel, ProjectsPanel, SourcesPanel } from "@/components/system/Status";
+import ToolsPanel from "@/components/system/ToolsPanel";
import { listActivity, runningActivity } from "@/lib/activity";
import { projectsNote, sourceBuckets, stateRows } from "@/lib/dashboard";
import { toolsCache } from "@/lib/doctor";
import { generationPolicyHref, settingsHref } from "@/lib/hrefs";
import { freeBytesUnder } from "@/lib/machine";
-import { REPORTS_ROOT } from "@/lib/paths";
-import { KINDS, decisionCounts, indexHealth, indexPrunePlan, listProjects } from "@/lib/projects";
-import { MEDIA_ROOT, MEDIA_TIERED } from "@/lib/paths";
+import { MEDIA_ROOT, MEDIA_TIERED, REPORTS_ROOT } from "@/lib/paths";
+import { KINDS, decisionCounts, indexPrunePlan, listProjects } from "@/lib/projects";
import { rootsReport } from "@/lib/system/roots.mjs";
import { storageRows } from "@/lib/system/storage-rows";
export const dynamic = "force-dynamic";
-// SETTINGS · SYSTEM (plans/umtool-redesign.md, P3): the machine and the
-// collection at a glance -- what ran, where every project stands, which
-// sources nobody has checked, what has been built, and whether the machine can
-// build at all. These were the dashboard's panels; what in them is a CALL
-// (a required tool missing, a disk nearly full) is an Inbox card instead.
+// SETTINGS · SYSTEM (plans/umtool-redesign.md, P3, P5, P6): the machine and
+// the collection at a glance -- whether this machine can build, its roots and
+// index, what ran, where every project stands, which sources nobody has
+// checked, what has been built; then storage. What in them is a CALL (a
+// required tool missing, a disk nearly full) is an Inbox card instead.
//
// Everything is read from the index, the job registries and a few stats;
// nothing here shells out -- the tools panel shows a cache or "not checked",
@@ -41,7 +37,6 @@ export default async function SystemPage() {
const running = runningActivity();
const recent = listActivity(8);
const tools = toolsCache();
- const ix = indexHealth();
const free = await freeBytesUnder(REPORTS_ROOT);
const [roots, prune, storage] = await Promise.all([rootsReport({ measureOld: false }), indexPrunePlan(), storageRows()]);
@@ -62,14 +57,14 @@ export default async function SystemPage() {
/>
<main className="deck-main flex-1 p-4">
<div className="grid gap-3 lg:grid-cols-2 2xl:grid-cols-3">
- <ToolsPanel initial={tools} freeBytes={free} index={ix} />
+ <ToolsPanel initial={tools} freeBytes={free} />
<RootsPanel roots={roots} />
<IndexPanel index={{ ok: prune.ok, records: prune.records, path: prune.path, builtAt: prune.builtAt, stale: prune.stale.length }} />
- <StoragePanel rows={storage} tiered={MEDIA_TIERED} mediaRoot={MEDIA_ROOT} />
- <NowPanel running={running} recent={recent} />
- <StateStrip rows={stateRows(KINDS, projects)} note={projectsNote(projects.length, blocking, openN)} />
- <SourcesPanel never={buckets.never} old={buckets.old} bad={buckets.bad} />
+ <ActivityPanel running={running} recent={recent} />
+ <ProjectsPanel rows={stateRows(KINDS, projects)} note={projectsNote(projects.length, blocking, openN)} />
<DeliverablesPanel projects={projects} />
+ <SourcesPanel never={buckets.never} old={buckets.old} bad={buckets.bad} />
+ <StoragePanel rows={storage} tiered={MEDIA_TIERED} mediaRoot={MEDIA_ROOT} />
</div>
</main>
</div>
diff --git a/umtool/components/dashboard/DeliverablesPanel.tsx b/umtool/components/dashboard/DeliverablesPanel.tsx
@@ -1,39 +0,0 @@
-import Link from "next/link";
-import type { ProjectSummary } from "@/lib/project-types";
-import { fmtAgo, fmtBytes } from "@/lib/format";
-import Panel from "./Panel";
-
-// Built count, total bytes, newest, stale -- all from `attrs.finalBytes` and
-// each project's state. Nothing here stats a file; the summariser already did.
-export default function DeliverablesPanel({ projects }: { projects: ProjectSummary[] }) {
- const built = projects.filter((p) => p.attrs?.["final-bytes"]);
- const bytes = built.reduce((n, p) => n + Number(p.attrs?.["final-bytes"] ?? 0), 0);
- const newest = [...built].sort((a, b) => b.newestMtimeMs - a.newestMtimeMs)[0] ?? null;
- const stale = projects.filter((p) => p.state === "stale");
- return (
- <Panel title="deliverables" testid="deliverables" more={{ href: "/projects?state=built", label: "built →" }}>
- <div className="flex flex-wrap gap-3 text-[11px] text-[var(--color-dim)]" data-deliverables={`${built.length}/${bytes}`}>
- <span>
- <b className="num text-[var(--color-text)]">{built.length}</b> built
- </span>
- <span>
- <b className="num text-[var(--color-meter)]">{fmtBytes(bytes)}</b> on disk
- </span>
- {newest && (
- <span>
- newest{" "}
- <Link href={`/projects/${newest.id}`} className="font-mono ink-link">
- {newest.id}
- </Link>{" "}
- <span className="num">{fmtAgo(newest.newestMtimeMs)}</span>
- </span>
- )}
- {stale.length > 0 && (
- <Link href="/projects?state=stale" className="text-[var(--color-dirty)] hover:underline" data-stale={stale.length}>
- {stale.length} stale
- </Link>
- )}
- </div>
- </Panel>
- );
-}
diff --git a/umtool/components/dashboard/NowLive.tsx b/umtool/components/dashboard/NowLive.tsx
@@ -1,106 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { useEffect, useState } from "react";
-import type { ActivityItem } from "@/lib/activity-types";
-import { fmtAgo } from "@/lib/format";
-
-// The running job, live. Polls /api/jobs every two seconds ONLY while something
-// is running: an idle dashboard makes no requests at all, and one that has just
-// watched a build finish stops the moment the state leaves "running".
-//
-// The per-entry boxes use the same vocabulary ReportBuildChain paints from
-// (fetching / cutting / done / failed), computed server-side in lib/activity.ts
-// so this file never re-parses events.
-
-const BOX = {
- fetching: "border-[var(--color-meter)] text-[var(--color-meter)]",
- cutting: "border-[var(--color-sel)] text-[var(--color-sel)]",
- done: "border-[var(--color-good)] text-[var(--color-good)]",
- failed: "border-[var(--color-bad)] text-[var(--color-bad)]",
-} as const;
-
-export default function NowLive({ initial }: { initial: ActivityItem | null }) {
- const [now, setNow] = useState<ActivityItem | null>(initial);
-
- // One fetch on mount, so the panel says what the registry says even if the
- // page render and the route disagreed; then a 2 s poll ONLY while running.
- useEffect(() => {
- let alive = true;
- void fetch("/api/jobs?n=1", { cache: "no-store" })
- .then((r) => (r.ok ? r.json() : null))
- .then((j: { running: ActivityItem | null } | null) => {
- if (alive && j && j.running) setNow(j.running);
- })
- .catch(() => {});
- return () => {
- alive = false;
- };
- }, []);
-
- useEffect(() => {
- if (!now || now.state !== "running") return;
- const t = setInterval(async () => {
- try {
- const r = await fetch("/api/jobs?n=1", { cache: "no-store" });
- if (!r.ok) return;
- const j = (await r.json()) as { running: ActivityItem | null; jobs: ActivityItem[] };
- // When the running item has gone, show what it became rather than
- // blanking: the newest job in the list is the one that just finished.
- setNow(j.running ?? j.jobs.find((x) => x.id === now.id) ?? null);
- } catch {
- /* a missed poll is the next poll's problem */
- }
- }, 2000);
- return () => clearInterval(t);
- }, [now]);
-
- if (!now) {
- return (
- <p className="text-[12px] text-[var(--color-dim)]" data-now="idle">
- nothing running
- </p>
- );
- }
-
- const p = now.progress;
- const entries = Object.entries(p?.entries ?? {});
- return (
- <div data-now={now.state} data-now-id={now.id} className="space-y-1.5">
- <div className="flex flex-wrap items-baseline gap-2 text-[12px]">
- <Link href={now.href} className="font-mono ink-link">
- {now.label}
- </Link>
- <span className="micro">{now.source}</span>
- {p && (
- <span className="num text-[11px] text-[var(--color-dim)]" data-now-step={`${p.step}/${p.of}`}>
- step {p.step}/{p.of}
- </span>
- )}
- {p?.clipsOf !== undefined && (
- <span className="num text-[11px] text-[var(--color-meter)]">
- {p.clipsDone ?? 0}/{p.clipsOf} entries
- </span>
- )}
- <span className="num ml-auto text-[11px] text-[var(--color-dim)]">
- {now.state === "running" ? `started ${fmtAgo(now.startedAt)}` : now.state}
- {now.error ? ` — ${now.error}` : ""}
- </span>
- </div>
- {entries.length > 0 && (
- <div className="flex flex-wrap gap-1">
- {entries.map(([id, st]) => (
- <span
- key={id}
- data-now-entry={id}
- data-entry-state={st}
- className={`rounded border px-1.5 py-0.5 font-mono text-[10px] ${BOX[st]}`}
- >
- {id}
- </span>
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/umtool/components/dashboard/NowPanel.tsx b/umtool/components/dashboard/NowPanel.tsx
@@ -1,46 +0,0 @@
-import Link from "next/link";
-import type { ActivityItem } from "@/lib/activity";
-import { fmtAgo } from "@/lib/format";
-import NowLive from "./NowLive";
-import Panel from "./Panel";
-
-// What is running, and what ran. Two registries (chain jobs, mix renders), one
-// list -- merged in lib/activity.ts, never here.
-export default function NowPanel({
- running,
- recent,
-}: {
- running: ActivityItem | null;
- recent: ActivityItem[];
-}) {
- const done = recent.filter((a) => a.state !== "running");
- return (
- <Panel title="now" testid="now">
- <NowLive initial={running} />
- {done.length > 0 && (
- <ul className="mt-2 space-y-0.5 border-t border-[var(--color-line)] pt-2" data-activity="">
- {done.map((a) => (
- <li
- key={a.id}
- data-activity-id={a.id}
- data-activity-state={a.state}
- className="flex flex-wrap items-baseline gap-2 text-[11px]"
- >
- <span
- className={
- a.state === "failed" ? "text-[var(--color-bad)]" : "text-[var(--color-dim)]"
- }
- >
- {a.state}
- </span>
- <Link href={a.href} className="font-mono text-[var(--color-text)] hover:text-[var(--color-sel)]">
- {a.label}
- </Link>
- <span className="num ml-auto text-[var(--color-dim)]">{fmtAgo(a.endedAt ?? a.startedAt)}</span>
- </li>
- ))}
- </ul>
- )}
- </Panel>
- );
-}
diff --git a/umtool/components/dashboard/Panel.tsx b/umtool/components/dashboard/Panel.tsx
@@ -1,34 +0,0 @@
-import Link from "next/link";
-import { Panel as UiPanel } from "@/components/ui/panel";
-
-/** The dashboard's one box shape: a micro title, an optional "all →", a body (components/ui/panel.tsx). */
-export default function Panel({
- title,
- testid,
- more,
- children,
- className = "",
-}: {
- title: string;
- testid: string;
- more?: { href: string; label: string };
- children: React.ReactNode;
- className?: string;
-}) {
- return (
- <UiPanel
- data-panel={testid}
- title={title}
- aside={
- more && (
- <Link href={more.href} className="ink-link text-[12px]">
- {more.label}
- </Link>
- )
- }
- className={className}
- >
- {children}
- </UiPanel>
- );
-}
diff --git a/umtool/components/dashboard/SourcesPanel.tsx b/umtool/components/dashboard/SourcesPanel.tsx
@@ -1,75 +0,0 @@
-import Link from "next/link";
-import type { ProjectSummary } from "@/lib/project-types";
-import { SOURCES_STALE_DAYS } from "@/lib/dashboard";
-import CheckSourcesButton from "./CheckSourcesButton";
-import Panel from "./Panel";
-
-// The long-form problem, on the front door: which projects have sources nobody
-// has checked, checked too long ago, or known to be dead. All of it read from
-// each project's summary attributes -- never probed here.
-export default function SourcesPanel({
- never,
- old,
- bad,
-}: {
- never: ProjectSummary[];
- old: ProjectSummary[];
- bad: ProjectSummary[];
-}) {
- const List = ({ items, attr }: { items: ProjectSummary[]; attr: string }) => (
- <ul className="space-y-0.5" data-sources-list={attr}>
- {items.map((p) => (
- <li key={p.id} data-source-project={p.id} className="flex flex-wrap gap-2 text-[11px]">
- <Link href={`/projects/${p.id}`} className="font-mono ink-link">
- {p.id}
- </Link>
- <span className="text-[var(--color-dim)]">
- {[
- p.attrs?.["sources-dead"] ? `${p.attrs["sources-dead"]} dead` : "",
- p.attrs?.["sources-missing"] ? `${p.attrs["sources-missing"]} no cues` : "",
- p.attrs?.["cue-gaps"] ? `${p.attrs["cue-gaps"]} cue gap${p.attrs["cue-gaps"] === "1" ? "" : "s"}` : "",
- ]
- .filter(Boolean)
- .join(" · ")}
- </span>
- </li>
- ))}
- </ul>
- );
- const recheck = [...never, ...old].map((p) => p.id);
- return (
- <Panel title="sources" testid="sources">
- <div className="mb-1.5 flex flex-wrap items-baseline gap-3 text-[11px]" data-sources-counts={`${never.length}/${old.length}/${bad.length}`}>
- <span className="text-[var(--color-dim)]">
- <b className="num text-[var(--color-text)]">{never.length}</b> never checked
- </span>
- <span className="text-[var(--color-dim)]">
- <b className="num text-[var(--color-text)]">{old.length}</b> older than {SOURCES_STALE_DAYS} d
- </span>
- <span className="text-[var(--color-dim)]">
- <b className={`num ${bad.length ? "text-[var(--color-bad)]" : "text-[var(--color-text)]"}`}>{bad.length}</b>{" "}
- with dead or missing sources
- </span>
- <span className="ml-auto">
- <CheckSourcesButton projects={recheck} />
- </span>
- </div>
- {bad.length > 0 && <List items={bad} attr="bad" />}
- {never.length > 0 && (
- <>
- <div className="micro mt-1.5">never checked</div>
- <List items={never} attr="never" />
- </>
- )}
- {old.length > 0 && (
- <>
- <div className="micro mt-1.5">older than {SOURCES_STALE_DAYS} d</div>
- <List items={old} attr="old" />
- </>
- )}
- {!never.length && !old.length && !bad.length && (
- <p className="text-[12px] text-[var(--color-dim)]">every source was checked recently and is reachable</p>
- )}
- </Panel>
- );
-}
diff --git a/umtool/components/dashboard/StateStrip.tsx b/umtool/components/dashboard/StateStrip.tsx
@@ -1,56 +0,0 @@
-import Link from "next/link";
-import type { StateRow } from "@/lib/dashboard";
-import Panel from "./Panel";
-
-// One row per kind, the six states as proportional segments.
-//
-// ONE meaningful colour. `stale` is the only state that is a judgement -- a
-// deliverable older than what describes it -- so it wears --color-dirty, and
-// every other state is a step on a neutral ramp. A strip that coloured "built"
-// green would be handing a verdict hue to a fact.
-const FILL: Record<string, string> = {
- draft: "var(--color-panel-2)",
- windows: "var(--color-line)",
- fetched: "color-mix(in srgb, var(--color-dim) 45%, transparent)",
- built: "color-mix(in srgb, var(--color-text) 55%, transparent)",
- shipped: "var(--color-text)",
- stale: "var(--color-dirty)",
-};
-
-export default function StateStrip({ rows, note }: { rows: StateRow[]; note: string }) {
- return (
- <Panel title="projects" testid="projects" more={{ href: "/projects", label: "every project →" }}>
- <p className="micro mb-1.5" data-projects-note="">
- {note}
- </p>
- <div className="space-y-1.5">
- {rows.map((r) => (
- <div key={r.kind} data-state-row={r.kind} className="flex items-center gap-2 text-[11px]">
- <Link href={`/projects?kind=${encodeURIComponent(r.kind)}`} className="w-24 truncate text-[var(--color-dim)] hover:text-[var(--color-text)]">
- {r.label}
- </Link>
- <span className="num w-6 text-right text-[var(--color-text)]">{r.total}</span>
- <div className="flex h-3 flex-1 overflow-hidden rounded-sm border border-[var(--color-line)]">
- {r.segments
- .filter((s) => s.n > 0)
- .map((s) => (
- <Link
- key={s.state}
- href={s.href}
- title={`${s.n} ${s.state}`}
- data-state-seg={s.state}
- data-n={s.n}
- style={{ flexGrow: s.n, background: FILL[s.state] }}
- className="block min-w-[3px] hover:opacity-80"
- />
- ))}
- </div>
- <span className="num w-40 truncate text-[10px] text-[var(--color-dim)]">
- {r.segments.filter((s) => s.n > 0).map((s) => `${s.n} ${s.state}`).join(" · ")}
- </span>
- </div>
- ))}
- </div>
- </Panel>
- );
-}
diff --git a/umtool/components/dashboard/ToolsPanel.tsx b/umtool/components/dashboard/ToolsPanel.tsx
@@ -1,89 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { buttonVariants } from "@/components/ui/button";
-import type { DoctorReport } from "@/lib/tool-types";
-import { fmtGB } from "@/lib/dashboard";
-import { fmtAgo } from "@/lib/format";
-
-// Tools, disk, index. The tool list is the CACHE handed down by the page, or
-// "not checked": the page never probes. The button POSTs, which is the one
-// place a probe happens in the app.
-//
-// Red ONLY when the report pipeline needs it and it is absent. A missing python
-// on a machine that never cuts a face is a fact, not a fault.
-export default function ToolsPanel({
- initial,
- freeBytes,
- index,
-}: {
- initial: DoctorReport | null;
- freeBytes: number | null;
- index: { ok: boolean; fresh: number; total: number };
-}) {
- const [report, setReport] = useState<DoctorReport | null>(initial);
- const [busy, setBusy] = useState(false);
-
- return (
- <section data-panel="tools" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2">
- <div className="mb-1.5 flex items-baseline gap-2">
- <h2 className="micro">tools & disk</h2>
- <span className="micro ml-auto" data-tools-checked={report ? String(report.checkedAt) : "never"}>
- {report ? `checked ${fmtAgo(report.checkedAt)}` : "not checked"}
- </span>
- <button
- type="button"
- data-action="doctor"
- disabled={busy}
- className={buttonVariants({ size: "sm" })}
- onClick={async () => {
- setBusy(true);
- try {
- const r = await fetch("/api/doctor", { method: "POST" });
- if (r.ok) setReport((await r.json()) as DoctorReport);
- } finally {
- setBusy(false);
- }
- }}
- >
- {busy ? "…" : report ? "re-check" : "check"}
- </button>
- </div>
- {report && (
- <ul className="grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px]">
- {report.tools.map((t) => {
- const bad = t.required && !t.present;
- return (
- <li
- key={t.id}
- data-tool={t.id}
- data-present={t.present ? "1" : "0"}
- data-required={t.required ? "1" : "0"}
- title={t.error ?? t.bin}
- className={`flex gap-1.5 ${bad ? "text-[var(--color-bad)]" : t.present ? "text-[var(--color-dim)]" : "text-[var(--color-dim)] opacity-70"}`}
- >
- <span className="font-mono text-[var(--color-text)]">{t.id}</span>
- <span className="num truncate">{t.present ? (t.version ?? "present") : "absent"}</span>
- </li>
- );
- })}
- </ul>
- )}
- <div className="mt-1.5 flex flex-wrap gap-3 border-t border-[var(--color-line)] pt-1.5 text-[11px] text-[var(--color-dim)]">
- <span data-free-bytes={freeBytes ?? ""}>
- free <b className="num text-[var(--color-meter)]">{fmtGB(freeBytes)}</b>
- </span>
- <span data-index={index.ok ? `${index.fresh}/${index.total}` : "off"}>
- index{" "}
- {index.ok ? (
- <>
- <b className="num text-[var(--color-text)]">{index.fresh}/{index.total}</b> fresh
- </>
- ) : (
- "off"
- )}
- </span>
- </div>
- </section>
- );
-}
diff --git a/umtool/components/system/Maintenance.tsx b/umtool/components/system/Maintenance.tsx
@@ -36,14 +36,14 @@ export function RootsPanel({ roots }: { roots: Roots }) {
{roots.reports.present ? "" : " — not there"}
</Row>
<Row k="media" bad={!!roots.media.problem}>
- {roots.media.tiered ? roots.media.path : "= reports (UMTOOL_MEDIA_DIR unset): out/ stays in each project"}
+ {roots.media.tiered ? roots.media.path : "= reports · UMTOOL_MEDIA_DIR unset"}
{roots.media.problem ? ` — ${roots.media.problem}` : ""}
</Row>
<Row k="cache">
{roots.cache.path}
{roots.cache.index ? "" : " — no index yet"}
</Row>
- {roots.oldCache.present && <Row k="old cache">{roots.oldCache.path} — the cache's old place, no longer read; derived, safe to delete</Row>}
+ {roots.oldCache.present && <Row k="old cache">{roots.oldCache.path} — not read; safe to delete</Row>}
</dl>
</Panel>
);
@@ -60,11 +60,10 @@ export function IndexPanel({ index }: { index: { ok: boolean; records: number; p
, <b className="num text-meter">{index.stale}</b> for projects that are gone
</>
) : null}
- {index.builtAt ? ` · rebuilt ${fmtAgo(index.builtAt)}` : ""}. A cache of the walk: every read checks its own signature, so deleting it changes nothing but
- latency.
+ {index.builtAt ? ` · rebuilt ${fmtAgo(index.builtAt)}` : ""}
</p>
) : (
- <p className="m-0 text-[12.5px] text-text-2">No index (the lmdb store did not open): a normal state — everything works, just slower.</p>
+ <p className="m-0 text-[12.5px] text-text-2">No index — every read walks the disk.</p>
)}
{index.path && <p className="m-0 mt-1 truncate font-mono text-[11px] text-muted-2">{index.path}</p>}
<div className="mt-2.5 flex flex-wrap items-start gap-2">
diff --git a/umtool/components/system/NowLive.tsx b/umtool/components/system/NowLive.tsx
@@ -0,0 +1,107 @@
+"use client";
+
+import Link from "next/link";
+import { useEffect, useState } from "react";
+import type { ActivityItem } from "@/lib/activity-types";
+import { fmtAgo } from "@/lib/format";
+
+// umtool's own running job, live (Settings · system's Activity). Polls /api/jobs
+// every two seconds ONLY while something is running: an idle page makes no
+// requests at all, and one that has just watched a build finish stops the
+// moment the state leaves "running".
+//
+// The per-entry boxes use the same vocabulary ReportBuildChain paints from
+// (fetching / cutting / done / failed), computed server-side in lib/activity.ts
+// so this file never re-parses events.
+
+const BOX = {
+ fetching: "border-[var(--color-meter)] text-[var(--color-meter)]",
+ cutting: "border-muted text-text",
+ done: "border-[var(--color-good)] text-[var(--color-good)]",
+ failed: "border-[var(--color-bad)] text-[var(--color-bad)]",
+} as const;
+
+export default function NowLive({ initial }: { initial: ActivityItem | null }) {
+ const [now, setNow] = useState<ActivityItem | null>(initial);
+
+ // One fetch on mount, so the panel says what the registry says even if the
+ // page render and the route disagreed; then a 2 s poll ONLY while running.
+ useEffect(() => {
+ let alive = true;
+ void fetch("/api/jobs?n=1", { cache: "no-store" })
+ .then((r) => (r.ok ? r.json() : null))
+ .then((j: { running: ActivityItem | null } | null) => {
+ if (alive && j && j.running) setNow(j.running);
+ })
+ .catch(() => {});
+ return () => {
+ alive = false;
+ };
+ }, []);
+
+ useEffect(() => {
+ if (!now || now.state !== "running") return;
+ const t = setInterval(async () => {
+ try {
+ const r = await fetch("/api/jobs?n=1", { cache: "no-store" });
+ if (!r.ok) return;
+ const j = (await r.json()) as { running: ActivityItem | null; jobs: ActivityItem[] };
+ // When the running item has gone, show what it became rather than
+ // blanking: the newest job in the list is the one that just finished.
+ setNow(j.running ?? j.jobs.find((x) => x.id === now.id) ?? null);
+ } catch {
+ /* a missed poll is the next poll's problem */
+ }
+ }, 2000);
+ return () => clearInterval(t);
+ }, [now]);
+
+ if (!now) {
+ return (
+ <p className="text-[12px] text-[var(--color-dim)]" data-now="idle">
+ Nothing running
+ </p>
+ );
+ }
+
+ const p = now.progress;
+ const entries = Object.entries(p?.entries ?? {});
+ return (
+ <div data-now={now.state} data-now-id={now.id} className="space-y-1.5">
+ <div className="flex flex-wrap items-baseline gap-2 text-[12px]">
+ <Link href={now.href} className="font-mono ink-link">
+ {now.label}
+ </Link>
+ <span className="micro">{now.source}</span>
+ {p && (
+ <span className="num text-[11px] text-[var(--color-dim)]" data-now-step={`${p.step}/${p.of}`}>
+ step {p.step}/{p.of}
+ </span>
+ )}
+ {p?.clipsOf !== undefined && (
+ <span className="num text-[11px] text-[var(--color-meter)]">
+ {p.clipsDone ?? 0}/{p.clipsOf} entries
+ </span>
+ )}
+ <span className="num ml-auto text-[11px] text-[var(--color-dim)]">
+ {now.state === "running" ? `started ${fmtAgo(now.startedAt)}` : now.state}
+ {now.error ? ` — ${now.error}` : ""}
+ </span>
+ </div>
+ {entries.length > 0 && (
+ <div className="flex flex-wrap gap-1">
+ {entries.map(([id, st]) => (
+ <span
+ key={id}
+ data-now-entry={id}
+ data-entry-state={st}
+ className={`rounded border px-1.5 py-0.5 font-mono text-[10px] ${BOX[st]}`}
+ >
+ {id}
+ </span>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/umtool/components/system/Status.tsx b/umtool/components/system/Status.tsx
@@ -0,0 +1,178 @@
+import Link from "next/link";
+import CheckSourcesButton from "@/components/dashboard/CheckSourcesButton";
+import { Panel } from "@/components/ui/panel";
+import type { ActivityItem } from "@/lib/activity";
+import { SOURCES_STALE_DAYS, type StateRow } from "@/lib/dashboard";
+import { fmtAgo, fmtBytes } from "@/lib/format";
+import { projectHref, projectsHref } from "@/lib/hrefs";
+import type { ProjectSummary } from "@/lib/project-types";
+import NowLive from "./NowLive";
+
+// ---------------------------------------------------------------------------
+// Settings · system's status panels (the old dashboard's, P3; moved here and
+// cut to status lines in P6). Everything is read from the index, the job
+// registries and the summaries -- nothing here probes or shells out.
+// ---------------------------------------------------------------------------
+
+/** umtool's own jobs: the one running (live), then the newest that ended. */
+export function ActivityPanel({ running, recent }: { running: ActivityItem | null; recent: ActivityItem[] }) {
+ const done = recent.filter((a) => a.state !== "running");
+ return (
+ <Panel title="Activity" data-panel="now" aside={<span className="text-muted-2">umtool's jobs</span>}>
+ <NowLive initial={running} />
+ {done.length > 0 && (
+ <ul className="m-0 mt-2 list-none space-y-0.5 border-t border-seam p-0 pt-2" data-activity="">
+ {done.map((a) => (
+ <li key={a.id} data-activity-id={a.id} data-activity-state={a.state} className="flex flex-wrap items-baseline gap-2 text-[11.5px]">
+ <span className={a.state === "failed" ? "text-reject-text" : "text-muted"}>{a.state}</span>
+ <Link href={a.href} prefetch={false} className="ink-link font-mono">
+ {a.label}
+ </Link>
+ <span className="num ml-auto text-muted">{fmtAgo(a.endedAt ?? a.startedAt)}</span>
+ </li>
+ ))}
+ </ul>
+ )}
+ </Panel>
+ );
+}
+
+// One row per kind, the six states as proportional segments. ONE meaningful
+// colour: `stale` (a deliverable older than what describes it) is the doubt
+// word; every other state is a step on a neutral ramp.
+const FILL: Record<string, string> = {
+ draft: "var(--color-panel-2)",
+ windows: "var(--color-line)",
+ fetched: "color-mix(in srgb, var(--color-dim) 45%, transparent)",
+ built: "color-mix(in srgb, var(--color-text) 55%, transparent)",
+ shipped: "var(--color-text)",
+ stale: "var(--color-dirty)",
+};
+
+export function ProjectsPanel({ rows, note }: { rows: StateRow[]; note: string }) {
+ return (
+ <Panel
+ title="Projects"
+ data-panel="projects"
+ aside={
+ <Link href={projectsHref()} prefetch={false} className="ink-link">
+ Every project →
+ </Link>
+ }
+ >
+ <p className="micro m-0 mb-1.5" data-projects-note="">
+ {note}
+ </p>
+ <div className="space-y-1.5">
+ {rows.map((r) => (
+ <div key={r.kind} data-state-row={r.kind} className="flex items-center gap-2 text-[11.5px]">
+ <Link href={projectsHref({ kind: r.kind })} prefetch={false} className="w-24 truncate text-muted hover:text-text">
+ {r.label}
+ </Link>
+ <span className="num w-6 text-right text-text">{r.total}</span>
+ <div className="flex h-3 flex-1 overflow-hidden rounded-sm border border-seam">
+ {r.segments
+ .filter((s) => s.n > 0)
+ .map((s) => (
+ <Link
+ key={s.state}
+ href={s.href}
+ prefetch={false}
+ title={`${s.n} ${s.state}`}
+ data-state-seg={s.state}
+ data-n={s.n}
+ style={{ flexGrow: s.n, background: FILL[s.state] }}
+ className="block min-w-[3px] hover:opacity-80"
+ />
+ ))}
+ </div>
+ <span className="num w-40 truncate text-[10.5px] text-muted">
+ {r.segments
+ .filter((s) => s.n > 0)
+ .map((s) => `${s.n} ${s.state}`)
+ .join(" · ")}
+ </span>
+ </div>
+ ))}
+ </div>
+ </Panel>
+ );
+}
+
+/** Report projects whose sources nobody checked, checked long ago, or found dead -- from summaries, never probed. */
+export function SourcesPanel({ never, old, bad }: { never: ProjectSummary[]; old: ProjectSummary[]; bad: ProjectSummary[] }) {
+ const List = ({ items, attr, label }: { items: ProjectSummary[]; attr: string; label: string }) => (
+ <>
+ <div className="micro mt-1.5">{label}</div>
+ <ul className="m-0 list-none space-y-0.5 p-0" data-sources-list={attr}>
+ {items.map((p) => (
+ <li key={p.id} data-source-project={p.id} className="flex flex-wrap gap-2 text-[11.5px]">
+ <Link href={projectHref(p.id, { tab: "sources" })} prefetch={false} className="ink-link font-mono">
+ {p.id}
+ </Link>
+ <span className="text-muted">
+ {[
+ p.attrs?.["sources-dead"] ? `${p.attrs["sources-dead"]} dead` : "",
+ p.attrs?.["sources-missing"] ? `${p.attrs["sources-missing"]} no cues` : "",
+ p.attrs?.["cue-gaps"] ? `${p.attrs["cue-gaps"]} cue gap${p.attrs["cue-gaps"] === "1" ? "" : "s"}` : "",
+ ]
+ .filter(Boolean)
+ .join(" · ")}
+ </span>
+ </li>
+ ))}
+ </ul>
+ </>
+ );
+ const recheck = [...never, ...old].map((p) => p.id);
+ return (
+ <Panel title="Sources" data-panel="sources" aside={<CheckSourcesButton projects={recheck} />}>
+ <p className="m-0 text-[12.5px] text-text-2" data-sources-counts={`${never.length}/${old.length}/${bad.length}`}>
+ <b className="num text-meter">{never.length}</b> never checked · <b className="num text-meter">{old.length}</b> older than{" "}
+ {SOURCES_STALE_DAYS} d · <b className={`num ${bad.length ? "text-reject-text" : "text-meter"}`}>{bad.length}</b> dead or missing
+ </p>
+ {bad.length > 0 && <List items={bad} attr="bad" label="dead or missing" />}
+ {never.length > 0 && <List items={never} attr="never" label="never checked" />}
+ {old.length > 0 && <List items={old} attr="old" label={`older than ${SOURCES_STALE_DAYS} d`} />}
+ </Panel>
+ );
+}
+
+/** Built count, bytes, newest, stale -- from each summary's `final-bytes` and state; nothing here stats a file. */
+export function DeliverablesPanel({ projects }: { projects: ProjectSummary[] }) {
+ const built = projects.filter((p) => p.attrs?.["final-bytes"]);
+ const bytes = built.reduce((n, p) => n + Number(p.attrs?.["final-bytes"] ?? 0), 0);
+ const newest = [...built].sort((a, b) => b.newestMtimeMs - a.newestMtimeMs)[0] ?? null;
+ const stale = projects.filter((p) => p.state === "stale");
+ return (
+ <Panel
+ title="Deliverables"
+ data-panel="deliverables"
+ aside={
+ <Link href={projectsHref({ state: "built" })} prefetch={false} className="ink-link">
+ Built →
+ </Link>
+ }
+ >
+ <p className="m-0 flex flex-wrap gap-x-3 text-[12.5px] text-text-2" data-deliverables={`${built.length}/${bytes}`}>
+ <span>
+ <b className="num text-meter">{built.length}</b> built · <b className="num text-meter">{fmtBytes(bytes)}</b>
+ </span>
+ {newest && (
+ <span>
+ newest{" "}
+ <Link href={projectHref(newest.id)} prefetch={false} className="ink-link font-mono">
+ {newest.id}
+ </Link>{" "}
+ <span className="num text-muted">{fmtAgo(newest.newestMtimeMs)}</span>
+ </span>
+ )}
+ {stale.length > 0 && (
+ <Link href={projectsHref({ state: "stale" })} prefetch={false} className="text-doubt-text hover:underline" data-stale={stale.length}>
+ {stale.length} stale
+ </Link>
+ )}
+ </p>
+ </Panel>
+ );
+}
diff --git a/umtool/components/system/ToolsPanel.tsx b/umtool/components/system/ToolsPanel.tsx
@@ -0,0 +1,74 @@
+"use client";
+
+import { useState } from "react";
+import { buttonVariants } from "@/components/ui/button";
+import { Panel } from "@/components/ui/panel";
+import type { DoctorReport } from "@/lib/tool-types";
+import { fmtGB } from "@/lib/dashboard";
+import { fmtAgo } from "@/lib/format";
+
+// Settings · system: the tools and the free disk. The tool list is the CACHE
+// the page hands down, or "not checked": the page never probes. The button
+// POSTs /api/doctor, the one place the app probes.
+//
+// Red ONLY when the report pipeline needs a tool and it is absent. A missing
+// python on a machine that never cuts a face is a fact, not a fault.
+export default function ToolsPanel({ initial, freeBytes }: { initial: DoctorReport | null; freeBytes: number | null }) {
+ const [report, setReport] = useState<DoctorReport | null>(initial);
+ const [busy, setBusy] = useState(false);
+
+ return (
+ <Panel
+ title="Tools & disk"
+ data-panel="tools"
+ aside={
+ <span className="flex items-center gap-2">
+ <span className="text-muted-2" data-tools-checked={report ? String(report.checkedAt) : "never"}>
+ {report ? `checked ${fmtAgo(report.checkedAt)}` : "not checked"}
+ </span>
+ <button
+ type="button"
+ data-action="doctor"
+ disabled={busy}
+ className={buttonVariants({ size: "sm" })}
+ onClick={async () => {
+ setBusy(true);
+ try {
+ const r = await fetch("/api/doctor", { method: "POST" });
+ if (r.ok) setReport((await r.json()) as DoctorReport);
+ } finally {
+ setBusy(false);
+ }
+ }}
+ >
+ {busy ? "Checking…" : report ? "Check again" : "Check"}
+ </button>
+ </span>
+ }
+ >
+ <p className="m-0 text-[12.5px] text-text-2" data-free-bytes={freeBytes ?? ""}>
+ <b className="num text-meter">{fmtGB(freeBytes)}</b> free under the reports root
+ </p>
+ {report && (
+ <ul className="m-0 mt-2 grid list-none grid-cols-2 gap-x-3 gap-y-0.5 p-0 text-[11.5px]">
+ {report.tools.map((t) => {
+ const bad = t.required && !t.present;
+ return (
+ <li
+ key={t.id}
+ data-tool={t.id}
+ data-present={t.present ? "1" : "0"}
+ data-required={t.required ? "1" : "0"}
+ title={t.error ?? t.bin}
+ className={`flex gap-1.5 ${bad ? "text-reject-text" : t.present ? "text-muted" : "text-muted opacity-70"}`}
+ >
+ <span className="font-mono text-text">{t.id}</span>
+ <span className="num truncate">{t.present ? (t.version ?? "present") : "absent"}</span>
+ </li>
+ );
+ })}
+ </ul>
+ )}
+ </Panel>
+ );
+}
diff --git a/umtool/e2e/settings.spec.ts b/umtool/e2e/settings.spec.ts
@@ -180,6 +180,9 @@ test("system: the doctor's roots are the fixture's", async ({ page, request }) =
const roots = page.locator("[data-panel=roots]");
await expect(roots).toContainText(".e2e-song");
await expect(roots).toContainText("UMTOOL_MEDIA_DIR unset");
+ // Status lines, not paragraphs (P6): the index is said once, in its own panel.
+ await expect(page.locator("[data-panel=index] p").first()).toHaveText(/^\d+ records(, \d+ for projects that are gone)?( · rebuilt .+)?$|^No index — every read walks the disk\.$/);
+ await expect(page.locator("[data-panel=tools]")).not.toContainText("index");
const doctor = await (await request.get("/api/doctor")).json();
expect(doctor.roots.reports.path).toContain(".e2e-song");
expect(doctor.roots.media.tiered).toBe(false);