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