Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: resolve cross-page document selection issue in metadata batch edit (#23000)
Guangdong Liu665fcad6551d
diff --git a/web/app/components/datasets/documents/index.tsx b/web/app/components/datasets/documents/index.tsxindex 676581a50f1..1f9f36e7b18 100644--- a/web/app/components/datasets/documents/index.tsx+++ b/web/app/components/datasets/documents/index.tsx@@ -164,7 +164,6 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {if (totalPages < currPage + 1)setCurrPage(totalPages === 0 ? 0 : totalPages - 1)}- // eslint-disable-next-line react-hooks/exhaustive-deps}, [documentsRes])const invalidDocumentDetail = useInvalidDocumentDetailKey()@@ -178,7 +177,6 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {invalidChunkList()invalidChildChunkList()}, 5000)- // eslint-disable-next-line react-hooks/exhaustive-deps}, [])const documentsWithProgress = useMemo(() => {@@ -273,6 +271,13 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {const documentsList = isDataSourceNotion ? documentsWithProgress?.data : documentsRes?.dataconst [selectedIds, setSelectedIds] = useState<string[]>([])++ // Clear selection when search changes to avoid confusion+ useEffect(() => {+ if (searchValue !== query.keyword)+ setSelectedIds([])+ }, [searchValue, query.keyword])+const { run: handleSearch } = useDebounceFn(() => {setSearchValue(inputValue)}, { wait: 500 })diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsxindex 2eb6a3ac1e1..2697580f4ef 100644--- a/web/app/components/datasets/documents/list.tsx+++ b/web/app/components/datasets/documents/list.tsx@@ -458,7 +458,8 @@ const DocumentList: FC<IDocumentListProps> = ({handleSave,} = useBatchEditDocumentMetadata({datasetId,- docList: documents.filter(item => selectedIds.includes(item.id)),+ docList: documents.filter(doc => selectedIds.includes(doc.id)),+ selectedDocumentIds: selectedIds, // Pass all selected IDs separatelyonUpdate,})diff --git a/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts b/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.tsindex 3bb6e1d6edc..f350fd7b8b9 100644--- a/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts+++ b/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts@@ -9,12 +9,14 @@ import { t } from 'i18next'type Props = {datasetId: stringdocList: SimpleDocumentDetail[]+ selectedDocumentIds?: string[]onUpdate: () => void}const useBatchEditDocumentMetadata = ({datasetId,docList,+ selectedDocumentIds,onUpdate,}: Props) => {const [isShowEditModal, {@@ -79,9 +81,12 @@ const useBatchEditDocumentMetadata = ({return false})- const res: MetadataBatchEditToServer = docList.map((item, i) => {- // the new metadata will override the old one- const oldMetadataList = metaDataList[i]+ // Use selectedDocumentIds if available, otherwise fall back to docList+ const documentIds = selectedDocumentIds || docList.map(doc => doc.id)+ const res: MetadataBatchEditToServer = documentIds.map((documentId) => {+ // Find the document in docList to get its metadata+ const docIndex = docList.findIndex(doc => doc.id === documentId)+ const oldMetadataList = docIndex >= 0 ? metaDataList[docIndex] : []let newMetadataList: MetadataItemWithValue[] = [...oldMetadataList, ...addedList].filter((item) => {return !removedList.find(removedItem => removedItem.id === item.id)@@ -108,7 +113,7 @@ const useBatchEditDocumentMetadata = ({})return {- document_id: item.id,+ document_id: documentId,metadata_list: newMetadataList,}})