// THE READINESS BAR (umtool redesign L7b; the workspace's row under its top bar): one pill each for the quote // check, the links, the captures, the render and X's jar -- ✓, a count, ! or — -- each a click to its fix or its // page. Read-only, and derived from nothing of its own: the rows are the Inbox's (the project reducer's // decisions, lib/projects/report.mjs; the report video's calls, lib/inbox/projectCalls.ts; X's jar, // lib/inbox/xJar.ts), bucketed here by kind. Pure: lib/inbox/readiness.ts reads them. // // state "bad" a blocking row (or X's jar stale): something downstream would lie or die // "count" rows that are open or informational, `count` of them // "ok" none, and the check applies (it has run, or there is something for it to judge) // "none" it does not apply here (no quote check, no clip, nothing rendered, no X post) -- or it is NOT // KNOWN: the project's checks did not read, the editor did not answer for X's jar. Never ✓ then. /** Which pill a row of the Inbox's is. */ export const PILL_KINDS = { "quote-check": ["clip-quote-moved", "clip-quote-missing", "quote-check-stale"], links: ["link-dead", "links-unverified", "links-unchecked", "site-deploy-behind", "clip-link-policy"], captures: ["clip-unfetchable", "clip-no-cues", "clip-unchecked"], render: ["stale-build", "version-unjudged"], "x-jar": ["x-jar-stale"], }; export const PILLS = [ { id: "quote-check", label: "Quote check" }, { id: "links", label: "Links" }, { id: "captures", label: "Captures" }, { id: "render", label: "Render" }, { id: "x-jar", label: "X jar" }, ]; const pillOfKind = new Map(Object.entries(PILL_KINDS).flatMap(([pill, kinds]) => kinds.map((k) => [k, pill]))); /** The pill a decision kind feeds, or null. */ export const pillOf = (kind) => pillOfKind.get(kind) ?? null; /** * @typedef {{ kind: string, target: string, why: string, href: string, severity: "blocking" | "open" | "info" }} Row * @typedef {{ id: string, label: string, state: "bad" | "count" | "ok" | "none", count: number, title: string, href: string | null, select?: string | null }} Pill */ /** * The five pills. * * @param {{ * rows: Row[], * facts: { quoteCheck: boolean, linksChecked: boolean, clips: number, xPosts: number, built: boolean, rendered: boolean, missing?: string[], * decisionsKnown?: boolean, xKnown?: boolean }, * hrefs: { decisions: string, home: string, deliver: string, takes: string, cut: string, xSettings: string, review: (take: string) => string }, * }} o * @returns {Pill[]} */ export function readinessPills({ rows, facts, hrefs }) { const by = new Map(PILLS.map((p) => [p.id, /** @type {Row[]} */ ([])])); for (const r of rows ?? []) { const p = pillOf(r?.kind); if (p) by.get(p).push(r); } const words = (rs) => rs.slice(0, 4).map((r) => `${r.target}: ${r.why}`).join(" · ") + (rs.length > 4 ? ` · and ${rs.length - 4} more` : ""); /** @returns {Pill} */ const pill = (id, { ok, none, okTitle, noneTitle, okHref = null, badHref, countHref = badHref, extra = [] }) => { const label = PILLS.find((p) => p.id === id).label; const rs = by.get(id); const bad = rs.filter((r) => r.severity === "blocking"); if (bad.length) return { id, label, state: "bad", count: bad.length, title: words(bad), href: badHref(bad), select: null }; const n = rs.length + extra.length; if (n) return { id, label, state: "count", count: n, title: [rs.length ? words(rs) : null, ...extra.map((x) => x.why)].filter(Boolean).join(" · "), href: countHref(rs), select: extra[0]?.select ?? null }; // A check that did not read is not known: "—", never ✓ (the reducer threw; its rows are not "nothing wrong"). if (ok && id !== "x-jar" && facts.decisionsKnown === false) return { id, label, state: "none", count: 0, title: "the project's checks could not be read", href: okHref, select: null }; if (ok) return { id, label, state: "ok", count: 0, title: okTitle, href: okHref, select: null }; return { id, label, state: "none", count: 0, title: noneTitle, href: okHref, select: null }; }; const missing = facts.missing ?? []; return [ pill("quote-check", { ok: facts.quoteCheck, okTitle: "every quoted clip heard where it plays (quote-check.json)", noneTitle: "no quote check here yet (umtool quote-check

)", okHref: hrefs.decisions, // A failing row is the piece's own decision (its settle on the Overview); stale rows are home's one press. badHref: () => hrefs.decisions, countHref: (rs) => (rs.every((r) => r.kind === "quote-check-stale") ? hrefs.home : hrefs.decisions), }), pill("links", { ok: facts.clips > 0 && facts.linksChecked, okTitle: "every QR opens on its site (out/links.json)", noneTitle: facts.clips ? "the QR links were never checked (umtool links

)" : "no clip, no QR link", okHref: hrefs.decisions, badHref: () => hrefs.decisions, }), pill("captures", { ok: facts.clips > 0, okTitle: "every clip's window is fetched and its source answers", noneTitle: "no clip to fetch", okHref: hrefs.cut, badHref: () => hrefs.decisions, countHref: (rs) => (rs.length ? hrefs.decisions : hrefs.cut), extra: missing.map((id) => ({ why: `${id}: no media fetched`, select: id })), }), pill("render", { // A render on record (a take's preview, the take panel's reader) or a build the checks call current. ok: facts.built || facts.rendered, okTitle: facts.rendered ? "rendered; every version judged" : "the build is current with the draft", noneTitle: "never rendered (Render ▾)", okHref: hrefs.takes, badHref: () => hrefs.deliver, countHref: (rs) => { const v = rs.find((r) => r.kind === "version-unjudged"); return v ? hrefs.review(v.target) : hrefs.deliver; }, }), // X's jar is the machine's: stale while X work waits on it (the editor's alert), whichever piece it is for. ((p) => (p.state === "count" ? { ...p, state: "bad" } : p))( pill("x-jar", { // ✓ only on the editor's word: a jar it did not answer for is not known. ok: facts.xPosts > 0 && facts.xKnown !== false, okTitle: "X's cookie jar: no X work waiting on it", noneTitle: facts.xKnown === false ? "the editor did not answer: X's jar is not known" : "no X post in the cut", okHref: hrefs.xSettings, badHref: (rs) => rs[0]?.href ?? hrefs.xSettings, }), ), ]; }