Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Fixed the issue where deleted images in the agent chat box would still be sent to the backend. (#12992)

balibabu2ff2e72488d6
diff --git a/web/src/pages/agent/chat/box.tsx b/web/src/pages/agent/chat/box.tsx
index 9b3371f72d..b209d8acde 100644
--- a/web/src/pages/agent/chat/box.tsx
+++ b/web/src/pages/agent/chat/box.tsx
@@ -36,6 +36,7 @@ function AgentChatBox() {
sendFormMessage,
findReferenceByMessageId,
appendUploadResponseList,
+ removeFile,
} = useSendAgentMessage({ refetch });
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
@@ -130,6 +131,7 @@ function AgentChatBox() {
onInputChange={handleInputChange}
stopOutputMessage={stopOutputMessage}
onUpload={handleUploadFile}
+ removeFile={removeFile}
conversationId=""
/>
)}
diff --git a/web/src/pages/agent/chat/use-send-agent-message.ts b/web/src/pages/agent/chat/use-send-agent-message.ts
index a40c08740d..cf1bd52f90 100644
--- a/web/src/pages/agent/chat/use-send-agent-message.ts
+++ b/web/src/pages/agent/chat/use-send-agent-message.ts
@@ -183,12 +183,20 @@ export function useSetUploadResponseData() {
setFileList([]);
}, []);
+ const removeFile = useCallback((file: File) => {
+ setFileList((prev) => prev.filter((f) => f !== file));
+ setUploadResponseList((prev) =>
+ prev.filter((item) => item.name !== file.name),
+ );
+ }, []);
+
return {
uploadResponseList,
fileList,
setUploadResponseList,
appendUploadResponseList: append,
clearUploadResponseList: clear,
+ removeFile,
};
}
@@ -251,6 +259,7 @@ export const useSendAgentMessage = ({
clearUploadResponseList,
uploadResponseList,
fileList,
+ removeFile,
} = useSetUploadResponseData();
const { stopMessage } = useStopMessage();
@@ -461,5 +470,6 @@ export const useSendAgentMessage = ({
appendUploadResponseList,
addNewestOneAnswer,
sendMessage,
+ removeFile,
};
};