Update useAutoChangeLayout.ts

This commit is contained in:
Nate Kelley 2025-03-04 20:29:16 -07:00
parent 790f062494
commit 21a39aebf9
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 7 additions and 6 deletions

View File

@ -12,17 +12,18 @@ export const useAutoChangeLayout = ({
onSetSelectedFile: (file: SelectedFile) => void; onSetSelectedFile: (file: SelectedFile) => void;
}) => { }) => {
const hasSeeningReasoningPage = useRef(false); //used when there is a delay in page load const hasSeeningReasoningPage = useRef(false); //used when there is a delay in page load
const message = useMessageIndividual(lastMessageId); const reasoningMessagesLength = useMessageIndividual(
const reasoningMessagesLength = message?.reasoning?.length; lastMessageId,
const isCompletedStream = message?.isCompletedStream; (x) => x?.reasoning_message_ids?.length || 0
const isLoading = !isCompletedStream; );
const isCompletedStream = useMessageIndividual(lastMessageId, (x) => x?.isCompletedStream);
const hasReasoning = !!reasoningMessagesLength; const hasReasoning = !!reasoningMessagesLength;
//change the page to reasoning file if we get a reasoning message //change the page to reasoning file if we get a reasoning message
useEffect(() => { useEffect(() => {
if (isLoading && !hasSeeningReasoningPage.current && hasReasoning) { if (!isCompletedStream && !hasSeeningReasoningPage.current && hasReasoning) {
hasSeeningReasoningPage.current = true; hasSeeningReasoningPage.current = true;
onSetSelectedFile({ id: lastMessageId, type: 'reasoning' }); onSetSelectedFile({ id: lastMessageId, type: 'reasoning' });
} }
}, [isLoading, hasReasoning]); }, [isCompletedStream, hasReasoning]);
}; };