chore: start form boolean to checkbox

This commit is contained in:
Joel 2025-07-30 10:53:12 +08:00
parent bd04ddd544
commit 6d03a15e0f
24 changed files with 50 additions and 27 deletions

View File

@ -97,8 +97,8 @@ const ConfigModal: FC<IConfigModalProps> = ({
value: InputVarType.number, value: InputVarType.number,
}, },
{ {
name: t('appDebug.variableConfig.boolean'), name: t('appDebug.variableConfig.checkbox'),
value: InputVarType.boolean, value: InputVarType.checkbox,
}, },
...(supportFile ? [ ...(supportFile ? [
{ {

View File

@ -65,7 +65,7 @@ const SelectVarType: FC<Props> = ({
<SelectItem type={InputVarType.paragraph} value='paragraph' text={t('appDebug.variableConfig.paragraph')} onClick={handleChange}></SelectItem> <SelectItem type={InputVarType.paragraph} value='paragraph' text={t('appDebug.variableConfig.paragraph')} onClick={handleChange}></SelectItem>
<SelectItem type={InputVarType.select} value='select' text={t('appDebug.variableConfig.select')} onClick={handleChange}></SelectItem> <SelectItem type={InputVarType.select} value='select' text={t('appDebug.variableConfig.select')} onClick={handleChange}></SelectItem>
<SelectItem type={InputVarType.number} value='number' text={t('appDebug.variableConfig.number')} onClick={handleChange}></SelectItem> <SelectItem type={InputVarType.number} value='number' text={t('appDebug.variableConfig.number')} onClick={handleChange}></SelectItem>
<SelectItem type={InputVarType.boolean} value='boolean' text={t('appDebug.variableConfig.boolean')} onClick={handleChange}></SelectItem> <SelectItem type={InputVarType.checkbox} value='checkbox' text={t('appDebug.variableConfig.checkbox')} onClick={handleChange}></SelectItem>
</div> </div>
<div className='h-[1px] border-t border-components-panel-border'></div> <div className='h-[1px] border-t border-components-panel-border'></div>
<div className='p-1'> <div className='p-1'>

View File

@ -120,6 +120,8 @@ const SettingBuiltInTool: FC<Props> = ({
return t('tools.setBuiltInTools.number') return t('tools.setBuiltInTools.number')
if (type === 'text-input') if (type === 'text-input')
return t('tools.setBuiltInTools.string') return t('tools.setBuiltInTools.string')
if (type === 'checkbox')
return 'boolean'
if (type === 'file') if (type === 'file')
return t('tools.setBuiltInTools.file') return t('tools.setBuiltInTools.file')
return type return type

View File

@ -90,7 +90,7 @@ const ChatWrapper = () => {
let hasEmptyInput = '' let hasEmptyInput = ''
let fileIsUploading = false let fileIsUploading = false
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox)
if (requiredVars.length) { if (requiredVars.length) {
requiredVars.forEach(({ variable, label, type }) => { requiredVars.forEach(({ variable, label, type }) => {
if (hasEmptyInput) if (hasEmptyInput)

View File

@ -208,11 +208,11 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
} }
} }
if(item.boolean) { if(item.checkbox) {
return { return {
...item.boolean, ...item.checkbox,
default: false, default: false,
type: 'boolean', type: 'checkbox',
} }
} }
if (item.select) { if (item.select) {
@ -333,7 +333,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
let hasEmptyInput = '' let hasEmptyInput = ''
let fileIsUploading = false let fileIsUploading = false
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox)
if (requiredVars.length) { if (requiredVars.length) {
requiredVars.forEach(({ variable, label, type }) => { requiredVars.forEach(({ variable, label, type }) => {
if (hasEmptyInput) if (hasEmptyInput)

View File

@ -43,7 +43,7 @@ const InputsFormContent = ({ showTip }: Props) => {
<div className='space-y-4'> <div className='space-y-4'>
{visibleInputsForms.map(form => ( {visibleInputsForms.map(form => (
<div key={form.variable} className='space-y-1'> <div key={form.variable} className='space-y-1'>
{form.type !== InputVarType.boolean && ( {form.type !== InputVarType.checkbox && (
<div className='flex h-6 items-center gap-1'> <div className='flex h-6 items-center gap-1'>
<div className='system-md-semibold text-text-secondary'>{form.label}</div> <div className='system-md-semibold text-text-secondary'>{form.label}</div>
{!form.required && ( {!form.required && (
@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => {
placeholder={form.label} placeholder={form.label}
/> />
)} )}
{form.type === InputVarType.boolean && ( {form.type === InputVarType.checkbox && (
<BoolInput <BoolInput
name={form.label} name={form.label}
value={!!inputsFormValue?.[form.variable]} value={!!inputsFormValue?.[form.variable]}

View File

@ -12,7 +12,7 @@ export const useCheckInputsForms = () => {
const checkInputsForm = useCallback((inputs: Record<string, any>, inputsForm: InputForm[]) => { const checkInputsForm = useCallback((inputs: Record<string, any>, inputsForm: InputForm[]) => {
let hasEmptyInput = '' let hasEmptyInput = ''
let fileIsUploading = false let fileIsUploading = false
const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.boolean) // boolean can be not checked const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.checkbox) // boolean can be not checked
if (requiredVars?.length) { if (requiredVars?.length) {
requiredVars.forEach(({ variable, label, type }) => { requiredVars.forEach(({ variable, label, type }) => {

View File

@ -32,7 +32,7 @@ export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: Inpu
inputsForm.forEach((item) => { inputsForm.forEach((item) => {
const inputValue = inputs[item.variable] const inputValue = inputs[item.variable]
// set boolean type default value // set boolean type default value
if(item.type === InputVarType.boolean) { if(item.type === InputVarType.checkbox) {
processedInputs[item.variable] = !!inputValue processedInputs[item.variable] = !!inputValue
return return
} }

View File

@ -90,7 +90,7 @@ const ChatWrapper = () => {
let hasEmptyInput = '' let hasEmptyInput = ''
let fileIsUploading = false let fileIsUploading = false
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox) // boolean can be not checked
if (requiredVars.length) { if (requiredVars.length) {
requiredVars.forEach(({ variable, label, type }) => { requiredVars.forEach(({ variable, label, type }) => {
if (hasEmptyInput) if (hasEmptyInput)

View File

@ -195,6 +195,13 @@ export const useEmbeddedChatbot = () => {
type: 'number', type: 'number',
} }
} }
if (item.checkbox) {
return {
...item.checkbox,
default: false,
type: 'checkbox',
}
}
if (item.select) { if (item.select) {
const isInputInOptions = item.select.options.includes(initInputs[item.select.variable]) const isInputInOptions = item.select.options.includes(initInputs[item.select.variable])
return { return {
@ -312,7 +319,7 @@ export const useEmbeddedChatbot = () => {
let hasEmptyInput = '' let hasEmptyInput = ''
let fileIsUploading = false let fileIsUploading = false
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox)
if (requiredVars.length) { if (requiredVars.length) {
requiredVars.forEach(({ variable, label, type }) => { requiredVars.forEach(({ variable, label, type }) => {
if (hasEmptyInput) if (hasEmptyInput)

View File

@ -43,7 +43,7 @@ const InputsFormContent = ({ showTip }: Props) => {
<div className='space-y-4'> <div className='space-y-4'>
{visibleInputsForms.map(form => ( {visibleInputsForms.map(form => (
<div key={form.variable} className='space-y-1'> <div key={form.variable} className='space-y-1'>
{form.type !== InputVarType.boolean && ( {form.type !== InputVarType.checkbox && (
<div className='flex h-6 items-center gap-1'> <div className='flex h-6 items-center gap-1'>
<div className='system-md-semibold text-text-secondary'>{form.label}</div> <div className='system-md-semibold text-text-secondary'>{form.label}</div>
{!form.required && ( {!form.required && (
@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => {
placeholder={form.label} placeholder={form.label}
/> />
)} )}
{form.type === InputVarType.boolean && ( {form.type === InputVarType.checkbox && (
<BoolInput <BoolInput
name={form.label} name={form.label}
value={inputsFormValue?.[form.variable]} value={inputsFormValue?.[form.variable]}

View File

@ -24,7 +24,7 @@ export enum FormTypeEnum {
secretInput = 'secret-input', secretInput = 'secret-input',
select = 'select', select = 'select',
radio = 'radio', radio = 'radio',
boolean = 'boolean', checkbox = 'checkbox',
files = 'files', files = 'files',
file = 'file', file = 'file',
modelSelector = 'model-selector', modelSelector = 'model-selector',

View File

@ -77,6 +77,13 @@ const AppInputsPanel = ({
required: false, required: false,
} }
} }
if(item.checkbox) {
return {
...item.checkbox,
type: 'checkbox',
required: false,
}
}
if (item.select) { if (item.select) {
return { return {
...item.select, ...item.select,

View File

@ -63,6 +63,8 @@ const StrategyDetail: FC<Props> = ({
return t('tools.setBuiltInTools.number') return t('tools.setBuiltInTools.number')
if (type === 'text-input') if (type === 'text-input')
return t('tools.setBuiltInTools.string') return t('tools.setBuiltInTools.string')
if (type === 'checkbox')
return 'boolean'
if (type === 'file') if (type === 'file')
return t('tools.setBuiltInTools.file') return t('tools.setBuiltInTools.file')
if (type === 'array[tools]') if (type === 'array[tools]')

View File

@ -8,6 +8,8 @@ export const toType = (type: string) => {
return 'text-input' return 'text-input'
case 'number': case 'number':
return 'number-input' return 'number-input'
case 'boolean':
return 'checkbox'
default: default:
return type return type
} }

View File

@ -93,7 +93,7 @@ const FormItem: FC<Props> = ({
return '' return ''
})() })()
const isBooleanType = type === InputVarType.boolean const isBooleanType = type === InputVarType.checkbox
const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type) const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type)
const isContext = type === InputVarType.contexts const isContext = type === InputVarType.contexts
const isIterator = type === InputVarType.iterator const isIterator = type === InputVarType.iterator

View File

@ -32,7 +32,7 @@ export type BeforeRunFormProps = {
} & Partial<SpecialResultPanelProps> } & Partial<SpecialResultPanelProps>
function formatValue(value: string | any, type: InputVarType) { function formatValue(value: string | any, type: InputVarType) {
if(type === InputVarType.boolean) if(type === InputVarType.checkbox)
return !!value return !!value
if(value === undefined || value === null) if(value === undefined || value === null)
return value return value
@ -89,7 +89,7 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
form.inputs.forEach((input) => { form.inputs.forEach((input) => {
const value = form.values[input.variable] as any const value = form.values[input.variable] as any
if (!errMsg && input.required && (input.type !== InputVarType.boolean) && !(input.variable in existVarValuesInForm) && (value === '' || value === undefined || value === null || (input.type === InputVarType.files && value.length === 0))) if (!errMsg && input.required && (input.type !== InputVarType.checkbox) && !(input.variable in existVarValuesInForm) && (value === '' || value === undefined || value === null || (input.type === InputVarType.files && value.length === 0)))
errMsg = t('workflow.errorMsg.fieldRequired', { field: typeof input.label === 'object' ? input.label.variable : input.label }) errMsg = t('workflow.errorMsg.fieldRequired', { field: typeof input.label === 'object' ? input.label.variable : input.label })
if (!errMsg && (input.type === InputVarType.singleFile || input.type === InputVarType.multiFiles) && value) { if (!errMsg && (input.type === InputVarType.singleFile || input.type === InputVarType.multiFiles) && value) {

View File

@ -15,7 +15,7 @@ const getIcon = (type: InputVarType) => {
[InputVarType.paragraph]: RiAlignLeft, [InputVarType.paragraph]: RiAlignLeft,
[InputVarType.select]: RiCheckboxMultipleLine, [InputVarType.select]: RiCheckboxMultipleLine,
[InputVarType.number]: RiHashtag, [InputVarType.number]: RiHashtag,
[InputVarType.boolean]: RiCheckboxLine, [InputVarType.checkbox]: RiCheckboxLine,
[InputVarType.singleFile]: RiFileList2Line, [InputVarType.singleFile]: RiFileList2Line,
[InputVarType.multiFiles]: RiFileCopy2Line, [InputVarType.multiFiles]: RiFileCopy2Line,
} as any)[type] || RiTextSnippet } as any)[type] || RiTextSnippet

View File

@ -59,7 +59,7 @@ export const hasValidChildren = (children: any): boolean => {
export const inputVarTypeToVarType = (type: InputVarType): VarType => { export const inputVarTypeToVarType = (type: InputVarType): VarType => {
return ({ return ({
[InputVarType.number]: VarType.number, [InputVarType.number]: VarType.number,
[InputVarType.boolean]: VarType.boolean, [InputVarType.checkbox]: VarType.boolean,
[InputVarType.singleFile]: VarType.file, [InputVarType.singleFile]: VarType.file,
[InputVarType.multiFiles]: VarType.arrayFile, [InputVarType.multiFiles]: VarType.arrayFile,
} as any)[type] || VarType.string } as any)[type] || VarType.string

View File

@ -95,7 +95,7 @@ const varTypeToInputVarType = (type: VarType, {
if (type === VarType.number) if (type === VarType.number)
return InputVarType.number return InputVarType.number
if (type === VarType.boolean) if (type === VarType.boolean)
return InputVarType.boolean return InputVarType.checkbox
if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type)) if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type))
return InputVarType.json return InputVarType.json
if (type === VarType.file) if (type === VarType.file)

View File

@ -178,7 +178,7 @@ export enum InputVarType {
paragraph = 'paragraph', paragraph = 'paragraph',
select = 'select', select = 'select',
number = 'number', number = 'number',
boolean = 'boolean', checkbox = 'checkbox',
url = 'url', url = 'url',
files = 'files', files = 'files',
json = 'json', // obj, array json = 'json', // obj, array
@ -449,6 +449,6 @@ export enum VersionHistoryContextMenuOptions {
delete = 'delete', delete = 'delete',
} }
export interface ChildNodeTypeCount { export type ChildNodeTypeCount = {
[key: string]: number; [key: string]: number;
} }

View File

@ -359,7 +359,7 @@ const translation = {
'paragraph': 'Paragraph', 'paragraph': 'Paragraph',
'select': 'Select', 'select': 'Select',
'number': 'Number', 'number': 'Number',
'boolean': 'Checkbox', 'checkbox': 'Checkbox',
'single-file': 'Single File', 'single-file': 'Single File',
'multi-files': 'File List', 'multi-files': 'File List',
'notSet': 'Not set, try typing {{input}} in the prefix prompt', 'notSet': 'Not set, try typing {{input}} in the prefix prompt',

View File

@ -355,7 +355,7 @@ const translation = {
'paragraph': '段落', 'paragraph': '段落',
'select': '下拉选项', 'select': '下拉选项',
'number': '数字', 'number': '数字',
'boolean': '复选框', 'checkbox': '复选框',
'single-file': '单文件', 'single-file': '单文件',
'multi-files': '文件列表', 'multi-files': '文件列表',
'notSet': '未设置,在 Prompt 中输入 {{input}} 试试', 'notSet': '未设置,在 Prompt 中输入 {{input}} 试试',

View File

@ -18,6 +18,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
if (item.number) if (item.number)
return ['number', item.number] return ['number', item.number]
if (item.checkbox)
return ['boolean', item.checkbox]
if (item.file) if (item.file)
return ['file', item.file] return ['file', item.file]