Response collapse Folding a long answer after a lead that stands on its own, with the control naming the size of what is hidden. Cutting at a fixed line count lands mid-sentence, and a bare show more leaves the reader nothing to decide with. npx shadcn@latest add button npm i lucide-react Tokens this needs: --card, --card-foreground, --background, --accent, --accent-foreground, --muted-foreground, --border, --chart-1 ──────────────────────────────────────────────────────────────────────── // ResponseCollapse.tsx ──────────────────────────────────────────────────────────────────────── import { useEffect, useRef, useState, type ReactNode } from "react"; import { ChevronDown, ChevronUp } from "lucide-react"; import { Button } from "@/components/ui/button"; type Section = { heading: string; body: string }; type Props = { /** Written to stand alone. Ask the model for one, rather than hoping the * first lines happen to serve. */ lead: string; /** Everything after the lead, cut on structure rather than on a line count. */ sections: Section[]; render?: (body: string) => ReactNode; }; const words = (s: string) => s.trim().split(/\s+/).length; export function ResponseCollapse({ lead, sections, render = (b) =>
{b}
}: Props) { const [open, setOpen] = useState(false); const fold = useRef{lead}