| 1 | // Adapted from DeepSeek Harness c291e7961a, ui-chat/ContextInjectionRow.tsx (MIT). |
| 2 | import { useState, type ReactNode } from "react"; |
| 3 | import { ClipboardList } from "lucide-react"; |
| 4 | import { DisclosureRow } from "./DisclosureRow"; |
| 5 | import css from "./ContextInjectionRow.styles"; |
| 6 | |
| 7 | export function ContextInjectionRow({ title, summary, children, beforeToggle }: { |
| 8 | title: string; summary?: string; children: ReactNode; beforeToggle?: () => void; |
| 9 | }) { |
| 10 | const [open, setOpen] = useState(false); |
| 11 | return <DisclosureRow className={css.root} icon={<ClipboardList size={14} />} title={title} |
| 12 | chevronClassName={css.chevron} open={open} expandable expandOnRowClick keepContentWhenOpen |
| 13 | onToggle={() => { beforeToggle?.(); setOpen(value => !value); }} |
| 14 | collapsedContent={summary && <><span className={css.sep} aria-hidden /><span className={css.summary}>{summary}</span></>}> |
| 15 | <div className={css.body}>{children}</div> |
| 16 | </DisclosureRow>; |
| 17 | } |
| 18 |