diff --git a/src/frontend/src/modals/IOModal/components/chatView/newChatView.tsx b/src/frontend/src/modals/IOModal/components/chatView/newChatView.tsx index 7619cce68..6785ed863 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/newChatView.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/newChatView.tsx @@ -36,6 +36,9 @@ export default function ChatView({ const nodes = useFlowStore((state) => state.nodes); const chatInput = inputs.find((input) => input.type === "ChatInput"); const chatInputNode = nodes.find((node) => node.id === chatInput?.id); + const displayLoadingMessage = useMessagesStore( + (state) => state.displayLoadingMessage, + ); const inputTypes = inputs.map((obj) => obj.type); const updateFlowPool = useFlowStore((state) => state.updateFlowPool); @@ -185,13 +188,13 @@ export default function ChatView({ ))}
- {lockChat && + {displayLoadingMessage && !(chatHistory?.[chatHistory.length - 1]?.category === "error") && flowRunningSkeletonMemo}
diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 8a2b821b1..caa315d13 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -46,6 +46,7 @@ import { getInputsAndOutputs } from "../utils/storeUtils"; import useAlertStore from "./alertStore"; import { useDarkStore } from "./darkStore"; import useFlowsManagerStore from "./flowsManagerStore"; +import { useMessagesStore } from "./messagesStore"; import { useTypesStore } from "./typesStore"; // this is our useStore hook that we can use in our components to get parts of the store and call actions @@ -83,6 +84,7 @@ const useFlowStore = create((set, get) => ({ onFlowPage: false, lockChat: false, setLockChat: (lockChat) => { + useMessagesStore.setState({ displayLoadingMessage: lockChat }); set({ lockChat }); }, setOnFlowPage: (FlowPage) => set({ onFlowPage: FlowPage }), diff --git a/src/frontend/src/stores/messagesStore.ts b/src/frontend/src/stores/messagesStore.ts index 983c84e5f..01227e257 100644 --- a/src/frontend/src/stores/messagesStore.ts +++ b/src/frontend/src/stores/messagesStore.ts @@ -2,6 +2,7 @@ import { create } from "zustand"; import { MessagesStoreType } from "../types/zustand/messages"; export const useMessagesStore = create((set, get) => ({ + displayLoadingMessage: false, deleteSession: (id) => { set((state) => { const updatedMessages = state.messages.filter( @@ -20,6 +21,9 @@ export const useMessagesStore = create((set, get) => ({ get().updateMessagePartial(message); return; } + if (message.sender === "Machine") { + set(() => ({ displayLoadingMessage: false })); + } set(() => ({ messages: [...get().messages, message] })); }, removeMessage: (message) => { diff --git a/src/frontend/src/types/zustand/messages/index.ts b/src/frontend/src/types/zustand/messages/index.ts index 66c75ba54..081ec32ce 100644 --- a/src/frontend/src/types/zustand/messages/index.ts +++ b/src/frontend/src/types/zustand/messages/index.ts @@ -12,4 +12,5 @@ export type MessagesStoreType = { clearMessages: () => void; removeMessages: (ids: string[]) => void; deleteSession: (id: string) => void; + displayLoadingMessage: boolean; };