import clsx from "clsx"; import { useState, useRef, useEffect } from "react"; import { ChatMessage } from "../store"; import Locale from "../locales"; import styles from "./thinking-content.module.scss"; import MaxIcon from "../icons/max.svg"; import MinIcon from "../icons/min.svg"; export function ThinkingContent({ message }: { message: ChatMessage }) { const [expanded, setExpanded] = useState(false); const thinkingContentRef = useRef(null); const thinkingContent = message.reasoningContent; const isThinking = message.streaming && thinkingContent && thinkingContent.length > 0; // Auto-scroll to bottom of thinking container useEffect(() => { if (isThinking && thinkingContentRef.current) { requestAnimationFrame(() => { if (thinkingContentRef.current) { thinkingContentRef.current.scrollTop = thinkingContentRef.current.scrollHeight; } }); } }, [thinkingContent, isThinking, expanded]); if (!thinkingContent) return null; return (
{Locale.Chat.Thinking.Title}
setExpanded(!expanded)} > {expanded ? : }
{!expanded &&
}
{thinkingContent}
{!expanded &&
}
); }