From c18330d4498453e54c4bca4406cf30932928967b Mon Sep 17 00:00:00 2001 From: Deon Sanchez <69873175+deon-sanchez@users.noreply.github.com> Date: Fri, 13 Jun 2025 13:57:18 -0600 Subject: [PATCH] fix: update selected_output field to handle which outputs is displayed first (#8538) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: update selected_output field in various starter project JSON files - Added or adjusted the "selected_output" field in multiple starter project JSON files to ensure consistency and correct functionality. - Refactored the output selection logic in the GenericNode component to utilize the updated "selected_output" property. Co-authored-by: Gabriel Luiz Freitas Almeida * fix: enhance output handling in GenericNode and NodeOutputField components - Added a check to prevent auto-unhiding outputs with group_outputs set to false in NodeOutputField. - Updated the GenericNode component to ensure the selected_output field is correctly assigned during node updates. - Introduced group_outputs property in the OutputFieldType to support new output handling logic. Co-authored-by: Gabriel Luiz Freitas Almeida * Revert starter_projects directory to main branch state * 📝 (general-bugs-shard-3909.spec.ts): update test description to match the changed button text for better clarity and maintainability --------- Co-authored-by: Gabriel Luiz Freitas Almeida Co-authored-by: cristhianzl --- .../components/NodeOutputfield/index.tsx | 13 +++++++++++-- src/frontend/src/CustomNodes/GenericNode/index.tsx | 4 ++++ src/frontend/src/types/api/index.ts | 1 + .../regression/general-bugs-shard-3909.spec.ts | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx index a0c6d5d5d..7db3b0079 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx @@ -216,10 +216,19 @@ function NodeOutputField({ ); useEffect(() => { - if (disabledOutput && hidden) { + const outputHasGroupOutputsFalse = + data.node?.outputs?.[index]?.group_outputs === false; + + if (disabledOutput && hidden && !outputHasGroupOutputsFalse) { handleUpdateOutputHide(false); } - }, [disabledOutput, handleUpdateOutputHide, hidden]); + }, [ + disabledOutput, + handleUpdateOutputHide, + hidden, + data.node?.outputs, + index, + ]); const [openOutputModal, setOpenOutputModal] = useState(false); diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 31c9c7d8b..d6406ae3b 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -313,7 +313,11 @@ function GenericNode({ newNode.data.node.outputs[outputIndex].selected = output.selected ?? defaultType; } + + const selectedOutput = newNode.data.node.outputs[outputIndex]?.name; + (newNode.data as NodeDataType).selected_output = selectedOutput; } + return newNode; }); updateNodeInternals(data.id); diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index d228d811e..b93b6dd12 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -104,6 +104,7 @@ export type OutputFieldType = { types: Array; selected?: string; name: string; + group_outputs?: boolean; method?: string; display_name: string; hidden?: boolean; diff --git a/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts b/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts index 7da8f1580..1bd3144fb 100644 --- a/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts +++ b/src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts @@ -44,7 +44,7 @@ test( await expect(page.getByTestId("button_run_chat output")).toBeVisible({ timeout: 30000, }); - await expect(page.getByTestId("button_run_openai")).toBeVisible({ + await expect(page.getByTestId("button_run_language model")).toBeVisible({ timeout: 30000, }); await expect(page.getByTestId("button_run_prompt")).toBeVisible({