feat: support multiple valueTypes for text input variables (#6801)

* feat: 文本输入框变量支持多 valueType

* fix: 文本输入框变量非 string valueType 的渲染映射

- formRender/utils.ts: variableInputTypeToInputType 在 text input 场景下
  按 valueType 派生,非 string 走 JSONEditor/textarea,让 Chat 表单与
  调试面板能正确渲染 object/array/any 变量
- packages/global/core/workflow/utils.ts: appData2FlowNodeIO 的
  renderTypeMap 对 text input + 非 string 使用 [JSONEditor, reference],
  保证父工作流节点输入同步跟进
- 补 appData2FlowNodeIO 的 text input valueType 分支测试

* feat(workflow): 全局变量联动清理节点引用及变量更新节点必填校验

* fix(workflow): 文本输入变量 legacy 兼容与引用存活校验

* refactor(workflow): 抽出文本输入变量 valueType 兜底 helper

* feat: adapt test for all node type

* revert(workflow): 移除全局变量引用联动清理

* feat: remove any in text input

* doc

---------

Co-authored-by: archer <545436317@qq.com>
This commit is contained in:
DigHuang
2026-04-24 22:01:29 +08:00
committed by GitHub
parent 27ebc0eeba
commit b7cdb3fb86
17 changed files with 599 additions and 47 deletions
@@ -753,6 +753,89 @@ describe('appData2FlowNodeIO', () => {
expect(switchVar?.renderTypeList).toContain(FlowNodeInputTypeEnum.switch);
});
it('should map text input variable with non-string valueType to JSONEditor', () => {
const result = appData2FlowNodeIO({
chatConfig: {
variables: [
{
key: 'objVar',
label: 'Object',
type: VariableInputEnum.input,
description: '',
valueType: WorkflowIOValueTypeEnum.object
},
{
key: 'arrVar',
label: 'Array',
type: VariableInputEnum.input,
description: '',
valueType: WorkflowIOValueTypeEnum.arrayString
},
{
key: 'strVar',
label: 'String',
type: VariableInputEnum.input,
description: '',
valueType: WorkflowIOValueTypeEnum.string
}
]
}
});
const objVar = result.inputs.find((i) => i.key === 'objVar');
expect(objVar?.renderTypeList).toEqual([
FlowNodeInputTypeEnum.JSONEditor,
FlowNodeInputTypeEnum.reference
]);
const arrVar = result.inputs.find((i) => i.key === 'arrVar');
expect(arrVar?.renderTypeList).toEqual([
FlowNodeInputTypeEnum.JSONEditor,
FlowNodeInputTypeEnum.reference
]);
const strVar = result.inputs.find((i) => i.key === 'strVar');
expect(strVar?.renderTypeList).toEqual([
FlowNodeInputTypeEnum.input,
FlowNodeInputTypeEnum.reference
]);
});
it('should snap legacy any valueType to string and keep undefined as text input', () => {
const result = appData2FlowNodeIO({
chatConfig: {
variables: [
{
key: 'anyVar',
label: 'Any',
type: VariableInputEnum.input,
description: '',
valueType: WorkflowIOValueTypeEnum.any
},
{
key: 'legacyVar',
label: 'Legacy',
type: VariableInputEnum.input,
description: ''
}
]
}
});
const anyVar = result.inputs.find((i) => i.key === 'anyVar');
expect(anyVar?.renderTypeList).toEqual([
FlowNodeInputTypeEnum.input,
FlowNodeInputTypeEnum.reference
]);
expect(anyVar?.valueType).toBe(WorkflowIOValueTypeEnum.string);
const legacyVar = result.inputs.find((i) => i.key === 'legacyVar');
expect(legacyVar?.renderTypeList).toEqual([
FlowNodeInputTypeEnum.input,
FlowNodeInputTypeEnum.reference
]);
});
it('should preserve defaultValue on variable inputs', () => {
const result = appData2FlowNodeIO({
chatConfig: {