mirror of https://github.com/langgenius/dify.git
fix: start/stop button on the node control not work
This commit is contained in:
parent
6a164f8811
commit
a152ce45d3
|
|
@ -9,7 +9,6 @@ import {
|
|||
RiPlayLargeLine,
|
||||
} from '@remixicon/react'
|
||||
import {
|
||||
useNodeDataUpdate,
|
||||
useNodesInteractions,
|
||||
} from '../../../hooks'
|
||||
import { type Node, NodeRunningStatus } from '../../../types'
|
||||
|
|
@ -19,6 +18,7 @@ import {
|
|||
Stop,
|
||||
} from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { useWorkflowStore } from '@/app/components/workflow/store'
|
||||
|
||||
type NodeControlProps = Pick<Node, 'id' | 'data'>
|
||||
const NodeControl: FC<NodeControlProps> = ({
|
||||
|
|
@ -27,8 +27,8 @@ const NodeControl: FC<NodeControlProps> = ({
|
|||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
const { handleNodeDataUpdate } = useNodeDataUpdate()
|
||||
const { handleNodeSelect } = useNodesInteractions()
|
||||
const workflowStore = useWorkflowStore()
|
||||
const isSingleRunning = data._singleRunningStatus === NodeRunningStatus.Running
|
||||
const handleOpenChange = useCallback((newOpen: boolean) => {
|
||||
setOpen(newOpen)
|
||||
|
|
@ -52,15 +52,12 @@ const NodeControl: FC<NodeControlProps> = ({
|
|||
<div
|
||||
className='flex h-5 w-5 cursor-pointer items-center justify-center rounded-md hover:bg-state-base-hover'
|
||||
onClick={() => {
|
||||
const nextData: Record<string, any> = {
|
||||
_isSingleRun: !isSingleRunning,
|
||||
}
|
||||
if(isSingleRunning)
|
||||
nextData._singleRunningStatus = undefined
|
||||
|
||||
handleNodeDataUpdate({
|
||||
id,
|
||||
data: nextData,
|
||||
const action = isSingleRunning ? 'stop' : 'run'
|
||||
const store = workflowStore.getState()
|
||||
store.setInitShowLastRunTab(true)
|
||||
store.setPendingSingleRun({
|
||||
nodeId: id,
|
||||
action,
|
||||
})
|
||||
handleNodeSelect(id)
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,13 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
const nodePanelWidth = useStore(s => s.nodePanelWidth)
|
||||
const otherPanelWidth = useStore(s => s.otherPanelWidth)
|
||||
const setNodePanelWidth = useStore(s => s.setNodePanelWidth)
|
||||
const {
|
||||
pendingSingleRun,
|
||||
setPendingSingleRun,
|
||||
} = useStore(s => ({
|
||||
pendingSingleRun: s.pendingSingleRun,
|
||||
setPendingSingleRun: s.setPendingSingleRun,
|
||||
}))
|
||||
|
||||
const reservedCanvasWidth = 400 // Reserve the minimum visible width for the canvas
|
||||
|
||||
|
|
@ -256,6 +263,18 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
setIsPaused(false)
|
||||
}, [tabType])
|
||||
|
||||
useEffect(() => {
|
||||
if (!pendingSingleRun || pendingSingleRun.nodeId !== id)
|
||||
return
|
||||
|
||||
if (pendingSingleRun.action === 'run')
|
||||
handleSingleRun()
|
||||
else
|
||||
handleStop()
|
||||
|
||||
setPendingSingleRun(undefined)
|
||||
}, [pendingSingleRun, id, handleSingleRun, handleStop, setPendingSingleRun])
|
||||
|
||||
const logParams = useLogs()
|
||||
const passedLogParams = (() => {
|
||||
if ([BlockEnum.Tool, BlockEnum.Agent, BlockEnum.Iteration, BlockEnum.Loop].includes(data.type))
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ export type NodeSliceShape = {
|
|||
setLoopTimes: (loopTimes: number) => void
|
||||
iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>
|
||||
setIterParallelLogMap: (iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>) => void
|
||||
pendingSingleRun?: {
|
||||
nodeId: string
|
||||
action: 'run' | 'stop'
|
||||
}
|
||||
setPendingSingleRun: (payload?: NodeSliceShape['pendingSingleRun']) => void
|
||||
}
|
||||
|
||||
export const createNodeSlice: StateCreator<NodeSliceShape> = set => ({
|
||||
|
|
@ -73,4 +78,6 @@ export const createNodeSlice: StateCreator<NodeSliceShape> = set => ({
|
|||
setLoopTimes: loopTimes => set(() => ({ loopTimes })),
|
||||
iterParallelLogMap: new Map<string, Map<string, NodeTracing[]>>(),
|
||||
setIterParallelLogMap: iterParallelLogMap => set(() => ({ iterParallelLogMap })),
|
||||
pendingSingleRun: undefined,
|
||||
setPendingSingleRun: payload => set(() => ({ pendingSingleRun: payload })),
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue