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