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: When switching between different pipeline versions on the dataset configuration page, the displayed operator configuration information is incorrect. (#21669)
balibabueee9b25f4bc3
diff --git a/internal/service/dataset/pipeline_version_binding_test.go b/internal/service/dataset/pipeline_version_binding_test.goindex 3e1cc3557e..af333b6b83 100644--- a/internal/service/dataset/pipeline_version_binding_test.go+++ b/internal/service/dataset/pipeline_version_binding_test.go@@ -500,12 +500,12 @@ func TestUpdateDataset_VersionChangeResetsParserConfigToNewVersionDefault(t *tes}}-// T26/C3 regression: a version switch must STILL reset parser_config to the new-// version DSL defaults when the client echoes the previous (edited) parser_config-// back. The settings form keeps the user's manual edit (e.g. chunk size 757) until-// the save, so the request carries the old parser_config. The C3 reset must take-// precedence over the echoed value (design A3 整体重置).-func TestUpdateDataset_VersionChangeWithEchoedParserConfigResets(t *testing.T) {+// T26/C3: a version switch with a submitted parser_config keeps the submitted+// values, reconciled against the NEW version's DSL by BuildParserConfig. The+// settings form resets itself to the new version's defaults on a switch, so+// the submitted config carries the user's edits of the new version — the+// backend must not discard it with a full reset.+func TestUpdateDataset_VersionChangeKeepsSubmittedParserConfig(t *testing.T) {db := setupDatasetUpdateTestDB(t)pushServiceDB(t, db)@@ -517,12 +517,12 @@ func TestUpdateDataset_VersionChangeWithEchoedParserConfigResets(t *testing.T) {seedCanvasVersionDSL(t, db, canvas1, verNew, dslWithResetMarker("NEW_VER_DEFAULT"), 1000)seedBoundKB(t, db, "kb-c3-echo", canvas1, verOld)- // The form still holds the user's manual edit (e.g. chunk size 757) as a real- // component param when the version is switched. Use the version DSL's own- // component so the override is recognized and survives BuildParserConfig.- echoed := entity.JSONMap{"Parser:ResetCpn": map[string]any{"c3_reset_marker": "ECHOED_757"}}+ // The user's edit of the new version's defaults (e.g. chunk size 757) as a+ // real component param. Use the version DSL's own component so the override+ // is recognized by BuildParserConfig.+ submitted := entity.JSONMap{"Parser:ResetCpn": map[string]any{"c3_reset_marker": "ECHOED_757"}}if err := db.Model(&entity.Knowledgebase{}).Where("id = ?", "kb-c3-echo").- Update("parser_config", echoed).Error; err != nil {+ Update("parser_config", entity.JSONMap{"Parser:ResetCpn": map[string]any{"c3_reset_marker": "OLD_VER_DEFAULT"}}).Error; err != nil {t.Fatalf("seed parser_config: %v", err)}@@ -532,8 +532,8 @@ func TestUpdateDataset_VersionChangeWithEchoedParserConfigResets(t *testing.T) {PipelineID: &canvas1,PipelineVersionID: &verNew,ParseType: &parseType,- // Echoed (edited) parser_config — must be discarded on version switch.- ParserConfig: echoed,+ // Edited parser_config of the new version — must survive the switch.+ ParserConfig: submitted,})if err != nil || code != common.CodeSuccess {t.Fatalf("UpdateDataset err=%v code=%d", err, code)@@ -546,24 +546,21 @@ func TestUpdateDataset_VersionChangeWithEchoedParserConfigResets(t *testing.T) {if kb.PipelineVersionID == nil || *kb.PipelineVersionID != verNew {t.Fatalf("PipelineVersionID = %v, want re-pinned %s", kb.PipelineVersionID, verNew)}- // The echoed component override must NOT survive the version switch.+ // The submitted override must survive the version switch, reconciled onto+ // the NEW version's DSL (same component set, submitted value wins).cpn, ok := kb.ParserConfig["Parser:ResetCpn"].(map[string]any)if !ok {t.Fatalf("Parser:ResetCpn missing after switch: %v", kb.ParserConfig)}- if cpn["c3_reset_marker"] == "ECHOED_757" {- t.Fatalf("parser_config still holds echoed value; C3 reset did not take precedence: %v", kb.ParserConfig)+ if cpn["c3_reset_marker"] != "ECHOED_757" {+ t.Fatalf("parser_config lost the submitted edit on version switch: %v", kb.ParserConfig)}- resolved, derr := service.ResolveComponentParamsDefaults(ctx, string(entity.ParserTypeNaive), &canvas1, &verNew)- if derr != nil {- t.Fatalf("resolve new-version defaults: %v", derr)- }- expected := service.ApplyComponentScopedParserConfig(resolved, "")+ // The persisted component set comes from the NEW version's DSL: nothing+ // beyond its components may survive.+ expected := service.ApplyComponentScopedParserConfig(+ entity.JSONMap{"Parser:ResetCpn": map[string]any{"c3_reset_marker": "ECHOED_757"}}, "")if !reflect.DeepEqual(kb.ParserConfig, expected) {- t.Fatalf("parser_config = %v, want new-version default %v", kb.ParserConfig, expected)- }- if cpn["c3_reset_marker"] != "NEW_VER_DEFAULT" {- t.Fatalf("reset did not load the NEW version default: %v", kb.ParserConfig)+ t.Fatalf("parser_config = %v, want submitted values on new-version DSL %v", kb.ParserConfig, expected)}}diff --git a/internal/service/dataset/update.go b/internal/service/dataset/update.goindex 6309714553..4d7f47932e 100644--- a/internal/service/dataset/update.go+++ b/internal/service/dataset/update.go@@ -399,27 +399,29 @@ func (d *DatasetService) UpdateDataset(ctx context.Context, datasetID, userID sttxCode = common.CodeBadRequestreturn service.ErrPipelineVersionEmpty}- // C3 / A3 整体重置: BOTH a pipeline (canvas) switch and a version switch- // force a full parser_config reset to the new DSL defaults, discarding any- // echoed/submitted parser_config. When the version or pipeline is switched- // the settings form may still hold the previous value (e.g. a manually- // edited chunk size), so the reset must take precedence over the submitted- // config rather than merging it in.+ // C3 / A3: a pipeline (canvas) switch or a version switch resets+ // parser_config to the new DSL defaults — but only when the request+ // carried no parser_config of its own. A submitted config has already+ // been reconciled against the new version's DSL by BuildParserConfig+ // above (unknown operators dropped, missing params defaulted), and the+ // settings form itself resets to the new defaults on a switch before+ // the user edits — so a submitted config is authoritative and must not+ // be discarded.if pipelineChanged || versionChanged {- cfgParserID := lockedKB.ParserID- if parserIDProvided {- cfgParserID = parserID- }- effVersionID, _ := resolvePipelineVersionID(ctx, tx, canvasCtx, requestedVersion)- cpDefaults, cpErr := service.ResolveComponentParamsDefaults(ctx, cfgParserID, canvasCtx, effVersionID)- if cpErr != nil {- common.Warn("failed to resolve component params defaults on pipeline/version change",- zap.String("parserID", cfgParserID), zap.Error(cpErr))- }- // Full reset: replace parser_config with the new DSL defaults. The- // previous (echoed) value is intentionally dropped (design A3 整体重置).- if cpErr == nil {- updates["parser_config"] = cpDefaults+ if _, submitted := updates["parser_config"]; !submitted {+ cfgParserID := lockedKB.ParserID+ if parserIDProvided {+ cfgParserID = parserID+ }+ effVersionID, _ := resolvePipelineVersionID(ctx, tx, canvasCtx, requestedVersion)+ cpDefaults, cpErr := service.ResolveComponentParamsDefaults(ctx, cfgParserID, canvasCtx, effVersionID)+ if cpErr != nil {+ common.Warn("failed to resolve component params defaults on pipeline/version change",+ zap.String("parserID", cfgParserID), zap.Error(cpErr))+ }+ if cpErr == nil {+ updates["parser_config"] = cpDefaults+ }}}diff --git a/internal/service/dataset/update_test.go b/internal/service/dataset/update_test.goindex bced015999..23473694e4 100644--- a/internal/service/dataset/update_test.go+++ b/internal/service/dataset/update_test.go@@ -295,7 +295,7 @@ func TestUpdateDataset_ParseTypePipelineRejectsParserID(t *testing.T) {}}-func TestUpdateDataset_PipelineSwitchResetsParserConfigToDefaults(t *testing.T) {+func TestUpdateDataset_PipelineSwitchKeepsSubmittedParserConfig(t *testing.T) {db := setupDatasetUpdateTestDB(t)pushServiceDB(t, db)insertDatasetUpdateKB(t, "kb-1", "tenant-1", "Original")@@ -345,10 +345,12 @@ func TestUpdateDataset_PipelineSwitchResetsParserConfigToDefaults(t *testing.T)if err != nil {t.Fatalf("get updated kb: %v", err)}- // C3 / A3 整体重置: a pipeline (canvas) switch forces a FULL reset of- // parser_config to the new canvas DSL defaults, discarding the submitted- // config (design section 5 + A3). The submitted remove_toc=true must NOT- // survive; the persisted value must be the new canvas DSL default (false).+ // A pipeline (canvas) switch with a submitted parser_config keeps the+ // submitted values, reconciled against the new canvas DSL by+ // BuildParserConfig: the settings form resets itself to the new defaults+ // on a switch, so the submitted config carries the user's edits of the new+ // pipeline and must not be discarded. remove_toc=true must survive on top+ // of the new canvas DSL default (false).parserParams, ok := persisted.ParserConfig["Parser:CustomP"].(map[string]interface{})if !ok {t.Fatalf("expected Parser:CustomP in parser_config, got %#v", persisted.ParserConfig)@@ -357,8 +359,8 @@ func TestUpdateDataset_PipelineSwitchResetsParserConfigToDefaults(t *testing.T)if !ok {t.Fatalf("expected pdf parser config, got %#v", parserParams)}- if removeTOC, ok := pdfParams["remove_toc"].(bool); !ok || removeTOC {- t.Fatalf("remove_toc = %#v, want false (submitted value discarded on pipeline switch reset)", pdfParams["remove_toc"])+ if removeTOC, ok := pdfParams["remove_toc"].(bool); !ok || !removeTOC {+ t.Fatalf("remove_toc = %#v, want true (submitted value kept on pipeline switch)", pdfParams["remove_toc"])}}diff --git a/internal/service/document/document_dataset_update.go b/internal/service/document/document_dataset_update.goindex 7557e81cbb..88790f3f5e 100644--- a/internal/service/document/document_dataset_update.go+++ b/internal/service/document/document_dataset_update.go@@ -297,14 +297,15 @@ func (s *DocumentService) UpdateDatasetDocument(ctx context.Context, userID, dat}}- // C3 / A3 整体重置: a pipeline (canvas) switch OR a version switch forces a- // full parser_config reset to the new DSL defaults, discarding any- // echoed/submitted parser_config. This mirrors the dataset-layer behavior so- // the two layers stay consistent (design A3 整体重置): a change to- // pipelineID or versionID must reset parser config to the DSL defaults. The- // reset overrides the first block's merge, so a stale form value (e.g. a- // manually edited chunk size) or a config submitted alongside the switch is- // dropped, exactly as the reset-on-switch contract requires.+ // C3 / A3: a pipeline (canvas) switch OR a version switch resets+ // parser_config to the new DSL defaults — but only when the request carried+ // no parser_config of its own. A submitted config has already been+ // reconciled against the new version's DSL by BuildParserConfig above+ // (unknown operators dropped, missing params defaulted), and the settings+ // form resets itself to the new defaults on a switch before the user+ // edits — so a submitted config is authoritative and must not be+ // discarded. This mirrors the dataset-layer behavior so the two layers+ // stay consistent.//// pipelineChanged tracks a genuine canvas change (incl. builtin→canvas);// versionChanged tracks a pinned-version change. Builtin→builtin switches are@@ -312,7 +313,7 @@ func (s *DocumentService) UpdateDatasetDocument(ctx context.Context, userID, dat// first block as a normal selection rebuild).pipelineChanged := isPipeline && req.PipelineID != nil &&(doc.PipelineID == nil || strings.TrimSpace(*req.PipelineID) != strings.TrimSpace(*doc.PipelineID))- if pipelineChanged || versionChanged {+ if (pipelineChanged || versionChanged) && !hasConfig {cpDefaults, cpErr := service.ResolveComponentParamsDefaults(ctx, effParserID, effPipelineID, effectiveVersionID)if cpErr != nil {common.Warn("document pipeline/version switch: failed to resolve component params defaults, keeping prior parser_config",diff --git a/internal/service/document/document_test.go b/internal/service/document/document_test.goindex 324786aa9e..a6de761893 100644--- a/internal/service/document/document_test.go+++ b/internal/service/document/document_test.go@@ -3212,14 +3212,15 @@ func TestUpdateDatasetDocumentParserConfigPreservesParseResults(t *testing.T) {present map[string]boolwantParser stringwantPipeline string- // reset marks a pipeline switch, which (by design A3 整体重置) must reset- // parser_config to the canvas DSL defaults, discarding the submitted config.- reset bool}{{name: "config only", wantParser: "naive"},{name: "same builtin", request: UpdateDatasetDocumentRequest{ParseType: &builtin, ParserID: sptr("naive")}, present: map[string]bool{"parse_type": true, "parser_id": true}, wantParser: "naive"},{name: "different builtin", request: UpdateDatasetDocumentRequest{ParseType: &builtin, ParserID: sptr("manual")}, present: map[string]bool{"parse_type": true, "parser_id": true}, wantParser: "manual"},- {name: "pipeline", request: UpdateDatasetDocumentRequest{ParseType: &pipeline, PipelineID: &pipelineID, PipelineVersionID: sptr("v-doc-pipe-0001")}, present: map[string]bool{"parse_type": true, "pipeline_id": true, "pipeline_version_id": true}, wantParser: "naive", wantPipeline: pipelineID, reset: true},+ // A pipeline switch with a submitted parser_config keeps the submitted+ // values, reconciled against the new pipeline's DSL (the form resets+ // itself on a switch, so the submitted config is the user's edit of the+ // new pipeline).+ {name: "pipeline", request: UpdateDatasetDocumentRequest{ParseType: &pipeline, PipelineID: &pipelineID, PipelineVersionID: sptr("v-doc-pipe-0001")}, present: map[string]bool{"parse_type": true, "pipeline_id": true, "pipeline_version_id": true}, wantParser: "naive", wantPipeline: pipelineID},{name: "chunk method", request: UpdateDatasetDocumentRequest{ChunkMethod: sptr("manual")}, present: map[string]bool{"chunk_method": true}, wantParser: "manual"},}for _, tc := range cases {@@ -3265,28 +3266,15 @@ func TestUpdateDatasetDocumentParserConfigPreservesParseResults(t *testing.T) {if doc.TokenNum != 10 || doc.ChunkNum != 5 || doc.Progress != 0.75 || doc.ProcessDuration != 42 {t.Fatalf("persisted parse results changed: %+v", doc)}- if tc.reset {- // A pipeline switch resets parser_config to the canvas DSL- // defaults (design A3 整体重置). The submitted- // Extractor keywords.top_n=5 must be discarded and replaced by the- // DSL default (0), proving the reset took effect.- extractor, ok := doc.ParserConfig["Extractor:AutoExtractDefault"].(map[string]interface{})- if !ok {- t.Fatalf("canvas DSL default parser_config missing Extractor after pipeline switch: %#v", doc.ParserConfig)- }- keywords, ok := extractor["keywords"].(map[string]interface{})- if !ok || keywords["top_n"] != float64(0) {- t.Fatalf("submitted keywords.top_n should be reset to DSL default (0), got %#v (config=%#v)", keywords["top_n"], doc.ParserConfig)- }- } else {- extractor, ok := doc.ParserConfig["Extractor:AutoExtractDefault"].(map[string]interface{})- if !ok {- t.Fatalf("extractor config not saved: %#v", doc.ParserConfig)- }- keywords, ok := extractor["keywords"].(map[string]interface{})- if !ok || keywords["top_n"] != float64(5) {- t.Fatalf("parser config not saved: %#v", doc.ParserConfig)- }+ // The submitted Extractor keywords.top_n=5 must survive (reconciled+ // onto the target DSL), including on a pipeline switch.+ extractor, ok := doc.ParserConfig["Extractor:AutoExtractDefault"].(map[string]interface{})+ if !ok {+ t.Fatalf("extractor config not saved: %#v", doc.ParserConfig)+ }+ keywords, ok := extractor["keywords"].(map[string]interface{})+ if !ok || keywords["top_n"] != float64(5) {+ t.Fatalf("parser config not saved: %#v", doc.ParserConfig)}kb, err := dao.NewKnowledgebaseDAO().GetByID(ctx, db, "kb-1")if err != nil {diff --git a/web/src/components/document-pipeline-dialog/use-document-pipeline-form.test.tsx b/web/src/components/document-pipeline-dialog/use-document-pipeline-form.test.tsxindex efff96097c..af5fc6ba9c 100644--- a/web/src/components/document-pipeline-dialog/use-document-pipeline-form.test.tsx+++ b/web/src/components/document-pipeline-dialog/use-document-pipeline-form.test.tsx@@ -19,6 +19,12 @@ jest.mock('@/hooks/use-agent-request', () => ({loading: false,isError: false,}),+ // The three hooks below back useParserTreeData, which the form hook+ // consults for the missing-option validation.+ useFetchBuiltinPipelines: () => ({ options: [], loading: false }),+ useFetchAgentList: () => ({ data: { canvas: [], total: 0 }, loading: false }),+ useFetchCanvasVersions: (canvasIds: string[]) =>+ canvasIds.map(() => ({ isSuccess: true, data: mockVersions })),}));// Cut the chain parser-config-validation -> compilation-form -> locales/configdiff --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 22b5237b62..3b64bf283a 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@@ -162,22 +162,33 @@ export function useDocumentPipelineForm({? pipelineId: parserId: undefined;+ const savedVersionId = isPipelineMode ? (pipelineVersionId ?? '') : '';++ // The saved parser_config overrides the DSL defaults only while the+ // selection matches the saved pipeline+version binding; a different version+ // renders that version's own DSL defaults. (The form's parser_config stays+ // the display source of truth via operatorValues either way.)+ const isSavedBindingSelected =+ !!selectedPipelineId &&+ selectedPipelineId === savedPipelineId &&+ (selectedVersionId ?? '') === savedVersionId;const { operatorNodes, loading: operatorNodesLoading } =- usePipelineOperatorNodes(- selectedPipelineId,- selectedPipelineId && selectedPipelineId === savedPipelineId- ? parserConfig- : undefined,- !isPipelineMode,- );+ usePipelineOperatorNodes({+ pipelineId: selectedPipelineId,+ versionId: isPipelineMode ? selectedVersionId : undefined,+ savedParserConfig: isSavedBindingSelected ? parserConfig : undefined,+ isBuiltin: !isPipelineMode,+ });- useResetParserConfigOnPipelineChange(+ useResetParserConfigOnPipelineChange({form,- selectedPipelineId,+ pipelineId: selectedPipelineId,+ versionId: isPipelineMode ? selectedVersionId : undefined,savedPipelineId,+ savedVersionId: isPipelineMode ? savedVersionId : undefined,operatorNodes,- );+ });// Design section 8 (T37): an unpinned document still pre-selects the latest// concrete version once the version list resolves. The "switch pipelinediff --git a/web/src/components/parser-tree-select/index.tsx b/web/src/components/parser-tree-select/index.tsxindex 06fcde5d18..2978a98c0a 100644--- a/web/src/components/parser-tree-select/index.tsx+++ b/web/src/components/parser-tree-select/index.tsx@@ -7,6 +7,7 @@ import { cn } from '@/lib/utils';import { AlertCircle, TriangleAlert } from 'lucide-react';import { useCallback } from 'react';import { useTranslation } from 'react-i18next';+import { PipelineVersionLabel } from '../pipeline-version-label';import { TreeSelect, TreeSelectNode } from '../tree-select';import { useParserTreeData } from './use-parser-tree-data';@@ -84,12 +85,12 @@ export function ParserTreeSelect({const alias = node.data?.alias;if (alias) {return (- <span className="flex w-full min-w-0 items-center gap-1.5">- <span className="truncate">{node.data?.title}</span>- <span className="max-w-[30%] shrink-0 truncate text-text-secondary">- {alias}- </span>- </span>+ <PipelineVersionLabel+ title={node.data?.title ?? ''}+ alias={alias}+ className="w-full"+ aliasClassName="max-w-[30%]"+ />);}return node.label ?? node.title;diff --git a/web/src/components/parser-tree-select/use-parser-tree-data.tsx b/web/src/components/parser-tree-select/use-parser-tree-data.tsxindex e2ae34f32c..c6a45b3467 100644--- a/web/src/components/parser-tree-select/use-parser-tree-data.tsx+++ b/web/src/components/parser-tree-select/use-parser-tree-data.tsx@@ -14,6 +14,7 @@ import { AgentListItemType } from '@/interfaces/database/agent';import { Loader2 } from 'lucide-react';import { useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';+import { PipelineVersionLabel } from '../pipeline-version-label';import {filterTreeNodes,TreeSelectNode,@@ -159,14 +160,10 @@ export function useParserTreeData({ value }: { value?: string }) {? { title: version.title, alias: version.alias }: undefined,label: (- <span className="flex items-center gap-1.5 min-w-0">- <span className="truncate">{version.title}</span>- {version.alias && (- <span className="text-text-secondary truncate flex-shrink-0">- {version.alias}- </span>- )}- </span>+ <PipelineVersionLabel+ title={version.title}+ alias={version.alias}+ />),}));}diff --git a/web/src/components/pipeline-version-label.tsx b/web/src/components/pipeline-version-label.tsxnew file mode 100644index 0000000000..d641b7815c--- /dev/null+++ b/web/src/components/pipeline-version-label.tsx@@ -0,0 +1,36 @@+import { cn } from '@/lib/utils';++interface PipelineVersionLabelProps {+ title: string;+ alias?: string;+ className?: string;+ aliasClassName?: string;+}++// The "version title + alias" line used everywhere a published pipeline+// version is displayed: the parser tree select's dropdown rows and closed+// trigger, and the dataset table's parse column. The title truncates first;+// the alias stays visible as secondary text, optionally width-capped via+// aliasClassName (the closed trigger caps it at 30% of the trigger width).+export function PipelineVersionLabel({+ title,+ alias,+ className,+ aliasClassName,+}: PipelineVersionLabelProps) {+ return (+ <span className={cn('flex min-w-0 items-center gap-1.5', className)}>+ <span className="truncate">{title}</span>+ {alias ? (+ <span+ className={cn(+ 'shrink-0 truncate text-text-secondary',+ aliasClassName,+ )}+ >+ {alias}+ </span>+ ) : null}+ </span>+ );+}diff --git a/web/src/hooks/__tests__/use-pipeline-operator.test.tsx b/web/src/hooks/__tests__/use-pipeline-operator.test.tsxnew file mode 100644index 0000000000..9a4e276435--- /dev/null+++ b/web/src/hooks/__tests__/use-pipeline-operator.test.tsx@@ -0,0 +1,312 @@+/*+ * 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 { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { renderHook, waitFor } from '@testing-library/react';+import { useForm } from 'react-hook-form';+import { useFetchPipelineDslByPipelineId } from '../use-agent-request';+import { useResetParserConfigOnPipelineChange } from '../use-pipeline-operator';++// This file goes through the esbuild-jest babel pass, which cannot rewrite an+// imported binding that also appears in a type position — so node fixtures+// use this local structural type instead of importing RAGFlowNodeType.+// eslint-disable-next-line @typescript-eslint/no-explicit-any+type OperatorNode = any;++jest.mock('@/services/agent-service', () => ({+ __esModule: true,+ default: {+ fetchVersion: jest.fn(),+ getBuiltinPipeline: jest.fn(),+ },+}));++// eslint-disable-next-line @typescript-eslint/no-var-requires+const agentService = require('@/services/agent-service').default;++const wrapper = ({ children }: { children: React.ReactNode }) => (+ <QueryClientProvider+ client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}+ >+ {children}+ </QueryClientProvider>+);++const versionDsl = { graph: { nodes: [], edges: [] } };++beforeEach(() => {+ jest.clearAllMocks();+});++describe('useFetchPipelineDslByPipelineId', () => {+ it('fetches the builtin pipeline DSL directly, ignoring the version id', async () => {+ agentService.getBuiltinPipeline.mockResolvedValue({+ data: { data: { dsl: versionDsl } },+ });++ const { result } = renderHook(+ () => useFetchPipelineDslByPipelineId('general', undefined, true),+ { wrapper },+ );++ await waitFor(() => expect(result.current.dsl).toEqual(versionDsl));+ expect(agentService.getBuiltinPipeline).toHaveBeenCalledWith('general');+ expect(agentService.fetchVersion).not.toHaveBeenCalled();+ });++ it('fetches the selected canvas version for a dataflow pipeline', async () => {+ agentService.fetchVersion.mockResolvedValue({+ data: { code: 0, data: { id: 'version-1', dsl: versionDsl } },+ });++ const { result } = renderHook(+ () => useFetchPipelineDslByPipelineId('pipeline', 'version-1'),+ { wrapper },+ );++ await waitFor(() => expect(result.current.dsl).toEqual(versionDsl));+ expect(agentService.fetchVersion).toHaveBeenCalledWith(+ {+ agentId: 'pipeline',+ versionId: 'version-1',+ skipGlobalErrorNotification: true,+ },+ true,+ );+ expect(agentService.getBuiltinPipeline).not.toHaveBeenCalled();+ });++ it('fetches nothing while the pipeline has no concrete version id', () => {+ const { result } = renderHook(+ () => useFetchPipelineDslByPipelineId('pipeline', ''),+ { wrapper },+ );++ expect(result.current.dsl).toBeUndefined();+ expect(result.current.loading).toBe(false);+ expect(agentService.fetchVersion).not.toHaveBeenCalled();+ });++ it('does not retry when the pinned version is gone', async () => {+ agentService.fetchVersion.mockResolvedValue({+ data: { code: 404, message: 'version not found' },+ });++ const { result } = renderHook(+ () => useFetchPipelineDslByPipelineId('pipeline', 'version-gone'),+ { wrapper },+ );++ // Wait long enough for a retry to have fired if one were configured.+ await waitFor(() => expect(result.current.loading).toBe(false));+ expect(result.current.dsl).toBeUndefined();+ expect(agentService.fetchVersion).toHaveBeenCalledTimes(1);+ });+});++// Drives a real RHF form through the reset hook with scripted operatorNodes,+// so the "DSL still loading" (empty nodes) and "DSL arrived" paths can be+// replayed without any network.+function renderResetForm(initialProps: {+ pipelineId?: string;+ versionId?: string;+ savedPipelineId?: string;+ savedVersionId?: string;+ operatorNodes: OperatorNode[];+ initialParserConfig?: Record<string, any>;+}) {+ return renderHook(+ (props) => {+ const form = useForm<{ parser_config: Record<string, any> }>({+ defaultValues: { parser_config: props.initialParserConfig ?? {} },+ });+ useResetParserConfigOnPipelineChange({+ form,+ pipelineId: props.pipelineId,+ versionId: props.versionId,+ savedPipelineId: props.savedPipelineId,+ savedVersionId: props.savedVersionId,+ operatorNodes: props.operatorNodes,+ });+ return form;+ },+ { initialProps },+ );+}++const operatorNode = (+ operatorId: string,+ form: Record<string, any>,+): OperatorNode => ({ id: operatorId, data: { operatorId, form } });++const savedConfig = { 'Parser:parse': { parse_method: 'deepdoc' } };++describe('useResetParserConfigOnPipelineChange', () => {+ it('leaves parser_config untouched on the initial load of the saved binding', () => {+ const { result } = renderResetForm({+ pipelineId: 'pipeline',+ versionId: 'version-1',+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ operatorNodes: [operatorNode('Parser:parse', { parse_method: 'vision' })],+ initialParserConfig: savedConfig,+ });++ expect(result.current.getValues('parser_config')).toEqual(savedConfig);+ });++ it('keeps the saved parser_config across the latest-version prefill', () => {+ const nodes = [operatorNode('Parser:parse', { parse_method: 'vision' })];+ const { result, rerender } = renderResetForm({+ pipelineId: 'pipeline',+ versionId: '',+ savedPipelineId: 'pipeline',+ savedVersionId: '',+ operatorNodes: [],+ initialParserConfig: savedConfig,+ });+ expect(result.current.getValues('parser_config')).toEqual(savedConfig);++ // Prefill writes the latest concrete version id; the saved config must+ // survive because it predates the version concept.+ rerender({+ pipelineId: 'pipeline',+ versionId: 'version-latest',+ savedPipelineId: 'pipeline',+ savedVersionId: '',+ operatorNodes: [],+ initialParserConfig: savedConfig,+ });+ expect(result.current.getValues('parser_config')).toEqual(savedConfig);++ // The adopted version's DSL arriving changes nothing either.+ rerender({+ pipelineId: 'pipeline',+ versionId: 'version-latest',+ savedPipelineId: 'pipeline',+ savedVersionId: '',+ operatorNodes: nodes,+ initialParserConfig: savedConfig,+ });+ expect(result.current.getValues('parser_config')).toEqual(savedConfig);+ });++ it('reseeds parser_config from the new version after a version switch', () => {+ const nodesV1 = [operatorNode('Parser:parse', { parse_method: 'deepdoc' })];+ const nodesV2 = [operatorNode('Parser:parse', { parse_method: 'mineru' })];+ const base = {+ pipelineId: 'pipeline',+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ initialParserConfig: savedConfig,+ };+ const { result, rerender } = renderResetForm({+ ...base,+ versionId: 'version-1',+ operatorNodes: nodesV1,+ });+ expect(result.current.getValues('parser_config')).toEqual(savedConfig);++ // Switch to v2: the new DSL is still loading, so the stale config is+ // cleared first.+ rerender({ ...base, versionId: 'version-2', operatorNodes: [] });+ expect(result.current.getValues('parser_config')).toEqual({});++ // Once v2's DSL arrives, its defaults are seeded.+ rerender({ ...base, versionId: 'version-2', operatorNodes: nodesV2 });+ expect(result.current.getValues('parser_config')).toEqual({+ 'Parser:parse': { parse_method: 'mineru' },+ });+ });++ it('reseeds parser_config when switching to another pipeline', () => {+ const { result, rerender } = renderResetForm({+ pipelineId: 'pipeline-a',+ versionId: 'version-1',+ savedPipelineId: 'pipeline-a',+ savedVersionId: 'version-1',+ operatorNodes: [operatorNode('Parser:parse', {})],+ initialParserConfig: savedConfig,+ });++ rerender({+ pipelineId: 'pipeline-b',+ versionId: 'version-9',+ savedPipelineId: 'pipeline-a',+ savedVersionId: 'version-1',+ operatorNodes: [operatorNode('Tokenizer:tokenize', { model: 'gpt-4' })],+ initialParserConfig: savedConfig,+ });+ expect(result.current.getValues('parser_config')).toEqual({+ 'Tokenizer:tokenize': { model: 'gpt-4' },+ });+ });++ it('clears parser_config when the selection is cleared', () => {+ const { result, rerender } = renderResetForm({+ pipelineId: 'pipeline',+ versionId: 'version-1',+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ operatorNodes: [operatorNode('Parser:parse', {})],+ initialParserConfig: savedConfig,+ });++ rerender({+ pipelineId: undefined,+ versionId: undefined,+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ operatorNodes: [],+ initialParserConfig: savedConfig,+ });+ expect(result.current.getValues('parser_config')).toEqual({});+ });++ it('does not mistake a re-selection after clearing for a prefill', () => {+ const { result, rerender } = renderResetForm({+ pipelineId: 'pipeline',+ versionId: 'version-1',+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ operatorNodes: [operatorNode('Parser:parse', {})],+ initialParserConfig: savedConfig,+ });++ rerender({+ pipelineId: undefined,+ versionId: undefined,+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ operatorNodes: [],+ initialParserConfig: savedConfig,+ });++ // Re-selecting the same pipeline with the same version is a fresh user+ // choice, so the (cleared) config is reseeded from the DSL defaults.+ rerender({+ pipelineId: 'pipeline',+ versionId: 'version-1',+ savedPipelineId: 'pipeline',+ savedVersionId: 'version-1',+ operatorNodes: [operatorNode('Parser:parse', { parse_method: 'mineru' })],+ initialParserConfig: savedConfig,+ });+ expect(result.current.getValues('parser_config')).toEqual({+ 'Parser:parse': { parse_method: 'mineru' },+ });+ });+});diff --git a/web/src/hooks/use-agent-request.ts b/web/src/hooks/use-agent-request.tsindex eddb63b707..6363ba3c9e 100644--- a/web/src/hooks/use-agent-request.ts+++ b/web/src/hooks/use-agent-request.ts@@ -109,7 +109,6 @@ export const enum AgentApiAction {FetchSharedAgent = 'fetchSharedAgent',FetchAgentTags = 'fetchAgentTags',UpdateAgentTags = 'updateAgentTags',- FetchPipelineNodes = 'fetchPipelineNodes',FetchBuiltinPipelineList = 'fetchBuiltinPipelineList',FetchBuiltinPipelineDetail = 'fetchBuiltinPipelineDetail',}@@ -942,6 +941,34 @@ export const useUpdateVersion = () => {return { loading, isError, updateVersion: mutateAsync };};+// Shared query options for a single canvas version's detail (IFlow, dsl+// included). Both useFetchVersion (canvas version dialog) and+// useFetchPipelineDslByPipelineId (operator tabs) must cache the same shape+// under AgentKeys.version so they can share the entry safely.+const canvasVersionQuery = (agentId?: string, versionId?: string) => ({+ queryKey: AgentKeys.version(agentId, versionId),+ gcTime: 0,+ // A pruned version never recovers on retry, and each attempt would+ // re-fire the error path.+ retry: false,+ queryFn: async (): Promise<IFlow | undefined> => {+ if (!agentId || !versionId) return undefined;++ // Consumers render their own error/empty state, so suppress the global+ // notification whose "no permission" wording misleads here.+ const { data } = await agentService.fetchVersion(+ { agentId, versionId, skipGlobalErrorNotification: true },+ true,+ );++ if (data?.code !== 0) {+ throw new Error(data?.message);+ }++ return data?.data ?? undefined;+ },+});+export const useFetchVersion = (version_id?: string,): {@@ -955,33 +982,8 @@ export const useFetchVersion = (isFetching: loading,isError,} = useQuery({- queryKey: AgentKeys.version(id, version_id),- initialData: undefined,- gcTime: 0,- // A pruned version never recovers on retry, and each attempt would- // re-fire the global error notification.- retry: false,+ ...canvasVersionQuery(id, version_id),enabled: !!id && !!version_id,- queryFn: async () => {- if (!id || !version_id) return undefined;-- // The dialog renders its own error state, so suppress the global- // notification whose "no permission" wording misleads here.- const { data } = await agentService.fetchVersion(- {- agentId: id,- versionId: version_id,- skipGlobalErrorNotification: true,- },- true,- );-- if (data?.code !== 0) {- throw new Error(data?.message);- }-- return data?.data ?? undefined;- },});return { data, loading, isError };@@ -1462,25 +1464,32 @@ export const useExportAgentLog = () => {return { exportLogs: mutateAsync, loading };};+// useFetchPipelineDslByPipelineId loads the DSL that backs the pipeline+// operator tabs. Builtin pipelines have no version concept and are fetched+// directly; a dataflow pipeline is versioned, so its DSL comes from the+// selected canvas version — without a version id nothing is fetched and the+// tabs stay hidden.export const useFetchPipelineDslByPipelineId = (pipelineId?: string,+ versionId?: string,isBuiltin = false,) => {- const { data: dsl, isFetching: loading } = useQuery({- queryKey: isBuiltin- ? BuiltinPipelineKeys.detail(pipelineId!)- : [AgentApiAction.FetchPipelineNodes, pipelineId],- initialData: {},+ const { data: builtinDsl, isFetching: builtinLoading } = useQuery({+ queryKey: BuiltinPipelineKeys.detail(pipelineId!),gcTime: 0,- enabled: !!pipelineId,- queryFn: async () => {- const { data } = isBuiltin- ? await agentService.getBuiltinPipeline(pipelineId!)- : await agentService.getAgent(pipelineId!);- const flow = data?.data;- return flow?.dsl ?? {};+ enabled: isBuiltin && !!pipelineId,+ queryFn: async (): Promise<DSL | undefined> => {+ const { data } = await agentService.getBuiltinPipeline(pipelineId!);+ return data?.data?.dsl;},});+ const { data: version, isFetching: versionLoading } = useQuery({+ ...canvasVersionQuery(pipelineId, versionId),+ enabled: !isBuiltin && !!pipelineId && !!versionId,+ });- return { dsl, loading };+ return {+ dsl: isBuiltin ? builtinDsl : version?.dsl,+ loading: isBuiltin ? builtinLoading : versionLoading,+ };};diff --git a/web/src/hooks/use-pipeline-operator.ts b/web/src/hooks/use-pipeline-operator.tsindex f95e9fcd18..9cca997a11 100644--- a/web/src/hooks/use-pipeline-operator.ts+++ b/web/src/hooks/use-pipeline-operator.ts@@ -23,70 +23,125 @@ import {import { useEffect, useMemo, useRef, useState } from 'react';import { UseFormReturn } from 'react-hook-form';-export const usePipelineOperatorNodes = (- pipelineId?: string,- pipelineParserConfig?: Record<string, any>,+export const usePipelineOperatorNodes = ({+ pipelineId,+ versionId,+ savedParserConfig,isBuiltin = false,-) => {+}: {+ pipelineId?: string;+ // Selected canvas version id; ignored for builtin pipelines. Without it no+ // version is fetched and operatorNodes stays empty (tabs hidden).+ versionId?: string;+ // Saved parser_config, passed only while the selection still matches the+ // saved pipeline+version binding; otherwise defaults come from the DSL.+ savedParserConfig?: Record<string, any>;+ isBuiltin?: boolean;+}) => {const { dsl, loading } = useFetchPipelineDslByPipelineId(pipelineId,+ versionId,isBuiltin,);const operatorNodes = useMemo(() => {- return buildPipelineOperatorNodes(dsl, pipelineParserConfig);- }, [dsl, pipelineParserConfig]);+ return buildPipelineOperatorNodes(dsl, savedParserConfig);+ }, [dsl, savedParserConfig]);return { operatorNodes, loading };};/**- * Resets parser_config when the selected pipeline changes, so stale configs- * from the previous pipeline are never submitted. Once the new pipeline's- * DSL has loaded, parser_config is seeded with the DSL defaults (i.e. what- * the operator tabs display).+ * Resets parser_config when the selected pipeline binding (pipeline ++ * version) changes, so stale configs from the previous binding are never+ * submitted. Once the new version's DSL has loaded, parser_config is seeded+ * with the DSL defaults (i.e. what the operator tabs display).*- * The very first pipeline seen is treated as the initial load: the form was+ * The very first binding seen is treated as the initial load: the form was* already reset with the saved parser_config on mount, so it is left- * untouched.+ * untouched when pipeline and version both match the saved binding.+ *+ * A `'' → versionId` transition within the same pipeline is the latest-+ * version prefill adopting a concrete version for an unpinned binding, not a+ * user switch — parser_config (which still holds the saved values) must not+ * be reset.*/-export const useResetParserConfigOnPipelineChange = (- form: UseFormReturn<any>,- pipelineId: string | undefined,- savedPipelineId: string | undefined,- operatorNodes: RAGFlowNodeType[],-) => {- const previousPipelineIdRef = useRef<string>();+export const useResetParserConfigOnPipelineChange = ({+ form,+ pipelineId,+ versionId,+ savedPipelineId,+ savedVersionId,+ operatorNodes,+}: {+ form: UseFormReturn<any>;+ pipelineId: string | undefined;+ versionId: string | undefined;+ savedPipelineId: string | undefined;+ savedVersionId: string | undefined;+ operatorNodes: RAGFlowNodeType[];+}) => {+ const previousBindingRef = useRef<string>();useEffect(() => {if (!pipelineId) {// Selection cleared (e.g. parse type switched): drop configs that// belonged to the previously selected pipeline.- if (previousPipelineIdRef.current) {- previousPipelineIdRef.current = '';+ if (previousBindingRef.current) {+ previousBindingRef.current = '';form.setValue('parser_config', {});}return;}- const isInitialLoad =- previousPipelineIdRef.current === undefined &&- pipelineId === savedPipelineId;- if (isInitialLoad || previousPipelineIdRef.current === pipelineId) {- previousPipelineIdRef.current = pipelineId;+ const binding = `${pipelineId}::${versionId ?? ''}`;+ const previousBinding = previousBindingRef.current;+ if (previousBinding === binding) {return;}+ if (previousBinding === undefined) {+ // Initial load: the form was already reset with the saved+ // parser_config on mount, so leave it untouched when the selection+ // still matches the saved binding.+ const matchesSavedBinding =+ pipelineId === savedPipelineId &&+ (versionId ?? '') === (savedVersionId ?? '');+ if (matchesSavedBinding) {+ previousBindingRef.current = binding;+ return;+ }+ } else {+ // Prefill adoption: a `'' → versionId` transition within the same+ // pipeline is the latest-version prefill, never a user switch.+ const [prevPipelineId, prevVersionId] = previousBinding.split('::');+ const isPrefillAdoption =+ prevPipelineId === pipelineId && prevVersionId === '' && !!versionId;+ if (isPrefillAdoption) {+ previousBindingRef.current = binding;+ return;+ }+ }+if (operatorNodes.length === 0) {- // The new pipeline's DSL is still loading — clear the previous- // pipeline's configs right away; defaults are seeded once it arrives.+ // The new binding's DSL is still loading — clear the previous+ // configs right away but keep the previous binding in the ref, so+ // the arrival of operatorNodes re-fires this effect and seeds the+ // defaults then.form.setValue('parser_config', {});return;}- previousPipelineIdRef.current = pipelineId;+ previousBindingRef.current = binding;form.setValue('parser_config', buildParserConfigFromNodes(operatorNodes));- }, [form, pipelineId, savedPipelineId, operatorNodes]);+ }, [+ form,+ pipelineId,+ versionId,+ savedPipelineId,+ savedVersionId,+ operatorNodes,+ ]);};export const useActiveTab = (operatorNodes: RAGFlowNodeType[]) => {diff --git a/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.test.ts b/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.test.tsindex f15b6aa260..272b6b7b7a 100644--- a/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.test.ts+++ b/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.test.ts@@ -34,7 +34,11 @@ jest.mock('react-router', () => ({}));jest.mock('@/hooks/use-agent-request', () => ({- useFetchPipelineDslByPipelineId: (_id: string, isBuiltin: boolean) => ({+ useFetchPipelineDslByPipelineId: (+ _id: string,+ _versionId: string | undefined,+ isBuiltin: boolean,+ ) => ({dsl: isBuiltin ? mockBuiltinDsl : {},loading: false,}),diff --git a/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.ts b/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.tsindex 18757c758a..807c8f7383 100644--- a/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.ts+++ b/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.ts@@ -11,7 +11,7 @@ import { dslToGraph } from '../agent/utils/dsl-bridge';// the DSL from the built-in pipeline endpoint instead of a user agent.export const useFetchBuiltinPipelineDataOnMount = () => {const { id } = useParams();- const { dsl, loading } = useFetchPipelineDslByPipelineId(id, true);+ const { dsl, loading } = useFetchPipelineDslByPipelineId(id, undefined, true);const setGraphInfo = useSetGraphInfo();const setClickedNodeId = useGraphStore((state) => state.setClickedNodeId);diff --git a/web/src/pages/dataset/dataset/change-parser-dialog.test.tsx b/web/src/pages/dataset/dataset/change-parser-dialog.test.tsxindex 307c49c39e..99bc531e4a 100644--- a/web/src/pages/dataset/dataset/change-parser-dialog.test.tsx+++ b/web/src/pages/dataset/dataset/change-parser-dialog.test.tsx@@ -37,6 +37,9 @@ const mockDsl = {const mockBuiltinDsl =require('../../../../../internal/ingestion/pipeline/template/ingestion_pipeline_general.json').dsl;let mockCustomDsl = mockDsl;+// Per-version DSLs for the mocked pipeline; versions not listed here fall+// back to mockCustomDsl so existing single-version tests keep working.+let mockCustomDslByVersion: Record<string, typeof mockDsl> = {};// Published versions of the mocked pipeline; a test can empty this to model a// pinned version that has been pruned since the document was saved.let mockVersions: { id: string; title: string; created_at: string }[] = [@@ -44,8 +47,14 @@ let mockVersions: { id: string; title: string; created_at: string }[] = [];jest.mock('@/hooks/use-agent-request', () => ({- useFetchPipelineDslByPipelineId: (_id: string, isBuiltin: boolean) => ({- dsl: isBuiltin ? mockBuiltinDsl : mockCustomDsl,+ useFetchPipelineDslByPipelineId: (+ _id: string,+ versionId: string | undefined,+ isBuiltin: boolean,+ ) => ({+ dsl: isBuiltin+ ? mockBuiltinDsl+ : (mockCustomDslByVersion[versionId ?? ''] ?? mockCustomDsl),loading: false,}),// The mocked ParserTreeSelect below emits version-1 on every pipeline@@ -87,6 +96,8 @@ jest.mock('@/components/parser-tree-select', () => ({// A pipeline-side choice always carries a concrete version id: only// version leaves are selectable in the merged parser tree select.const choosePipeline = () => onChange('pipeline', 'pipeline', 'version-1');+ const choosePipelineV2 = () =>+ onChange('pipeline', 'pipeline', 'version-2');const chooseBuiltin = () => onChange('builtin', 'general');const clearParser = () => onChange(null, '');return (@@ -94,6 +105,9 @@ jest.mock('@/components/parser-tree-select', () => ({<button type="button" onClick={choosePipeline}>Choose pipeline</button>+ <button type="button" onClick={choosePipelineV2}>+ Choose pipeline v2+ </button><button type="button" onClick={chooseBuiltin}>Choose builtin</button>@@ -196,6 +210,7 @@ beforeEach(() => {mockSave.mockReset().mockResolvedValue(0);mockRun.mockReset().mockResolvedValue(0);mockCustomDsl = mockDsl;+ mockCustomDslByVersion = {};mockVersions = [{ id: 'version-1', title: 'v1', created_at: '' }];});@@ -336,6 +351,72 @@ it('still rejects a pipeline selection without a pipeline ID', async () => {expect(mockSave).not.toHaveBeenCalled();});+it('resets parser_config to the new version defaults after a version switch', async () => {+ mockVersions = [+ { id: 'version-2', title: 'v2', created_at: '' },+ { id: 'version-1', title: 'v1', created_at: '' },+ ];+ mockCustomDslByVersion = {+ 'version-1': mockDsl,+ 'version-2': {+ graph: {+ nodes: [+ { id: 'File', data: { form: {} } },+ {+ id: 'Compiler:compile',+ data: {+ form: {+ compilation_template_group_id: 'v2-template-group',+ llm_id: 'v2-model',+ },+ },+ },+ ],+ edges: [{ source: 'File', target: 'Compiler:compile' }],+ },+ },+ };+ renderHarness({ versionId: 'version-1' });+ fireEvent.click(screen.getByRole('button', { name: 'Open' }));+ fireEvent.click(screen.getByRole('button', { name: 'Choose pipeline v2' }));+ fireEvent.click(screen.getByRole('button', { name: 'common.save' }));+ await waitFor(() => expect(mockSave).toHaveBeenCalledTimes(1));+ expect(mockSave.mock.calls[0][0]).toEqual(+ expect.objectContaining({+ pipelineId: 'pipeline',+ pipelineVersionId: 'version-2',+ parserConfig: expect.objectContaining({+ // The saved 'document-model' pin belongs to version-1; after the+ // switch only version-2's DSL defaults remain.+ 'Compiler:compile': expect.objectContaining({+ compilation_template_group_id: 'v2-template-group',+ llm_id: 'v2-model',+ }),+ }),+ }),+ );+});++it('keeps the saved parser_config across the latest-version prefill', async () => {+ // Unpinned document: the form opens with an empty version and the prefill+ // adopts the latest one — the saved config must survive intact.+ renderHarness({});+ fireEvent.click(screen.getByRole('button', { name: 'Open' }));+ fireEvent.click(screen.getByRole('button', { name: 'common.save' }));+ await waitFor(() => expect(mockSave).toHaveBeenCalledTimes(1));+ expect(mockSave.mock.calls[0][0]).toEqual(+ expect.objectContaining({+ pipelineId: 'pipeline',+ pipelineVersionId: 'version-1',+ parserConfig: expect.objectContaining({+ 'Compiler:compile': expect.objectContaining({+ llm_id: 'document-model',+ }),+ }),+ }),+ );+});+it('blocks saving when the pinned pipeline version no longer exists', async () => {mockVersions = [];renderHarness({ versionId: 'version-1' });diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsxindex 0427b502ed..e30708e705 100644--- a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx+++ b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx@@ -11,6 +11,7 @@ jest.mock('./reparse-dialog', () => ({const mockRunDocumentByIds = jest.fn();const mockShowReparseDialog = jest.fn();+const mockUseDocumentPipelineVersion = jest.fn();jest.mock('./use-run-document', () => ({useHandleRunDocumentByIds: () => ({@@ -21,6 +22,11 @@ jest.mock('./use-run-document', () => ({}),}));+jest.mock('./use-document-pipeline-version', () => ({+ useDocumentPipelineVersion: (record: unknown) =>+ mockUseDocumentPipelineVersion(record),+}));+import { IngestionTaskStatus } from './constant';import { ParseDropdownButton, ParsingStatusCell } from './parsing-status-cell';import { TooltipProvider } from '@/components/ui/tooltip';@@ -84,6 +90,8 @@ describe('ParsingStatusCell', () => {beforeEach(() => {mockRunDocumentByIds.mockClear();mockShowReparseDialog.mockClear();+ mockUseDocumentPipelineVersion.mockReset();+ mockUseDocumentPipelineVersion.mockReturnValue(undefined);});it('shows the queued chip for CREATED tasks', () => {@@ -208,6 +216,41 @@ describe('ParsingStatusCell', () => {);}+ it('labels a pipeline document by its version title and alias', () => {+ mockUseDocumentPipelineVersion.mockReturnValue({+ id: 'v1',+ title: 'geek pipeline 2026-10-29 11:47:29',+ alias: '111',+ });+ renderDropdown({+ pipeline_id: 'canvas-1',+ pipeline_name: 'My pipeline',+ pipeline_version_id: 'v1',+ });++ expect(+ screen.getByText('geek pipeline 2026-10-29 11:47:29'),+ ).toBeInTheDocument();+ expect(screen.getByText('111')).toBeInTheDocument();+ expect(screen.queryByText('My pipeline')).not.toBeInTheDocument();+ });++ it('falls back to the pipeline name while the version is unresolved', () => {+ renderDropdown({+ pipeline_id: 'canvas-1',+ pipeline_name: 'My pipeline',+ pipeline_version_id: 'v1',+ });++ expect(screen.getByText('My pipeline')).toBeInTheDocument();+ });++ it('keeps the plain parser label for built-in parsers', () => {+ renderDropdown({ pipeline_id: '', chunk_method: 'naive' });++ expect(screen.getByText('General')).toBeInTheDocument();+ });+it('shows the outdated bang when the pinned pipeline version is not the latest', () => {renderDropdown({pipeline_id: 'canvas-1',diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.tsxindex 4563eba986..cfcdb3f6d3 100644--- a/web/src/pages/dataset/dataset/parsing-status-cell.tsx+++ b/web/src/pages/dataset/dataset/parsing-status-cell.tsx@@ -1,4 +1,5 @@import { IconFontFill } from '@/components/icon-font';+import { PipelineVersionLabel } from '@/components/pipeline-version-label';import { Button } from '@/components/ui/button';import {DropdownMenu,@@ -23,6 +24,7 @@ import { DocumentType, RunningStatus } from './constant';import { ParsingCard } from './parsing-card';import { ReparseDialog } from './reparse-dialog';import { UseChangeDocumentParserShowType } from './use-change-document-parser';+import { useDocumentPipelineVersion } from './use-document-pipeline-version';import { useHandleRunDocumentByIds } from './use-run-document';import {getDocumentParserLabel,@@ -74,11 +76,20 @@ export function ParseDropdownButton({} & UseChangeDocumentParserShowType) {const { t } = useTranslation();const parserLabel = getDocumentParserLabel(record);+ const version = useDocumentPipelineVersion(record);+ const isPipeline = !!record.pipeline_id;const handleShowChangeParserModal = useCallback(() => {showChangeParserModal(record);}, [record, showChangeParserModal]);+ // Pipeline documents are labeled by the version they parse with — the+ // version title plus its alias as secondary text, the same display the+ // parser tree select uses. While the version list is still loading, or when+ // the pinned version is gone, fall back to the pipeline name. Built-in+ // parsers keep the plain parser label.+ const versionTitle = version?.title ?? parserLabel;+return (<DropdownMenu><DropdownMenuTrigger asChild>@@ -86,11 +97,26 @@ export function ParseDropdownButton({<Tooltip><TooltipTrigger asChild><Button variant="static" size="auto">- {parserLabel}+ {isPipeline ? (+ <PipelineVersionLabel+ title={versionTitle}+ alias={version?.alias}+ className="max-w-72"+ />+ ) : (+ parserLabel+ )}</Button></TooltipTrigger><TooltipContent>- <p>{parserLabel}</p>+ {isPipeline ? (+ <div>+ <p>{versionTitle}</p>+ {version?.alias ? <p>{version.alias}</p> : null}+ </div>+ ) : (+ <p>{parserLabel}</p>+ )}</TooltipContent></Tooltip>{record.pipeline_version_outdated ? (diff --git a/web/src/pages/dataset/dataset/use-document-pipeline-version.test.ts b/web/src/pages/dataset/dataset/use-document-pipeline-version.test.tsnew file mode 100644index 0000000000..0817b92457--- /dev/null+++ b/web/src/pages/dataset/dataset/use-document-pipeline-version.test.ts@@ -0,0 +1,73 @@+import { renderHook } from '@testing-library/react';++const mockUseFetchCanvasVersionList = jest.fn();++jest.mock('@/hooks/use-agent-request', () => ({+ useFetchCanvasVersionList: (canvasId?: string) =>+ mockUseFetchCanvasVersionList(canvasId),+}));++import { useDocumentPipelineVersion } from './use-document-pipeline-version';++const versions = [+ { id: 'v2', title: 'newest', created_at: '2026-10-29' },+ { id: 'v1', title: 'older', created_at: '2026-10-28', alias: '111' },+];++describe('useDocumentPipelineVersion', () => {+ beforeEach(() => {+ mockUseFetchCanvasVersionList.mockReset();+ // Mirrors useFetchCanvasVersionList: a disabled query (no canvas id)+ // never produces data.+ mockUseFetchCanvasVersionList.mockImplementation((canvasId?: string) => ({+ data: canvasId ? versions : undefined,+ }));+ });++ it('returns the pinned version', () => {+ const { result } = renderHook(() =>+ useDocumentPipelineVersion({+ pipeline_id: 'canvas-1',+ pipeline_version_id: 'v1',+ }),+ );++ expect(mockUseFetchCanvasVersionList).toHaveBeenCalledWith('canvas-1');+ expect(result.current?.id).toBe('v1');+ expect(result.current?.alias).toBe('111');+ });++ it('tracks the latest version when nothing is pinned', () => {+ const { result } = renderHook(() =>+ useDocumentPipelineVersion({+ pipeline_id: 'canvas-1',+ pipeline_version_id: '',+ }),+ );++ expect(result.current?.id).toBe('v2');+ });++ it('resolves to undefined when the pinned version is gone', () => {+ const { result } = renderHook(() =>+ useDocumentPipelineVersion({+ pipeline_id: 'canvas-1',+ pipeline_version_id: 'deleted',+ }),+ );++ expect(result.current).toBeUndefined();+ });++ it('stays disabled for built-in parser documents', () => {+ const { result } = renderHook(() =>+ useDocumentPipelineVersion({+ pipeline_id: '',+ pipeline_version_id: '',+ }),+ );++ expect(mockUseFetchCanvasVersionList).toHaveBeenCalledWith(undefined);+ expect(result.current).toBeUndefined();+ });+});diff --git a/web/src/pages/dataset/dataset/use-document-pipeline-version.ts b/web/src/pages/dataset/dataset/use-document-pipeline-version.tsnew file mode 100644index 0000000000..c6de7d2431--- /dev/null+++ b/web/src/pages/dataset/dataset/use-document-pipeline-version.ts@@ -0,0 +1,20 @@+import { useFetchCanvasVersionList } from '@/hooks/use-agent-request';+import { IDocumentInfo } from '@/interfaces/database/document';++// Resolves the published pipeline version a document parses with, so the parse+// column can show the version title/alias instead of the pipeline name. The+// version list query is keyed by canvas id, so rows sharing a pipeline share+// one fetch. A document without a pinned version tracks the latest published+// version (the list is newest-first); a pinned version that no longer exists+// resolves to undefined and the caller falls back to the pipeline name.+export const useDocumentPipelineVersion = (+ record: Pick<IDocumentInfo, 'pipeline_id' | 'pipeline_version_id'>,+) => {+ const { data: versions } = useFetchCanvasVersionList(+ record.pipeline_id || undefined,+ );++ return record.pipeline_version_id+ ? versions?.find((item) => item.id === record.pipeline_version_id)+ : versions?.[0];+};diff --git a/web/src/pages/dataset/dataset/utils.ts b/web/src/pages/dataset/dataset/utils.tsindex 6583a02528..97ae03fad7 100644--- a/web/src/pages/dataset/dataset/utils.ts+++ b/web/src/pages/dataset/dataset/utils.ts@@ -86,10 +86,12 @@ export const getDocumentProgressMessage = () => document.latest_ingestion_event?.message || '-';/**- * Label shown in the dataset table's parse column. A built-in pipeline renders- * its parser id with the first letter capitalized ("general" -> "General"); a- * canvas pipeline keeps the user-chosen title (falling back to the raw id)- * untouched. "naive" is the legacy alias of the built-in general pipeline.+ * Parser label for a document. A built-in pipeline renders its parser id with+ * the first letter capitalized ("general" -> "General"); a canvas pipeline+ * keeps the user-chosen title (falling back to the raw id) untouched. "naive"+ * is the legacy alias of the built-in general pipeline. The parse column shows+ * this for built-in parsers, and as the fallback for pipeline documents until+ * their pipeline version resolves (see useDocumentPipelineVersion).*/export const getDocumentParserLabel = (document: Pick<diff --git a/web/src/pages/dataset/setting/index.tsx b/web/src/pages/dataset/setting/index.tsxindex e598b78010..5db3cd8600 100644--- a/web/src/pages/dataset/setting/index.tsx+++ b/web/src/pages/dataset/setting/index.tsx@@ -179,6 +179,9 @@ export default function DatasetSetting() {? knowledgeDetails?.pipeline_id: knowledgeDetails?.parser_id: undefined;+ const savedVersionId = isPipelineMode+ ? (knowledgeDetails?.pipeline_version_id ?? '')+ : '';// Published versions of the selected dataflow canvas, fetched here only to// prefill the latest version for unpinned datasets (design C1/C2); the@@ -201,21 +204,33 @@ export default function DatasetSetting() {canvasVersions?.[0]?.id,);+ // The saved parser_config overrides the DSL defaults only while the+ // selection matches the saved pipeline+version binding; a different version+ // renders that version's own DSL defaults. (The form's parser_config stays+ // the display source of truth via operatorValues either way.)+ const isSavedBindingSelected =+ !!selectedPipelineId &&+ selectedPipelineId === savedPipelineId &&+ (pipelineVersionId ?? '') === savedVersionId;+const { operatorNodes, loading: operatorNodesLoading } =- usePipelineOperatorNodes(- selectedPipelineId,- selectedPipelineId && selectedPipelineId === savedPipelineId+ usePipelineOperatorNodes({+ pipelineId: selectedPipelineId,+ versionId: isPipelineMode ? pipelineVersionId : undefined,+ savedParserConfig: isSavedBindingSelected? pipelineParserConfig: undefined,- !isPipelineMode,- );+ isBuiltin: !isPipelineMode,+ });- useResetParserConfigOnPipelineChange(+ useResetParserConfigOnPipelineChange({form,- selectedPipelineId,+ pipelineId: selectedPipelineId,+ versionId: isPipelineMode ? pipelineVersionId : undefined,savedPipelineId,+ savedVersionId: isPipelineMode ? savedVersionId : undefined,operatorNodes,- );+ });const { activeTab, setActiveTab } = useActiveTab(operatorNodes);