import { Badge, Text } from "@cloudflare/kumo"; import { CheckCircle, GearSix, type Icon, Robot, User, WarningCircle } from "@phosphor-icons/react"; import type { ReactNode } from "react"; import { SectionEmpty } from "./SectionEmpty.tsx"; /** One thing that happened to the page being built (RFC-0020 §6). */ export interface BuildActivityItem { id: string; /** `change`: applied; `rejected`: an agent's operations were refused (it will try again). */ kind: "change" | "rejected"; actor: { kind: "human" | "agent" | "system" | string; name: string }; /** What did it: `patch_draft`, `update_page`, `studio`. */ tool: string; at: string; /** One line: "2 sections changed", "3 operations". */ summary: string; /** Repairs Cloudhal made, or the refused parts with their JSON Pointers. */ details?: readonly string[]; } export interface BuildActivityLabels { empty: string; emptyDescription?: string; applied: string; rejected: string; } export interface BuildActivityProps { items: readonly BuildActivityItem[]; labels: BuildActivityLabels; emptyIcon?: ReactNode; /** Renders a time; screens pass a relative time. */ renderTime: (iso: string) => ReactNode; } const ACTOR_ICON: Record = { human: User, agent: Robot, system: GearSix }; /** * The live feed of a build (RFC-0020 §6, DESIGN.md §2ac), newest first: who changed the page with * which tool, what changed, and Cloudhal's repairs or the refused parts the agent will fix. Render * it inside a `SectionCard`. */ export function BuildActivity({ items, labels, emptyIcon, renderTime: time }: BuildActivityProps) { if (items.length === 0) return ( ); return (
    {items.map((item) => { const ActorIcon = ACTOR_ICON[item.actor.kind] ?? GearSix; const failed = item.kind === "rejected"; return (
  1. {item.actor.name} {item.tool} {failed ? labels.rejected : labels.applied} {time(item.at)}
    {failed ? ( ) : ( )}
    {item.summary} {item.details?.map((d) => ( {d} ))}
  2. ); })}
); }