diff --git a/src/frontend/src/components/IOview/index.tsx b/src/frontend/src/components/IOview/index.tsx index 57569c7e7..7e3e24f76 100644 --- a/src/frontend/src/components/IOview/index.tsx +++ b/src/frontend/src/components/IOview/index.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { CHAT_FORM_DIALOG_SUBTITLE } from "../../constants/constants"; import BaseModal from "../../modals/baseModal"; import useFlowStore from "../../stores/flowStore"; @@ -35,6 +35,11 @@ export default function IOView({ children, open, setOpen }): JSX.Element { { type: string; id: string } | undefined >(undefined); + useEffect(() => { + setSelectedViewField(undefined); + setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); + }, [inputs.length, outputs.length]); + return (
-
-
-
- - -
- {selectedViewField && haveChat && ( - + {selectedTab !== 0 && ( +
-
- {selectedTab === 1 && ( - <> - - Text Inputs - - )} - {selectedTab === 2 && ( - <> - - Prompt Outputs - - )} -
- {nodes - .filter((node) => - selectedTab === 1 - ? inputs.some((input) => input.id === node.id) - : outputs.some((output) => output.id === node.id) - ) - .map((node, index) => { - const input = - selectedTab === 1 - ? inputs.find((input) => input.id === node.id)! - : outputs.find((output) => output.id === node.id)!; - return ( -
- - - {input.id} - - {haveChat && ( -
{ - event.stopPropagation(); - setSelectedViewField(input); - }} - > - -
- )} -
- } - key={index} - keyValue={input.id} + > +
+
+ {inputs.length > 0 && ( + + )} + {outputs.length > 0 && ( + + )} +
+ {selectedViewField && haveChat && ( + + )} +
+
+ {selectedTab === 1 && ( + <> + + Text Inputs + + )} + {selectedTab === 2 && ( + <> + + Prompt Outputs + + )} +
+ {nodes + .filter((node) => + selectedTab === 1 + ? inputs.some((input) => input.id === node.id) + : outputs.some((output) => output.id === node.id) + ) + .map((node, index) => { + const input = + selectedTab === 1 + ? inputs.find((input) => input.id === node.id)! + : outputs.find((output) => output.id === node.id)!; + return ( +
+ + + {input.id} + + {haveChat && ( +
{ + event.stopPropagation(); + setSelectedViewField(input); + }} + > + +
+ )} +
+ } + key={index} + keyValue={input.id} + > +
+
+ {input && + (selectedTab === 1 ? ( + + ) : ( + + ))} +
-
- -
- ); - })} -
+ +
+ ); + })} + + )} + {haveChat ? ( selectedViewField ? ( inputs.some((input) => input.id === selectedViewField.id) ? ( diff --git a/src/frontend/src/constants/constants.ts b/src/frontend/src/constants/constants.ts index c1eaa999d..b9422efab 100644 --- a/src/frontend/src/constants/constants.ts +++ b/src/frontend/src/constants/constants.ts @@ -681,4 +681,4 @@ export const LANGFLOW_SUPPORTED_TYPES = new Set([ export const priorityFields = new Set(["code", "template"]); export const INPUT_TYPES = new Set(["ChatInput", "TextInput"]); -export const OUTPUT_TYPES = new Set(["ChatOutput", "PromptTemplate"]); +export const OUTPUT_TYPES = new Set(["ChatOutput"]);