diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 751eacea1..81b15559c 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -67,14 +67,17 @@ export default function FormModal({ const id = useRef(flow.id); const tabsStateFlowId = tabsState[flow.id]; const tabsStateFlowIdFormKeysData = tabsStateFlowId.formKeysData; - const [chatKey, setChatKey] = useState( - Object.keys(tabsState[flow.id].formKeysData.input_keys).find( - (k) => - !tabsState[flow.id].formKeysData.handle_keys.some((j) => j === k) && - tabsState[flow.id].formKeysData.input_keys[k] === "" - ) - ); - + const [chatKey, setChatKey] = useState(() => { + if (tabsState[flow.id]?.formKeysData?.input_keys) { + return Object.keys(tabsState[flow.id].formKeysData.input_keys).find( + (k) => + !tabsState[flow.id].formKeysData.handle_keys.some((j) => j === k) && + tabsState[flow.id].formKeysData.input_keys[k] === "" + ); + } + // TODO: return a sensible default + return ""; + }); useEffect(() => { if (messagesRef.current) { messagesRef.current.scrollTop = messagesRef.current.scrollHeight; @@ -419,68 +422,70 @@ export default function FormModal({ - {Object.keys(tabsState[id.current].formKeysData.input_keys).map( - (i, k) => ( -
- - - {i} - + {tabsState[id.current]?.formKeysData?.input_keys + ? Object.keys( + tabsState[id.current].formKeysData.input_keys + ).map((i, k) => ( +
+ + + {i} + -
{ - event.stopPropagation(); +
{ + event.stopPropagation(); + }} + > + + handleOnCheckedChange(value, i) + } + size="small" + disabled={tabsState[ + id.current + ].formKeysData.handle_keys.some((t) => t === i)} + /> +
+
+ } + key={k} + keyValue={i} + > +
+ {tabsState[id.current].formKeysData.handle_keys.some( + (t) => t === i + ) && ( +
+ Source: Component +
+ )} +
- } - key={k} - keyValue={i} - > -
- {tabsState[id.current].formKeysData.handle_keys.some( - (t) => t === i - ) && ( -
- Source: Component -
- )} - -
-
-
- ) - )} +
+
+ )) + : null} {tabsState[id.current].formKeysData.memory_keys.map((i, k) => (