Archilyzer · Source

archilyzer

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

commit 4d3e305703aab6d4a1b2a57885c056bd60f95a52
parent cab41c8131e2f0beafe7b33512da1d49a1195ce4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 18:00:50 -0400

umtool: components/dashboard and lib/dashboard.ts get names that say what they are

The dashboard is gone; its leftovers were the Inbox's, the piece's and
the system page's. InboxList and ResumeChip → components/inbox/;
Lifecycle → components/piece/; SlashFocus → components/shell/; ToolList
→ components/tools/; CheckSourcesButton → components/system/;
lib/dashboard.ts (the projects note, state rows, source buckets, fmtGB)
→ lib/system/status.ts. Every import moved with them; no behaviour change.

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

Diffstat:
Mumtool/app/page.tsx | 6+++---
Mumtool/app/projects/page.tsx | 2+-
Mumtool/app/settings/page.tsx | 2+-
Mumtool/app/settings/system/page.tsx | 2+-
Mumtool/app/tools/page.tsx | 2+-
Mumtool/app/tools/song/page.tsx | 2+-
Mumtool/app/work/page.tsx | 4++--
Mumtool/components/LastPage.tsx | 2+-
Dumtool/components/dashboard/InboxList.tsx | 152-------------------------------------------------------------------------------
Aumtool/components/inbox/InboxList.tsx | 152+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rumtool/components/dashboard/ResumeChip.tsx -> umtool/components/inbox/ResumeChip.tsx | 0
Rumtool/components/dashboard/Lifecycle.tsx -> umtool/components/piece/Lifecycle.tsx | 0
Mumtool/components/piece/LifecycleChip.tsx | 4++--
Mumtool/components/piece/NextCard.tsx | 2+-
Mumtool/components/piece/PieceFrame.tsx | 2+-
Mumtool/components/projects/report/SourcesTab.tsx | 2+-
Mumtool/components/projects/song/OverviewTab.tsx | 2+-
Rumtool/components/dashboard/SlashFocus.tsx -> umtool/components/shell/SlashFocus.tsx | 0
Rumtool/components/dashboard/CheckSourcesButton.tsx -> umtool/components/system/CheckSourcesButton.tsx | 0
Mumtool/components/system/Status.tsx | 4++--
Mumtool/components/system/ToolsPanel.tsx | 2+-
Rumtool/components/dashboard/ToolList.tsx -> umtool/components/tools/ToolList.tsx | 0
Dumtool/lib/dashboard.ts | 73-------------------------------------------------------------------------
Aumtool/lib/system/status.ts | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 files changed, 245 insertions(+), 245 deletions(-)

