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(prompt-editor): prevent premature variable path merge during typing (#16811)
chanxea9b3789ceed
diff --git a/web/src/pages/agent/form/components/prompt-editor/index.tsx b/web/src/pages/agent/form/components/prompt-editor/index.tsxindex d9e2a688ba..5ec8cb4c9b 100644--- a/web/src/pages/agent/form/components/prompt-editor/index.tsx+++ b/web/src/pages/agent/form/components/prompt-editor/index.tsx@@ -153,7 +153,7 @@ function PromptContent({<div className="absolute inset-y-0 right-2 z-10 flex items-center"><Tooltip><TooltipTrigger asChild>- <label className="flex cursor-pointer items-center rounded-sm border border-border bg-bg-base/95 px-1 py-0.5 shadow-sm backdrop-blur-sm">+ <label className="flex cursor-pointer items-center rounded-sm px-1 py-0.5 shadow-sm backdrop-blur-sm"><span className="sr-only">{t('flow.mergePath')}</span><div className="origin-right scale-75"><Switchdiff --git a/web/src/pages/agent/form/components/prompt-editor/variable-path-transform.ts b/web/src/pages/agent/form/components/prompt-editor/variable-path-transform.tsindex d095afe780..6ba21bf10b 100644--- a/web/src/pages/agent/form/components/prompt-editor/variable-path-transform.ts+++ b/web/src/pages/agent/form/components/prompt-editor/variable-path-transform.ts@@ -1,4 +1,4 @@-import { TextNode } from 'lexical';+import { $getSelection, $isRangeSelection, TextNode } from 'lexical';import {appendPromptVariablePath,extractLeadingPromptVariablePath,@@ -19,6 +19,30 @@ export function mergeLeadingVariablePathTextNode(textNode: TextNode): boolean {return false;}+ // Don't merge while the user may still be typing the path.+ //+ // Case 1: The path suffix reaches the end of the text (no remaining text).+ // The user may type more identifier characters to extend the path.+ //+ // Case 2: The cursor sits right after the matched path suffix even though+ // there is trailing text (e.g. a space left over from a previous+ // merge). This means the user is actively typing the path before+ // that pre-existing text, and the path may still grow. Merging now+ // would lock the path to its current length.+ if (leadingPath.remainingText === '') {+ return false;+ }++ const selection = $getSelection();+ if (+ $isRangeSelection(selection) &&+ selection.isCollapsed() &&+ selection.anchor.key === textNode.getKey() &&+ selection.anchor.offset === leadingPath.pathSuffix.length+ ) {+ return false;+ }+const nextVariable = appendPromptVariablePath({value: previousSibling.__value,