import { useEffect, useRef, useState } from "react";
import { Check, CircleDashed } from "lucide-react";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
import { ActivityStep } from "./ActivityStep";
import { compactReasoningPreview } from "./reasoning-preview";
export function ReasoningRow({
text,
streaming,
className,
}: {
text: string;
streaming: boolean;
className?: string;
}) {
const { t } = useTranslation();
const fallback = streaming
? t("message.reasoningStreaming", { defaultValue: "Thinking…" })
: t("message.reasoning", { defaultValue: "Thinking" });
const preview = compactReasoningPreview(text) || fallback;
return (
}
active={streaming}
tone={streaming ? "active" : "success"}
label={preview}
labelClassName="italic text-muted-foreground/78"
contentClassName="overflow-hidden"
className={className}
/>
);
}
function ReasoningMarker({ streaming }: { streaming: boolean }) {
const wasStreamingRef = useRef(streaming);
const [justCompleted, setJustCompleted] = useState(false);
useEffect(() => {
if (wasStreamingRef.current && !streaming) {
setJustCompleted(true);
const timeout = window.setTimeout(() => setJustCompleted(false), 650);
wasStreamingRef.current = streaming;
return () => window.clearTimeout(timeout);
}
wasStreamingRef.current = streaming;
return undefined;
}, [streaming]);
if (streaming) {
return (
);
}
return (
);
}