| @@ -244,6 +244,7 @@ const ConfigModal: FC<IConfigModalProps> = ({ | |||
| <SimpleSelect | |||
| key={`default-select-${options.join('-')}`} | |||
| className="w-full" | |||
| optionWrapClassName="max-h-[140px] overflow-y-auto" | |||
| items={[ | |||
| { value: '', name: t('appDebug.variableConfig.noDefaultValue') }, | |||
| ...options.filter(opt => opt.trim() !== '').map(option => ({ | |||
| @@ -77,7 +77,6 @@ const Select: FC<ISelectProps> = ({ | |||
| defaultSelect = existed | |||
| setSelectedItem(defaultSelect) | |||
| // eslint-disable-next-line react-hooks/exhaustive-deps | |||
| }, [defaultValue]) | |||
| const filteredItems: Item[] | |||
| @@ -201,7 +200,6 @@ const SimpleSelect: FC<ISelectProps> = ({ | |||
| defaultSelect = existed | |||
| setSelectedItem(defaultSelect) | |||
| // eslint-disable-next-line react-hooks/exhaustive-deps | |||
| }, [defaultValue]) | |||
| const listboxRef = useRef<HTMLDivElement>(null) | |||
| @@ -344,7 +342,7 @@ const PortalSelect: FC<PortalSelectProps> = ({ | |||
| > | |||
| <span | |||
| className={` | |||
| grow truncate | |||
| grow truncate text-text-secondary | |||
| ${!selectedItem?.name && 'text-components-input-text-placeholder'} | |||
| `} | |||
| > | |||
| @@ -66,7 +66,9 @@ const RunOnce: FC<IRunOnceProps> = ({ | |||
| useEffect(() => { | |||
| const newInputs: Record<string, any> = {} | |||
| promptConfig.prompt_variables.forEach((item) => { | |||
| if (item.type === 'string' || item.type === 'paragraph') | |||
| if (item.type === 'select') | |||
| newInputs[item.key] = item.default | |||
| else if (item.type === 'string' || item.type === 'paragraph') | |||
| newInputs[item.key] = '' | |||
| else | |||
| newInputs[item.key] = undefined | |||
| @@ -1,6 +1,7 @@ | |||
| import { | |||
| memo, | |||
| useCallback, | |||
| useEffect, | |||
| useMemo, | |||
| } from 'react' | |||
| import { useTranslation } from 'react-i18next' | |||
| @@ -32,9 +33,12 @@ type Props = { | |||
| const InputsPanel = ({ onRun }: Props) => { | |||
| const { t } = useTranslation() | |||
| const workflowStore = useWorkflowStore() | |||
| const { inputs, setInputs } = useStore(s => ({ | |||
| inputs: s.inputs, | |||
| setInputs: s.setInputs, | |||
| })) | |||
| const fileSettings = useFeatures(s => s.features.file) | |||
| const nodes = useNodes<StartNodeType>() | |||
| const inputs = useStore(s => s.inputs) | |||
| const files = useStore(s => s.files) | |||
| const workflowRunningData = useStore(s => s.workflowRunningData) | |||
| const { | |||
| @@ -44,6 +48,24 @@ const InputsPanel = ({ onRun }: Props) => { | |||
| const startVariables = startNode?.data.variables | |||
| const { checkInputsForm } = useCheckInputsForms() | |||
| const initialInputs = useMemo(() => { | |||
| const initInputs: Record<string, any> = {} | |||
| if (startVariables) { | |||
| startVariables.forEach((variable) => { | |||
| if (variable.default) | |||
| initInputs[variable.variable] = variable.default | |||
| }) | |||
| } | |||
| return initInputs | |||
| }, [startVariables]) | |||
| useEffect(() => { | |||
| setInputs({ | |||
| ...initialInputs, | |||
| ...inputs, | |||
| }) | |||
| }, [initialInputs]) | |||
| const variables = useMemo(() => { | |||
| const data = startVariables || [] | |||
| if (fileSettings?.image?.enabled) { | |||
| @@ -62,6 +62,7 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] | | |||
| options: content.options, | |||
| is_context_var, | |||
| hide: content.hide, | |||
| default: content.default, | |||
| }) | |||
| } | |||
| else if (type === 'file') { | |||
| @@ -148,7 +149,7 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[ | |||
| variable: item.key, | |||
| required: item.required !== false, // default true | |||
| options: item.options, | |||
| default: '', | |||
| default: item.default ?? '', | |||
| hide: item.hide, | |||
| }, | |||
| } as any) | |||