diff --git a/src/frontend/src/components/newChatView/index.tsx b/src/frontend/src/components/newChatView/index.tsx index 56e0ae38e..477394c6b 100644 --- a/src/frontend/src/components/newChatView/index.tsx +++ b/src/frontend/src/components/newChatView/index.tsx @@ -1,8 +1,10 @@ import { cloneDeep } from "lodash"; import { useEffect, useRef, useState } from "react"; import IconComponent from "../../components/genericIconComponent"; +import { deleteFlowPool } from "../../controllers/API"; import useAlertStore from "../../stores/alertStore"; import useFlowStore from "../../stores/flowStore"; +import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { sendAllProps } from "../../types/api"; import { ChatMessageType, @@ -29,6 +31,7 @@ export default function newChatView(): JSX.Element { CleanFlowPool, } = useFlowStore(); const { setErrorData } = useAlertStore(); + const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); const [lockChat, setLockChat] = useState(false); const messagesRef = useRef(null); @@ -112,7 +115,9 @@ export default function newChatView(): JSX.Element { } function clearChat(): void { setChatHistory([]); - CleanFlowPool(); + deleteFlowPool(currentFlowId).then((_) => { + CleanFlowPool(); + }); //TODO tell backend to clear chat session if (lockChat) setLockChat(false); } diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index f394cc247..73dd0f2e4 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -879,8 +879,17 @@ export async function getFlowPool({ nodeId?: string; }): Promise> { const config = {}; + config["params"] = { flow_id: flowId }; if (nodeId) { config["params"] = { nodeId }; } - return await api.get(`${BASE_URL_API}flow_pool/${flowId}`, config); + return await api.get(`${BASE_URL_API}monitor/builds`, config); +} + +export async function deleteFlowPool( + flowId: string +): Promise> { + const config = {}; + config["params"] = { flow_id: flowId }; + return await api.delete(`${BASE_URL_API}monitor/builds`, config); }