feat: improve workflow variable identifiers#6586
Open
yoqu wants to merge 3 commits intolabring:mainfrom
Open
Conversation
Collaborator
|
目前没有该需求,暂不计划合入。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an optional technical identifier (
key) for workflow global variables, while preserving the previous runtime behavior for users who do not need custom identifiers.Before this change, global variables only exposed a display name (
label) in the UI, while the real runtime identifier was hidden and generated internally. That made workflow debugging, API integration, and variable inspection harder because users could not define a readable key such ascustomer_name.With this PR:
What changed
key.mp4
Optional custom variable identifiers in the editor
The workflow global variable settings modal now shows a
Variable Identifierfield when creating a variable.Default behavior stays backward-compatible
If the user does not manually set a variable identifier, the saved variable still uses the old random key generation flow. The identifier no longer auto-syncs from the variable name.
Shared identifier validation rules
Added reusable identifier helpers to validate:
Server-side validation before persistence
App update and publish flows now validate
chatConfig.variablesso invalid, duplicate, or reserved identifiers are rejected before being saved.Better visibility in the variable list
The variable table now shows each variable's identifier and provides a copy action, which makes debugging and integration easier.
Localization and tests
Added i18n strings and regression coverage for the identifier helpers, editor behavior, and server-side validation.
Files changed
packages/global/core/app/variableIdentifier.ts- shared identifier validation utilitiespackages/service/core/app/controller.ts- validate variable identifiers before persistenceprojects/app/src/components/core/app/VariableEdit.tsx- show/copy variable identifiers in the variable listprojects/app/src/components/core/app/VariableEditModal/index.tsx- manual identifier editing flowprojects/app/src/components/core/app/utils/formValidation.ts- frontend validation hooks for labels and identifiersprojects/app/src/components/core/app/utils/variableEditor.ts- identifier edit-mode behavior helperprojects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig.tsx- render identifier input for workflow variablesprojects/app/src/pages/api/core/app/update.ts- validate identifiers on app updateprojects/app/src/pages/api/core/app/version/publish.ts- validate identifiers on publishpackages/web/i18n/en/app.json- English copypackages/web/i18n/zh-CN/app.json- Simplified Chinese copypackages/web/i18n/zh-Hant/app.json- Traditional Chinese copyprojects/app/test/web/core/app/variableEditor.test.ts- frontend helper teststest/cases/global/core/app/variableIdentifier.test.ts- identifier utility teststest/cases/service/core/app/controller.test.ts- server-side validation testsHow to test
Create a new workflow global variable and leave
Variable Identifierempty.The variable should still save successfully and use the old random-key behavior.
Create a new workflow global variable and manually set
Variable Identifierto something likecustomer_name.Save the variable and confirm that:
Try invalid identifiers, for example:
userIdcustomer-nameThe editor should block the save with validation feedback.
Edit an existing variable.
The identifier should be visible but read-only.
Trigger app update / publish with invalid variable identifiers.
The server should reject invalid, duplicate, or reserved keys before persistence.
Notes