From 273c830b55f844b5d3c1c2dd5cf60dc50f6a422f Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 25 Jun 2026 12:23:41 +0100 Subject: [PATCH] Make the Choose documents mode reachable on a fresh agent node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking "Choose…" with nothing selected now opens the document picker. The mode was derived purely from the stored input_documents, so an empty selection read back as None and the picker never appeared — leaving per-node document selection unreachable unless a value was already set. An explicit per-node flag now keeps Choose mode active even when empty, without leaking across nodes. --- .../src/agents/workflow/WorkflowBuilder.tsx | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/frontend/src/agents/workflow/WorkflowBuilder.tsx b/frontend/src/agents/workflow/WorkflowBuilder.tsx index 82c5f518..5f458e78 100644 --- a/frontend/src/agents/workflow/WorkflowBuilder.tsx +++ b/frontend/src/agents/workflow/WorkflowBuilder.tsx @@ -359,6 +359,9 @@ function WorkflowBuilderInner() { const reactFlowWrapper = useRef(null); const [selectedNode, setSelectedNode] = useState(null); + // Node id for which the author explicitly entered "Choose…" documents mode, + // so the picker shows even before any document is selected (empty reads as None). + const [docChooseNodeId, setDocChooseNodeId] = useState(null); const [workflowName, setWorkflowName] = useState('New Workflow'); const [workflowDescription, setWorkflowDescription] = useState(''); const [showWorkflowSettings, setShowWorkflowSettings] = useState(false); @@ -2216,10 +2219,15 @@ function WorkflowBuilderInner() { selectedNode.data.config?.input_documents; const documentsMode = getDocumentsMode(inputDocuments); - const chosenDocuments = - documentsMode === 'choose' - ? (inputDocuments ?? []) - : []; + const showChoose = + documentsMode === 'choose' || + docChooseNodeId === selectedNode.id; + const chosenDocuments = showChoose + ? documentsModeToInputDocuments( + 'choose', + inputDocuments ?? [], + ) + : []; const filePassing = normalizeFilePassing( selectedNode.data.config?.file_passing, ); @@ -2251,16 +2259,23 @@ function WorkflowBuilderInner() { type="button" variant="ghost" size="sm" - onClick={() => + onClick={() => { + setDocChooseNodeId( + mode === 'choose' + ? selectedNode.id + : null, + ); setInputDocuments( documentsModeToInputDocuments( mode, chosenDocuments, ), - ) - } + ); + }} className={`h-auto flex-1 rounded-lg px-2 py-1.5 text-xs font-medium ${ - documentsMode === mode + (showChoose + ? 'choose' + : documentsMode) === mode ? 'bg-primary text-white' : 'text-gray-600 dark:text-gray-300' }`} @@ -2269,7 +2284,7 @@ function WorkflowBuilderInner() { ))} - {documentsMode === 'choose' && ( + {showChoose && (