From 84a87a3c39707b381ebc92accf30db85a1d41808 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 7 Jun 2024 16:10:05 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(chatView,=20flowStore):?= =?UTF-8?q?=20refactor=20message=20handling=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modals/IOModal/components/chatView/index.tsx | 7 ++----- src/frontend/src/stores/flowStore.ts | 2 +- src/frontend/src/types/api/index.ts | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/index.tsx index 8e7fb2cda..f183c830e 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/index.tsx @@ -62,14 +62,11 @@ export default function ChatView({ const chatMessages: ChatMessageType[] = chatOutputResponses .sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp)) // - .filter( - (output) => - output?.data?.messages && output?.data?.messages?.length > 0, - ) + .filter((output) => output.data.message) .map((output, index) => { try { const { sender, message, sender_name, stream_url, files } = output - ?.data?.messages[0] as ChatOutputType; + .data.message as ChatOutputType; const is_ai = sender === "Machine" || sender === null; return { diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 86646d15c..d966868a2 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -90,7 +90,7 @@ const useFlowStore = create((set, get) => ({ } //update data results else { - newFlowPool[nodeId][index].data.messages[0] = data as + newFlowPool[nodeId][index].data.message = data as | ChatOutputType | ChatInputType; } diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index ca704a137..86dd13c87 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -167,6 +167,7 @@ export type VertexDataTypeAPI = { timedelta?: number; duration?: string; artifacts?: any; + message: ChatOutputType | ChatInputType; }; export type CodeErrorDataTypeAPI = {