Streaming with auto-collapse
Hand the panel reasoning as it streams. When `thinking` flips false, it collapses on its own.
const [thinking, setThinking] = React.useState(true);
const [reasoning, setReasoning] = React.useState("");
React.useEffect(() => {
const FULL = "The user wants a concise answer. Lead with the recommendation…";
let i = 0;
const id = setInterval(() => {
i += 3;
setReasoning(FULL.slice(0, i));
if (i >= FULL.length) {
clearInterval(id);
setTimeout(() => setThinking(false), 700);
}
}, 28);
return () => clearInterval(id);
}, []);
return <ReasoningTrace reasoning={reasoning} thinking={thinking} />;