feat: implement Schedule Trigger validation with multi-start node topology support (#24134)

This commit is contained in:
lyzno1
2025-08-19 11:55:15 +08:00
committed by GitHub
parent d4ff1e031a
commit f7bb3b852a
7 changed files with 439 additions and 21 deletions

View File

@ -131,19 +131,46 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => {
}
}
if (errorMessage || !validNodes.find(n => n.id === node.id)) {
// Start nodes and Trigger nodes should not show unConnected error if they have validation errors
// or if they are valid start nodes (even without incoming connections)
const isStartNode = node.data.type === BlockEnum.Start
|| node.data.type === BlockEnum.TriggerSchedule
|| node.data.type === BlockEnum.TriggerWebhook
|| node.data.type === BlockEnum.TriggerPlugin
const isUnconnected = !validNodes.find(n => n.id === node.id)
const shouldShowError = errorMessage || (isUnconnected && !isStartNode)
if (shouldShowError) {
list.push({
id: node.id,
type: node.data.type,
title: node.data.title,
toolIcon,
unConnected: !validNodes.find(n => n.id === node.id),
unConnected: isUnconnected && !isStartNode,
errorMessage,
})
}
}
}
// Check for start nodes (including triggers)
const startNodes = nodes.filter(node =>
node.data.type === BlockEnum.Start
|| node.data.type === BlockEnum.TriggerSchedule
|| node.data.type === BlockEnum.TriggerWebhook
|| node.data.type === BlockEnum.TriggerPlugin,
)
if (startNodes.length === 0) {
list.push({
id: 'start-node-required',
type: BlockEnum.Start,
title: t('workflow.blocks.start'),
errorMessage: t('workflow.common.needStartNode'),
})
}
if (isChatMode && !nodes.find(node => node.data.type === BlockEnum.Answer)) {
list.push({
id: 'answer-need-added',
@ -270,6 +297,18 @@ export const useChecklistBeforePublish = () => {
}
}
const startNodes = nodes.filter(node =>
node.data.type === BlockEnum.Start
|| node.data.type === BlockEnum.TriggerSchedule
|| node.data.type === BlockEnum.TriggerWebhook
|| node.data.type === BlockEnum.TriggerPlugin,
)
if (startNodes.length === 0) {
notify({ type: 'error', message: t('workflow.common.needStartNode') })
return false
}
if (isChatMode && !nodes.find(node => node.data.type === BlockEnum.Answer)) {
notify({ type: 'error', message: t('workflow.common.needAnswerNode') })
return false