feat: enhance variable handling and UI components with business labels and descriptions

This commit is contained in:
mlogclub
2026-06-29 18:37:31 +08:00
parent 295c7b4bea
commit 87760d5e89
8 changed files with 166 additions and 85 deletions
@@ -65,6 +65,13 @@ export type WorkflowVariableRef = {
valueOptions?: WorkflowVariableValueOption[]
}
export type WorkflowVariableOption = {
value: string
label: string
subtitle: string
description: string
}
export type WorkflowNodeSpec = AIWorkflowNodeSpec
export type WorkflowDraftValidation = {
@@ -92,6 +99,17 @@ export function refField(value: WorkflowValue | undefined): string {
return isRefValue(value) ? value.content[1] : ""
}
export function buildVariableOption(variable: WorkflowVariableRef): WorkflowVariableOption {
const ref = `${variable.nodeId}.${variable.field}`
const label = `${variable.nodeName} / ${variable.label || variable.field}`
return {
value: ref,
label,
subtitle: [ref, variable.type].filter(Boolean).join(" · "),
description: variable.description,
}
}
export function getNodeTitle(
node: AIWorkflowDefinition["nodes"][number] | undefined,
specs: AIWorkflowNodeSpec[] = []