diff --git a/src/frontend/src/modals/chatModal/index.tsx b/src/frontend/src/modals/chatModal/index.tsx index a2d148ca0..ba5164917 100644 --- a/src/frontend/src/modals/chatModal/index.tsx +++ b/src/frontend/src/modals/chatModal/index.tsx @@ -112,9 +112,12 @@ export default function ChatModal({ // Do something with the data received from the WebSocket }; newWs.onclose = (e) => { - console.log(e.code); + console.log("close"); setLockChat(false); }; + newWs.onerror = (e) => { + window.alert("error"); + }; setWs(newWs); return () => { @@ -132,6 +135,12 @@ export default function ChatModal({ if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" }); }, [chatHistory]); + useEffect(() => { + if (ws &&ws.readyState===ws.CLOSED) { + setLockChat(false); + } + }, [lockChat]); + function validateNode(n: NodeType): Array { if (!n.data?.node?.template || !Object.keys(n.data.node.template)) { setNoticeData({ @@ -195,20 +204,6 @@ export default function ChatModal({ chatHistory, name: flow.name, description: flow.description, - }).catch((error) => { - setErrorData({ - title: error.message ?? "Unknown Error", - list: [error.response.data.detail], - }); - setLockChat(false); - let lastMessage; - setChatHistory((chatHistory) => { - let newChat = chatHistory; - - lastMessage = newChat.pop().message; - return newChat; - }); - setChatValue(lastMessage); }); } else { setErrorData({