import { useId, useState } from "react"; import { ChevronDown, CircleCheck, Info, OctagonAlert, TriangleAlert, type LucideIcon, } from "lucide-react"; import { cn } from "@/lib/utils"; import { MarkdownBody } from "@/components/MarkdownBody"; import { SystemNoticeMetadataSections, type SystemNoticeTone, } from "@/components/SystemNotice"; import { humanizeSystemNotice } from "@/lib/system-notice-humanizer"; import { mapCommentMetadataToSystemNoticeSections } from "@/lib/system-notice-comment"; import { timeAgo } from "@/lib/timeAgo"; import type { TaskChatMessageItem } from "./task-chat-model"; const TONE_ICON: Record = { neutral: Info, info: Info, success: CircleCheck, warning: TriangleAlert, danger: OctagonAlert, }; const TONE_ICON_CLASS: Record = { neutral: "text-muted-foreground", info: "text-(--status-task-icon-in_progress)", success: "text-(--status-task-icon-done)", warning: "text-(--status-task-icon-todo)", danger: "text-(--status-task-icon-blocked)", }; /** * System comment row in the chat shell (PAP-443 / PAP-442 Phase 1): collapsed, * it reads as a quiet centered one-liner in TaskChatMarker's register — tone * icon + humanized plain-English title + relative time + chevron — instead of * a large gray paragraph of raw text. Expanding reveals the full * markdown-rendered body plus any structured metadata sections; nothing is * suppressed, only folded. */ export function TaskChatSystemNotice({ item }: { item: TaskChatMessageItem }) { const [open, setOpen] = useState(Boolean(item.presentation?.detailsDefaultOpen)); const detailsId = useId(); const { title, tone, detail } = humanizeSystemNotice({ body: item.text, presentation: item.presentation, }); const sections = mapCommentMetadataToSystemNoticeSections(item.metadata, { runAgentId: item.runAgentId, }); const ToneIcon = TONE_ICON[tone]; const relative = item.createdAtIso ? timeAgo(item.createdAtIso) : undefined; return (
{open ? (
{item.text}
{sections.length > 0 ? (
) : null}
) : null}
); }