Skip to content

task: Add versioning to regenerating response#361

Open
chloebyun-wd wants to merge 7 commits intomainfrom
task/add-versionining-when-regenerating-response
Open

task: Add versioning to regenerating response#361
chloebyun-wd wants to merge 7 commits intomainfrom
task/add-versionining-when-regenerating-response

Conversation

@chloebyun-wd
Copy link
Copy Markdown
Contributor

@chloebyun-wd chloebyun-wd commented Apr 2, 2026

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/components/Bot.tsx Outdated
Comment thread src/components/Bot.tsx Outdated
Comment thread src/components/bubbles/BotBubble.tsx Outdated
@chloebyun-wd chloebyun-wd force-pushed the faet/regenrate-response-functionality branch from 6fb52a4 to 0ecad59 Compare April 6, 2026 15:11
@chloebyun-wd chloebyun-wd force-pushed the task/add-versionining-when-regenerating-response branch from d385ea3 to 4fc71b5 Compare April 6, 2026 16:07
@chloebyun-wd chloebyun-wd changed the base branch from faet/regenrate-response-functionality to main April 6, 2026 16:07
Comment thread src/components/Bot.tsx
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];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/components/Bot.tsx
break;
case 'error':
updateErrorMessage(payload.data);
closeResponse();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure feedback buttons always appear after bot messages, even when errors occur.

@chloebyun-wd chloebyun-wd marked this pull request as ready for review April 7, 2026 20:11
@HenryHengZJ HenryHengZJ requested a review from mmattu-wd April 9, 2026 20:54
Copy link
Copy Markdown
Contributor

@mmattu-wd mmattu-wd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/components/Bot.tsx
Comment thread src/components/Bot.tsx
{props.chatFeedbackStatus && activeMessage().messageId && (
<>
<RegenerateResponseButton class="regenerate-response-button" feedbackColor={props.feedbackColor} onClick={() => props.onRegenerateResponse?.()} />
<Show when={props.showRegenerateResponseButton}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the regenerate is gated behind the props.chatFeedbackStatus, but should bots that don't have feedback enabled also allow for regenerating the response?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, cool with this being a separate jira but I think the regenerate response would be great in general to expose

Comment thread src/components/bubbles/BotBubble.tsx
Comment thread src/components/bubbles/BotBubble.tsx
Comment thread src/components/Bot.tsx
Comment thread src/components/Bot.tsx
switch (payload.event) {
case 'start':
setMessages((prevMessages) => [...prevMessages, { message: '', type: 'apiMessage' }]);
setMessages((prevMessages) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: if the network or browser is disrupted mid stream, the local storage data would become polluted with a message that didn't complete

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@chloebyun-wd chloebyun-wd force-pushed the task/add-versionining-when-regenerating-response branch from cb64f8e to cc6f2eb Compare April 13, 2026 18:03
Copy link
Copy Markdown
Contributor

@mmattu-wd mmattu-wd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants