From b3be035c64118836a520c57fa62c65bd394f66a8 Mon Sep 17 00:00:00 2001 From: twwu Date: Wed, 28 Jan 2026 11:51:08 +0800 Subject: [PATCH] fix(userActions): update error messages to include dynamic max length and improve validation logic --- .../plugins/hitl-input-block/input-field.tsx | 2 +- .../workflow/nodes/human-input/components/user-action.tsx | 8 +++++--- web/i18n/en-US/workflow.json | 4 ++-- web/i18n/zh-Hans/workflow.json | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx index 36c10ebcf7..06f7e1db7a 100644 --- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx +++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx @@ -39,7 +39,7 @@ const InputField: React.FC = ({ return false if (name.includes(' ')) return false - return /^(?:[a-z_]\w{0,29}){1,10}$/.test(name) + return /^[a-z_]\w{0,29}$/.test(name) }, [tempPayload.output_variable_name]) const handleSave = useCallback(() => { if (!nameValid) diff --git a/web/app/components/workflow/nodes/human-input/components/user-action.tsx b/web/app/components/workflow/nodes/human-input/components/user-action.tsx index cbaf564fac..d124a80051 100644 --- a/web/app/components/workflow/nodes/human-input/components/user-action.tsx +++ b/web/app/components/workflow/nodes/human-input/components/user-action.tsx @@ -46,13 +46,15 @@ const UserActionItem: FC = ({ }) .join('') - if (sanitized !== withUnderscores) + if (sanitized !== withUnderscores) { Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.actionIdFormatTip`, { ns: 'workflow' }) }) + return + } // Limit to 20 characters if (sanitized.length > ACTION_ID_MAX_LENGTH) { sanitized = sanitized.slice(0, ACTION_ID_MAX_LENGTH) - Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.actionIdTooLong`, { ns: 'workflow' }) }) + Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.actionIdTooLong`, { ns: 'workflow', maxLength: ACTION_ID_MAX_LENGTH }) }) } if (sanitized) @@ -63,7 +65,7 @@ const UserActionItem: FC = ({ let value = e.target.value if (value.length > BUTTON_TEXT_MAX_LENGTH) { value = value.slice(0, BUTTON_TEXT_MAX_LENGTH) - Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.buttonTextTooLong`, { ns: 'workflow' }) }) + Toast.notify({ type: 'error', message: t(`${i18nPrefix}.userActions.buttonTextTooLong`, { ns: 'workflow', maxLength: BUTTON_TEXT_MAX_LENGTH }) }) } onChange({ ...data, title: value }) } diff --git a/web/i18n/en-US/workflow.json b/web/i18n/en-US/workflow.json index 1289c455a8..3df856e2d0 100644 --- a/web/i18n/en-US/workflow.json +++ b/web/i18n/en-US/workflow.json @@ -593,10 +593,10 @@ "nodes.humanInput.timeout.hours": "Hours", "nodes.humanInput.timeout.title": "Timeout", "nodes.humanInput.userActions.actionIdFormatTip": "Action ID must start with a letter or underscores, followed by letters, numbers, or underscores", - "nodes.humanInput.userActions.actionIdTooLong": "Action ID must be 20 characters or less", + "nodes.humanInput.userActions.actionIdTooLong": "Action ID must be {{maxLength}} characters or less", "nodes.humanInput.userActions.actionNamePlaceholder": "Action Name", "nodes.humanInput.userActions.buttonTextPlaceholder": "Button display Text", - "nodes.humanInput.userActions.buttonTextTooLong": "Button text must be 40 characters or less", + "nodes.humanInput.userActions.buttonTextTooLong": "Button text must be {{maxLength}} characters or less", "nodes.humanInput.userActions.chooseStyle": "Choose a button style", "nodes.humanInput.userActions.emptyTip": "Click the '+' button to add user actions", "nodes.humanInput.userActions.title": "User Actions", diff --git a/web/i18n/zh-Hans/workflow.json b/web/i18n/zh-Hans/workflow.json index 828290a81e..ac7eea6023 100644 --- a/web/i18n/zh-Hans/workflow.json +++ b/web/i18n/zh-Hans/workflow.json @@ -593,10 +593,10 @@ "nodes.humanInput.timeout.hours": "小时", "nodes.humanInput.timeout.title": "超时设置", "nodes.humanInput.userActions.actionIdFormatTip": "操作 ID 必须以字母或下划线开头,后跟字母、数字或下划线", - "nodes.humanInput.userActions.actionIdTooLong": "操作 ID 不能超过 20 个字符", + "nodes.humanInput.userActions.actionIdTooLong": "操作 ID 不能超过 {{maxLength}} 个字符", "nodes.humanInput.userActions.actionNamePlaceholder": "操作名称", "nodes.humanInput.userActions.buttonTextPlaceholder": "按钮显示文本", - "nodes.humanInput.userActions.buttonTextTooLong": "按钮文本不能超过 40 个字符", + "nodes.humanInput.userActions.buttonTextTooLong": "按钮文本不能超过 {{maxLength}} 个字符", "nodes.humanInput.userActions.chooseStyle": "选择按钮样式", "nodes.humanInput.userActions.emptyTip": "点击 '+' 按钮添加用户操作", "nodes.humanInput.userActions.title": "用户操作",