stop handle

pull/21369/head
jZonG 12 months ago
parent d89e40c7c0
commit f1b8ad3dff

@ -19,6 +19,8 @@ import cn from '@/utils/classnames'
import { import {
StopCircle, StopCircle,
} from '@/app/components/base/icons/src/vender/line/mediaAndDevices' } from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { EVENT_WORKFLOW_STOP } from '@/app/components/workflow/variable-inspect/types'
const RunMode = memo(() => { const RunMode = memo(() => {
const { t } = useTranslation() const { t } = useTranslation()
@ -27,6 +29,16 @@ const RunMode = memo(() => {
const workflowRunningData = useStore(s => s.workflowRunningData) const workflowRunningData = useStore(s => s.workflowRunningData)
const isRunning = workflowRunningData?.result.status === WorkflowRunningStatus.Running const isRunning = workflowRunningData?.result.status === WorkflowRunningStatus.Running
const handleStop = () => {
handleStopRun(workflowRunningData?.task_id || '')
}
const { eventEmitter } = useEventEmitterContextContext()
eventEmitter?.useSubscription((v: any) => {
if (v.type === EVENT_WORKFLOW_STOP)
handleStop()
})
return ( return (
<> <>
<div <div
@ -59,7 +71,7 @@ const RunMode = memo(() => {
isRunning && ( isRunning && (
<div <div
className='ml-0.5 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md hover:bg-black/5' className='ml-0.5 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md hover:bg-black/5'
onClick={() => handleStopRun(workflowRunningData?.task_id || '')} onClick={handleStop}
> >
<StopCircle className='h-4 w-4 text-components-button-ghost-text' /> <StopCircle className='h-4 w-4 text-components-button-ghost-text' />
</div> </div>

@ -21,6 +21,8 @@ import {
import { useStore as useAppStore } from '@/app/components/app/store' import { useStore as useAppStore } from '@/app/components/app/store'
import { getLastAnswer, isValidGeneratedAnswer } from '@/app/components/base/chat/utils' import { getLastAnswer, isValidGeneratedAnswer } from '@/app/components/base/chat/utils'
import type { FileEntity } from '@/app/components/base/file-uploader/types' import type { FileEntity } from '@/app/components/base/file-uploader/types'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { EVENT_WORKFLOW_STOP } from '@/app/components/workflow/variable-inspect/types'
type ChatWrapperProps = { type ChatWrapperProps = {
showConversationVariableModal: boolean showConversationVariableModal: boolean
@ -105,6 +107,12 @@ const ChatWrapper = (
) )
}, [chatList, doSend]) }, [chatList, doSend])
const { eventEmitter } = useEventEmitterContextContext()
eventEmitter?.useSubscription((v: any) => {
if (v.type === EVENT_WORKFLOW_STOP)
handleStop()
})
useImperativeHandle(ref, () => { useImperativeHandle(ref, () => {
return { return {
handleRestart, handleRestart,

@ -9,10 +9,13 @@ import useCurrentVars from '../hooks/use-inspect-vars-crud'
import { WorkflowRunningStatus } from '@/app/components/workflow/types' import { WorkflowRunningStatus } from '@/app/components/workflow/types'
import { NodeRunningStatus } from '@/app/components/workflow/types' import { NodeRunningStatus } from '@/app/components/workflow/types'
import type { CommonNodeType } from '@/app/components/workflow/types' import type { CommonNodeType } from '@/app/components/workflow/types'
import { useEventEmitterContextContext } from '@/context/event-emitter'
import { EVENT_WORKFLOW_STOP } from '@/app/components/workflow/variable-inspect/types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
const VariableInspectTrigger: FC = () => { const VariableInspectTrigger: FC = () => {
const { t } = useTranslation() const { t } = useTranslation()
const { eventEmitter } = useEventEmitterContextContext()
const showVariableInspectPanel = useStore(s => s.showVariableInspectPanel) const showVariableInspectPanel = useStore(s => s.showVariableInspectPanel)
const setShowVariableInspectPanel = useStore(s => s.setShowVariableInspectPanel) const setShowVariableInspectPanel = useStore(s => s.setShowVariableInspectPanel)
@ -41,7 +44,9 @@ const VariableInspectTrigger: FC = () => {
const isRunning = useMemo(() => isPreviewRunning || isStepRunning, [isPreviewRunning, isStepRunning]) const isRunning = useMemo(() => isPreviewRunning || isStepRunning, [isPreviewRunning, isStepRunning])
const handleStop = () => { const handleStop = () => {
// TODO: Implement stop functionality eventEmitter?.emit({
type: EVENT_WORKFLOW_STOP,
} as any)
} }
const handleClearAll = () => { const handleClearAll = () => {

@ -0,0 +1 @@
export const EVENT_WORKFLOW_STOP = 'WORKFLOW_STOP'
Loading…
Cancel
Save