Skip to content

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

Feat: Display the built-in pipeline canvas in read-only mode. (#20742)

balibabu992577d1b045
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_audio.json b/internal/ingestion/pipeline/template/ingestion_pipeline_audio.json
index a994404a92..6ef1d0b73d 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_audio.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_audio.json
@@ -194,7 +194,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -246,12 +246,12 @@
"dragging": false,
"id": "Parser:SongsFillAir",
"measured": {
- "height": 57,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -273,12 +273,12 @@
},
"id": "OneChunker:BlueSkiesLaugh",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -301,12 +301,12 @@
},
"id": "Tokenizer:KindEyesWatch",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -315,9 +315,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_book.json b/internal/ingestion/pipeline/template/ingestion_pipeline_book.json
index 60319e2f57..844e039c79 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_book.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_book.json
@@ -255,7 +255,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -343,12 +343,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 97,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 176
},
"selected": false,
"sourcePosition": "right",
@@ -464,12 +464,12 @@
},
"id": "TitleChunker:GrumpyGarlicsBake",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -492,12 +492,12 @@
},
"id": "Tokenizer:HotDonutsRing",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -506,9 +506,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_email.json b/internal/ingestion/pipeline/template/ingestion_pipeline_email.json
index e2f42542a5..d3e23b5128 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_email.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_email.json
@@ -199,7 +199,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -261,12 +261,12 @@
"dragging": false,
"id": "Parser:BirdsFlutterHigh",
"measured": {
- "height": 57,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -310,12 +310,12 @@
},
"id": "TokenChunker:WarmBreadSmells",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -338,12 +338,12 @@
},
"id": "Tokenizer:NiceWordsSpoken",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -352,9 +352,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_general.json b/internal/ingestion/pipeline/template/ingestion_pipeline_general.json
index 1edd9a70b4..bc62e676f4 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_general.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_general.json
@@ -265,7 +265,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -351,12 +351,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 121,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 164
},
"selected": true,
"sourcePosition": "right",
@@ -408,12 +408,12 @@
},
"id": "GeneralChunker:SixApplesFall",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -436,12 +436,12 @@
},
"id": "Tokenizer:LegalReadersDecide",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -450,9 +450,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_laws.json b/internal/ingestion/pipeline/template/ingestion_pipeline_laws.json
index 9ce7847c31..9854cb6d18 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_laws.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_laws.json
@@ -271,7 +271,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -362,12 +362,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 97,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 176
},
"selected": false,
"sourcePosition": "right",
@@ -483,12 +483,12 @@
},
"id": "TitleChunker:SpicyKeysKick",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -511,12 +511,12 @@
},
"id": "Tokenizer:PublicJobsTake",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"selected": true,
"sourcePosition": "right",
@@ -526,9 +526,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_manual.json b/internal/ingestion/pipeline/template/ingestion_pipeline_manual.json
index ef65faa8b6..0dbd509e15 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_manual.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_manual.json
@@ -235,7 +235,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -304,12 +304,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -425,12 +425,12 @@
},
"id": "ManualChunker:NineInsectsFind",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -453,12 +453,12 @@
},
"id": "Tokenizer:FunnyBalloonsGrin",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -467,9 +467,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_one.json b/internal/ingestion/pipeline/template/ingestion_pipeline_one.json
index 4503cecd25..8cbe03276c 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_one.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_one.json
@@ -248,7 +248,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -348,12 +348,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 121,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 164
},
"selected": false,
"sourcePosition": "right",
@@ -375,12 +375,12 @@
},
"id": "OneChunker:DryDrinksVisit",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -403,12 +403,12 @@
},
"id": "Tokenizer:FrankWeeksListen",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -417,9 +417,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_paper.json b/internal/ingestion/pipeline/template/ingestion_pipeline_paper.json
index 14922f6afb..43e15deb1f 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_paper.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_paper.json
@@ -219,7 +219,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -275,12 +275,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 198,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -396,12 +396,12 @@
},
"id": "TitleChunker:SparklySchoolsTravel",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -424,12 +424,12 @@
},
"id": "Tokenizer:GreatCarsWash",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"selected": false,
"sourcePosition": "right",
@@ -439,9 +439,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_picture.json b/internal/ingestion/pipeline/template/ingestion_pipeline_picture.json
index a03c537829..c26705b2a1 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_picture.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_picture.json
@@ -208,7 +208,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -268,12 +268,12 @@
"dragging": false,
"id": "Parser:ViewsCaptureLight",
"measured": {
- "height": 57,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -295,12 +295,12 @@
},
"id": "OneChunker:BrightColorsGlow",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -323,12 +323,12 @@
},
"id": "Tokenizer:SharpLensFocus",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -337,9 +337,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json b/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
index 1112f9ee52..3a8660dd2c 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
@@ -194,7 +194,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -257,12 +257,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -284,12 +284,12 @@
},
"id": "PageChunker:HappyHillsGlow",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -312,12 +312,12 @@
},
"id": "Tokenizer:TallTreesDance",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
- "x": 916.9952409420641,
- "y": 195.39629819663406
+ "x": 1216.9952409420641,
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
@@ -326,9 +326,13 @@
{
"id": "Extractor:AutoExtractDefault",
"type": "contextNode",
+ "measured": {
+ "height": 59,
+ "width": 200
+ },
"position": {
- "x": 796.9952409420641,
- "y": 195.39629819663406
+ "x": 916.9952409420641,
+ "y": 195
},
"data": {
"label": "Extractor",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_qa.json b/internal/ingestion/pipeline/template/ingestion_pipeline_qa.json
index d1a0c8cc91..a9c6f73430 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_qa.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_qa.json
@@ -191,7 +191,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -281,12 +281,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 121,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 164
},
"selected": true,
"sourcePosition": "right",
@@ -308,12 +308,12 @@
},
"id": "QAChunker:TidyCloudsThink",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -336,12 +336,12 @@
},
"id": "Tokenizer:ColdCloudsDream",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
"x": 916.9952409420641,
- "y": 195.39629819663406
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
diff --git a/internal/ingestion/pipeline/template/ingestion_pipeline_table.json b/internal/ingestion/pipeline/template/ingestion_pipeline_table.json
index e8235a309b..f2555ba2c4 100644
--- a/internal/ingestion/pipeline/template/ingestion_pipeline_table.json
+++ b/internal/ingestion/pipeline/template/ingestion_pipeline_table.json
@@ -158,7 +158,7 @@
},
"id": "File",
"measured": {
- "height": 50,
+ "height": 49,
"width": 200
},
"position": {
@@ -220,12 +220,12 @@
"dragging": false,
"id": "Parser:HipSignsRhyme",
"measured": {
- "height": 57,
+ "height": 73,
"width": 200
},
"position": {
"x": 316.99524094206413,
- "y": 195.39629819663406
+ "y": 188
},
"selected": true,
"sourcePosition": "right",
@@ -247,12 +247,12 @@
},
"id": "TableChunker:FastFoxesJump",
"measured": {
- "height": 74,
+ "height": 73,
"width": 200
},
"position": {
"x": 616.9952409420641,
- "y": 195.39629819663406
+ "y": 188
},
"selected": false,
"sourcePosition": "right",
@@ -275,12 +275,12 @@
},
"id": "Tokenizer:DeepLakesShine",
"measured": {
- "height": 114,
+ "height": 113,
"width": 200
},
"position": {
"x": 916.9952409420641,
- "y": 195.39629819663406
+ "y": 168
},
"sourcePosition": "right",
"targetPosition": "left",
diff --git a/web/src/hooks/logic-hooks/navigate-hooks.ts b/web/src/hooks/logic-hooks/navigate-hooks.ts
index f53d814993..e2999f31ca 100644
--- a/web/src/hooks/logic-hooks/navigate-hooks.ts
+++ b/web/src/hooks/logic-hooks/navigate-hooks.ts
@@ -125,6 +125,18 @@ export const useNavigatePage = () => {
[navigate],
);
+ // Built-in pipelines open on the dedicated read-only canvas, not on the
+ // editing canvas. The dataflow_canvas category query keeps the pipeline
+ // rendering semantics (handle topology, node forms) identical to editing.
+ const navigateToBuiltinPipeline = useCallback(
+ (id: string) => () => {
+ navigate(
+ `${Routes.Pipeline}/${id}?${AgentQuery.Category}=${AgentCategory.DataflowCanvas}`,
+ );
+ },
+ [navigate],
+ );
+
const navigateToAgentExplore = useCallback(
(id: string) => () => {
navigate(`${Routes.Agent}/${id}/explore`);
@@ -251,6 +263,7 @@ export const useNavigatePage = () => {
navigateToAgentExplore,
navigateToAgentLogs,
navigateToAgentTemplates,
+ navigateToBuiltinPipeline,
navigateToSearchList,
navigateToSearch,
navigateToFiles,
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 95ad3cca29..84a4f2ac8e 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -51,6 +51,7 @@ export default {
languagePlaceholder: 'select your language',
copy: 'Copy',
copied: 'Copied',
+ readOnly: 'Read-only',
viewMore: 'View more',
viewLess: 'View less',
comingSoon: 'Coming soon',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index a887e91174..6b8218e2fc 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -40,6 +40,7 @@ export default {
languagePlaceholder: '请选择语言',
copy: '复制',
copied: '复制成功',
+ readOnly: '只读',
viewMore: '查看更多',
viewLess: '收起',
comingSoon: '即将推出',
diff --git a/web/src/pages/agent/canvas/edge/readonly-edge.test.tsx b/web/src/pages/agent/canvas/edge/readonly-edge.test.tsx
new file mode 100644
index 0000000000..fc229e35ad
--- /dev/null
+++ b/web/src/pages/agent/canvas/edge/readonly-edge.test.tsx
@@ -0,0 +1,41 @@
+import { render } from '@testing-library/react';
+import { Position } from '@xyflow/react';
+import { ReadonlyEdge } from './readonly-edge';
+
+// Minimal EdgeProps payload; BaseEdge only needs the geometry to build the
+// bezier path.
+const baseEdgeProps: any = {
+ id: 'edge-1',
+ source: 'File',
+ target: 'Parser:1',
+ sourceX: 0,
+ sourceY: 0,
+ targetX: 100,
+ targetY: 100,
+ sourcePosition: Position.Right,
+ targetPosition: Position.Left,
+};
+
+describe('ReadonlyEdge', () => {
+ it('renders the edge path without any delete button', () => {
+ const { container } = render(
+ <svg>
+ <ReadonlyEdge {...baseEdgeProps} />
+ </svg>,
+ );
+
+ expect(container.querySelector('path')).not.toBeNull();
+ expect(container.querySelector('button')).toBeNull();
+ });
+
+ it('highlights with the selected marker when selected', () => {
+ const { container } = render(
+ <svg>
+ <ReadonlyEdge {...baseEdgeProps} selected />
+ </svg>,
+ );
+
+ const path = container.querySelector('path');
+ expect(path?.getAttribute('marker-end')).toBe('url(#selected-marker)');
+ });
+});
diff --git a/web/src/pages/agent/canvas/edge/readonly-edge.tsx b/web/src/pages/agent/canvas/edge/readonly-edge.tsx
new file mode 100644
index 0000000000..c146a534e6
--- /dev/null
+++ b/web/src/pages/agent/canvas/edge/readonly-edge.tsx
@@ -0,0 +1,45 @@
+import { cn } from '@/lib/utils';
+import { BaseEdge, Edge, EdgeProps, getBezierPath } from '@xyflow/react';
+import { memo, useMemo } from 'react';
+
+// ReadonlyEdge renders an edge on the read-only canvas (e.g. the built-in
+// pipeline preview). It keeps the path, arrow marker and selection highlight
+// of ButtonEdge but drops the delete button and the run-path highlight —
+// the latter would call useFetchAgent with a built-in pipeline id and 404.
+function InnerReadonlyEdge({
+ sourceX,
+ sourceY,
+ targetX,
+ targetY,
+ sourcePosition,
+ targetPosition,
+ style = {},
+ markerEnd,
+ selected,
+}: EdgeProps<Edge>) {
+ const [edgePath] = getBezierPath({
+ sourceX,
+ sourceY,
+ sourcePosition,
+ targetX,
+ targetY,
+ targetPosition,
+ });
+
+ const selectedStyle = useMemo(() => {
+ return selected
+ ? { strokeWidth: 1, stroke: 'rgb(var(--accent-primary))' }
+ : {};
+ }, [selected]);
+
+ return (
+ <BaseEdge
+ path={edgePath}
+ markerEnd={selected ? 'url(#selected-marker)' : markerEnd}
+ style={{ ...style, ...selectedStyle }}
+ className={cn('text-text-disabled')}
+ />
+ );
+}
+
+export const ReadonlyEdge = memo(InnerReadonlyEdge);
diff --git a/web/src/pages/agent/canvas/index.tsx b/web/src/pages/agent/canvas/index.tsx
index 41aee17311..b8f1f97207 100644
--- a/web/src/pages/agent/canvas/index.tsx
+++ b/web/src/pages/agent/canvas/index.tsx
@@ -24,6 +24,7 @@ import {
AgentChatContext,
AgentChatLogContext,
AgentInstanceContext,
+ CanvasReadonlyContext,
HandleContext,
} from '../context';
@@ -54,6 +55,7 @@ import { useStopMessageUnmount } from '../hooks/use-stop-message';
import { LogSheet } from '../log-sheet';
import RunSheet from '../run-sheet';
import { ButtonEdge } from './edge';
+import { ReadonlyEdge } from './edge/readonly-edge';
import styles from './index.module.less';
import { RagNode } from './node';
import { AgentNode } from './node/agent-node';
@@ -117,12 +119,28 @@ const edgeTypes = {
buttonEdge: ButtonEdge,
};
+// ReadonlyEdgeTypes swaps ButtonEdge for ReadonlyEdge on the read-only canvas.
+// The mapping covers both the persisted edge `type: 'buttonEdge'` in DSL graph
+// data and `defaultEdgeOptions.type`, so every edge renders without the delete
+// button and without ButtonEdge's useFetchAgent call (a built-in pipeline id
+// would 404 against GET /agents/:id).
+const ReadonlyEdgeTypes = {
+ buttonEdge: ReadonlyEdge,
+};
+
interface IProps {
- drawerVisible: boolean;
- hideDrawer(): void;
+ drawerVisible?: boolean;
+ hideDrawer?: () => void;
+ readOnly?: boolean;
}
-function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {
+const NoopDrawer = () => {};
+
+function AgentCanvas({
+ drawerVisible = false,
+ hideDrawer = NoopDrawer,
+ readOnly = false,
+}: IProps) {
const { t } = useTranslation();
const {
nodes,
@@ -338,143 +356,150 @@ function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {
</marker>
</defs>
</svg>
- <AgentInstanceContext.Provider
- value={{
- addCanvasNode,
- showFormDrawer,
- lastNode,
- currentSendLoading,
- startButNotFinishedNodeIds,
- }}
- >
- <ReactFlow
- connectionMode={ConnectionMode.Loose}
- nodes={nodes}
- onNodesChange={onNodesChange}
- edges={edges}
- onEdgesChange={onEdgesChange}
- fitView
- onConnect={handleConnect}
- nodeTypes={nodeTypes}
- edgeTypes={edgeTypes}
- onConnectStart={onConnectStart}
- onConnectEnd={onConnectEnd}
- onMove={onMove}
- onNodeClick={onNodeClick}
- onPaneClick={onPaneClick}
- onInit={setReactFlowInstance}
- onSelectionChange={onSelectionChange}
- nodeOrigin={[0.5, 0]}
- isValidConnection={isValidConnection}
- onEdgeMouseEnter={onEdgeMouseEnter}
- onEdgeMouseLeave={onEdgeMouseLeave}
- className="h-full"
- colorMode={theme}
- defaultEdgeOptions={{
- type: 'buttonEdge',
- markerEnd: 'logo',
- zIndex: 1001, // https://github.com/xyflow/xyflow/discussions/3498
+ <CanvasReadonlyContext.Provider value={readOnly}>
+ <AgentInstanceContext.Provider
+ value={{
+ addCanvasNode,
+ showFormDrawer,
+ lastNode,
+ currentSendLoading,
+ startButNotFinishedNodeIds,
}}
- deleteKeyCode={['Delete', 'Backspace']}
- onBeforeDelete={handleBeforeDelete}
- panActivationKeyCode={null}
>
- <AgentBackground></AgentBackground>
- <Spotlight className="z-0" opcity={0.7} coverage={70} />
- <Controls
- position={'bottom-center'}
- orientation="horizontal"
- className="bg-bg-base px-4 py-2 h-auto w-auto [&>button]:bg-transparent [&>button]:border-0 [&>button]:text-text-primary [&>button]:hover:bg-bg-base-hover [&>button]:hover:text-text-primary [&>button]:active:bg-bg-base-active [&>button]:p-0 [&>button]:size-4 gap-2.5 rounded-md"
+ <ReactFlow
+ connectionMode={ConnectionMode.Loose}
+ nodes={nodes}
+ onNodesChange={onNodesChange}
+ edges={edges}
+ onEdgesChange={onEdgesChange}
+ fitView
+ onConnect={readOnly ? undefined : handleConnect}
+ nodeTypes={nodeTypes}
+ edgeTypes={readOnly ? ReadonlyEdgeTypes : edgeTypes}
+ onConnectStart={readOnly ? undefined : onConnectStart}
+ onConnectEnd={readOnly ? undefined : onConnectEnd}
+ onMove={onMove}
+ onNodeClick={onNodeClick}
+ onPaneClick={onPaneClick}
+ onInit={setReactFlowInstance}
+ onSelectionChange={onSelectionChange}
+ nodeOrigin={[0.5, 0]}
+ isValidConnection={isValidConnection}
+ onEdgeMouseEnter={onEdgeMouseEnter}
+ onEdgeMouseLeave={onEdgeMouseLeave}
+ className="h-full"
+ colorMode={theme}
+ defaultEdgeOptions={{
+ type: 'buttonEdge',
+ markerEnd: 'logo',
+ zIndex: 1001, // https://github.com/xyflow/xyflow/discussions/3498
+ }}
+ nodesDraggable={!readOnly}
+ nodesConnectable={!readOnly}
+ deleteKeyCode={readOnly ? null : ['Delete', 'Backspace']}
+ onBeforeDelete={handleBeforeDelete}
+ panActivationKeyCode={null}
>
- <ControlButton>
- <Tooltip>
- <TooltipTrigger asChild>
- <NotebookPen className="!fill-none" onClick={showImage} />
- </TooltipTrigger>
- <TooltipContent>{t('flow.note')}</TooltipContent>
- </Tooltip>
- </ControlButton>
- </Controls>
- </ReactFlow>
- {visible && (
- <HandleContext.Provider
- value={
- getConnectionStartContext() || {
- nodeId: '',
- id: '',
- type: 'source',
- position: Position.Right,
- isFromConnectionDrag: true,
+ <AgentBackground></AgentBackground>
+ <Spotlight className="z-0" opcity={0.7} coverage={70} />
+ <Controls
+ position={'bottom-center'}
+ orientation="horizontal"
+ className="bg-bg-base px-4 py-2 h-auto w-auto [&>button]:bg-transparent [&>button]:border-0 [&>button]:text-text-primary [&>button]:hover:bg-bg-base-hover [&>button]:hover:text-text-primary [&>button]:active:bg-bg-base-active [&>button]:p-0 [&>button]:size-4 gap-2.5 rounded-md"
+ >
+ {!readOnly && (
+ <ControlButton>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <NotebookPen className="!fill-none" onClick={showImage} />
+ </TooltipTrigger>
+ <TooltipContent>{t('flow.note')}</TooltipContent>
+ </Tooltip>
+ </ControlButton>
+ )}
+ </Controls>
+ </ReactFlow>
+ {!readOnly && visible && (
+ <HandleContext.Provider
+ value={
+ getConnectionStartContext() || {
+ nodeId: '',
+ id: '',
+ type: 'source',
+ position: Position.Right,
+ isFromConnectionDrag: true,
+ }
}
- }
- >
- <NextStepDropdown
- hideModal={() => {
- removePlaceholderNode();
- hideModal();
- clearActiveDropdown();
- }}
- position={dropdownPosition}
- onNodeCreated={onNodeCreated}
- nodeId={nodeId}
>
- <span></span>
- </NextStepDropdown>
- </HandleContext.Provider>
- )}
- </AgentInstanceContext.Provider>
- <NotebookPen
- className={cn('hidden absolute size-6', { block: imgVisible })}
- ref={ref}
- ></NotebookPen>
- {formDrawerVisible && (
- <AgentInstanceContext.Provider
- value={{ addCanvasNode, showFormDrawer }}
- >
- <FormSheet
- node={clickedNode}
- visible={formDrawerVisible}
- hideModal={hideFormDrawer}
- chatVisible={chatVisible}
- singleDebugDrawerVisible={singleDebugDrawerVisible}
- hideSingleDebugDrawer={hideSingleDebugDrawer}
- showSingleDebugDrawer={showSingleDebugDrawer}
- ></FormSheet>
+ <NextStepDropdown
+ hideModal={() => {
+ removePlaceholderNode();
+ hideModal();
+ clearActiveDropdown();
+ }}
+ position={dropdownPosition}
+ onNodeCreated={onNodeCreated}
+ nodeId={nodeId}
+ >
+ <span></span>
+ </NextStepDropdown>
+ </HandleContext.Provider>
+ )}
</AgentInstanceContext.Provider>
- )}
+ <NotebookPen
+ className={cn('hidden absolute size-6', { block: imgVisible })}
+ ref={ref}
+ ></NotebookPen>
+ {formDrawerVisible && (
+ <AgentInstanceContext.Provider
+ value={{ addCanvasNode, showFormDrawer }}
+ >
+ <FormSheet
+ node={clickedNode}
+ visible={formDrawerVisible}
+ hideModal={hideFormDrawer}
+ chatVisible={chatVisible}
+ singleDebugDrawerVisible={singleDebugDrawerVisible}
+ hideSingleDebugDrawer={hideSingleDebugDrawer}
+ showSingleDebugDrawer={showSingleDebugDrawer}
+ readOnly={readOnly}
+ ></FormSheet>
+ </AgentInstanceContext.Provider>
+ )}
- {chatVisible && (
- <AgentChatContext.Provider
- value={{ showLogSheet, setLastSendLoadingFunc, setDerivedMessages }}
- >
- <AgentChatLogContext.Provider
- value={{ addEventList, setCurrentMessageId }}
+ {chatVisible && (
+ <AgentChatContext.Provider
+ value={{ showLogSheet, setLastSendLoadingFunc, setDerivedMessages }}
>
- <ChatSheet
- hideModal={() => {
- hideRunOrChatDrawer();
- hideLogSheet();
- }}
- ></ChatSheet>
- </AgentChatLogContext.Provider>
- </AgentChatContext.Provider>
- )}
- {runVisible && (
- <RunSheet
- hideModal={hideRunOrChatDrawer}
- showModal={showChatModal}
- ></RunSheet>
- )}
- {logSheetVisible && (
- <LogSheet
- hideModal={hideLogSheet}
- currentEventListWithoutMessageById={
- currentEventListWithoutMessageById
- }
- currentMessageId={currentMessageId}
- sendLoading={lastSendLoading}
- ></LogSheet>
- )}
+ <AgentChatLogContext.Provider
+ value={{ addEventList, setCurrentMessageId }}
+ >
+ <ChatSheet
+ hideModal={() => {
+ hideRunOrChatDrawer();
+ hideLogSheet();
+ }}
+ ></ChatSheet>
+ </AgentChatLogContext.Provider>
+ </AgentChatContext.Provider>
+ )}
+ {runVisible && (
+ <RunSheet
+ hideModal={hideRunOrChatDrawer}
+ showModal={showChatModal}
+ ></RunSheet>
+ )}
+ {logSheetVisible && (
+ <LogSheet
+ hideModal={hideLogSheet}
+ currentEventListWithoutMessageById={
+ currentEventListWithoutMessageById
+ }
+ currentMessageId={currentMessageId}
+ sendLoading={lastSendLoading}
+ ></LogSheet>
+ )}
+ </CanvasReadonlyContext.Provider>
</div>
);
}
diff --git a/web/src/pages/agent/canvas/node/handle.tsx b/web/src/pages/agent/canvas/node/handle.tsx
index 38bcb0b7ee..cd3ed06c7b 100644
--- a/web/src/pages/agent/canvas/node/handle.tsx
+++ b/web/src/pages/agent/canvas/node/handle.tsx
@@ -4,7 +4,7 @@ import { Handle, HandleProps, Position } from '@xyflow/react';
import { Plus, ChevronDown } from 'lucide-react';
import { useMemo, type MouseEvent } from 'react';
import { NodeHandleId } from '../../constant';
-import { HandleContext } from '../../context';
+import { HandleContext, useCanvasReadonly } from '../../context';
import { useIsPipeline } from '../../hooks/use-is-pipeline';
import useGraphStore from '../../store';
import { useDropdownManager } from '../context';
@@ -22,6 +22,7 @@ export function CommonHandle({
(state) => state,
);
const isPipeline = useIsPipeline();
+ const readOnly = useCanvasReadonly();
let isConnectable = true;
@@ -48,7 +49,7 @@ export function CommonHandle({
<HandleContext.Provider value={value}>
<Handle
{...props}
- isConnectable={isConnectable}
+ isConnectable={isConnectable && !readOnly}
className={cn(
'inline-flex justify-center items-center !bg-accent-primary !border-none group-hover:!size-4 group-hover:!rounded-sm',
className,
@@ -56,7 +57,10 @@ export function CommonHandle({
onClick={(e) => {
e.stopPropagation();
- if (!isConnectable) {
+ // A read-only canvas never opens the next-step menu: the click
+ // handler is a custom add-node entry that nodesConnectable={false}
+ // does not cover.
+ if (readOnly || !isConnectable) {
return;
}
@@ -69,7 +73,7 @@ export function CommonHandle({
}}
>
<Plus className="size-3 pointer-events-none text-white hidden group-hover:inline-block" />
- {visible && (
+ {!readOnly && visible && (
<NextStepDropdown
nodeId={nodeId}
hideModal={() => {
diff --git a/web/src/pages/agent/canvas/node/iteration-node.tsx b/web/src/pages/agent/canvas/node/iteration-node.tsx
index 8cae265a44..ba0eb71a8b 100644
--- a/web/src/pages/agent/canvas/node/iteration-node.tsx
+++ b/web/src/pages/agent/canvas/node/iteration-node.tsx
@@ -6,6 +6,7 @@ import { cn } from '@/lib/utils';
import { NodeProps, NodeResizeControl, Position } from '@xyflow/react';
import { memo } from 'react';
import { NodeHandleId, Operator } from '../../constant';
+import { useCanvasReadonly } from '../../context';
import OperatorIcon from '@/components/operator-icon';
import { CommonHandle, LeftEndHandle } from './handle';
import NodeHeader from './node-header';
@@ -19,6 +20,8 @@ export function InnerIterationNode({
isConnectable = true,
selected,
}: NodeProps<IIterationNode>) {
+ const readOnly = useCanvasReadonly();
+
return (
<ToolBar selected={selected} id={id} label={data.label} showRun={false}>
<section
@@ -29,13 +32,15 @@ export function InnerIterationNode({
},
)}
>
- <NodeResizeControl
- style={{ ...controlStyle, pointerEvents: 'auto' }}
- minWidth={100}
- minHeight={50}
- >
- <ResizeIcon />
- </NodeResizeControl>
+ {!readOnly && (
+ <NodeResizeControl
+ style={{ ...controlStyle, pointerEvents: 'auto' }}
+ minWidth={100}
+ minHeight={50}
+ >
+ <ResizeIcon />
+ </NodeResizeControl>
+ )}
<LeftEndHandle className="!pointer-events-auto"></LeftEndHandle>
<CommonHandle
id={NodeHandleId.Start}
diff --git a/web/src/pages/agent/canvas/node/note-node/index.tsx b/web/src/pages/agent/canvas/node/note-node/index.tsx
index f91eb24deb..1118da0042 100644
--- a/web/src/pages/agent/canvas/node/note-node/index.tsx
+++ b/web/src/pages/agent/canvas/node/note-node/index.tsx
@@ -16,6 +16,7 @@ import { memo } from 'react';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
+import { useCanvasReadonly } from '../../../context';
import { NodeWrapper } from '../node-wrapper';
import { ResizeIcon, controlStyle } from '../resize-icon';
import { ToolBar } from '../toolbar';
@@ -42,6 +43,7 @@ function NoteNode({
useWatchNoteNameFormChange,
}: NoteNodeProps) {
const { t } = useTranslation();
+ const readOnly = useCanvasReadonly();
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
@@ -53,9 +55,17 @@ function NoteNode({
defaultValues: { name: data.name },
});
- (useWatchNoteFormChange || useWatchFormChange)(id, form);
+ // Read-only canvas: pass no id so the sync hooks (which write the form back
+ // to the store) stay inert, and the inputs below are disabled.
+ (useWatchNoteFormChange || useWatchFormChange)(
+ readOnly ? undefined : id,
+ form,
+ );
- (useWatchNoteNameFormChange || useWatchNameFormChange)(id, nameForm);
+ (useWatchNoteNameFormChange || useWatchNameFormChange)(
+ readOnly ? undefined : id,
+ nameForm,
+ );
return (
<ToolBar
@@ -69,9 +79,15 @@ function NoteNode({
className="p-0 w-full h-full flex flex-col bg-bg-component border border-accent-primary rounded-lg shadow-md pb-1"
selected={selected}
>
- <NodeResizeControl minWidth={190} minHeight={128} style={controlStyle}>
- <ResizeIcon />
- </NodeResizeControl>
+ {!readOnly && (
+ <NodeResizeControl
+ minWidth={190}
+ minHeight={128}
+ style={controlStyle}
+ >
+ <ResizeIcon />
+ </NodeResizeControl>
+ )}
<section className="px-2 py-1 flex gap-2 items-center note-drag-handle rounded-t border-t-2 border-accent-primary">
<NotebookPen className="size-4" />
<Form {...nameForm}>
@@ -86,6 +102,7 @@ function NoteNode({
placeholder={t('flow.notePlaceholder')}
{...field}
type="text"
+ disabled={readOnly}
className="bg-transparent border-none focus-visible:outline focus-visible:outline-text-sub-title p-1"
/>
</FormControl>
@@ -107,6 +124,7 @@ function NoteNode({
<Textarea
placeholder={t('flow.notePlaceholder')}
resize="none"
+ disabled={readOnly}
className="resize-none rounded-none p-1 py-0 overflow-auto bg-transparent focus-visible:ring-0 border-none text-text-secondary focus-visible:ring-offset-0 !text-xs h-full"
{...field}
/>
diff --git a/web/src/pages/agent/canvas/node/toolbar.test.tsx b/web/src/pages/agent/canvas/node/toolbar.test.tsx
new file mode 100644
index 0000000000..a1276c3913
--- /dev/null
+++ b/web/src/pages/agent/canvas/node/toolbar.test.tsx
@@ -0,0 +1,47 @@
+import { render, screen } from '@testing-library/react';
+import { CanvasReadonlyContext } from '../../context';
+import { ToolBar } from './toolbar';
+
+// TooltipContent relies on React Flow's NodeToolbar portal, which jsdom
+// cannot satisfy; flatten the tooltip wrappers into plain divs so the
+// assertions focus on whether ToolBar renders its action bar at all.
+jest.mock('@/components/xyflow/tooltip-node', () => ({
+ TooltipNode: ({ children }: any) => <div>{children}</div>,
+ TooltipTrigger: ({ children }: any) => <div>{children}</div>,
+ TooltipContent: ({ children }: any) => (
+ <div data-testid="node-toolbar">{children}</div>
+ ),
+}));
+
+jest.mock('../../hooks', () => ({
+ useDuplicateNode: () => jest.fn(),
+}));
+
+function renderToolBar(readOnly: boolean) {
+ return render(
+ <CanvasReadonlyContext.Provider value={readOnly}>
+ <ToolBar selected={false} id="node-1" label="Parser">
+ <div>node body</div>
+ </ToolBar>
+ </CanvasReadonlyContext.Provider>,
+ );
+}
+
+describe('ToolBar', () => {
+ it('shows the run/copy/delete action bar on an editable canvas', () => {
+ renderToolBar(false);
+
+ expect(screen.getByTestId('node-toolbar')).toBeInTheDocument();
+ expect(
+ screen.getByTestId('node-toolbar').querySelector('[data-play]'),
+ ).not.toBeNull();
+ });
+
+ it('hides the whole action bar on a read-only canvas', () => {
+ renderToolBar(true);
+
+ expect(screen.queryByTestId('node-toolbar')).not.toBeInTheDocument();
+ // The node body itself must still render so the canvas stays viewable.
+ expect(screen.getByText('node body')).toBeInTheDocument();
+ });
+});
diff --git a/web/src/pages/agent/canvas/node/toolbar.tsx b/web/src/pages/agent/canvas/node/toolbar.tsx
index fd1b1c67eb..14a3e18d03 100644
--- a/web/src/pages/agent/canvas/node/toolbar.tsx
+++ b/web/src/pages/agent/canvas/node/toolbar.tsx
@@ -9,6 +9,7 @@ import { Position } from '@xyflow/react';
import { Copy, Play, Trash2 } from 'lucide-react';
import { MouseEventHandler, PropsWithChildren, useCallback } from 'react';
import { Operator } from '../../constant';
+import { useCanvasReadonly } from '../../context';
import { useDuplicateNode } from '../../hooks';
import useGraphStore from '../../store';
import { isSingleInstanceOperator } from '../../utils/pipeline-connection';
@@ -63,6 +64,7 @@ export function ToolBar({
);
const duplicateNode = useDuplicateNode();
+ const readOnly = useCanvasReadonly();
// A single-instance operator can never be duplicated: a copy would
// immediately exceed the one-instance limit.
@@ -80,26 +82,33 @@ export function ToolBar({
<TooltipNode selected={selected}>
<TooltipTrigger className="h-full">{children}</TooltipTrigger>
- <TooltipContent position={Position.Top}>
- <section className="flex gap-2 items-center text-text-secondary pb-2">
- {showRun && (
- <IconWrapper>
- <Play className="size-3.5" data-play />
+ {/* A read-only canvas keeps the trigger wrapper (so node layout is
+ unchanged) but never shows the run/copy/delete action bar. */}
+ {!readOnly && (
+ <TooltipContent position={Position.Top}>
+ <section className="flex gap-2 items-center text-text-secondary pb-2">
+ {showRun && (
+ <IconWrapper>
+ <Play className="size-3.5" data-play />
+ </IconWrapper>
+ )}
+ {showCopy && (
+ <IconWrapper
+ onClick={handleDuplicate}
+ disabled={duplicateDisabled}
+ >
+ <Copy className="size-3.5" />
+ </IconWrapper>
+ )}
+ <IconWrapper
+ className="hover:text-state-error hover:border-state-error"
+ onClick={deleteNode}
+ >
+ <Trash2 className="size-3.5" />
</IconWrapper>
- )}
- {showCopy && (
- <IconWrapper onClick={handleDuplicate} disabled={duplicateDisabled}>
- <Copy className="size-3.5" />
- </IconWrapper>
- )}
- <IconWrapper
- className="hover:text-state-error hover:border-state-error"
- onClick={deleteNode}
- >
- <Trash2 className="size-3.5" />
- </IconWrapper>
- </section>
- </TooltipContent>
+ </section>
+ </TooltipContent>
+ )}
</TooltipNode>
);
}
diff --git a/web/src/pages/agent/context.ts b/web/src/pages/agent/context.ts
index 2e899194c4..b3241dc7d3 100644
--- a/web/src/pages/agent/context.ts
+++ b/web/src/pages/agent/context.ts
@@ -18,6 +18,15 @@ export const OwnerTenantIdContext = createContext<string | undefined>(
// oxlint-disable-next-line react-refresh/only-export-components
export const useOwnerTenantId = () => useContext(OwnerTenantIdContext);
+// CanvasReadonlyContext marks the canvas as view-only (e.g. the built-in
+// pipeline preview page). Node/toolbar/form components consume it to disable
+// every editing entry point while keeping viewing interactions (pan, zoom,
+// selection highlight, opening the parameter sheet) intact.
+export const CanvasReadonlyContext = createContext(false);
+
+// oxlint-disable-next-line react-refresh/only-export-components
+export const useCanvasReadonly = () => useContext(CanvasReadonlyContext);
+
type AgentInstanceContextType = Pick<
ReturnType<typeof useAddNode>,
'addCanvasNode'
diff --git a/web/src/pages/agent/form-sheet/next.tsx b/web/src/pages/agent/form-sheet/next.tsx
index 3ee374a80e..54992ee111 100644
--- a/web/src/pages/agent/form-sheet/next.tsx
+++ b/web/src/pages/agent/form-sheet/next.tsx
@@ -29,6 +29,7 @@ interface IProps {
hideSingleDebugDrawer: IModalProps<any>['hideModal'];
showSingleDebugDrawer: IModalProps<any>['showModal'];
chatVisible: boolean;
+ readOnly?: boolean;
}
const EmptyContent = () => <div></div>;
@@ -48,6 +49,7 @@ const FormSheet = ({
chatVisible,
hideSingleDebugDrawer,
showSingleDebugDrawer,
+ readOnly = false,
}: IModalProps<any> & IProps) => {
const operatorName: Operator = node?.data.label as Operator;
const { clickedToolId, getAgentToolById } = useGraphStore();
@@ -79,8 +81,10 @@ const FormSheet = ({
<OperatorIcon
name={toolComponentName || operatorName}
></OperatorIcon>
- <TitleInput node={node}></TitleInput>
- {needsSingleStepDebugging(operatorName) && (
+ <TitleInput node={node} readOnly={readOnly}></TitleInput>
+ {/* Single-step debugging saves the graph before running, so it
+ must stay hidden on a read-only canvas. */}
+ {!readOnly && needsSingleStepDebugging(operatorName) && (
<RunTooltip>
<Button
variant="ghost"
@@ -126,9 +130,23 @@ const FormSheet = ({
<section className="pt-4 overflow-auto flex-1">
{visible && (
- <AgentFormContext.Provider value={node}>
- <OperatorForm node={node} key={node?.id}></OperatorForm>
- </AgentFormContext.Provider>
+ // fieldset disabled natively covers every button-type control
+ // (input, select trigger, switch, checkbox, segmented, buttons);
+ // pointer-events-none additionally blocks mouse interaction with
+ // non-native controls like the Radix slider. min-w-0 overrides the
+ // fieldset's default min-width: min-content so the sheet keeps its
+ // horizontal layout. Store write-back is separately gated in
+ // useWatchFormChange, so no change can leave the local form state.
+ <fieldset
+ disabled={readOnly || undefined}
+ className={cn('border-0 p-0 m-0 min-w-0', {
+ 'pointer-events-none': readOnly,
+ })}
+ >
+ <AgentFormContext.Provider value={node}>
+ <OperatorForm node={node} key={node?.id}></OperatorForm>
+ </AgentFormContext.Provider>
+ </fieldset>
)}
</section>
</SheetContent>
diff --git a/web/src/pages/agent/form-sheet/title-input.test.tsx b/web/src/pages/agent/form-sheet/title-input.test.tsx
new file mode 100644
index 0000000000..923c77b80d
--- /dev/null
+++ b/web/src/pages/agent/form-sheet/title-input.test.tsx
@@ -0,0 +1,46 @@
+import { fireEvent, render, screen } from '@testing-library/react';
+import { TitleInput } from './title-input';
+
+jest.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+// The name-change hook writes the canvas store; the read-only assertions only
+// care whether an editing entry point is rendered, not what it does.
+const mockHandleNameBlur = jest.fn(() => true);
+jest.mock('../hooks/use-change-node-name', () => ({
+ useHandleNodeNameChange: () => ({
+ name: 'My Parser',
+ handleNameBlur: mockHandleNameBlur,
+ handleNameChange: jest.fn(),
+ }),
+}));
+
+jest.mock('../hooks/use-is-mcp', () => ({
+ useIsMcp: () => false,
+}));
+
+const baseNode: any = {
+ id: 'Parser:1',
+ data: { label: 'Parser', name: 'My Parser' },
+};
+
+describe('TitleInput', () => {
+ it('renders an edit button that switches to editing mode when editable', () => {
+ render(<TitleInput node={baseNode} />);
+
+ expect(screen.getByText('My Parser')).toBeInTheDocument();
+ const editButton = screen.getByRole('button');
+ fireEvent.click(editButton);
+ expect(screen.getByDisplayValue('My Parser')).toBeInTheDocument();
+ });
+
+ it('renders plain text without an edit button on a read-only canvas', () => {
+ render(<TitleInput node={baseNode} readOnly />);
+
+ expect(screen.getByText('My Parser')).toBeInTheDocument();
+ expect(screen.queryByRole('button')).toBeNull();
+ // Never enters editing mode.
+ expect(screen.queryByDisplayValue('My Parser')).toBeNull();
+ });
+});
diff --git a/web/src/pages/agent/form-sheet/title-input.tsx b/web/src/pages/agent/form-sheet/title-input.tsx
index 0cc520c86f..0443fae8ee 100644
--- a/web/src/pages/agent/form-sheet/title-input.tsx
+++ b/web/src/pages/agent/form-sheet/title-input.tsx
@@ -10,9 +10,10 @@ import { useIsMcp } from '../hooks/use-is-mcp';
type TitleInputProps = {
node?: RAGFlowNodeType;
+ readOnly?: boolean;
};
-export function TitleInput({ node }: TitleInputProps) {
+export function TitleInput({ node, readOnly = false }: TitleInputProps) {
const { t } = useTranslation();
const inputRef = useRef<HTMLInputElement>(null);
const { name, handleNameBlur, handleNameChange } = useHandleNodeNameChange({
@@ -58,6 +59,10 @@ export function TitleInput({ node }: TitleInputProps) {
{node?.id === BeginId ? (
// Begin node is not editable
<span>{t(`flow.${BeginId}`)}</span>
+ ) : readOnly ? (
+ // A read-only canvas never enters name-editing mode: renaming writes
+ // the store via useHandleNodeNameChange.
+ <div className="flex items-center gap-2.5 text-base">{name}</div>
) : isEditingMode ? (
<Input
ref={inputRef}
diff --git a/web/src/pages/agent/hooks/use-watch-form-change.ts b/web/src/pages/agent/hooks/use-watch-form-change.ts
index dd4cc56788..a8ff7ddf49 100644
--- a/web/src/pages/agent/hooks/use-watch-form-change.ts
+++ b/web/src/pages/agent/hooks/use-watch-form-change.ts
@@ -1,5 +1,6 @@
import { useEffect } from 'react';
import { UseFormReturn, useWatch } from 'react-hook-form';
+import { useCanvasReadonly } from '../context';
import useGraphStore from '../store';
export function useWatchFormChange(
@@ -8,12 +9,19 @@ export function useWatchFormChange(
enableReplacement = false,
) {
let values = useWatch({ control: form?.control });
+ const readOnly = useCanvasReadonly();
const { updateNodeForm, replaceNodeForm, markNodeFormEdited } = useGraphStore(
(state) => state,
);
useEffect(() => {
- // Manually triggered form updates are synchronized to the canvas
+ // Manually triggered form updates are synchronized to the canvas.
+ // On a read-only canvas the form must never write back: this effect runs
+ // once on mount without a dirty check, and disabled controls (e.g. the
+ // Radix slider thumb) can still change local RHF state via the keyboard.
+ if (readOnly) {
+ return;
+ }
if (id) {
if (form?.formState.isDirty) {
markNodeFormEdited(id);
@@ -24,5 +32,12 @@ export function useWatchFormChange(
(enableReplacement ? replaceNodeForm : updateNodeForm)(id, nextValues);
}
- }, [form?.formState.isDirty, id, markNodeFormEdited, updateNodeForm, values]);
+ }, [
+ form?.formState.isDirty,
+ id,
+ markNodeFormEdited,
+ readOnly,
+ updateNodeForm,
+ values,
+ ]);
}
diff --git a/web/src/pages/agents/builtin-pipeline-card.test.tsx b/web/src/pages/agents/builtin-pipeline-card.test.tsx
index 9672d9a37e..934fd09d49 100644
--- a/web/src/pages/agents/builtin-pipeline-card.test.tsx
+++ b/web/src/pages/agents/builtin-pipeline-card.test.tsx
@@ -4,12 +4,7 @@ import { BuiltinPipelineCard } from './builtin-pipeline-card';
jest.mock('react-i18next', () => ({
useTranslation: () => ({
- t: (key: string) =>
- key === 'knowledgeConfiguration.builtInBadge'
- ? 'Built in'
- : key === 'common.copy'
- ? 'Copy'
- : key,
+ t: (key: string) => (key === 'common.copy' ? 'Copy' : key),
}),
}));
@@ -23,6 +18,16 @@ jest.mock('./use-copy-builtin-pipeline', () => ({
}),
}));
+// Card navigation goes through useNavigatePage; navigateToBuiltinPipeline is
+// curried (id) => navigate, so the inner mock is what a card click invokes.
+const mockNavigate = jest.fn();
+const mockNavigateToBuiltinPipeline = jest.fn(() => mockNavigate);
+jest.mock('@/hooks/logic-hooks/navigate-hooks', () => ({
+ useNavigatePage: () => ({
+ navigateToBuiltinPipeline: mockNavigateToBuiltinPipeline,
+ }),
+}));
+
const baseData: any = {
id: 'general',
title: 'General',
@@ -35,11 +40,13 @@ const baseData: any = {
beforeEach(() => {
mockCopy.mockClear();
+ mockNavigate.mockClear();
+ mockNavigateToBuiltinPipeline.mockClear();
copyState.copying = false;
});
describe('BuiltinPipelineCard', () => {
- it('renders the title, description and a Built-in badge', () => {
+ it('renders the title and description without a Built-in badge', () => {
render(
<TooltipProvider>
<BuiltinPipelineCard data={baseData} />
@@ -47,10 +54,10 @@ describe('BuiltinPipelineCard', () => {
);
expect(screen.getByText('General')).toBeInTheDocument();
expect(screen.getByText('Default parsing method')).toBeInTheDocument();
- expect(screen.getByTestId('builtin-badge')).toHaveTextContent('Built in');
+ expect(screen.queryByTestId('builtin-badge')).not.toBeInTheDocument();
});
- it('renders a Copy button and no edit/delete dropdown', () => {
+ it('renders an icon-only Copy button and no edit/delete dropdown', () => {
render(
<TooltipProvider>
<BuiltinPipelineCard data={baseData} />
@@ -58,7 +65,7 @@ describe('BuiltinPipelineCard', () => {
);
const copyButton = screen.getByTestId('copy-builtin-pipeline');
expect(copyButton).toBeInTheDocument();
- expect(copyButton).toHaveTextContent('Copy');
+ expect(copyButton).toHaveAccessibleName('Copy');
// Read-only: there is no "more" menu for built-in items.
expect(screen.queryByText('common.rename')).not.toBeInTheDocument();
});
@@ -73,16 +80,29 @@ describe('BuiltinPipelineCard', () => {
expect(mockCopy).toHaveBeenCalledWith({ id: 'general', title: 'General' });
});
- it('is read-only: clicking the card body does not trigger copy', () => {
+ it('clicking the card opens the read-only canvas and does not trigger copy', () => {
render(
<TooltipProvider>
<BuiltinPipelineCard data={baseData} />
</TooltipProvider>,
);
fireEvent.click(screen.getByTestId('builtin-pipeline-card'));
+ expect(mockNavigateToBuiltinPipeline).toHaveBeenCalledWith('general');
+ expect(mockNavigate).toHaveBeenCalledTimes(1);
expect(mockCopy).not.toHaveBeenCalled();
});
+ it('clicking Copy does not navigate to the read-only canvas', () => {
+ render(
+ <TooltipProvider>
+ <BuiltinPipelineCard data={baseData} />
+ </TooltipProvider>,
+ );
+ fireEvent.click(screen.getByTestId('copy-builtin-pipeline'));
+ expect(mockCopy).toHaveBeenCalledWith({ id: 'general', title: 'General' });
+ expect(mockNavigate).not.toHaveBeenCalled();
+ });
+
it('disables the Copy button while copying', () => {
copyState.copying = true;
render(
@@ -102,6 +122,6 @@ describe('BuiltinPipelineCard', () => {
</TooltipProvider>,
);
expect(screen.getByTestId('builtin-pipeline-card')).toBeInTheDocument();
- expect(screen.getByTestId('builtin-badge')).toBeInTheDocument();
+ expect(screen.getByTestId('copy-builtin-pipeline')).toBeInTheDocument();
});
});
diff --git a/web/src/pages/agents/builtin-pipeline-card.tsx b/web/src/pages/agents/builtin-pipeline-card.tsx
index 33afc2e526..8ae370643a 100644
--- a/web/src/pages/agents/builtin-pipeline-card.tsx
+++ b/web/src/pages/agents/builtin-pipeline-card.tsx
@@ -1,6 +1,11 @@
import { HomeCard } from '@/components/home-card';
-import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from '@/components/ui/tooltip';
+import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { IBuiltinPipelineListItem } from '@/interfaces/database/agent';
import { Copy } from 'lucide-react';
import type { MouseEvent } from 'react';
@@ -8,9 +13,9 @@ import { useTranslation } from 'react-i18next';
import { useCopyBuiltinPipeline } from './use-copy-builtin-pipeline';
// BuiltinPipelineCard renders a read-only built-in ingestion pipeline in the
-// agents list. Built-in pipelines are static, non-user resources: they cannot
-// be opened, renamed, or deleted, but can be copied into a user-owned dataflow
-// canvas via the Copy action.
+// agents list. Built-in pipelines are static, non-user resources: clicking the
+// card opens them on the read-only canvas (view only, no editing or autosave),
+// and the Copy action turns them into a user-owned editable dataflow canvas.
export function BuiltinPipelineCard({
data,
}: {
@@ -18,18 +23,13 @@ export function BuiltinPipelineCard({
}) {
const { t } = useTranslation();
const { copy, copying } = useCopyBuiltinPipeline();
+ const { navigateToBuiltinPipeline } = useNavigatePage();
const handleCopyClick = (e: MouseEvent) => {
e.stopPropagation();
copy({ id: data.id, title: data.title ?? '' });
};
- // The built-in marker is rendered as a badge. Use a dedicated translation
- // key (builtInBadge) rather than the parser dropdown's builtInSuffix, so the
- // badge label is decoupled from that unrelated feature. Fall back to a plain
- // label if the locale is missing it.
- const builtInLabel = t('knowledgeConfiguration.builtInBadge') || 'Built in';
-
return (
<HomeCard
testId="builtin-pipeline-card"
@@ -37,26 +37,27 @@ export function BuiltinPipelineCard({
name: data.title ?? '',
description: data.description || '',
}}
- // Read-only: a built-in pipeline cannot be opened for editing.
- onClick={undefined}
- // No rename / delete / edit-tags menu for built-in items.
- moreDropdown={null}
- icon={
- <Badge variant="secondary" data-testid="builtin-badge">
- {builtInLabel}
- </Badge>
- }
- extra={
- <Button
- data-testid="copy-builtin-pipeline"
- variant="static"
- size="auto"
- disabled={copying}
- onClick={handleCopyClick}
- >
- <Copy className="size-4" />
- {t('common.copy')}
- </Button>
+ // Read-only: clicking opens the built-in pipeline on the view-only
+ // canvas; the template itself can never be edited.
+ onClick={navigateToBuiltinPipeline(data.id)}
+ // No rename / delete / edit-tags menu for built-in items; the top-right
+ // slot carries the icon-only Copy action instead.
+ moreDropdown={
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ data-testid="copy-builtin-pipeline"
+ variant="static"
+ size="icon-sm"
+ disabled={copying}
+ aria-label={t('common.copy')}
+ onClick={handleCopyClick}
+ >
+ <Copy className="size-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>{t('common.copy')}</TooltipContent>
+ </Tooltip>
}
/>
);
diff --git a/web/src/pages/agents/builtin-pipeline-section.test.tsx b/web/src/pages/agents/builtin-pipeline-section.test.tsx
index 93ebb3f13b..9805483bb2 100644
--- a/web/src/pages/agents/builtin-pipeline-section.test.tsx
+++ b/web/src/pages/agents/builtin-pipeline-section.test.tsx
@@ -1,6 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
-import { renderHook } from '@testing-library/react';
import { TooltipProvider } from '@/components/ui/tooltip';
import { BuiltinPipelineSection } from './builtin-pipeline-section';
import { AgentCategory } from '@/constants/agent';
@@ -14,6 +13,15 @@ jest.mock('./use-copy-builtin-pipeline', () => ({
useCopyBuiltinPipeline: () => ({ copy: mockCopy, copying: false }),
}));
+// The card navigates via useNavigatePage; mock it so the test never loads
+// routes.tsx (its top-level createBrowserRouter needs the `Request` global
+// that jsdom lacks).
+jest.mock('@/hooks/logic-hooks/navigate-hooks', () => ({
+ useNavigatePage: () => ({
+ navigateToBuiltinPipeline: () => jest.fn(),
+ }),
+}));
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
const agentRequest = require('@/hooks/use-agent-request');
@@ -77,7 +85,7 @@ describe('BuiltinPipelineSection', () => {
expect(screen.getByTestId('builtin-pipeline-section')).toBeInTheDocument();
expect(screen.getAllByTestId('copy-builtin-pipeline')).toHaveLength(1);
expect(
- container.querySelector('[data-testid="builtin-badge"]'),
+ container.querySelector('[data-testid="builtin-pipeline-card"]'),
).toBeTruthy();
});
diff --git a/web/src/pages/agents/index.test.tsx b/web/src/pages/agents/index.test.tsx
index 6dca6d3ae9..2e4bc2210d 100644
--- a/web/src/pages/agents/index.test.tsx
+++ b/web/src/pages/agents/index.test.tsx
@@ -35,6 +35,7 @@ jest.mock('@/hooks/logic-hooks/navigate-hooks', () => ({
useNavigatePage: () => ({
navigateToAgent: jest.fn(),
navigateToAgentTemplates: jest.fn(),
+ navigateToBuiltinPipeline: jest.fn(() => jest.fn()),
}),
}));
// Avoid loading routes.tsx (it builds a data router that needs the `Request`
diff --git a/web/src/pages/builtin-pipeline/index.tsx b/web/src/pages/builtin-pipeline/index.tsx
new file mode 100644
index 0000000000..fa126b7c01
--- /dev/null
+++ b/web/src/pages/builtin-pipeline/index.tsx
@@ -0,0 +1,73 @@
+import { PageHeader } from '@/components/page-header';
+import { Badge } from '@/components/ui/badge';
+import {
+ Breadcrumb,
+ BreadcrumbItem,
+ BreadcrumbLink,
+ BreadcrumbList,
+ BreadcrumbPage,
+ BreadcrumbSeparator,
+} from '@/components/ui/breadcrumb';
+import { Spin } from '@/components/ui/spin';
+import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
+import { useFetchBuiltinPipelines } from '@/hooks/use-agent-request';
+import { ReactFlowProvider } from '@xyflow/react';
+import { useTranslation } from 'react-i18next';
+import { useParams } from 'react-router';
+import AgentCanvas from '../agent/canvas';
+import { DropdownProvider } from '../agent/canvas/context';
+import { useFetchBuiltinPipelineDataOnMount } from './use-fetch-builtin-pipeline-data';
+
+// BuiltinPipelinePage renders a built-in ingestion pipeline on the shared
+// agent canvas in read-only mode: no editing, no autosave, no run/publish
+// chrome. Unlike the editing page it mounts none of the save/run/log hooks
+// (useWatchAgentChange, useAgentHistoryManager, pipeline log polling), so a
+// built-in template can never be persisted back as a user canvas from here.
+// The title comes from the pipeline catalog query rather than route state so
+// a directly opened or refreshed URL still resolves it.
+export default function BuiltinPipelinePage() {
+ const { id } = useParams();
+ const { t } = useTranslation();
+ const { navigateToAgents } = useNavigatePage();
+ const { loading } = useFetchBuiltinPipelineDataOnMount();
+ const { data } = useFetchBuiltinPipelines();
+ const title = data.canvas.find((x) => x.id === id)?.title ?? '';
+
+ return (
+ <section className="h-full" data-testid="builtin-pipeline-page">
+ <PageHeader>
+ <section>
+ <Breadcrumb>
+ <BreadcrumbList>
+ <BreadcrumbItem>
+ <BreadcrumbLink onClick={navigateToAgents}>
+ {t('flow.agents')}
+ </BreadcrumbLink>
+ </BreadcrumbItem>
+ <BreadcrumbSeparator />
+ <BreadcrumbItem>
+ <BreadcrumbPage className="flex items-center gap-2">
+ {title}
+ <Badge variant="secondary">
+ {t('knowledgeConfiguration.builtInBadge')}
+ </Badge>
+ </BreadcrumbPage>
+ </BreadcrumbItem>
+ </BreadcrumbList>
+ </Breadcrumb>
+ </section>
+ </PageHeader>
+ {loading ? (
+ <div className="flex items-center justify-center h-[calc(100%-64px)]">
+ <Spin size="large" />
+ </div>
+ ) : (
+ <ReactFlowProvider>
+ <DropdownProvider>
+ <AgentCanvas readOnly />
+ </DropdownProvider>
+ </ReactFlowProvider>
+ )}
+ </section>
+ );
+}
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.ts
new file mode 100644
index 0000000000..f15b6aa260
--- /dev/null
+++ b/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.test.ts
@@ -0,0 +1,71 @@
+import { renderHook } from '@testing-library/react';
+import useGraphStore from '../agent/store';
+import { useFetchBuiltinPipelineDataOnMount } from './use-fetch-builtin-pipeline-data';
+
+// Referenced from jest.mock factories, so the name must start with "mock".
+const mockBuiltinDsl = {
+ graph: {
+ nodes: [
+ {
+ id: 'File',
+ type: 'fileNode',
+ position: { x: 0, y: 0 },
+ data: { label: 'File', name: 'File', form: {} },
+ },
+ {
+ id: 'Parser:1',
+ type: 'parserNode',
+ position: { x: 100, y: 0 },
+ data: { label: 'Parser', name: 'Parser', form: {} },
+ },
+ ],
+ edges: [
+ {
+ id: 'edge-1',
+ source: 'File',
+ target: 'Parser:1',
+ },
+ ],
+ },
+};
+
+jest.mock('react-router', () => ({
+ useParams: () => ({ id: 'general' }),
+}));
+
+jest.mock('@/hooks/use-agent-request', () => ({
+ useFetchPipelineDslByPipelineId: (_id: string, isBuiltin: boolean) => ({
+ dsl: isBuiltin ? mockBuiltinDsl : {},
+ loading: false,
+ }),
+}));
+
+describe('useFetchBuiltinPipelineDataOnMount', () => {
+ beforeEach(() => {
+ useGraphStore.setState({
+ nodes: [],
+ edges: [],
+ clickedNodeId: '',
+ });
+ });
+
+ it('loads the builtin DSL graph into the shared store', () => {
+ renderHook(() => useFetchBuiltinPipelineDataOnMount());
+
+ const { nodes, edges } = useGraphStore.getState();
+ expect(nodes.map((x) => x.id)).toEqual(['File', 'Parser:1']);
+ expect(edges.map((x) => x.id)).toEqual(['edge-1']);
+ });
+
+ it('empties the store and the clicked node on unmount', () => {
+ const { unmount } = renderHook(() => useFetchBuiltinPipelineDataOnMount());
+
+ expect(useGraphStore.getState().nodes).toHaveLength(2);
+ unmount();
+
+ const { nodes, edges, clickedNodeId } = useGraphStore.getState();
+ expect(nodes).toEqual([]);
+ expect(edges).toEqual([]);
+ expect(clickedNodeId).toBe('');
+ });
+});
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.ts
new file mode 100644
index 0000000000..18757c758a
--- /dev/null
+++ b/web/src/pages/builtin-pipeline/use-fetch-builtin-pipeline-data.ts
@@ -0,0 +1,44 @@
+import { useFetchPipelineDslByPipelineId } from '@/hooks/use-agent-request';
+import { DSL } from '@/interfaces/database/agent';
+import { useEffect, useLayoutEffect } from 'react';
+import { useParams } from 'react-router';
+import { useSetGraphInfo } from '../agent/hooks/use-set-graph';
+import useGraphStore from '../agent/store';
+import { dslToGraph } from '../agent/utils/dsl-bridge';
+
+// Loads a built-in pipeline's DSL into the shared graph store for the
+// read-only canvas. Mirrors useFetchDataOnMount (editing canvas) but sources
+// 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 setGraphInfo = useSetGraphInfo();
+ const setClickedNodeId = useGraphStore((state) => state.setClickedNodeId);
+
+ // The graph store outlives a route transition. Empty it before nodes mount
+ // so nothing from a previously opened canvas leaks into this one.
+ useLayoutEffect(() => {
+ if (id) {
+ setGraphInfo({ nodes: [], edges: [] });
+ }
+ }, [id, setGraphInfo]);
+
+ useEffect(() => {
+ if (!dsl?.graph) {
+ return;
+ }
+ setGraphInfo(dslToGraph(dsl as DSL));
+ }, [setGraphInfo, dsl]);
+
+ // The store is a module-level singleton shared with the editing canvas:
+ // leave it empty on the way out, and drop the clicked-node pointer so a
+ // stale form-sheet target cannot survive the page switch.
+ useEffect(() => {
+ return () => {
+ setGraphInfo({ nodes: [], edges: [] });
+ setClickedNodeId('');
+ };
+ }, [setGraphInfo, setClickedNodeId]);
+
+ return { loading };
+};
diff --git a/web/src/routes.tsx b/web/src/routes.tsx
index 42caf0f458..1edf58054c 100644
--- a/web/src/routes.tsx
+++ b/web/src/routes.tsx
@@ -37,6 +37,7 @@ export enum Routes {
Agent = '/agent',
AgentTemplates = '/agent-templates',
Agents = '/agents',
+ Pipeline = '/pipeline',
Explore = '/explore',
AgentExplore = `${Routes.Agent}/:id/explore`,
Memories = '/memories',
@@ -359,6 +360,10 @@ const routeConfigOptions = [
},
],
},
+ {
+ path: `${Routes.Pipeline}/:id`,
+ Component: () => import('@/pages/builtin-pipeline'),
+ },
{
path: `${Routes.AgentLogPage}/:id`,
Component: () => import('@/pages/agents/agent-log-page'),