diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 38f6ecb91..fdd074d2b 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -53,9 +53,24 @@ export default function IOModal({ const [selectedTab, setSelectedTab] = useState( inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0 ); + + function startView(){ + if(!chatInput && !chatOutput){ + if(outputs.length > 0){ + return outputs[0]; + } + else{ + return inputs[0]; + } + } + else{ + return undefined + } + } + const [selectedViewField, setSelectedViewField] = useState< - { type: string; id: string } | undefined - >(undefined); + { type: string; id: string }|undefined + >(startView()); const buildFlow = useFlowStore((state) => state.buildFlow); const setIsBuilding = useFlowStore((state) => state.setIsBuilding); @@ -100,7 +115,7 @@ export default function IOModal({ } useEffect(() => { - setSelectedViewField(undefined); + setSelectedViewField(startView()); setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); }, [inputs.length, outputs.length]); @@ -129,7 +144,7 @@ export default function IOModal({ {selectedTab !== 0 && (
- + )} { nodes.find((node) => node.id === selectedViewField.id) ?.data.node.display_name