mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 02:28:30 +08:00
fix: restore responding state after HITL resume (#38992)
This commit is contained in:
parent
ab3e4daa95
commit
10da5e8f9d
@ -590,6 +590,39 @@ describe('useChat', () => {
|
||||
expect(result.current.isResponding).toBe(false) // from onError
|
||||
})
|
||||
|
||||
it('should restore responding state when a paused human input workflow resumes', async () => {
|
||||
let initialCallbacks: HookCallbacks
|
||||
let resumedCallbacks: HookCallbacks
|
||||
|
||||
vi.mocked(ssePost).mockImplementation(async (_url, _params, options) => {
|
||||
initialCallbacks = options as HookCallbacks
|
||||
})
|
||||
vi.mocked(sseGet).mockImplementation(async (_url, _params, options) => {
|
||||
resumedCallbacks = options as HookCallbacks
|
||||
})
|
||||
|
||||
const { result } = renderHook(() => useChat())
|
||||
|
||||
act(() => {
|
||||
result.current.handleSend('test-url', { query: 'human input test' }, {})
|
||||
})
|
||||
act(() => {
|
||||
initialCallbacks.onWorkflowStarted({ workflow_run_id: 'wr-1', task_id: 't-1' })
|
||||
initialCallbacks.onWorkflowPaused({ data: { workflow_run_id: 'wr-1' } })
|
||||
})
|
||||
await act(async () => {
|
||||
await initialCallbacks.onCompleted()
|
||||
})
|
||||
|
||||
expect(result.current.isResponding).toBe(false)
|
||||
|
||||
act(() => {
|
||||
resumedCallbacks.onWorkflowStarted({ workflow_run_id: 'wr-1', task_id: 't-1' })
|
||||
})
|
||||
|
||||
expect(result.current.isResponding).toBe(true)
|
||||
})
|
||||
|
||||
it('should handle file uploads in onFile', () => {
|
||||
let callbacks: HookCallbacks
|
||||
|
||||
|
||||
@ -1242,6 +1242,7 @@ export const useChat = (
|
||||
})
|
||||
},
|
||||
onWorkflowStarted: ({ workflow_run_id, task_id, conversation_id, message_id }) => {
|
||||
handleResponding(true)
|
||||
// If there are no streaming messages, we still need to set the conversation_id to avoid create a new conversation when regeneration in chat-flow.
|
||||
if (conversation_id) {
|
||||
conversationIdRef.current = conversation_id
|
||||
|
||||
Loading…
Reference in New Issue
Block a user