"use client"; import { memo, type FC, type PropsWithChildren } from "react"; import { BrainIcon } from "lucide-react"; import { useAuiState } from "@assistant-ui/react"; import { cn } from "@/lib/utils"; type GroupedPartsGroup = { indices: readonly number[]; }; const ReasoningGroupImpl: FC< PropsWithChildren<{ group: GroupedPartsGroup }> > = ({ children, group }) => { const startIndex = group.indices[0]!; const endIndex = group.indices.at(-1)!; const isMultiLine = useAuiState((s) => { let totalLength = 0; for (let i = startIndex; i <= endIndex; i++) { const part = s.message.parts[i]; if (part?.type === "reasoning") { if (part.text.includes("\n\n")) return true; totalLength += part.text.length; } } return totalLength > 120; }); const textAfter = useAuiState((s) => { for (let i = endIndex + 1; i < s.message.parts.length; i++) { const type = s.message.parts[i]?.type; if (type === "data") continue; return type === "text"; } return false; }); return (
{children}
); }; export const ReasoningGroup = memo(ReasoningGroupImpl); ReasoningGroup.displayName = "ReasoningGroup";