import { makeAssistantDataUI, useAuiState } from "@assistant-ui/react"; import { ChevronRightIcon } from "lucide-react"; import type { FC } from "react"; import { useCallback, useEffect, useState } from "react"; import { ChainOfThoughtItem } from "@/components/prompt-kit/chain-of-thought"; import { TextShimmerLoader } from "@/components/prompt-kit/loader"; import { cn } from "@/lib/utils"; export interface ThinkingStep { id: string; title: string; items: string[]; status: "pending" | "in_progress" | "completed"; } /** * Chain of thought display component - single collapsible dropdown design */ export const ThinkingStepsDisplay: FC<{ steps: ThinkingStep[]; isThreadRunning?: boolean }> = ({ steps, isThreadRunning = true, }) => { const getEffectiveStatus = useCallback( (step: ThinkingStep): "pending" | "in_progress" | "completed" => { if (step.status === "in_progress" && !isThreadRunning) { return "completed"; } return step.status; }, [isThreadRunning] ); const inProgressStep = steps.find((s) => getEffectiveStatus(s) === "in_progress"); const allCompleted = steps.length > 0 && !isThreadRunning && steps.every((s) => getEffectiveStatus(s) === "completed"); const isProcessing = isThreadRunning && !allCompleted; const [isOpen, setIsOpen] = useState(() => isProcessing); useEffect(() => { if (isProcessing) { setIsOpen(true); return; } if (allCompleted) { setIsOpen(false); } }, [allCompleted, isProcessing]); if (steps.length === 0) return null; const getHeaderText = () => { if (allCompleted) { return "Reviewed"; } if (inProgressStep) { return inProgressStep.title; } if (isProcessing) { return "Processing"; } return "Reviewed"; }; return (