import { useEffect, useRef, useState } from 'react'; import { Sparkles, ChevronDown, ChevronRight, Brain } from 'lucide-react'; interface IntentStreamingViewProps { text: string; thinkingText?: string; } /** * 意图解析流式视图:与 OutlineStreamingView / DraftStreamingView 同样的打字机机制, * 颜色用蓝色主题区分意图理解阶段。展示 LLM 边吐 JSON 边滚动的过程,结果由 * IntentResultCard 接力展示结构化字段。 */ export function IntentStreamingView({ text, thinkingText }: IntentStreamingViewProps) { const preRef = useRef(null); const thinkRef = useRef(null); const [thinkOpen, setThinkOpen] = useState(true); useEffect(() => { if (preRef.current) { preRef.current.scrollTop = preRef.current.scrollHeight; } }, [text]); useEffect(() => { if (thinkOpen && thinkRef.current) { thinkRef.current.scrollTop = thinkRef.current.scrollHeight; } }, [thinkingText, thinkOpen]); if (!text && !thinkingText) return null; return (
{thinkingText && (
{thinkOpen && (
              {thinkingText}
              {!text && (
                
              )}
            
)}
)} {text && (
意图解析中… {[0, 1, 2].map((i) => ( ))}
            {text}
            
          
)}
); }