diff --git a/umtool/app/page.tsx b/umtool/app/page.tsx @@ -1,7 +1,7 @@ import Link from "next/link"; -import InboxList, { type InboxCard, type InboxGroup } from "@/components/dashboard/InboxList"; -import { UndoBar } from "@/components/dashboard/Lifecycle"; -import ResumeChip from "@/components/dashboard/ResumeChip"; +import InboxList, { type InboxCard, type InboxGroup } from "@/components/inbox/InboxList"; +import { UndoBar } from "@/components/piece/Lifecycle"; +import ResumeChip from "@/components/inbox/ResumeChip"; import AppShell from "@/components/shell/AppShell"; import { buttonVariants } from "@/components/ui/button"; import { machineCalls } from "@/lib/machine"; diff --git a/umtool/app/projects/page.tsx b/umtool/app/projects/page.tsx @@ -11,7 +11,7 @@ import CopyButton from "@/components/CopyButton"; import ProjectGrid from "@/components/projects/ProjectGrid"; import { KINDS, decisionCounts, indexHealth, listFolders, listProjects } from "@/lib/projects"; import { PROJECT_STATES } from "@/lib/project-types"; -import { projectsNote } from "@/lib/dashboard"; +import { projectsNote } from "@/lib/system/status"; export const dynamic = "force-dynamic"; diff --git a/umtool/app/settings/page.tsx b/umtool/app/settings/page.tsx @@ -1,5 +1,5 @@ import AppShell from "@/components/shell/AppShell"; -import ToolList from "@/components/dashboard/ToolList"; +import ToolList from "@/components/tools/ToolList"; import { generationPolicyHref, systemHref } from "@/lib/hrefs"; export const dynamic = "force-dynamic"; diff --git a/umtool/app/settings/system/page.tsx b/umtool/app/settings/system/page.tsx @@ -4,7 +4,7 @@ import { IndexPanel, RootsPanel, StoragePanel } from "@/components/system/Mainte 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 { projectsNote, sourceBuckets, stateRows } from "@/lib/system/status"; import { toolsCache } from "@/lib/doctor"; import { generationPolicyHref, settingsHref } from "@/lib/hrefs"; import { freeBytesUnder } from "@/lib/machine"; diff --git a/umtool/app/tools/page.tsx b/umtool/app/tools/page.tsx @@ -1,5 +1,5 @@ import AppShell from "@/components/shell/AppShell"; -import ToolList, { PILE_WHAT, type ToolEntry } from "@/components/dashboard/ToolList"; +import ToolList, { PILE_WHAT, type ToolEntry } from "@/components/tools/ToolList"; import { benchHref, facesHref, findHref, mixHref, pileHref, songToolsHref, sourcesHref, trimHref } from "@/lib/hrefs"; import { TRIM_SETS } from "@/lib/trim"; diff --git a/umtool/app/tools/song/page.tsx b/umtool/app/tools/song/page.tsx @@ -1,5 +1,5 @@ import AppShell from "@/components/shell/AppShell"; -import ToolList, { PILE_WHAT } from "@/components/dashboard/ToolList"; +import ToolList, { PILE_WHAT } from "@/components/tools/ToolList"; import { pileHref, toolsHref } from "@/lib/hrefs"; import { MODES } from "@/lib/types"; diff --git a/umtool/app/work/page.tsx b/umtool/app/work/page.tsx @@ -1,6 +1,6 @@ import Link from "next/link"; -import { UndoBar, LifecycleButton } from "@/components/dashboard/Lifecycle"; -import SlashFocus from "@/components/dashboard/SlashFocus"; +import { UndoBar, LifecycleButton } from "@/components/piece/Lifecycle"; +import SlashFocus from "@/components/shell/SlashFocus"; import AppShell from "@/components/shell/AppShell"; import { badgeVariants } from "@/components/ui/badge"; import { buttonVariants } from "@/components/ui/button"; diff --git a/umtool/components/LastPage.tsx b/umtool/components/LastPage.tsx @@ -5,7 +5,7 @@ import { usePathname } from "next/navigation"; import { LAST_PAGE_KEY, isRecordable } from "@/lib/last-page"; // The recorder rides in the root layout and writes down where you are. What -// reads it back is components/dashboard/ResumeChip.tsx, which offers the URL as +// reads it back is components/inbox/ResumeChip.tsx, which offers the URL as // a link on the dashboard -- / stopped being a doorway when it became a page. // // Neither uses useSearchParams(). That hook demands a Suspense boundary, and diff --git a/umtool/components/dashboard/InboxList.tsx b/umtool/components/dashboard/InboxList.tsx @@ -1,152 +0,0 @@ -"use client"; - -import Link from "next/link"; -import { useState } from "react"; -import { buttonVariants } from "@/components/ui/button"; -import { LitList } from "@/components/ui/lit-list"; -import { LitActions, LitGroup, LitLine } from "@/components/ui/lit-line"; -import { cn } from "@/lib/utils"; -import { LifecycleButton, MuteButton, type LifecycleState } from "./Lifecycle"; - -// --------------------------------------------------------------------------- -// The Inbox's cards as ONE lit list (canvas "Inbox"): a group head, then a -// line per card -- piece · what, why under it, the count in Meter, the ONE -// primary action (filled Signal on the lit line only, app/globals.css -// `.lit-go`), then Park and Mute. -// -// Park and Mark done are the piece's lifecycle (lib/lifecycle.ts); Mute is one -// kind of call on one piece (lib/mutes.ts, beside it). Both are the server's, -// so every page and the API agree; a muted or parked card is listed again under -// "Muted N" / "Show hidden" with Unmute / Reactivate. -// --------------------------------------------------------------------------- - -export type InboxCard = { - key: string; - piece: string | null; - title: string; - kind: string; - what: string; - why: string; - count: number; - severity: string; - action: { label: string; href: string }; - /** The piece's lifecycle (a hidden card's is parked or done). */ - lifecycle: LifecycleState; - /** This kind of call is muted on the piece: the action is Unmute. */ - muted?: boolean; - /** Mark done is the action (POST), not a link. */ - finish?: boolean; -}; - -export type InboxGroup = { - id: string; - label: string; - note?: string; - collapsed: boolean; - decisions: number; - hidden: number; - cards: InboxCard[]; -}; - -export default function InboxList({ groups }: { groups: InboxGroup[] }) { - const [open, setOpen] = useState<Record<string, boolean>>({}); - const shown = groups.filter((g) => g.cards.length > 0); - - if (shown.length === 0) { - return ( - <p data-empty="" className="py-6 text-[12.5px] text-text-2"> - Nothing waiting on you - </p> - ); - } - return ( - <LitList label="Inbox" global> - {shown.map((g) => - g.collapsed && !open[g.id] ? ( - <button - key={g.id} - type="button" - data-group={g.id} - data-collapsed="" - aria-expanded={false} - onClick={() => setOpen((o) => ({ ...o, [g.id]: true }))} - className="mt-[18px] flex w-full items-center gap-2.5 border-b border-seam py-2 pl-5 pr-3 text-left text-[12.5px] text-muted-2 hover:text-text" - > - <span className="micro">{g.label}</span> - <span className="font-mono text-[12px] text-meter">{g.decisions}</span> - <span className="truncate">{g.note}</span> - <span aria-hidden="true" className="ml-auto"> - ▸ - </span> - </button> - ) : ( - <LitGroup - key={g.id} - data-group={g.id} - className="mt-[18px]" - title={g.label} - count={g.cards.length} - note={ - g.collapsed ? ( - <button type="button" onClick={() => setOpen((o) => ({ ...o, [g.id]: false }))} className="hover:text-text"> - collapse ▾ - </button> - ) : ( - g.note - ) - } - > - {g.cards.map((c) => ( - <Card key={c.key} card={c} /> - ))} - </LitGroup> - ), - )} - </LitList> - ); -} - -function Card({ card: c }: { card: InboxCard }) { - const parked = c.lifecycle !== "active"; - return ( - <LitLine - id={c.key} - data-card={c.kind} - data-piece={c.piece ?? undefined} - data-severity={c.severity} - data-muted={c.muted ? "" : undefined} - className="grid grid-cols-[minmax(0,1fr)_56px_190px_112px] items-center gap-x-3.5" - > - <div className="min-w-0"> - <b className="block truncate font-medium text-inherit" data-card-title=""> - {c.title} <span className="font-normal text-muted-2">·</span> {c.what} - </b> - <small className="block truncate text-[12px] text-muted-2">{c.why}</small> - </div> - <span className="text-right font-mono text-[12.5px] font-medium text-meter" data-count={c.count}> - {c.count} - </span> - <span className="justify-self-end"> - {c.muted && c.piece ? ( - <MuteButton piece={c.piece} kind={c.kind} title={c.title} muted variant="outline" size="md" className="lit-go" /> - ) : parked && c.piece ? ( - <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="active" label="Reactivate" variant="outline" size="md" className="lit-go" /> - ) : c.finish && c.piece ? ( - <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="done" label="Mark done" variant="outline" size="md" className="lit-go" /> - ) : ( - <Link href={c.action.href} prefetch={false} data-action-link="" className={cn(buttonVariants({ variant: "outline", size: "md" }), "lit-go")}> - {c.action.label} - </Link> - )} - </span> - <LitActions className="gap-0.5"> - {!parked && !c.muted && c.piece && ( - <> - <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="parked" label="Park" /> - <MuteButton piece={c.piece} kind={c.kind} title={c.title} muted={false} label={c.finish ? "Not yet" : "Mute"} /> - </> - )} - </LitActions> - </LitLine> - ); -} diff --git a/umtool/components/inbox/InboxList.tsx b/umtool/components/inbox/InboxList.tsx @@ -0,0 +1,152 @@ +"use client"; + +import Link from "next/link"; +import { useState } from "react"; +import { buttonVariants } from "@/components/ui/button"; +import { LitList } from "@/components/ui/lit-list"; +import { LitActions, LitGroup, LitLine } from "@/components/ui/lit-line"; +import { cn } from "@/lib/utils"; +import { LifecycleButton, MuteButton, type LifecycleState } from "@/components/piece/Lifecycle"; + +// --------------------------------------------------------------------------- +// The Inbox's cards as ONE lit list (canvas "Inbox"): a group head, then a +// line per card -- piece · what, why under it, the count in Meter, the ONE +// primary action (filled Signal on the lit line only, app/globals.css +// `.lit-go`), then Park and Mute. +// +// Park and Mark done are the piece's lifecycle (lib/lifecycle.ts); Mute is one +// kind of call on one piece (lib/mutes.ts, beside it). Both are the server's, +// so every page and the API agree; a muted or parked card is listed again under +// "Muted N" / "Show hidden" with Unmute / Reactivate. +// --------------------------------------------------------------------------- + +export type InboxCard = { + key: string; + piece: string | null; + title: string; + kind: string; + what: string; + why: string; + count: number; + severity: string; + action: { label: string; href: string }; + /** The piece's lifecycle (a hidden card's is parked or done). */ + lifecycle: LifecycleState; + /** This kind of call is muted on the piece: the action is Unmute. */ + muted?: boolean; + /** Mark done is the action (POST), not a link. */ + finish?: boolean; +}; + +export type InboxGroup = { + id: string; + label: string; + note?: string; + collapsed: boolean; + decisions: number; + hidden: number; + cards: InboxCard[]; +}; + +export default function InboxList({ groups }: { groups: InboxGroup[] }) { + const [open, setOpen] = useState<Record<string, boolean>>({}); + const shown = groups.filter((g) => g.cards.length > 0); + + if (shown.length === 0) { + return ( + <p data-empty="" className="py-6 text-[12.5px] text-text-2"> + Nothing waiting on you + </p> + ); + } + return ( + <LitList label="Inbox" global> + {shown.map((g) => + g.collapsed && !open[g.id] ? ( + <button + key={g.id} + type="button" + data-group={g.id} + data-collapsed="" + aria-expanded={false} + onClick={() => setOpen((o) => ({ ...o, [g.id]: true }))} + className="mt-[18px] flex w-full items-center gap-2.5 border-b border-seam py-2 pl-5 pr-3 text-left text-[12.5px] text-muted-2 hover:text-text" + > + <span className="micro">{g.label}</span> + <span className="font-mono text-[12px] text-meter">{g.decisions}</span> + <span className="truncate">{g.note}</span> + <span aria-hidden="true" className="ml-auto"> + ▸ + </span> + </button> + ) : ( + <LitGroup + key={g.id} + data-group={g.id} + className="mt-[18px]" + title={g.label} + count={g.cards.length} + note={ + g.collapsed ? ( + <button type="button" onClick={() => setOpen((o) => ({ ...o, [g.id]: false }))} className="hover:text-text"> + collapse ▾ + </button> + ) : ( + g.note + ) + } + > + {g.cards.map((c) => ( + <Card key={c.key} card={c} /> + ))} + </LitGroup> + ), + )} + </LitList> + ); +} + +function Card({ card: c }: { card: InboxCard }) { + const parked = c.lifecycle !== "active"; + return ( + <LitLine + id={c.key} + data-card={c.kind} + data-piece={c.piece ?? undefined} + data-severity={c.severity} + data-muted={c.muted ? "" : undefined} + className="grid grid-cols-[minmax(0,1fr)_56px_190px_112px] items-center gap-x-3.5" + > + <div className="min-w-0"> + <b className="block truncate font-medium text-inherit" data-card-title=""> + {c.title} <span className="font-normal text-muted-2">·</span> {c.what} + </b> + <small className="block truncate text-[12px] text-muted-2">{c.why}</small> + </div> + <span className="text-right font-mono text-[12.5px] font-medium text-meter" data-count={c.count}> + {c.count} + </span> + <span className="justify-self-end"> + {c.muted && c.piece ? ( + <MuteButton piece={c.piece} kind={c.kind} title={c.title} muted variant="outline" size="md" className="lit-go" /> + ) : parked && c.piece ? ( + <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="active" label="Reactivate" variant="outline" size="md" className="lit-go" /> + ) : c.finish && c.piece ? ( + <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="done" label="Mark done" variant="outline" size="md" className="lit-go" /> + ) : ( + <Link href={c.action.href} prefetch={false} data-action-link="" className={cn(buttonVariants({ variant: "outline", size: "md" }), "lit-go")}> + {c.action.label} + </Link> + )} + </span> + <LitActions className="gap-0.5"> + {!parked && !c.muted && c.piece && ( + <> + <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="parked" label="Park" /> + <MuteButton piece={c.piece} kind={c.kind} title={c.title} muted={false} label={c.finish ? "Not yet" : "Mute"} /> + </> + )} + </LitActions> + </LitLine> + ); +} diff --git a/umtool/components/dashboard/ResumeChip.tsx b/umtool/components/inbox/ResumeChip.tsx diff --git a/umtool/components/dashboard/Lifecycle.tsx b/umtool/components/piece/Lifecycle.tsx diff --git a/umtool/components/piece/LifecycleChip.tsx b/umtool/components/piece/LifecycleChip.tsx @@ -1,6 +1,6 @@ "use client"; -import { LifecycleButton, type LifecycleState } from "@/components/dashboard/Lifecycle"; +import { LifecycleButton, type LifecycleState } from "@/components/piece/Lifecycle"; import { badgeVariants } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; import Menu from "./Menu"; @@ -8,7 +8,7 @@ import Menu from "./Menu"; // The piece's lifecycle in its head (canvas "Piece · Overview", `Active ▾`): // the state as a chip, and the moves out of it -- Park and Mark done while it // is active, Reactivate (and Mark done) while it is parked, Reactivate once it -// is done. The same POST and Undo bar as the Inbox's (components/dashboard/ +// is done. The same POST and Undo bar as the Inbox's (components/piece/ // Lifecycle.tsx); the page re-reads on a change. const WORD: Record<LifecycleState, string> = { active: "Active", parked: "Parked", done: "Done" }; diff --git a/umtool/components/piece/NextCard.tsx b/umtool/components/piece/NextCard.tsx @@ -1,5 +1,5 @@ import Link from "next/link"; -import { LifecycleButton } from "@/components/dashboard/Lifecycle"; +import { LifecycleButton } from "@/components/piece/Lifecycle"; import { buttonVariants } from "@/components/ui/button"; import { Card } from "@/components/ui/panel"; import { readNextCall } from "@/lib/pieces/frame"; diff --git a/umtool/components/piece/PieceFrame.tsx b/umtool/components/piece/PieceFrame.tsx @@ -1,5 +1,5 @@ import Link from "next/link"; -import { UndoBar } from "@/components/dashboard/Lifecycle"; +import { UndoBar } from "@/components/piece/Lifecycle"; import AppShell from "@/components/shell/AppShell"; import { buttonVariants } from "@/components/ui/button"; import { Stepper } from "@/components/ui/stepper"; diff --git a/umtool/components/projects/report/SourcesTab.tsx b/umtool/components/projects/report/SourcesTab.tsx @@ -1,5 +1,5 @@ import Link from "next/link"; -import CheckSourcesButton from "@/components/dashboard/CheckSourcesButton"; +import CheckSourcesButton from "@/components/system/CheckSourcesButton"; import { sourcesOf } from "@/lib/projects/report.mjs"; import { clipBenchHref } from "@/lib/hrefs"; import TagCitedButton from "../TagCitedButton"; diff --git a/umtool/components/projects/song/OverviewTab.tsx b/umtool/components/projects/song/OverviewTab.tsx @@ -3,7 +3,7 @@ import { Suspense } from "react"; import CopyButton from "@/components/CopyButton"; import NextCard, { NextCardShell } from "@/components/piece/NextCard"; import { ProjectDecisions } from "@/components/projects/report/OverviewTab"; -import { PILE_WHAT } from "@/components/dashboard/ToolList"; +import { PILE_WHAT } from "@/components/tools/ToolList"; import { CUT_NAMES, type Song } from "@/lib/browse"; import { decisionsForProject } from "@/lib/projects"; import { fmtBytes } from "@/lib/format"; diff --git a/umtool/components/dashboard/SlashFocus.tsx b/umtool/components/shell/SlashFocus.tsx diff --git a/umtool/components/dashboard/CheckSourcesButton.tsx b/umtool/components/system/CheckSourcesButton.tsx diff --git a/umtool/components/system/Status.tsx b/umtool/components/system/Status.tsx @@ -1,8 +1,8 @@ import Link from "next/link"; -import CheckSourcesButton from "@/components/dashboard/CheckSourcesButton"; +import CheckSourcesButton from "@/components/system/CheckSourcesButton"; import { Panel } from "@/components/ui/panel"; import type { ActivityItem } from "@/lib/activity"; -import { SOURCES_STALE_DAYS, type StateRow } from "@/lib/dashboard"; +import { SOURCES_STALE_DAYS, type StateRow } from "@/lib/system/status"; import { fmtAgo, fmtBytes } from "@/lib/format"; import { projectHref, projectsHref } from "@/lib/hrefs"; import type { ProjectSummary } from "@/lib/project-types"; diff --git a/umtool/components/system/ToolsPanel.tsx b/umtool/components/system/ToolsPanel.tsx @@ -4,7 +4,7 @@ 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 { fmtGB } from "@/lib/system/status"; import { fmtAgo } from "@/lib/format"; // Settings · system: the tools and the free disk. The tool list is the CACHE diff --git a/umtool/components/dashboard/ToolList.tsx b/umtool/components/tools/ToolList.tsx diff --git a/umtool/lib/dashboard.ts b/umtool/lib/dashboard.ts @@ -1,73 +0,0 @@ -// Pure helpers /settings/system and /projects share. NO `node:` import: the state -// strip is rendered on the server but its labels are also what the e2e suite -// compares against /projects' header, and one helper is how the two pages are -// kept from disagreeing by a plural. -import { PROJECT_STATES, type ProjectState } from "./project-types"; - -/** The header /projects prints and /settings/system's Projects panel repeats. */ -export const projectsNote = (total: number, blocking: number, open: number) => - `${total} projects · ${blocking} blocking · ${open} open`; - -export type StateRow = { - kind: string; - label: string; - total: number; - /** Every state, in PROJECT_STATES order, zero included -- the strip is proportional. */ - segments: { state: ProjectState; n: number; href: string }[]; -}; - -/** One row per kind: how many projects sit in each of the six states. */ -export function stateRows( - kinds: { id: string; label: string }[], - projects: { kind: string; state: ProjectState }[], -): StateRow[] { - return kinds.map((k) => { - const mine = projects.filter((p) => p.kind === k.id); - return { - kind: k.id, - label: k.label, - total: mine.length, - segments: PROJECT_STATES.map((state) => ({ - state, - n: mine.filter((p) => p.state === state).length, - href: `/projects?kind=${encodeURIComponent(k.id)}&state=${state}`, - })), - }; - }); -} - -/** Thirty days: the age past which a recorded availability check is "old". */ -export const SOURCES_STALE_DAYS = 30; - -/** - * The Sources panel's three buckets, from each report project's summary - * attributes (report.mjs writes `sources-checked-at`, `sources-dead`, - * `cue-gaps`). Never checked / checked too long ago / something wrong. - */ -export function sourceBuckets<T extends { id: string; attrs?: Record<string, string> }>( - projects: T[], - now = Date.now(), -): { never: T[]; old: T[]; bad: T[] } { - const never: T[] = []; - const old: T[] = []; - const bad: T[] = []; - for (const p of projects) { - const a = p.attrs ?? {}; - // Only kinds that report sources at all -- a song has no `sources` attr. - if (!("sources" in a)) continue; - if (Number(a.sources) === 0) continue; - const at = Number(a["sources-checked-at"] ?? 0); - if (!at) never.push(p); - else if (now - at > SOURCES_STALE_DAYS * 86_400_000) old.push(p); - if (Number(a["sources-dead"] ?? 0) > 0 || Number(a["sources-missing"] ?? 0) > 0 || Number(a["cue-gaps"] ?? 0) > 0) { - bad.push(p); - } - } - return { never, old, bad }; -} - -export function fmtGB(bytes: number | null): string { - if (bytes == null) return "–"; - const gb = bytes / 1e9; - return gb >= 100 ? `${gb.toFixed(0)} GB` : `${gb.toFixed(1)} GB`; -} diff --git a/umtool/lib/system/status.ts b/umtool/lib/system/status.ts @@ -0,0 +1,73 @@ +// Pure helpers /settings/system and /projects share. NO `node:` import: the state +// strip is rendered on the server but its labels are also what the e2e suite +// compares against /projects' header, and one helper is how the two pages are +// kept from disagreeing by a plural. +import { PROJECT_STATES, type ProjectState } from "../project-types"; + +/** The header /projects prints and /settings/system's Projects panel repeats. */ +export const projectsNote = (total: number, blocking: number, open: number) => + `${total} projects · ${blocking} blocking · ${open} open`; + +export type StateRow = { + kind: string; + label: string; + total: number; + /** Every state, in PROJECT_STATES order, zero included -- the strip is proportional. */ + segments: { state: ProjectState; n: number; href: string }[]; +}; + +/** One row per kind: how many projects sit in each of the six states. */ +export function stateRows( + kinds: { id: string; label: string }[], + projects: { kind: string; state: ProjectState }[], +): StateRow[] { + return kinds.map((k) => { + const mine = projects.filter((p) => p.kind === k.id); + return { + kind: k.id, + label: k.label, + total: mine.length, + segments: PROJECT_STATES.map((state) => ({ + state, + n: mine.filter((p) => p.state === state).length, + href: `/projects?kind=${encodeURIComponent(k.id)}&state=${state}`, + })), + }; + }); +} + +/** Thirty days: the age past which a recorded availability check is "old". */ +export const SOURCES_STALE_DAYS = 30; + +/** + * The Sources panel's three buckets, from each report project's summary + * attributes (report.mjs writes `sources-checked-at`, `sources-dead`, + * `cue-gaps`). Never checked / checked too long ago / something wrong. + */ +export function sourceBuckets<T extends { id: string; attrs?: Record<string, string> }>( + projects: T[], + now = Date.now(), +): { never: T[]; old: T[]; bad: T[] } { + const never: T[] = []; + const old: T[] = []; + const bad: T[] = []; + for (const p of projects) { + const a = p.attrs ?? {}; + // Only kinds that report sources at all -- a song has no `sources` attr. + if (!("sources" in a)) continue; + if (Number(a.sources) === 0) continue; + const at = Number(a["sources-checked-at"] ?? 0); + if (!at) never.push(p); + else if (now - at > SOURCES_STALE_DAYS * 86_400_000) old.push(p); + if (Number(a["sources-dead"] ?? 0) > 0 || Number(a["sources-missing"] ?? 0) > 0 || Number(a["cue-gaps"] ?? 0) > 0) { + bad.push(p); + } + } + return { never, old, bad }; +} + +export function fmtGB(bytes: number | null): string { + if (bytes == null) return "–"; + const gb = bytes / 1e9; + return gb >= 100 ? `${gb.toFixed(0)} GB` : `${gb.toFixed(1)} GB`; +}