Skip to content

Commit

Permalink
Merge branch 'feat/workflow-continue-on-error' into deploy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zxhlyh committed Dec 6, 2024
2 parents 0475c4e + b8eaff8 commit 5a91484
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
45 changes: 33 additions & 12 deletions web/app/components/workflow/hooks/use-workflow-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { usePathname } from 'next/navigation'
import { useWorkflowStore } from '../store'
import { useNodesSyncDraft } from '../hooks'
import {
BlockEnum,
NodeRunningStatus,
WorkflowRunningStatus,
} from '../types'
Expand All @@ -26,6 +27,7 @@ import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player
import {
getFilesInLogs,
} from '@/app/components/base/file-uploader/utils'
import { ErrorHandleTypeEnum } from '@/app/components/workflow/nodes/_base/components/error-handle/types'

export const useWorkflowRun = () => {
const store = useStoreApi()
Expand Down Expand Up @@ -323,14 +325,22 @@ export const useWorkflowRun = () => {
})
setNodes(newNodes)
const newEdges = produce(edges, (draft) => {
const incomeEdges = draft.filter(edge => edge.target === data.node_id)
const incomeEdges = draft.filter((edge) => {
return edge.target === data.node_id
})

incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
_sourceRunningStatus: nodes.find(node => node.id === edge.source)!.data._runningStatus,
_targetRunningStatus: NodeRunningStatus.Running,
_waitingRun: false,
const incomeNode = nodes.find(node => node.id === edge.source)!
if (
!incomeNode.data._runningBranchId
|| (incomeNode.data._runningBranchId && edge.sourceHandle === incomeNode.data._runningBranchId)
) {
edge.data = {
...edge.data,
_sourceRunningStatus: incomeNode.data._runningStatus,
_targetRunningStatus: NodeRunningStatus.Running,
_waitingRun: false,
}
}
})
})
Expand Down Expand Up @@ -439,17 +449,28 @@ export const useWorkflowRun = () => {
const newNodes = produce(nodes, (draft) => {
const currentNode = draft.find(node => node.id === data.node_id)!
currentNode.data._runningStatus = data.status as any
if (data.status === NodeRunningStatus.Exception) {
currentNode.data._runningBranchId = ErrorHandleTypeEnum.failBranch
}
else {
if (data.node_type === BlockEnum.IfElse)
currentNode.data._runningBranchId = data?.outputs?.selected_case_id

if (data.node_type === BlockEnum.QuestionClassifier)
currentNode.data._runningBranchId = data?.outputs?.class_id
}
})
setNodes(newNodes)
const newEdges = produce(edges, (draft) => {
const currentEdge = draft.find(edge => edge.target === data.node_id)!

if (currentEdge) {
currentEdge.data = {
...currentEdge.data,
const incomeEdges = draft.filter((edge) => {
return edge.target === data.node_id
})
incomeEdges.forEach((edge) => {
edge.data = {
...edge.data,
_targetRunningStatus: data.status as any,
}
}
})
})
setEdges(newEdges)
prevNodeId = data.node_id
Expand Down
1 change: 1 addition & 0 deletions web/app/components/workflow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type CommonNodeType<T = {}> = {
_targetBranches?: Branch[]
_isSingleRun?: boolean
_runningStatus?: NodeRunningStatus
_runningBranchId?: string
_singleRunningStatus?: NodeRunningStatus
_isCandidate?: boolean
_isBundled?: boolean
Expand Down

0 comments on commit 5a91484

Please sign in to comment.