task: Add versioning to regenerating response#361
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for multiple response versions, enabling users to regenerate bot responses and navigate through a history of versions for a single message. The changes include new data structures for response versions, updated state management to track ratings per version, and UI enhancements in the bot bubble for version navigation. Review feedback highlights the need for defensive checks in the regeneration logic, more robust error handling when parsing stored chat history, and better cleanup in callback refs.
6fb52a4 to
0ecad59
Compare
d385ea3 to
4fc71b5
Compare
| const cleanedMessage = errorMessage.replace(/^Error:\s*\S+\s*-\s*/, ''); | ||
| setMessages((prevMessages) => { | ||
| const allMessages = [...prevMessages, { message: props.errorMessage || cleanedMessage, type: 'apiMessage' as messageType }]; | ||
| const lastMsg = prevMessages[prevMessages.length - 1]; |
There was a problem hiding this comment.
Logic below differentiates the different scenarios of when errors are happening and treats them differently.
Mostly noticeably, when a successful response follows an error, the user would see both messages which is confusing ux. Going on the route of silencing the error if there is a valid message, to suppress the error, but down the line we should explore designs of exposing this error, maybe as a toast or notif somewhow.
| break; | ||
| case 'error': | ||
| updateErrorMessage(payload.data); | ||
| closeResponse(); |
There was a problem hiding this comment.
Ensure feedback buttons always appear after bot messages, even when errors occur.
mmattu-wd
left a comment
There was a problem hiding this comment.
Not sure if I was missing something on the oss server but I could not get the versioning to show up.
Screen.Recording.2026-04-10.at.8.58.40.PM.mov
| {props.chatFeedbackStatus && activeMessage().messageId && ( | ||
| <> | ||
| <RegenerateResponseButton class="regenerate-response-button" feedbackColor={props.feedbackColor} onClick={() => props.onRegenerateResponse?.()} /> | ||
| <Show when={props.showRegenerateResponseButton}> |
There was a problem hiding this comment.
the regenerate is gated behind the props.chatFeedbackStatus, but should bots that don't have feedback enabled also allow for regenerating the response?
There was a problem hiding this comment.
This is more of a product decision to make and to proprogate from flowise, where we decide the visibility of the regenerate functionality. I dont have a strong preference either way and cluttering the feedback may not be best either. Also i think a similar decision can be made for the "copy" functionality but i think we can take that in another ticket
There was a problem hiding this comment.
yea, cool with this being a separate jira but I think the regenerate response would be great in general to expose
| switch (payload.event) { | ||
| case 'start': | ||
| setMessages((prevMessages) => [...prevMessages, { message: '', type: 'apiMessage' }]); | ||
| setMessages((prevMessages) => { |
There was a problem hiding this comment.
nb: if the network or browser is disrupted mid stream, the local storage data would become polluted with a message that didn't complete
There was a problem hiding this comment.
Added a 'isStreaming' flag to try and mitigate the pollution, and added clean up for empty messages on unexpected close
…ated outputs on each assistant message and add previous/next navigation so users can compare alternate regenerated responses in place.
cb64f8e to
cc6f2eb
Compare
mmattu-wd
left a comment
There was a problem hiding this comment.
Ok, I see why the response versions aren't showing up, I was testing with an agentflow and not a chatflow. The versions show up for chatflow perfectly fine, but is that intentional that it doesn't work for agentflow?
It seems for agentflows the responseVersions are being reset on every token stream. I put up a fix for it here you can take a look at: c8ca0cb
Probably requires a side convo but with multiple response versions how do we retain the context when we go to the next chat message. Like if the users next message references their previous message does it reference the latest message or all of their previous generations
Add support for versioning of regenerated response (ie, i can see the history of the regenerated responses)
Each response has unique messageId and feedback capabilities.
Screen.Recording.2026-04-07.at.11.39.03.AM.mov