From fc0dea5647f4dc9c8f470a265b904fe9dd39d3bf Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 9 Jul 2025 10:53:52 +0800 Subject: [PATCH] feat: workflow debug add bool --- .../base/chat/chat/check-input-forms-hooks.ts | 2 +- web/app/components/base/chat/chat/utils.ts | 6 ++++ .../components/before-run-form/bool-input.tsx | 31 +++++++++++++++++++ .../components/before-run-form/form-item.tsx | 12 ++++++- 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 web/app/components/workflow/nodes/_base/components/before-run-form/bool-input.tsx diff --git a/web/app/components/base/chat/chat/check-input-forms-hooks.ts b/web/app/components/base/chat/chat/check-input-forms-hooks.ts index 62c59a06fb..5e7dbd3fb2 100644 --- a/web/app/components/base/chat/chat/check-input-forms-hooks.ts +++ b/web/app/components/base/chat/chat/check-input-forms-hooks.ts @@ -12,7 +12,7 @@ export const useCheckInputsForms = () => { const checkInputsForm = useCallback((inputs: Record, inputsForm: InputForm[]) => { let hasEmptyInput = '' let fileIsUploading = false - const requiredVars = inputsForm.filter(({ required }) => required) + const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.boolean) // boolean can be not checked if (requiredVars?.length) { requiredVars.forEach(({ variable, label, type }) => { diff --git a/web/app/components/base/chat/chat/utils.ts b/web/app/components/base/chat/chat/utils.ts index 69bc680777..9e4957ce9d 100644 --- a/web/app/components/base/chat/chat/utils.ts +++ b/web/app/components/base/chat/chat/utils.ts @@ -31,6 +31,12 @@ export const getProcessedInputs = (inputs: Record, inputsForm: Inpu inputsForm.forEach((item) => { const inputValue = inputs[item.variable] + // set boolean type default value + if(item.type === InputVarType.boolean) { + processedInputs[item.variable] = !!inputValue + return + } + if (!inputValue) return diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/bool-input.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/bool-input.tsx new file mode 100644 index 0000000000..7ed13d87fc --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/bool-input.tsx @@ -0,0 +1,31 @@ +'use client' +import Checkbox from '@/app/components/base/checkbox' +import type { FC } from 'react' +import React, { useCallback } from 'react' + +type Props = { + name: string + value: boolean + onChange: (value: boolean) => void +} + +const BoolInput: FC = ({ + value, + onChange, + name, +}) => { + const handleChange = useCallback(() => { + onChange(!value) + }, [value, onChange]) + return ( +
+ +
{name}
+
+ ) +} +export default React.memo(BoolInput) diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx index 269f5e0a96..071ffded5e 100644 --- a/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx @@ -25,6 +25,7 @@ import { BubbleX } from '@/app/components/base/icons/src/vender/line/others' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' import cn from '@/utils/classnames' import type { FileEntity } from '@/app/components/base/file-uploader/types' +import BoolInput from './bool-input' type Props = { payload: InputVar @@ -92,6 +93,7 @@ const FormItem: FC = ({ return '' })() + const isBooleanType = type === InputVarType.boolean const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type) const isContext = type === InputVarType.contexts const isIterator = type === InputVarType.iterator @@ -113,7 +115,7 @@ const FormItem: FC = ({ return (
- {!isArrayLikeType && ( + {!isArrayLikeType && !isBooleanType && (
{typeof payload.label === 'object' ? nodeKey : payload.label}
{!payload.required && {t('workflow.panel.optional')}} @@ -166,6 +168,14 @@ const FormItem: FC = ({ ) } + { isBooleanType && ( + + )} + { type === InputVarType.json && (