Skip to content

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

fix(dataset): confirm before re-parse Go documents with chunks (#20210)

chanx6fcf96a3b645
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 0a25e00bb4..ba414b5744 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -473,6 +473,7 @@ Example: A 1 KB message with 1024-dim embedding uses ~9 KB. The 5 MB default lim
redoAll: 'Clear existing chunks',
applyAutoMetadataSettings: 'Apply global auto-metadata settings',
parseFileTip: 'Are you sure to parse?',
+ clearChunksReparseTip: 'Are you sure to clear chunks to re-parse?',
parseFile: 'Parse file',
emptyMetadata: 'No metadata',
metadataField: 'Metadata field',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 22495952ee..10e3db4e6c 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -422,6 +422,7 @@ export default {
redoAll: '清除现有分块',
applyAutoMetadataSettings: '应用全局自动元数据设置',
parseFileTip: '您确定要解析吗?',
+ clearChunksReparseTip: '您确定要清空分块重新解析吗?',
parseFile: '解析文件',
emptyMetadata: '无元数据',
localUpload: '本地上传',
diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
index a6fd46c54f..3ce13361ed 100644
--- a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
+++ b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
@@ -215,7 +215,7 @@ describe('ParsingStatusCell', () => {
).not.toBeInTheDocument();
});
- it('re-parses straight away without the drop-chunks confirmation', () => {
+ it('asks for confirmation before dropping existing chunks', () => {
renderCell({
run: undefined,
ingestion_status: IngestionTaskStatus.COMPLETED,
@@ -225,6 +225,20 @@ describe('ParsingStatusCell', () => {
fireEvent.click(screen.getByTestId('document-parse-toggle'));
+ expect(mockShowReparseDialog).toHaveBeenCalledTimes(1);
+ expect(mockRunDocumentByIds).not.toHaveBeenCalled();
+ });
+
+ it('re-parses a chunkless document straight away without confirmation', () => {
+ renderCell({
+ run: undefined,
+ ingestion_status: IngestionTaskStatus.COMPLETED,
+ chunk_count: 0,
+ parser_config: { enable_metadata: true },
+ });
+
+ fireEvent.click(screen.getByTestId('document-parse-toggle'));
+
expect(mockRunDocumentByIds).toHaveBeenCalledTimes(1);
expect(mockShowReparseDialog).not.toHaveBeenCalled();
});
diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.tsx
index eef586b84b..f8095b8a7b 100644
--- a/web/src/pages/dataset/dataset/parsing-status-cell.tsx
+++ b/web/src/pages/dataset/dataset/parsing-status-cell.tsx
@@ -150,12 +150,13 @@ export function ParsingStatusCell({
// The confirmation only offers real choices when there are existing chunks to
// drop or auto-metadata to re-apply. Otherwise, and always when cancelling a
- // run, the action fires straight away. Go re-ingests in place server-side, so
- // the dialog is Python-only.
+ // run, the action fires straight away. Go always drops existing chunks
+ // server-side, so its dialog shows the delete notice locked on and only the
+ // auto-metadata choice is Python-only.
const needsParseConfirm =
- !isGo &&
!isRunning &&
- (!isZeroChunk || Boolean(record?.parser_config?.enable_metadata));
+ (!isZeroChunk ||
+ (!isGo && Boolean(record?.parser_config?.enable_metadata)));
const handleParseClick = () => {
if (needsParseConfirm) {
@@ -280,6 +281,7 @@ export function ParsingStatusCell({
{reparseDialogVisible && (
<ReparseDialog
enable_metadata={record?.parser_config?.enable_metadata}
+ forceDelete={isGo}
handleOperationIconClick={handleOperationIconClick}
chunk_num={chunk_count}
visible={reparseDialogVisible}
diff --git a/web/src/pages/dataset/dataset/reparse-dialog.tsx b/web/src/pages/dataset/dataset/reparse-dialog.tsx
index ddbd869a19..803cd43634 100644
--- a/web/src/pages/dataset/dataset/reparse-dialog.tsx
+++ b/web/src/pages/dataset/dataset/reparse-dialog.tsx
@@ -16,6 +16,7 @@ export const ReparseDialog = memo(
handleOperationIconClick,
chunk_num,
enable_metadata = false,
+ forceDelete = false,
visible = true,
hideModal,
}: DialogProps & {
@@ -25,6 +26,9 @@ export const ReparseDialog = memo(
apply_kb: boolean;
}) => void;
enable_metadata?: boolean;
+ // Go always drops existing chunks on re-ingest, so it only shows a plain
+ // confirmation with no checkboxes.
+ forceDelete?: boolean;
visible: boolean;
hideModal: () => void;
}) => {
@@ -34,7 +38,7 @@ export const ReparseDialog = memo(
useEffect(() => {
setDefaultValues({
- delete: chunk_num > 0,
+ delete: forceDelete || chunk_num > 0,
apply_kb: false,
});
const deleteField = {
@@ -80,7 +84,11 @@ export const ReparseDialog = memo(
</div>
),
};
- if (chunk_num > 0 && enable_metadata) {
+ // Go only needs a plain confirm: chunks are always dropped, so no
+ // checkboxes are rendered.
+ if (forceDelete) {
+ setFields([]);
+ } else if (chunk_num > 0 && enable_metadata) {
setFields([deleteField, applyKBField]);
} else if (chunk_num > 0 && !enable_metadata) {
setFields([deleteField]);
@@ -89,7 +97,7 @@ export const ReparseDialog = memo(
} else {
setFields([]);
}
- }, [chunk_num, t, enable_metadata]);
+ }, [chunk_num, t, enable_metadata, forceDelete]);
const formCallbackRef = useRef<DynamicFormRef>(null);
@@ -128,7 +136,11 @@ export const ReparseDialog = memo(
open={visible}
okButtonText={t('common.confirm')}
content={{
- title: t(`knowledgeDetails.parseFileTip`),
+ title: t(
+ forceDelete
+ ? `knowledgeDetails.clearChunksReparseTip`
+ : `knowledgeDetails.parseFileTip`,
+ ),
node: (
<div>
<DynamicForm.Root