fix: update selected_output field to handle which outputs is displayed first (#8538)

* 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 <gabriel@langflow.org>

* 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 <gabriel@langflow.org>

* 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 <gabriel@langflow.org>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
This commit is contained in:
Deon Sanchez 2025-06-13 13:57:18 -06:00 committed by GitHub
commit c18330d449
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 3 deletions

View file

@ -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);

View file

@ -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);

View file

@ -104,6 +104,7 @@ export type OutputFieldType = {
types: Array<string>;
selected?: string;
name: string;
group_outputs?: boolean;
method?: string;
display_name: string;
hidden?: boolean;

View file

@ -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({