From 3643ed101437f2e95b8e769c288c29b4e54e39aa Mon Sep 17 00:00:00 2001 From: Minamiyama Date: Wed, 9 Jul 2025 15:18:23 +0800 Subject: [PATCH] Feat: description field for env variables (#21556) --- api/fields/workflow_fields.py | 2 + .../nodes/_base/components/variable/utils.ts | 3 +- .../components/variable-modal.tsx | 10 ++-- .../workflow/panel/env-panel/env-item.tsx | 48 ++++++++++++------- .../panel/env-panel/variable-modal.tsx | 17 ++++++- web/app/components/workflow/types.ts | 1 + web/i18n/de-DE/workflow.ts | 2 + web/i18n/en-US/workflow.ts | 2 + web/i18n/es-ES/workflow.ts | 2 + web/i18n/fa-IR/workflow.ts | 2 + web/i18n/fr-FR/workflow.ts | 2 + web/i18n/hi-IN/workflow.ts | 2 + web/i18n/it-IT/workflow.ts | 2 + web/i18n/ja-JP/workflow.ts | 2 + web/i18n/ko-KR/workflow.ts | 2 + web/i18n/pl-PL/workflow.ts | 2 + web/i18n/pt-BR/workflow.ts | 2 + web/i18n/ro-RO/workflow.ts | 2 + web/i18n/ru-RU/workflow.ts | 2 + web/i18n/sl-SI/workflow.ts | 4 +- web/i18n/th-TH/workflow.ts | 2 + web/i18n/tr-TR/workflow.ts | 2 + web/i18n/uk-UA/workflow.ts | 2 + web/i18n/vi-VN/workflow.ts | 2 + web/i18n/zh-Hans/workflow.ts | 2 + web/i18n/zh-Hant/workflow.ts | 2 + 26 files changed, 97 insertions(+), 26 deletions(-) diff --git a/api/fields/workflow_fields.py b/api/fields/workflow_fields.py index 9f1bef3b3..f00ea71c5 100644 --- a/api/fields/workflow_fields.py +++ b/api/fields/workflow_fields.py @@ -17,6 +17,7 @@ class EnvironmentVariableField(fields.Raw): "name": value.name, "value": encrypter.obfuscated_token(value.value), "value_type": value.value_type.value, + "description": value.description, } if isinstance(value, Variable): return { @@ -24,6 +25,7 @@ class EnvironmentVariableField(fields.Raw): "name": value.name, "value": value.value, "value_type": value.value_type.value, + "description": value.description, } if isinstance(value, dict): value_type = value.get("value_type") diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 1058f2911..ac95f5475 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -462,6 +462,7 @@ const formatItem = ( return { variable: `env.${env.name}`, type: env.value_type, + description: env.description, } }) as Var[] break @@ -472,7 +473,7 @@ const formatItem = ( return { variable: `conversation.${chatVar.name}`, type: chatVar.value_type, - des: chatVar.description, + description: chatVar.description, } }) as Var[] break diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx index 347c83c15..869317ca6 100644 --- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx +++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx @@ -80,7 +80,7 @@ const ChatVariableModal = ({ const [objectValue, setObjectValue] = React.useState([DEFAULT_OBJECT_VALUE]) const [editorContent, setEditorContent] = React.useState() const [editInJSON, setEditInJSON] = React.useState(false) - const [des, setDes] = React.useState('') + const [description, setDescription] = React.useState('') const editorMinHeight = useMemo(() => { if (type === ChatVarType.ArrayObject) @@ -237,7 +237,7 @@ const ChatVariableModal = ({ name, value_type: type, value: formatValue(value), - description: des, + description, }) onClose() } @@ -247,7 +247,7 @@ const ChatVariableModal = ({ setName(chatVar.name) setType(chatVar.value_type) setValue(chatVar.value) - setDes(chatVar.description) + setDescription(chatVar.description) setObjectValue(getObjectValue()) if (chatVar.value_type === ChatVarType.ArrayObject) { setEditorContent(JSON.stringify(chatVar.value)) @@ -385,9 +385,9 @@ const ChatVariableModal = ({