mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
fix: do not stop when workflow paused event recieved
This commit is contained in:
@ -71,6 +71,7 @@ export const useChat = (
|
|||||||
const [isResponding, setIsResponding] = useState(false)
|
const [isResponding, setIsResponding] = useState(false)
|
||||||
const isRespondingRef = useRef(false)
|
const isRespondingRef = useRef(false)
|
||||||
const taskIdRef = useRef('')
|
const taskIdRef = useRef('')
|
||||||
|
const pausedStateRef = useRef(false)
|
||||||
const [suggestedQuestions, setSuggestQuestions] = useState<string[]>([])
|
const [suggestedQuestions, setSuggestQuestions] = useState<string[]>([])
|
||||||
const conversationMessagesAbortControllerRef = useRef<AbortController | null>(null)
|
const conversationMessagesAbortControllerRef = useRef<AbortController | null>(null)
|
||||||
const suggestedQuestionsAbortControllerRef = useRef<AbortController | null>(null)
|
const suggestedQuestionsAbortControllerRef = useRef<AbortController | null>(null)
|
||||||
@ -166,7 +167,7 @@ export const useChat = (
|
|||||||
const handleStop = useCallback(() => {
|
const handleStop = useCallback(() => {
|
||||||
hasStopResponded.current = true
|
hasStopResponded.current = true
|
||||||
handleResponding(false)
|
handleResponding(false)
|
||||||
if (stopChat && taskIdRef.current)
|
if (stopChat && taskIdRef.current && !pausedStateRef.current)
|
||||||
stopChat(taskIdRef.current)
|
stopChat(taskIdRef.current)
|
||||||
if (conversationMessagesAbortControllerRef.current)
|
if (conversationMessagesAbortControllerRef.current)
|
||||||
conversationMessagesAbortControllerRef.current.abort()
|
conversationMessagesAbortControllerRef.current.abort()
|
||||||
@ -537,6 +538,7 @@ export const useChat = (
|
|||||||
},
|
},
|
||||||
onWorkflowPaused: ({ data: workflowPausedData }) => {
|
onWorkflowPaused: ({ data: workflowPausedData }) => {
|
||||||
const resumeUrl = `/workflow/${workflowPausedData.workflow_run_id}/events`
|
const resumeUrl = `/workflow/${workflowPausedData.workflow_run_id}/events`
|
||||||
|
pausedStateRef.current = true
|
||||||
sseGet(
|
sseGet(
|
||||||
resumeUrl,
|
resumeUrl,
|
||||||
{},
|
{},
|
||||||
@ -921,6 +923,8 @@ export const useChat = (
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onWorkflowFinished: ({ data: workflowFinishedData }) => {
|
onWorkflowFinished: ({ data: workflowFinishedData }) => {
|
||||||
|
if (pausedStateRef.current)
|
||||||
|
pausedStateRef.current = false
|
||||||
responseItem.workflowProcess!.status = workflowFinishedData.status as WorkflowRunningStatus
|
responseItem.workflowProcess!.status = workflowFinishedData.status as WorkflowRunningStatus
|
||||||
updateCurrentQAOnTree({
|
updateCurrentQAOnTree({
|
||||||
placeholderQuestionId,
|
placeholderQuestionId,
|
||||||
@ -1111,6 +1115,7 @@ export const useChat = (
|
|||||||
},
|
},
|
||||||
onWorkflowPaused: ({ data: workflowPausedData }) => {
|
onWorkflowPaused: ({ data: workflowPausedData }) => {
|
||||||
const url = `/workflow/${workflowPausedData.workflow_run_id}/events`
|
const url = `/workflow/${workflowPausedData.workflow_run_id}/events`
|
||||||
|
pausedStateRef.current = true
|
||||||
sseGet(
|
sseGet(
|
||||||
url,
|
url,
|
||||||
{},
|
{},
|
||||||
|
|||||||
Reference in New Issue
Block a user