Fix branching chat edit/regenerate using wrong checkpoint in useStream (Vue)#1
Draft
Fix branching chat edit/regenerate using wrong checkpoint in useStream (Vue)#1
Conversation
Co-authored-by: Jourdelune <64205064+Jourdelune@users.noreply.github.com>
Co-authored-by: Jourdelune <64205064+Jourdelune@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix edit and regenerate functionality for useStream in Vue
Fix branching chat edit/regenerate using wrong checkpoint in useStream (Vue)
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Edit and regenerate in the branching chat pattern were appending messages to the end of the conversation instead of branching from the correct checkpoint. The regenerate function was particularly broken: it traversed back to find the preceding human message and used that message's
parent_checkpoint, going one step too far back in history.Changes
handleRegeneratelogic fix: Remove the backward human-message search. Use the AI message's ownparent_checkpointdirectly — this is the state after the user input was committed but before the AI responded, which is the correct branching point for regeneration.Type corrections: Replaced the nonexistent
UIMessageimport from'ai'withBaseMessagefrom@langchain/core/messages(the actual runtime type). Updated all function signatures accordingly. Changed theHumanMessage/AIMessageimport source from'langchain'to'@langchain/core/messages'.Minor fixes: Explicit type on the
.map()callback ingetMessageText;msg.id ?? nullto satisfyRef<string | null>(sinceBaseMessage.idisstring | undefined).💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.