From b33ebf675af512f85c6519d3da3f0be537411d61 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 13 Mar 2025 13:41:55 -0600 Subject: [PATCH] =?UTF-8?q?fixed=20broken=20data=20getter=20=F0=9F=A5=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/buster_rest/chats/queryRequests.ts | 2 +- .../ReasoningMessageSelector.tsx | 22 +++++++++---------- .../ChatResponseMessageSelector.tsx | 2 +- .../ChatResponseMessages.tsx | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/web/src/api/buster_rest/chats/queryRequests.ts b/web/src/api/buster_rest/chats/queryRequests.ts index a896f0a06..f27d305e6 100644 --- a/web/src/api/buster_rest/chats/queryRequests.ts +++ b/web/src/api/buster_rest/chats/queryRequests.ts @@ -156,5 +156,5 @@ export const useGetChatMessage = ( enabled: false, //this will come from the chat select: selector }); - return data || ({} as TData); + return data; }; diff --git a/web/src/controllers/ReasoningController/ReasoningMessages/ReasoningMessageSelector.tsx b/web/src/controllers/ReasoningController/ReasoningMessages/ReasoningMessageSelector.tsx index d773b8305..bef0513fc 100644 --- a/web/src/controllers/ReasoningController/ReasoningMessages/ReasoningMessageSelector.tsx +++ b/web/src/controllers/ReasoningController/ReasoningMessages/ReasoningMessageSelector.tsx @@ -67,20 +67,18 @@ export const ReasoningMessageSelector: React.FC = 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]); diff --git a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessageSelector.tsx b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessageSelector.tsx index 5969a2f66..be8624464 100644 --- a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessageSelector.tsx +++ b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessageSelector.tsx @@ -32,7 +32,7 @@ export const ChatResponseMessageSelector: React.FC x?.response_messages?.[responseMessageId]?.type || 'text' - ); + )!; const ChatResponseMessage = ChatResponseMessageRecord[messageType]; return ( diff --git a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessages.tsx b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessages.tsx index 9c4d6fac6..17c60de80 100644 --- a/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessages.tsx +++ b/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatResponseMessages/ChatResponseMessages.tsx @@ -11,7 +11,7 @@ interface ChatResponseMessagesProps { export const ChatResponseMessages: React.FC = 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]