New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loss of Chat message response on chat switch mid response #4190
Comments
To address the issue of losing chat message responses when switching between chats mid-response in Dify, you can implement a mechanism to save and restore the chat response state. This involves capturing the current state of the chat response before switching and restoring it upon returning to the original chat. Here's a concise approach:
Example implementation snippet: // Modify handleConversationSwitch to save current chat response
const handleConversationSwitch = () => {
const currentResponse = getCurrentChatResponse(); // Implement based on your chat input management
localStorage.setItem(`chatResponse_${currConversationId}`, currentResponse);
}
// Restore chat response when returning to a chat
useEffect(() => {
const savedResponse = localStorage.getItem(`chatResponse_${currConversationId}`);
if (savedResponse) {
restoreChatResponse(savedResponse); // Implement to restore chat response
localStorage.removeItem(`chatResponse_${currConversationId}`);
}
}, [currConversationId]); Ensure to adapt this example to fit your application's specific data structures and state management approaches. This solution should prevent the loss of chat message responses during chat switches.
|
Self Checks
Dify version
0.6.6
Cloud or Self Hosted
Cloud and Self Hosted (Docker)
Steps to reproduce
Greeting
toGreeting myself
and back)This issue can be reproduced both in the Cloud and Self Hosted Docker versions of Dify.
✔️ Expected Behavior
When switching chats, the agent's entire response should be saved. This means that not only the part of the response generated before the chat switch, but also the full, completed response should be visible when returning to the original chat.
Ideally, the expected behavior is similar to the current behavior with starting different chats with the same agent on different browser tabs. In such a case, you can see the message being generated in real time as you switch between tabs, and the final version is properly saved.
❌ Actual Behavior
As a side note,
agent_though
event received from the backend which is cutoff on context switch due to ChatStopAPI call.agent_thought
event is recieved also means if you hit Stop Responding Icon on the UI, the half-generated message will not be saved in DB and disappear on reload. See image below:The text was updated successfully, but these errors were encountered: