feat(assistant-steps): only open last comp

This commit is contained in:
ItzCrazyKns
2025-12-23 17:17:56 +05:30
parent 5f04034650
commit c3b74a3fd0
2 changed files with 8 additions and 3 deletions

View File

@@ -54,17 +54,21 @@ const getStepTitle = (
const AssistantSteps = ({ const AssistantSteps = ({
block, block,
status, status,
isLast,
}: { }: {
block: ResearchBlock; block: ResearchBlock;
status: 'answering' | 'completed' | 'error'; status: 'answering' | 'completed' | 'error';
isLast: boolean;
}) => { }) => {
const [isExpanded, setIsExpanded] = useState(true); const [isExpanded, setIsExpanded] = useState(
isLast && status === 'answering' ? true : false,
);
const { researchEnded, loading } = useChat(); const { researchEnded, loading } = useChat();
useEffect(() => { useEffect(() => {
if (researchEnded) { if (researchEnded && isLast) {
setIsExpanded(false); setIsExpanded(false);
} else if (status === 'answering') { } else if (status === 'answering' && isLast) {
setIsExpanded(true); setIsExpanded(true);
} }
}, [researchEnded, status]); }, [researchEnded, status]);

View File

@@ -131,6 +131,7 @@ const MessageBox = ({
<AssistantSteps <AssistantSteps
block={researchBlock} block={researchBlock}
status={section.message.status} status={section.message.status}
isLast={isLast}
/> />
</div> </div>
))} ))}