Skip to content

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

Fix: After clearing data from pages other than the first page, the data in the filters and search box should also be cleared. (#19255)

balibabudbeaab1648af
diff --git a/web/src/components/list-filter-bar/utils.ts b/web/src/components/list-filter-bar/utils.ts
new file mode 100644
index 0000000000..3acaf13280
--- /dev/null
+++ b/web/src/components/list-filter-bar/utils.ts
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { isArray, isEmpty, isObject, some } from 'lodash';
+
+import { FilterValue } from './interface';
+
+// A filter value may hold empty structures (e.g. every field set to an empty
+// array) once the user clears the popover; only values with at least one
+// selected id count as an active filter.
+export function hasActiveFilter(value?: FilterValue): boolean {
+ return some(value, (fieldValue) =>
+ isArray(fieldValue)
+ ? !isEmpty(fieldValue)
+ : isObject(fieldValue) && some(fieldValue, (ids) => !isEmpty(ids)),
+ );
+}
diff --git a/web/src/constants/list-deletion.ts b/web/src/constants/list-deletion.ts
new file mode 100644
index 0000000000..cf8bd981b4
--- /dev/null
+++ b/web/src/constants/list-deletion.ts
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Keys identifying each paged list whose search keywords and filter selection
+// are cleared after a deletion empties its current page.
+export const ListDeletionKey = {
+ AgentList: 'agentList',
+ KnowledgeList: 'knowledgeList',
+ ChatList: 'chatList',
+ SearchList: 'searchList',
+ MemoryList: 'memoryList',
+ FileList: 'fileList',
+ McpServerList: 'mcpServerList',
+} as const;
diff --git a/web/src/hooks/logic-hooks.ts b/web/src/hooks/logic-hooks.ts
index 49af78ac47..1865da292e 100644
--- a/web/src/hooks/logic-hooks.ts
+++ b/web/src/hooks/logic-hooks.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import { FilterValue } from '@/components/list-filter-bar/interface';
+import { hasActiveFilter } from '@/components/list-filter-bar/utils';
import message from '@/components/ui/message';
import { Authorization } from '@/constants/authorization';
import { MessageType } from '@/constants/chat';
@@ -31,6 +33,10 @@ import { changeLanguageAsync } from '@/locales/config';
import api from '@/utils/api';
import { getAuthorization } from '@/utils/authorization-util';
import { buildMessageUuid } from '@/utils/chat';
+import {
+ consumeListDeletionMarker,
+ discardListDeletionMarker,
+} from '@/utils/list-deletion-util';
import axios from 'axios';
import { EventSourceParserStream } from 'eventsource-parser/stream';
import { has, isEmpty, omit } from 'lodash';
@@ -127,15 +133,53 @@ export const useGetPaginationWithRouter = () => {
};
// When the current page becomes empty (e.g. after deleting the last card on
-// the last page), navigate back to the previous page automatically.
+// the last page), navigate back to the previous page automatically. When the
+// empty page was caused by a deletion (recorded via markListItemsDeleted) and
+// a search or filter is active, clear them and jump to the first page of the
+// unfiltered list instead — the filtered result set no longer exists, so the
+// previous page of it would be meaningless.
export const useGoToPreviousPageOnEmpty = (
listLength: number | undefined,
loading: boolean = false,
+ options?: {
+ deletionKey?: string;
+ searchString?: string;
+ setSearchString?: (value: string) => void;
+ filterValue?: FilterValue;
+ setFilterValue?: (value: FilterValue) => void;
+ },
) => {
const { pagination, setPagination } = useGetPaginationWithRouter();
+ const optionsRef = useRef(options);
+ optionsRef.current = options;
useEffect(() => {
- if (!loading && listLength === 0 && pagination.current > 1) {
+ if (loading || listLength !== 0 || pagination.current <= 1) {
+ return;
+ }
+
+ const {
+ deletionKey,
+ searchString,
+ setSearchString,
+ filterValue,
+ setFilterValue,
+ } = optionsRef.current ?? {};
+ const clearedByDeletion =
+ deletionKey &&
+ (Boolean(searchString) || hasActiveFilter(filterValue)) &&
+ consumeListDeletionMarker(deletionKey);
+
+ if (clearedByDeletion) {
+ setSearchString?.('');
+ setFilterValue?.({});
+ setPagination({ page: 1, pageSize: pagination.pageSize });
+ } else {
+ if (deletionKey) {
+ // The empty page was not caused by a deletion (e.g. a search with no
+ // matches); drop any stale marker so it cannot fire later.
+ discardListDeletionMarker(deletionKey);
+ }
setPagination({
page: pagination.current - 1,
pageSize: pagination.pageSize,
@@ -156,7 +200,13 @@ export const useHandleSearchChange = () => {
[setPagination],
);
- return { handleInputChange, searchString, pagination, setPagination };
+ return {
+ handleInputChange,
+ searchString,
+ setSearchString,
+ pagination,
+ setPagination,
+ };
};
export const useGetPagination = (options?: { pageSize?: number }) => {
diff --git a/web/src/hooks/use-agent-request.ts b/web/src/hooks/use-agent-request.ts
index c3ed79ee77..f471a1b52a 100644
--- a/web/src/hooks/use-agent-request.ts
+++ b/web/src/hooks/use-agent-request.ts
@@ -18,6 +18,7 @@ import { FileUploadProps } from '@/components/file-upload';
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
import message from '@/components/ui/message';
import { AgentCategory, AgentGlobals } from '@/constants/agent';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useFetchTenantInfo } from '@/hooks/use-user-setting-request';
import {
AgentListItem,
@@ -52,6 +53,7 @@ import agentService, {
uploadAgentFile,
} from '@/services/agent-service';
import { buildMessageListWithUuid } from '@/utils/chat';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
import { get, isEmpty, set } from 'lodash';
@@ -170,10 +172,12 @@ const buildAgentListParams = ({
};
export const useFetchAgentListByPage = () => {
- const { searchString, handleInputChange } = useHandleSearchChange();
+ const { searchString, setSearchString, handleInputChange } =
+ useHandleSearchChange();
const { pagination, setPagination } = useGetPaginationWithRouter();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
- const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
+ const { filterValue, setFilterValue, handleFilterSubmit } =
+ useHandleFilterSubmit();
const canvasCategoryIds = Array.isArray(filterValue.canvasCategory)
? (filterValue.canvasCategory as string[])
: undefined;
@@ -229,10 +233,12 @@ export const useFetchAgentListByPage = () => {
data: data?.canvas ?? [],
loading,
searchString,
+ setSearchString,
handleInputChange: onInputChange,
pagination: { ...pagination, total: data?.total ?? 0 },
setPagination,
filterValue,
+ setFilterValue,
handleFilterSubmit,
};
};
@@ -364,6 +370,7 @@ export const useDeleteAgent = () => {
queryClient.invalidateQueries({
queryKey: AgentKeys.tags(),
});
+ markListItemsDeleted(ListDeletionKey.AgentList);
}
return data?.data ?? false;
},
diff --git a/web/src/hooks/use-chat-request.ts b/web/src/hooks/use-chat-request.ts
index 1a089e9589..d12189c3f1 100644
--- a/web/src/hooks/use-chat-request.ts
+++ b/web/src/hooks/use-chat-request.ts
@@ -18,6 +18,7 @@ import { FileUploadProps } from '@/components/file-upload';
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
import message from '@/components/ui/message';
import { ChatSearchParams } from '@/constants/chat';
+import { ListDeletionKey } from '@/constants/list-deletion';
import {
IClientConversation,
IConversation,
@@ -33,6 +34,7 @@ import { useGetSharedChatSearchParams } from '@/pages/next-chats/hooks/use-send-
import chatService from '@/services/next-chat-service';
import api from '@/utils/api';
import { buildMessageListWithUuid } from '@/utils/chat';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
import { has } from 'lodash';
@@ -79,10 +81,12 @@ export const useGetChatSearchParams = () => {
};
export const useFetchChatList = () => {
- const { searchString, handleInputChange } = useHandleSearchChange();
+ const { searchString, setSearchString, handleInputChange } =
+ useHandleSearchChange();
const { pagination, setPagination } = useGetPaginationWithRouter();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
- const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
+ const { filterValue, setFilterValue, handleFilterSubmit } =
+ useHandleFilterSubmit();
const {
data,
@@ -131,10 +135,12 @@ export const useFetchChatList = () => {
loading,
refetch,
searchString,
+ setSearchString,
handleInputChange: onInputChange,
pagination: { ...pagination, total: data?.total },
setPagination,
filterValue,
+ setFilterValue,
handleFilterSubmit,
};
};
@@ -155,6 +161,7 @@ export const useDeleteChat = () => {
queryClient.invalidateQueries({
queryKey: [ChatApiAction.FetchChatList],
});
+ markListItemsDeleted(ListDeletionKey.ChatList);
message.success(t('message.deleted'));
}
return data.code;
diff --git a/web/src/hooks/use-compilation-template-group-request.ts b/web/src/hooks/use-compilation-template-group-request.ts
index 704f846c2d..3d63a12d65 100644
--- a/web/src/hooks/use-compilation-template-group-request.ts
+++ b/web/src/hooks/use-compilation-template-group-request.ts
@@ -15,6 +15,7 @@
*/
import message from '@/components/ui/message';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { ICompilationTemplateGroup } from '@/interfaces/database/compilation-template';
import {
ICreateCompilationTemplateGroupRequestBody,
@@ -29,6 +30,7 @@ import {
updateCompilationTemplateGroup,
} from '@/services/compilation-template-group-service';
import { isCreateCompilationTemplateGroup } from '@/utils/compilation-template-util';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useCallback, useMemo } from 'react';
import { useParams } from 'react-router';
@@ -188,6 +190,7 @@ export const useDeleteCompilationTemplateGroup = () => {
queryClient.invalidateQueries({
queryKey: AgentKeys.tags(),
});
+ markListItemsDeleted(ListDeletionKey.AgentList);
}
return data?.data ?? true;
},
diff --git a/web/src/hooks/use-file-request.ts b/web/src/hooks/use-file-request.ts
index 6bc2fc8a3a..cbb1f36961 100644
--- a/web/src/hooks/use-file-request.ts
+++ b/web/src/hooks/use-file-request.ts
@@ -15,6 +15,7 @@
*/
import message from '@/components/ui/message';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { PaginationProps } from '@/interfaces/antd-compat';
import {
IFetchFileListResult,
@@ -28,6 +29,7 @@ import {
import fileManagerService from '@/services/file-manager-service';
import api from '@/utils/api';
import { downloadFileFromBlob } from '@/utils/file-util';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import request from '@/utils/request';
import {
useMutation,
@@ -198,7 +200,8 @@ export interface IListResult {
}
export const useFetchFileList = () => {
- const { searchString, handleInputChange } = useHandleSearchChange();
+ const { searchString, setSearchString, handleInputChange } =
+ useHandleSearchChange();
const { pagination, setPagination } = useGetPaginationWithRouter();
const id = useGetFolderId();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
@@ -237,6 +240,7 @@ export const useFetchFileList = () => {
return {
...data,
searchString,
+ setSearchString,
handleInputChange: onInputChange,
pagination: { ...pagination, total: data?.total },
setPagination,
@@ -261,6 +265,7 @@ export const useDeleteFile = () => {
});
if (data.code === 0) {
message.success(t('message.deleted'));
+ markListItemsDeleted(ListDeletionKey.FileList);
}
queryClient.invalidateQueries({
queryKey: [FileApiAction.FetchFileList],
@@ -332,10 +337,9 @@ const areDatasetsLinked = (
fileIds: string[],
kbIds: string[],
) => {
- const cached =
- queryClient.getQueriesData<IFetchFileListResult>({
- queryKey: [FileApiAction.FetchFileList],
- })[0]?.[1] ?? { files: [] };
+ const cached = queryClient.getQueriesData<IFetchFileListResult>({
+ queryKey: [FileApiAction.FetchFileList],
+ })[0]?.[1] ?? { files: [] };
const verifiableFiles = (cached.files ?? []).filter(
(file) => fileIds.includes(file.id) && file.type !== 'folder',
);
diff --git a/web/src/hooks/use-knowledge-request.ts b/web/src/hooks/use-knowledge-request.ts
index af15221dd0..2c1d83e325 100644
--- a/web/src/hooks/use-knowledge-request.ts
+++ b/web/src/hooks/use-knowledge-request.ts
@@ -18,7 +18,9 @@ import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-f
import message from '@/components/ui/message';
import { useIsGoBackend } from '@/utils/backend-variant';
import { isDatasetId } from '@/utils/dataset-util';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import { GenerateType, ParseType } from '@/constants/knowledge';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { ResponsePostType, ResponseType } from '@/interfaces/database/base';
import {
IArtifact,
@@ -193,10 +195,12 @@ export const useTestRetrieval = () => {
};
export const useFetchNextKnowledgeListByPage = () => {
- const { searchString, handleInputChange } = useHandleSearchChange();
+ const { searchString, setSearchString, handleInputChange } =
+ useHandleSearchChange();
const { pagination, setPagination } = useGetPaginationWithRouter();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
- const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
+ const { filterValue, setFilterValue, handleFilterSubmit } =
+ useHandleFilterSubmit();
const { data, isFetching: loading } = useQuery<IDatasetListResult>({
queryKey: [
@@ -235,11 +239,13 @@ export const useFetchNextKnowledgeListByPage = () => {
return {
...data,
searchString,
+ setSearchString,
handleInputChange: onInputChange,
pagination: { ...pagination, total: data?.total_datasets },
setPagination,
loading,
filterValue,
+ setFilterValue,
handleFilterSubmit,
};
};
@@ -316,6 +322,7 @@ export const useDeleteKnowledge = () => {
queryClient.invalidateQueries({
queryKey: [KnowledgeApiAction.FetchDatasetFilter],
});
+ markListItemsDeleted(ListDeletionKey.KnowledgeList);
}
return data?.data ?? [];
},
diff --git a/web/src/hooks/use-mcp-request.ts b/web/src/hooks/use-mcp-request.ts
index e59ec0a927..4b97384876 100644
--- a/web/src/hooks/use-mcp-request.ts
+++ b/web/src/hooks/use-mcp-request.ts
@@ -15,6 +15,7 @@
*/
import message from '@/components/ui/message';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { ResponseType } from '@/interfaces/database/base';
import {
IExportedMcpServers,
@@ -30,6 +31,7 @@ import i18n from '@/locales/config';
import mcpServerService, {
listMcpServers,
} from '@/services/mcp-server-service';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
import {
@@ -51,7 +53,8 @@ export const enum McpApiAction {
}
export const useListMcpServer = () => {
- const { searchString, handleInputChange } = useHandleSearchChange();
+ const { searchString, setSearchString, handleInputChange } =
+ useHandleSearchChange();
const { pagination, setPagination } = useGetPaginationWithRouter();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
@@ -81,6 +84,7 @@ export const useListMcpServer = () => {
handleInputChange,
setPagination,
searchString,
+ setSearchString,
pagination: { ...pagination, total: data?.total },
};
};
@@ -168,6 +172,7 @@ export const useDeleteMcpServer = () => {
queryClient.invalidateQueries({
queryKey: [McpApiAction.ListMcpServer],
});
+ markListItemsDeleted(ListDeletionKey.McpServerList);
}
return data;
},
diff --git a/web/src/pages/agents/index.tsx b/web/src/pages/agents/index.tsx
index 3b95090817..65efc4be32 100644
--- a/web/src/pages/agents/index.tsx
+++ b/web/src/pages/agents/index.tsx
@@ -11,6 +11,7 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { useFetchAgentListByPage } from '@/hooks/use-agent-request';
@@ -41,8 +42,10 @@ export default function Agents() {
pagination,
setPagination,
searchString,
+ setSearchString,
handleInputChange,
filterValue,
+ setFilterValue,
handleFilterSubmit,
} = useFetchAgentListByPage();
@@ -83,7 +86,13 @@ export default function Agents() {
},
[setPagination],
);
- useGoToPreviousPageOnEmpty(data?.length, listLoading);
+ useGoToPreviousPageOnEmpty(data?.length, listLoading, {
+ deletionKey: ListDeletionKey.AgentList,
+ searchString,
+ setSearchString,
+ filterValue,
+ setFilterValue,
+ });
const handleEditCompilation = useCallback(
(id: string) => () => {
diff --git a/web/src/pages/datasets/index.tsx b/web/src/pages/datasets/index.tsx
index b792257e10..c8f27fb3b5 100644
--- a/web/src/pages/datasets/index.tsx
+++ b/web/src/pages/datasets/index.tsx
@@ -6,6 +6,7 @@ import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
import { Spin } from '@/components/ui/spin';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { useFetchNextKnowledgeListByPage } from '@/hooks/use-knowledge-request';
import { useQueryClient } from '@tanstack/react-query';
@@ -37,7 +38,9 @@ export default function Datasets() {
setPagination,
handleInputChange,
searchString,
+ setSearchString,
filterValue,
+ setFilterValue,
handleFilterSubmit,
loading,
} = useFetchNextKnowledgeListByPage();
@@ -59,7 +62,13 @@ export default function Datasets() {
},
[setPagination],
);
- useGoToPreviousPageOnEmpty(kbs?.length, loading);
+ useGoToPreviousPageOnEmpty(kbs?.length, loading, {
+ deletionKey: ListDeletionKey.KnowledgeList,
+ searchString,
+ setSearchString,
+ filterValue,
+ setFilterValue,
+ });
const [searchUrl, setSearchUrl] = useSearchParams();
const isCreate = searchUrl.get('isCreate') === 'true';
const queryClient = useQueryClient();
diff --git a/web/src/pages/files/index.tsx b/web/src/pages/files/index.tsx
index 9f79c5592c..bc61d46a95 100644
--- a/web/src/pages/files/index.tsx
+++ b/web/src/pages/files/index.tsx
@@ -9,6 +9,8 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
+import { ListDeletionKey } from '@/constants/list-deletion';
+import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { useClearSelectionOnPageChange } from '@/hooks/logic-hooks/use-clear-selection-on-page-change';
import { useRowSelection } from '@/hooks/logic-hooks/use-row-selection';
import { useFetchFileList } from '@/hooks/use-file-request';
@@ -53,6 +55,7 @@ export default function Files() {
loading,
setPagination,
searchString,
+ setSearchString,
handleInputChange,
} = useFetchFileList();
@@ -66,6 +69,12 @@ export default function Files() {
useClearSelectionOnPageChange(pagination, clearRowSelection);
+ useGoToPreviousPageOnEmpty(files?.length, loading, {
+ deletionKey: ListDeletionKey.FileList,
+ searchString,
+ setSearchString,
+ });
+
const {
showMoveFileModal,
moveFileVisible,
diff --git a/web/src/pages/memories/hooks.ts b/web/src/pages/memories/hooks.ts
index 8eb8c47e82..2c3fddc62b 100644
--- a/web/src/pages/memories/hooks.ts
+++ b/web/src/pages/memories/hooks.ts
@@ -3,10 +3,12 @@
import { FilterCollection } from '@/components/list-filter-bar/interface';
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
import message from '@/components/ui/message';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useSetModalState } from '@/hooks/common-hooks';
import { useHandleSearchChange } from '@/hooks/logic-hooks';
import { useFetchDefaultModelDictionary } from '@/hooks/use-llm-request';
import memoryService, { updateMemoryById } from '@/services/memory-service';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import {
buildOwnersFilter,
groupListByArray,
@@ -51,9 +53,15 @@ export const useCreateMemory = () => {
};
export const useFetchMemoryList = () => {
- const { handleInputChange, searchString, pagination, setPagination } =
- useHandleSearchChange();
- const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
+ const {
+ handleInputChange,
+ searchString,
+ setSearchString,
+ pagination,
+ setPagination,
+ } = useHandleSearchChange();
+ const { filterValue, setFilterValue, handleFilterSubmit } =
+ useHandleFilterSubmit();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
const memoryType = Array.isArray(filterValue.memoryType)
@@ -115,10 +123,12 @@ export const useFetchMemoryList = () => {
isError,
pagination,
searchString,
+ setSearchString,
handleInputChange,
setPagination,
refetch,
filterValue,
+ setFilterValue,
handleFilterSubmit,
};
};
@@ -175,6 +185,7 @@ export const useDeleteMemory = () => {
}
queryClient.invalidateQueries({ queryKey: ['memoryList'] });
+ markListItemsDeleted(ListDeletionKey.MemoryList);
return response;
},
onSuccess: () => {
diff --git a/web/src/pages/memories/index.tsx b/web/src/pages/memories/index.tsx
index f7d5c31a24..14b0b9fa8d 100644
--- a/web/src/pages/memories/index.tsx
+++ b/web/src/pages/memories/index.tsx
@@ -4,6 +4,7 @@ import { EmptyAppCard } from '@/components/empty/empty';
import ListFilterBar from '@/components/list-filter-bar';
import { Button } from '@/components/ui/button';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useTranslate } from '@/hooks/common-hooks';
import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { pick } from 'lodash';
@@ -26,10 +27,12 @@ export default function MemoryList() {
isLoading,
pagination,
searchString,
+ setSearchString,
handleInputChange,
setPagination,
refetch: refetchList,
filterValue,
+ setFilterValue,
handleFilterSubmit,
} = useFetchMemoryList();
@@ -58,7 +61,13 @@ export default function MemoryList() {
},
[setPagination],
);
- useGoToPreviousPageOnEmpty(list?.data?.memory_list?.length, isLoading);
+ useGoToPreviousPageOnEmpty(list?.data?.memory_list?.length, isLoading, {
+ deletionKey: ListDeletionKey.MemoryList,
+ searchString,
+ setSearchString,
+ filterValue,
+ setFilterValue,
+ });
const [searchUrl, setMemoryUrl] = useSearchParams();
const { filters } = useSelectFilters();
diff --git a/web/src/pages/next-chats/index.tsx b/web/src/pages/next-chats/index.tsx
index b3aa7f2a15..8197e5b37d 100644
--- a/web/src/pages/next-chats/index.tsx
+++ b/web/src/pages/next-chats/index.tsx
@@ -6,6 +6,7 @@ import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
import { Spin } from '@/components/ui/spin';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { useFetchChatList } from '@/hooks/use-chat-request';
import { buildOwnersFilter } from '@/utils/list-filter-util';
@@ -25,7 +26,9 @@ export default function ChatList() {
pagination,
handleInputChange,
searchString,
+ setSearchString,
filterValue,
+ setFilterValue,
handleFilterSubmit,
loading,
} = useFetchChatList();
@@ -54,7 +57,13 @@ export default function ChatList() {
},
[setPagination],
);
- useGoToPreviousPageOnEmpty(data?.chats?.length, loading);
+ useGoToPreviousPageOnEmpty(data?.chats?.length, loading, {
+ deletionKey: ListDeletionKey.ChatList,
+ searchString,
+ setSearchString,
+ filterValue,
+ setFilterValue,
+ });
const handleShowCreateModal = useCallback(() => {
showCreateChatModal();
diff --git a/web/src/pages/next-searches/hooks.ts b/web/src/pages/next-searches/hooks.ts
index caf8f6018e..6489086405 100644
--- a/web/src/pages/next-searches/hooks.ts
+++ b/web/src/pages/next-searches/hooks.ts
@@ -18,10 +18,12 @@
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
import message from '@/components/ui/message';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useSetModalState } from '@/hooks/common-hooks';
import { useHandleSearchChange } from '@/hooks/logic-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import searchService from '@/services/search-service';
+import { markListItemsDeleted } from '@/utils/list-deletion-util';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
import { useCallback, useState } from 'react';
@@ -104,10 +106,16 @@ interface SearchListResponse {
}
export const useFetchSearchList = () => {
- const { handleInputChange, searchString, pagination, setPagination } =
- useHandleSearchChange();
+ const {
+ handleInputChange,
+ searchString,
+ setSearchString,
+ pagination,
+ setPagination,
+ } = useHandleSearchChange();
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
- const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
+ const { filterValue, setFilterValue, handleFilterSubmit } =
+ useHandleFilterSubmit();
const { data, isLoading, isError, refetch } = useQuery<
SearchListResponse,
Error
@@ -146,10 +154,12 @@ export const useFetchSearchList = () => {
isError,
pagination,
searchString,
+ setSearchString,
handleInputChange,
setPagination,
refetch,
filterValue,
+ setFilterValue,
handleFilterSubmit,
};
};
@@ -274,6 +284,7 @@ export const useDeleteSearch = () => {
}
queryClient.invalidateQueries({ queryKey: ['searchList'] });
+ markListItemsDeleted(ListDeletionKey.SearchList);
return response;
},
onSuccess: () => {
diff --git a/web/src/pages/next-searches/index.tsx b/web/src/pages/next-searches/index.tsx
index a56b3594e2..63943d2799 100644
--- a/web/src/pages/next-searches/index.tsx
+++ b/web/src/pages/next-searches/index.tsx
@@ -21,6 +21,7 @@ import ListFilterBar from '@/components/list-filter-bar';
import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useTranslate } from '@/hooks/common-hooks';
import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { buildOwnersFilter } from '@/utils/list-filter-util';
@@ -41,10 +42,12 @@ export default function SearchList() {
isLoading,
pagination,
searchString,
+ setSearchString,
handleInputChange,
setPagination,
refetch: refetchList,
filterValue,
+ setFilterValue,
handleFilterSubmit,
} = useFetchSearchList();
const owners = [
@@ -77,7 +80,13 @@ export default function SearchList() {
},
[setPagination],
);
- useGoToPreviousPageOnEmpty(list?.data?.search_apps?.length, isLoading);
+ useGoToPreviousPageOnEmpty(list?.data?.search_apps?.length, isLoading, {
+ deletionKey: ListDeletionKey.SearchList,
+ searchString,
+ setSearchString,
+ filterValue,
+ setFilterValue,
+ });
const [searchUrl, setSearchUrl] = useSearchParams();
const isCreate = searchUrl.get('isCreate') === 'true';
diff --git a/web/src/pages/user-setting/mcp/index.tsx b/web/src/pages/user-setting/mcp/index.tsx
index 95ce82ce7e..728417adeb 100644
--- a/web/src/pages/user-setting/mcp/index.tsx
+++ b/web/src/pages/user-setting/mcp/index.tsx
@@ -24,6 +24,7 @@ import { Checkbox } from '@/components/ui/checkbox';
import { SearchInput } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
+import { ListDeletionKey } from '@/constants/list-deletion';
import { useGoToPreviousPageOnEmpty } from '@/hooks/logic-hooks';
import { useClearSelectionOnPageChange } from '@/hooks/logic-hooks/use-clear-selection-on-page-change';
import { useListMcpServer } from '@/hooks/use-mcp-request';
@@ -51,11 +52,16 @@ export default function McpServer() {
data,
setPagination,
searchString,
+ setSearchString,
handleInputChange,
pagination,
loading: listLoading,
} = useListMcpServer();
- useGoToPreviousPageOnEmpty(data.mcp_servers?.length, listLoading);
+ useGoToPreviousPageOnEmpty(data.mcp_servers?.length, listLoading, {
+ deletionKey: ListDeletionKey.McpServerList,
+ searchString,
+ setSearchString,
+ });
const { editVisible, showEditModal, hideEditModal, handleOk, id, loading } =
useEditMcp();
const {
diff --git a/web/src/utils/list-deletion-util.ts b/web/src/utils/list-deletion-util.ts
new file mode 100644
index 0000000000..4bd6be3ec8
--- /dev/null
+++ b/web/src/utils/list-deletion-util.ts
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// A list page cannot tell "the current page became empty after a deletion"
+// apart from "the user typed a search with no matches" just by looking at the
+// list length. Delete mutations record a marker keyed by the list they feed;
+// the list page consumes the marker when an empty page sends the user back to
+// the first page of the unfiltered list, and only then clears the search
+// keywords and the filter selection. Markers expire quickly so a deletion
+// made on a surface that never renders the list afterwards cannot affect the
+// list page later.
+
+const MarkerTtlMs = 30_000;
+
+const DeletionMarkers = new Map<string, number>();
+
+export function markListItemsDeleted(key: string) {
+ DeletionMarkers.set(key, Date.now());
+}
+
+export function discardListDeletionMarker(key: string) {
+ DeletionMarkers.delete(key);
+}
+
+export function consumeListDeletionMarker(key: string): boolean {
+ const markedAt = DeletionMarkers.get(key);
+ if (markedAt === undefined) {
+ return false;
+ }
+ DeletionMarkers.delete(key);
+ return Date.now() - markedAt < MarkerTtlMs;
+}