RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: For datasets with doc, docx, or markdown formats, the "remove original directory" toggle fails to save successfully. (#18976)
balibabu70be528c2824
diff --git a/web/CLAUDE.md b/web/CLAUDE.mdindex 98dea3a38d..666181caf7 100644--- a/web/CLAUDE.md+++ b/web/CLAUDE.md@@ -144,6 +144,7 @@ The folder `src/components/ui/` is the project's **shared UI library** — it co- Components: `EditableTextarea`, `RAGFlowFormItem`- Constants: `InitialMockData`, `DefaultPlaceholder`- Avoid camelCase or SCREAMING_SNAKE_CASE for components and top-level constants.+- **Name things semantically, not generically.** A name should say what the value holds or what the callback does, so call sites read naturally. Don't leak a generic underlying-primitive API into your own component's public props — rename at the wrapper boundary (e.g., a tabs wrapper exposes `activeTab` / `onTabChange`, mapped internally to Radix's `value` / `onValueChange`), and align with what callers already name the state. Same for variables and functions: `hiddenNodeIds` over `nodeIdSet`, `pickByBackend` over `resolveVariant`.- Avoid duplicating component structures in JSX; favor render props or reusable components.### Utility Libraries and Reusediff --git a/web/src/components/document-pipeline-dialog/index.tsx b/web/src/components/document-pipeline-dialog/index.tsxindex 86357e032f..b4975b518b 100644--- a/web/src/components/document-pipeline-dialog/index.tsx+++ b/web/src/components/document-pipeline-dialog/index.tsx@@ -63,6 +63,7 @@ export function DocumentPipelineDialog({activeTab,setActiveTab,handleOperatorValuesChange,+ operatorValues,showOperatorTabs,buildSubmitData,} = useDocumentPipelineForm({ parserId, pipelineId, parserConfig });@@ -118,9 +119,10 @@ export function DocumentPipelineDialog({{showOperatorTabs && (<PipelineOperatorTabsnodes={operatorNodes}- value={activeTab}- onValueChange={setActiveTab}+ activeTab={activeTab}+ onTabChange={setActiveTab}onOperatorValuesChange={handleOperatorValuesChange}+ operatorValues={operatorValues}operatorFormErrors={errors.parser_config as| Record<string, FieldErrors | undefined>diff --git a/web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts b/web/src/components/document-pipeline-dialog/use-document-pipeline-form.tsindex abe9fff455..de07d71206 100644--- a/web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts+++ b/web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts@@ -23,10 +23,11 @@ import {import { IChangeParserRequestBody } from '@/interfaces/request/document';import {getOperatorType,- transformApiConfigToForm,transformFormConfigToApi,+ transformSavedParserConfigToForm,} from '@/utils/pipeline-operator';import { zodResolver } from '@hookform/resolvers/zod';+import { isEqual } from 'lodash';import { useCallback, useEffect, useMemo } from 'react';import { useForm, useWatch } from 'react-hook-form';import { useTranslation } from 'react-i18next';@@ -39,39 +40,6 @@ export interface IDocumentPipelineDialogProps {parserConfig?: Record<string, any>;}-/**- * Converts the saved parser_config (API format, keyed by operator id) to the- * form format expected by the operator tabs, mirroring- * useFetchDatasetSettingOnMount on the dataset setting page.- */-function transformSavedParserConfigToForm(- parserConfig?: Record<string, any>,-): Record<string, any> {- if (- !parserConfig ||- typeof parserConfig !== 'object' ||- Array.isArray(parserConfig)- ) {- return {};- }-- const hasPipelineKeys = Object.keys(parserConfig).some((key) =>- key.includes(':'),- );- if (!hasPipelineKeys) {- return parserConfig;- }-- const formParserConfig: Record<string, any> = {};- for (const [operatorId, config] of Object.entries(parserConfig)) {- formParserConfig[operatorId] = transformApiConfigToForm(- getOperatorType(operatorId),- config as Record<string, any>,- );- }- return formParserConfig;-}-export function useDocumentPipelineForm({parserId,pipelineId,@@ -173,6 +141,12 @@ export function useDocumentPipelineForm({const handleOperatorValuesChange = useCallback((operatorId: string, values: any) => {const currentParserConfig = form.getValues('parser_config') || {};+ // Skip no-op syncs (e.g. a remounted tab pushing back the values it was+ // just initialized with) — otherwise each setValue re-renders the tabs,+ // which re-fires the operator form's change callback in a loop.+ if (isEqual(currentParserConfig[operatorId], values)) {+ return;+ }form.setValue('parser_config', {...currentParserConfig,[operatorId]: values,@@ -181,6 +155,11 @@ export function useDocumentPipelineForm({[form],);+ const operatorValues = useWatch({+ control: form.control,+ name: 'parser_config',+ });+const showOperatorTabs =operatorNodes.length > 0 &&((parseType === ParseType.Pipeline && !!selectedDataFlowId) ||@@ -217,6 +196,7 @@ export function useDocumentPipelineForm({activeTab,setActiveTab,handleOperatorValuesChange,+ operatorValues,showOperatorTabs,buildSubmitData,};diff --git a/web/src/components/pipeline-operator-tabs/index.tsx b/web/src/components/pipeline-operator-tabs/index.tsxindex 895b36dbe7..c1d3c26d4b 100644--- a/web/src/components/pipeline-operator-tabs/index.tsx+++ b/web/src/components/pipeline-operator-tabs/index.tsx@@ -16,15 +16,22 @@import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';import { RAGFlowNodeType } from '@/interfaces/database/agent';-import { memo, useCallback } from 'react';+import { normalizeOperatorForm } from '@/utils/pipeline-operator';+import { memo, useCallback, useMemo } from 'react';import { FieldErrors } from 'react-hook-form';import PipelineOperatorForm from './pipeline-operator-form';type PipelineOperatorTabsProps = {nodes: RAGFlowNodeType[];- value: string;- onValueChange: (value: string) => void;+ activeTab: string;+ onTabChange: (tab: string) => void;onOperatorValuesChange: (operatorId: string, values: any) => void;+ // Current values of the outer form's parser_config, keyed by operatorId.+ // The outer form is the single source of truth: Radix unmounts inactive+ // tabs, so a remounted operator form must initialize from these values —+ // not from the static node form built off the pipeline DSL — otherwise+ // unsaved edits are lost on tab switches.+ operatorValues?: Record<string, any>;// Validation errors from the outer form's parser_config, keyed by// operatorId; each entry is mirrored onto the operator form's fields.operatorFormErrors?: Record<string, FieldErrors | undefined>;@@ -32,9 +39,10 @@ type PipelineOperatorTabsProps = {const PipelineOperatorTabs = ({nodes,- value,- onValueChange,+ activeTab,+ onTabChange,onOperatorValuesChange,+ operatorValues,operatorFormErrors,}: PipelineOperatorTabsProps) => {const getOperatorId = useCallback((node: RAGFlowNodeType) => {@@ -43,6 +51,26 @@ const PipelineOperatorTabs = ({);}, []);+ const mergedNodes = useMemo(() => {+ if (!operatorValues) {+ return nodes;+ }+ return nodes.map((node) => {+ const operatorId = getOperatorId(node);+ const values = operatorValues[operatorId];+ if (!values || typeof values !== 'object') {+ return node;+ }+ return {+ ...node,+ data: {+ ...node.data,+ form: normalizeOperatorForm(operatorId, values),+ },+ };+ });+ }, [nodes, operatorValues, getOperatorId]);+const getTabValue = useCallback((node: RAGFlowNodeType, index: number) => {return getOperatorId(node) || String(index);@@ -58,9 +86,9 @@ const PipelineOperatorTabs = ({);return (- <Tabs value={value} onValueChange={onValueChange} className="w-full">+ <Tabs value={activeTab} onValueChange={onTabChange} className="w-full"><TabsList className="w-full justify-start">- {nodes.map((node, index) => {+ {mergedNodes.map((node, index) => {const tabValue = getTabValue(node, index);return (<TabsTrigger key={tabValue} value={tabValue}>@@ -69,7 +97,7 @@ const PipelineOperatorTabs = ({);})}</TabsList>- {nodes.map((node, index) => {+ {mergedNodes.map((node, index) => {const tabValue = getTabValue(node, index);return (<TabsContent key={tabValue} value={tabValue}>diff --git a/web/src/pages/agent/utils.ts b/web/src/pages/agent/utils.tsindex b6c87afe72..cb806f8ef4 100644--- a/web/src/pages/agent/utils.ts+++ b/web/src/pages/agent/utils.ts@@ -290,6 +290,7 @@ export function transformParserParams(params: ParserFormSchemaType) {...filteredSetup,vlm: { llm_id: cur.vlm?.llm_id },flatten_media_to_text: cur.flatten_media_to_text,+ remove_toc: cur.remove_toc,remove_header_footer: cur.remove_header_footer || false,};break;@@ -298,6 +299,7 @@ export function transformParserParams(params: ParserFormSchemaType) {...filteredSetup,vlm: { llm_id: cur.vlm?.llm_id },flatten_media_to_text: cur.flatten_media_to_text,+ remove_toc: cur.remove_toc,remove_header_footer: cur.remove_header_footer || false,};break;@@ -313,6 +315,7 @@ export function transformParserParams(params: ParserFormSchemaType) {...filteredSetup,vlm: { llm_id: cur.vlm?.llm_id },flatten_media_to_text: cur.flatten_media_to_text,+ remove_toc: cur.remove_toc,};break;case FileType.Video:diff --git a/web/src/pages/dataset/setting/go/hooks.ts b/web/src/pages/dataset/setting/go/hooks.tsindex 8d8a181ea3..9fe84da872 100644--- a/web/src/pages/dataset/setting/go/hooks.ts+++ b/web/src/pages/dataset/setting/go/hooks.ts@@ -9,8 +9,8 @@ import { useDataSourceInfo } from '@/pages/user-setting/data-source/constant';import { checkEmbedding } from '@/services/knowledge-service';import {getOperatorType,- transformApiConfigToForm,transformFormConfigToApi,+ transformSavedParserConfigToForm,} from '@/utils/pipeline-operator';import { pick } from 'lodash';import {@@ -69,30 +69,9 @@ export const useFetchDatasetSettingOnMount = (}, [knowledgeDetails?.connectors, dataSourceInfo]);useEffect(() => {- const parserConfig = knowledgeDetails.parser_config as- | Record<string, any>- | undefined;- let formParserConfig: Record<string, any> | undefined = parserConfig;-- // Convert parser_config to form format if in pipeline mode- if (- parserConfig &&- typeof parserConfig === 'object' &&- !Array.isArray(parserConfig)- ) {- const keys = Object.keys(parserConfig);- const hasPipelineKeys = keys.some((key) => key.includes(':'));- if (hasPipelineKeys) {- formParserConfig = {};- for (const [operatorId, config] of Object.entries(parserConfig)) {- const operatorType = getOperatorType(operatorId);- formParserConfig[operatorId] = transformApiConfigToForm(- operatorType,- config as Record<string, any>,- );- }- }- }+ const formParserConfig = transformSavedParserConfigToForm(+ knowledgeDetails.parser_config as Record<string, any> | undefined,+ );const formValues = {...pick(knowledgeDetails, [diff --git a/web/src/pages/dataset/setting/go/index.tsx b/web/src/pages/dataset/setting/go/index.tsxindex e24fb99b7f..bdc86fea9a 100644--- a/web/src/pages/dataset/setting/go/index.tsx+++ b/web/src/pages/dataset/setting/go/index.tsx@@ -20,6 +20,7 @@ import {useResetParserConfigOnPipelineChange,} from '@/hooks/use-pipeline-operator';import { zodResolver } from '@hookform/resolvers/zod';+import { isEqual } from 'lodash';import { useCallback, useEffect, useState } from 'react';import { FieldErrors, useForm, useFormState, useWatch } from 'react-hook-form';import { useTranslation } from 'react-i18next';@@ -165,6 +166,12 @@ export default function DatasetSetting() {const handleOperatorValuesChange = useCallback((operatorId: string, values: any) => {const currentParserConfig = form.getValues('parser_config') || {};+ // Skip no-op syncs (e.g. a remounted tab pushing back the values it was+ // just initialized with) — otherwise each setValue re-renders the tabs,+ // which re-fires the operator form's change callback in a loop.+ if (isEqual(currentParserConfig[operatorId], values)) {+ return;+ }form.setValue('parser_config', {...currentParserConfig,[operatorId]: values,@@ -173,6 +180,11 @@ export default function DatasetSetting() {[form],);+ const parserConfigValues = useWatch({+ control: form.control,+ name: 'parser_config',+ });+const pipelineDataList = usePipelineDataList(sourceDataState);const showOperatorTabs =@@ -226,9 +238,10 @@ export default function DatasetSetting() {{showOperatorTabs && (<PipelineOperatorTabsnodes={operatorNodes}- value={activeTab}- onValueChange={setActiveTab}+ activeTab={activeTab}+ onTabChange={setActiveTab}onOperatorValuesChange={handleOperatorValuesChange}+ operatorValues={parserConfigValues}operatorFormErrors={errors.parser_config as| Record<string, FieldErrors | undefined>diff --git a/web/src/utils/pipeline-operator.ts b/web/src/utils/pipeline-operator.tsindex 7e65b28489..6b22136a77 100644--- a/web/src/utils/pipeline-operator.ts+++ b/web/src/utils/pipeline-operator.ts@@ -328,6 +328,43 @@ export function transformApiConfigToForm(}}+/**+ * Converts a saved parser_config (API format, keyed by operator id) to the+ * form format used by the operator tabs. Configs without pipeline keys+ * (built-in parse type) are returned as-is.+ *+ * The dataset-level metadata group is authoritative for Extractor nodes,+ * mirroring buildOperatorNode, so the values seeded into the outer form match+ * what the operator tabs initialize from.+ */+export function transformSavedParserConfigToForm(+ parserConfig?: Record<string, any>,+): Record<string, any> | undefined {+ if (+ !parserConfig ||+ typeof parserConfig !== 'object' ||+ Array.isArray(parserConfig) ||+ !Object.keys(parserConfig).some((key) => key.includes(':'))+ ) {+ return parserConfig;+ }++ const formParserConfig: Record<string, any> = {};+ for (const [operatorId, config] of Object.entries(parserConfig)) {+ const operatorType = getOperatorType(operatorId);+ const apiConfig =+ operatorType === Operator.Extractor &&+ isDatasetMetadataGroup(parserConfig.metadata)+ ? { ...config, metadata: parserConfig.metadata }+ : (config as Record<string, any>);+ formParserConfig[operatorId] = transformApiConfigToForm(+ operatorType,+ apiConfig,+ );+ }+ return formParserConfig;+}+/*** Dispatches forward transform by operator type.* Converts form-format config to DSL format for saving.@@ -354,7 +391,7 @@ export function transformFormConfigToApi(}}-function normalizeOperatorForm(+export function normalizeOperatorForm(operatorId: string,rawForm: Record<string, any> | undefined,): Record<string, any> {