Fix #5742: Chat UI in Agentic Flow shows delayed responses, duplicated/#5815
Fix #5742: Chat UI in Agentic Flow shows delayed responses, duplicated/#5815danielalanbates wants to merge 1 commit intoFlowiseAI:mainfrom
Conversation
…low chat UI - Add AbortController to fetchResponseFromEventStream so that each new stream request cancels any previously in-flight stream. This stops multiple concurrent fetchEventSource calls from POSTing the same message to the backend multiple times. - Abort the controller after receiving the 'end' or 'abort' SSE event so that @microsoft/fetch-event-source does not automatically retry the POST request (which was the root cause of the infinite/duplicated executions reported in FlowiseAI#5742). - Abort and null the controller in the useEffect cleanup that runs when the chat popup closes or the chatflowid changes, preventing orphaned streams from updating state after unmount and eliminating the delayed-response symptom. - In ChatPopUp.clearChat(), after deleting chat messages, also delete the corresponding executions for the session when running in agent canvas mode. Previously the executions were re-fetched on dialog reopen and re-displayed even though the chat history had been cleared. Fixes FlowiseAI#5742
Summary of ChangesHello @danielalanbates, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the stability and responsiveness of the chat UI within agentic flows. By introducing robust stream cancellation mechanisms and enhancing the chat clearing process to include agent executions, it resolves critical issues such as delayed responses, unintended duplicate executions, and incomplete chat history resets, leading to a more predictable and reliable user experience. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces important fixes for the Agentic Flow chat UI. The use of AbortController to manage fetchEventSource requests in ChatMessage.jsx is a solid approach to prevent delayed responses and duplicate executions. This correctly handles request cancellation when the component unmounts, the chatflow changes, or a new request is initiated. The addition of logic in ChatPopUp.jsx to clear associated executions for agentic flows is also a crucial fix for ensuring complete chat history clearing. The suggestion for improvement in ChatPopUp.jsx to make the execution deletion more robust by paginating through all results is a valid and important point.
| const executionsRes = await executionsApi.getAllExecutions({ | ||
| agentflowId: chatflowid, | ||
| sessionId: objChatDetails.chatId, | ||
| limit: 100 | ||
| }) | ||
| const executions = executionsRes.data?.data ?? [] | ||
| if (executions.length > 0) { | ||
| await executionsApi.deleteExecutions(executions.map((e) => e.id)) | ||
| } |
There was a problem hiding this comment.
The current implementation fetches up to 100 executions to delete. If a session has more than 100 executions, not all of them will be cleared. To ensure all executions are deleted, you should paginate through all results from the getAllExecutions API.
const executionsToDelete = [];
let page = 1;
const limit = 100;
let hasMore = true;
while (hasMore) {
const executionsRes = await executionsApi.getAllExecutions({
agentflowId: chatflowid,
sessionId: objChatDetails.chatId,
limit,
page
});
const executions = executionsRes.data?.data ?? [];
if (executions.length > 0) {
executionsToDelete.push(...executions);
}
if (executions.length < limit) {
hasMore = false;
}
page += 1;
}
if (executionsToDelete.length > 0) {
await executionsApi.deleteExecutions(executionsToDelete.map((e) => e.id));
}
Fixes #5742
Summary
This PR addresses: Chat UI in Agentic Flow shows delayed responses, duplicated/infinite executions, and incomplete chat clearing
Changes
Testing
Please review the changes carefully. The fix was verified against the existing test suite.
This PR was created with the assistance of Claude Sonnet 4.6 by Anthropic | effort: low. Happy to make any adjustments!
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license (contributor license agreement).