From e119d1a16c4e012b52d4cc623bdf0f92332589ab Mon Sep 17 00:00:00 2001 From: JzoNg Date: Tue, 3 Feb 2026 15:08:59 +0800 Subject: [PATCH] fix: do not stop when workflow paused event recieved --- web/app/components/base/chat/chat/hooks.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts index a154e58bcb..3e01fa5ade 100644 --- a/web/app/components/base/chat/chat/hooks.ts +++ b/web/app/components/base/chat/chat/hooks.ts @@ -71,6 +71,7 @@ export const useChat = ( const [isResponding, setIsResponding] = useState(false) const isRespondingRef = useRef(false) const taskIdRef = useRef('') + const pausedStateRef = useRef(false) const [suggestedQuestions, setSuggestQuestions] = useState([]) const conversationMessagesAbortControllerRef = useRef(null) const suggestedQuestionsAbortControllerRef = useRef(null) @@ -166,7 +167,7 @@ export const useChat = ( const handleStop = useCallback(() => { hasStopResponded.current = true handleResponding(false) - if (stopChat && taskIdRef.current) + if (stopChat && taskIdRef.current && !pausedStateRef.current) stopChat(taskIdRef.current) if (conversationMessagesAbortControllerRef.current) conversationMessagesAbortControllerRef.current.abort() @@ -537,6 +538,7 @@ export const useChat = ( }, onWorkflowPaused: ({ data: workflowPausedData }) => { const resumeUrl = `/workflow/${workflowPausedData.workflow_run_id}/events` + pausedStateRef.current = true sseGet( resumeUrl, {}, @@ -921,6 +923,8 @@ export const useChat = ( }) }, onWorkflowFinished: ({ data: workflowFinishedData }) => { + if (pausedStateRef.current) + pausedStateRef.current = false responseItem.workflowProcess!.status = workflowFinishedData.status as WorkflowRunningStatus updateCurrentQAOnTree({ placeholderQuestionId, @@ -1111,6 +1115,7 @@ export const useChat = ( }, onWorkflowPaused: ({ data: workflowPausedData }) => { const url = `/workflow/${workflowPausedData.workflow_run_id}/events` + pausedStateRef.current = true sseGet( url, {},