Skip to content

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

Fix: After selecting upload, the document is parsed directly, but the parsing progress cannot be seen. (#18741)

balibabuc4175c38804c
diff --git a/web/src/hooks/use-document-request.ts b/web/src/hooks/use-document-request.ts
index fc0815b8b0..07f6bf36d8 100644
--- a/web/src/hooks/use-document-request.ts
+++ b/web/src/hooks/use-document-request.ts
@@ -132,7 +132,11 @@ export const useUploadDocument = () => {
const code = get(ret, 'code');
if (code === 0 || code === 500) {
- queryClient.invalidateQueries({
+ // Await the refetch so the fresh list (including the just-uploaded
+ // documents) reaches the cache before callers optimistically mark
+ // them RUNNING. Otherwise the late refetch lands after the
+ // optimistic update, overwrites it, and polling never starts.
+ await queryClient.invalidateQueries({
queryKey: DocumentKeys.all(),
});
}
@@ -165,11 +169,6 @@ export const useFetchDocumentList = (loop = true) => {
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
const { filterValue, handleFilterSubmit, checkValue } =
useHandleFilterSubmit();
- const [docs, setDocs] = useState<IDocumentInfo[]>([]);
-
- const isLoop = useMemo(() => {
- return loop && docs.some((doc) => doc.run === RunningStatus.RUNNING);
- }, [docs, loop]);
const { data, isFetching: loading } = useQuery<{
docs: IDocumentInfo[];
@@ -177,7 +176,11 @@ export const useFetchDocumentList = (loop = true) => {
}>({
queryKey: DocumentKeys.list(debouncedSearchString, pagination, filterValue),
initialData: { docs: [], total: 0 },
- refetchInterval: isLoop ? 5000 : false,
+ refetchInterval: (query) =>
+ loop &&
+ query.state.data?.docs.some((doc) => doc.run === RunningStatus.RUNNING)
+ ? 5000
+ : false,
enabled: !!knowledgeId || !!id,
queryFn: async () => {
let run = [] as any;
@@ -221,9 +224,6 @@ export const useFetchDocumentList = (loop = true) => {
};
},
});
- useMemo(() => {
- setDocs(data.docs);
- }, [data.docs]);
const onInputChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
(e) => {
setPagination({ page: 1 });