/** * One run in detail (RFC-0008 §11.7, §15.1 History): its state and outcome, the error, the summary * the job or the agent wrote (plain text), the counts, and the findings of a built-in job — broken * links with their redirect proposals, stale articles, feed problems, the digest's sections — each * with its stable code in words. Text that came from visitors or a fetched document is marked and * shown as plain text only. */ import type { ScheduleRun } from "@cloudhal/core-contracts"; import { formatNumber } from "@cloudhal/messages/format"; import { Badge, InsetPanel, LayerDialog, Link, ScheduleStatusBadge, SectionEmpty, SkeletonLine, Text, Tooltip, } from "@cloudhal/ui"; import { ShieldWarning } from "@phosphor-icons/react"; import { useQuery } from "@tanstack/react-query"; import type { RunFinding } from "../lib/api.ts"; import { entryHref } from "../lib/entry-href.ts"; import { formatWhen } from "../lib/schedules.ts"; import { schedulesApi } from "../lib/schedules-api.ts"; import { type ST, scheduleKeys, useScheduleWords, useSiteZone } from "./Schedules.tsx"; const CODES = [ "broken-internal-link", "broken-media-reference", "broken-menu-target", "link-to-gated-content", "not-found-path", "stale-entry", "feed-unreachable", "feed-invalid", "feed-item-incomplete", "feed-future-date", "feed-missing-entry", "feed-gated-node", "feed-asset-not-live", "digest-published", "digest-scheduled", "digest-attention", "digest-open-findings", "stale-draft", ] as const; type Code = (typeof CODES)[number]; const isCode = (c: string): c is Code => (CODES as readonly string[]).includes(c); const SEVERITY = { error: "error", warning: "warning", info: "secondary" } as const; /** Where a node is edited, from its id's prefix. */ function nodeHref(siteId: string, id: string | undefined): string | undefined { if (!id) return undefined; if (id.startsWith("entry_")) return entryHref(siteId, id); if (id.startsWith("page_")) return `/sites/${siteId}/pages/${id}`; if (id.startsWith("term_")) return `/sites/${siteId}/taxonomy/${id}`; if (id.startsWith("rel_")) return `/sites/${siteId}/schedules/releases/${id}`; return undefined; } function FindingRow({ t, siteId, finding }: { t: ST; siteId: string; finding: RunFinding }) { const r = "schedules.history.run" as const; const code = isCode(finding.code) ? finding.code : "other"; const href = nodeHref(siteId, finding.nodeId); // Everything below is data from the site or from visitors: plain text, never HTML or a link out. const lines = [finding.title, finding.path, finding.href, finding.url, finding.detail].filter( (x): x is string => typeof x === "string" && x.length > 0, ); return (