mirror of
https://github.com/langgenius/dify.git
synced 2026-04-30 15:38:08 +08:00
fix: workflow run edge status
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { useCallback } from 'react'
|
||||
import {
|
||||
getIncomers,
|
||||
useReactFlow,
|
||||
useStoreApi,
|
||||
} from 'reactflow'
|
||||
@ -8,6 +9,7 @@ import { v4 as uuidV4 } from 'uuid'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { useWorkflowStore } from '../store'
|
||||
import { useNodesSyncDraft } from '../hooks'
|
||||
import type { Node } from '../types'
|
||||
import {
|
||||
NodeRunningStatus,
|
||||
WorkflowRunningStatus,
|
||||
@ -288,11 +290,12 @@ export const useWorkflowRun = () => {
|
||||
draft[currentNodeIndex].data._runningStatus = NodeRunningStatus.Running
|
||||
})
|
||||
setNodes(newNodes)
|
||||
const incomeNodesId = getIncomers({ id: data.node_id } as Node, newNodes, edges).filter(node => node.data._runningStatus === NodeRunningStatus.Succeeded).map(node => node.id)
|
||||
const newEdges = produce(edges, (draft) => {
|
||||
const edge = draft.find(edge => edge.target === data.node_id && edge.source === prevNodeId)
|
||||
|
||||
if (edge)
|
||||
edge.data = { ...edge.data, _runned: true } as any
|
||||
draft.forEach((edge) => {
|
||||
if (edge.target === data.node_id && incomeNodesId.includes(edge.source))
|
||||
edge.data = { ...edge.data, _runned: true } as any
|
||||
})
|
||||
})
|
||||
setEdges(newEdges)
|
||||
}
|
||||
@ -470,6 +473,12 @@ export const useWorkflowRun = () => {
|
||||
if (onIterationFinish)
|
||||
onIterationFinish(params)
|
||||
},
|
||||
onParallelBranchStarted: (params) => {
|
||||
// console.log(params, 'parallel start')
|
||||
},
|
||||
onParallelBranchFinished: (params) => {
|
||||
// console.log(params, 'finished')
|
||||
},
|
||||
onTextChunk: (params) => {
|
||||
const { data: { text } } = params
|
||||
const {
|
||||
|
||||
@ -55,6 +55,7 @@ export type CommonNodeType<T = {}> = {
|
||||
_iterationLength?: number
|
||||
_iterationIndex?: number
|
||||
_inParallelHovering?: boolean
|
||||
start_node_in_iteration?: boolean
|
||||
isIterationStart?: boolean
|
||||
isInIteration?: boolean
|
||||
iteration_id?: string
|
||||
|
||||
Reference in New Issue
Block a user