fixed broken data getter 🥰

This commit is contained in:
Nate Kelley 2025-03-13 13:41:55 -06:00
parent d20d6bf333
commit b33ebf675a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 13 additions and 15 deletions

View File

@ -156,5 +156,5 @@ export const useGetChatMessage = <TData = IBusterChatMessage>(
enabled: false, //this will come from the chat enabled: false, //this will come from the chat
select: selector select: selector
}); });
return data || ({} as TData); return data;
}; };

View File

@ -67,20 +67,18 @@ export const ReasoningMessageSelector: React.FC<ReasoningMessageSelectorProps> =
chatId, chatId,
messageId messageId
}) => { }) => {
const { title, type, secondary_title, status, hasMessage } = useGetChatMessage( const messageStuff = useGetChatMessage(messageId, (x) => ({
messageId, title: x?.reasoning_messages[reasoningMessageId]?.title,
(x) => ({ secondary_title: x?.reasoning_messages[reasoningMessageId]?.secondary_title,
title: x?.reasoning_messages[reasoningMessageId]?.title, type: x?.reasoning_messages[reasoningMessageId]?.type,
secondary_title: x?.reasoning_messages[reasoningMessageId]?.secondary_title, status: x?.reasoning_messages[reasoningMessageId]?.status,
type: x?.reasoning_messages[reasoningMessageId]?.type, hasMessage: !!(x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_text)
status: x?.reasoning_messages[reasoningMessageId]?.status, ?.message
hasMessage: !!(x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_text) }));
?.message const { title, secondary_title, type, status, hasMessage } = messageStuff || {};
})
);
const showBar = useMemo(() => { const showBar = useMemo(() => {
if (type === 'text') return hasMessage; if (type === 'text') return !!hasMessage;
return true; return true;
}, [type, hasMessage]); }, [type, hasMessage]);

View File

@ -32,7 +32,7 @@ export const ChatResponseMessageSelector: React.FC<ChatResponseMessageSelectorPr
const messageType = useGetChatMessage( const messageType = useGetChatMessage(
messageId, messageId,
(x) => x?.response_messages?.[responseMessageId]?.type || 'text' (x) => x?.response_messages?.[responseMessageId]?.type || 'text'
); )!;
const ChatResponseMessage = ChatResponseMessageRecord[messageType]; const ChatResponseMessage = ChatResponseMessageRecord[messageType];
return ( return (

View File

@ -11,7 +11,7 @@ interface ChatResponseMessagesProps {
export const ChatResponseMessages: React.FC<ChatResponseMessagesProps> = React.memo( export const ChatResponseMessages: React.FC<ChatResponseMessagesProps> = React.memo(
({ isCompletedStream, messageId }) => { ({ isCompletedStream, messageId }) => {
const responseMessageIds = useGetChatMessage(messageId, (x) => x?.response_message_ids || []); const responseMessageIds = useGetChatMessage(messageId, (x) => x?.response_message_ids || [])!;
const lastReasoningMessageId = useGetChatMessage( const lastReasoningMessageId = useGetChatMessage(
messageId, messageId,
(x) => x?.reasoning_message_ids?.[x.reasoning_message_ids.length - 1] (x) => x?.reasoning_message_ids?.[x.reasoning_message_ids.length - 1]