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
select: selector
});
return data || ({} as TData);
return data;
};

View File

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

View File

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

View File

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