mirror of https://github.com/buster-so/buster.git
Update useAutoChangeLayout.ts
This commit is contained in:
parent
790f062494
commit
21a39aebf9
|
@ -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]);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue