Fix workflow detail (#3382)

* fix: loop node init

* fix: workflow detail

* fix: point table

* add null check
This commit is contained in:
Archer
2024-12-12 17:14:46 +08:00
committed by GitHub
parent 181b854342
commit ddddd998c8
34 changed files with 292 additions and 237 deletions

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useMemo } from 'react';
import React, { useEffect } from 'react';
import { Controller, UseFormReturn } from 'react-hook-form';
import { useTranslation } from 'next-i18next';
import { Box, Button, Card, Textarea } from '@chakra-ui/react';
@@ -121,21 +121,7 @@ const VariableInput = ({
const variablesForm = useContextSelector(ChatItemContext, (v) => v.variablesForm);
const variableList = useContextSelector(ChatBoxContext, (v) => v.variableList);
const { setValue, handleSubmit: handleSubmitChat } = variablesForm;
const defaultValues = useMemo(() => {
return variableList.reduce((acc: Record<string, any>, item) => {
acc[item.key] = item.defaultValue;
return acc;
}, {});
}, [variableList]);
useEffect(() => {
const values = variablesForm.getValues('variables');
// If form is not empty, do not reset the variables
if (Object.values(values).filter(Boolean).length > 0) return;
setValue('variables', defaultValues);
}, [defaultValues, setValue, variablesForm]);
const { handleSubmit: handleSubmitChat } = variablesForm;
return (
<Box py={3}>

View File

@@ -805,7 +805,7 @@ const ChatBox = ({
setQuestionGuide([]);
setValue('chatStarted', false);
abortRequest('leave');
}, [abortRequest, setValue]);
}, [chatId, appId, abortRequest, setValue]);
// Add listener
useEffect(() => {

View File

@@ -110,17 +110,15 @@ const RenderInput = () => {
return;
}
const defaultFormValues = formatPluginInputs.reduce(
(acc, input) => {
acc[input.key] = input.defaultValue;
return acc;
},
{} as Record<string, any>
);
reset({
files: [],
variables: defaultFormValues
variables: formatPluginInputs.reduce(
(acc, input) => {
acc[input.key] = input.defaultValue;
return acc;
},
{} as Record<string, any>
)
});
return;
}
@@ -164,7 +162,7 @@ const RenderInput = () => {
files: historyFileList
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [histories]);
}, [histories, formatPluginInputs]);
const [uploading, setUploading] = useState(false);

View File

@@ -172,7 +172,6 @@ const RenderPluginInput = ({
return (
<Textarea
value={value}
defaultValue={input.defaultValue}
onChange={onChange}
isDisabled={isDisabled}
placeholder={t(input.placeholder as any)}
@@ -192,7 +191,6 @@ const RenderPluginInput = ({
isInvalid={isInvalid}
value={value}
onChange={onChange}
defaultValue={input.defaultValue}
/>
);
}
@@ -203,7 +201,6 @@ const RenderPluginInput = ({
onChange={onChange}
isDisabled={isDisabled}
isInvalid={isInvalid}
defaultChecked={!!input.defaultValue}
/>
);
}
@@ -216,7 +213,6 @@ const RenderPluginInput = ({
value={value}
onChange={onChange}
isInvalid={isInvalid}
defaultValue={input.defaultValue}
/>
);
})();