Skip to content

Fix branching chat edit/regenerate using wrong checkpoint in useStream (Vue)#1

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-usestream-edit-regenerate
Draft

Fix branching chat edit/regenerate using wrong checkpoint in useStream (Vue)#1
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-usestream-edit-regenerate

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 19, 2026

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

  • handleRegenerate logic fix: Remove the backward human-message search. Use the AI message's own parent_checkpoint directly — this is the state after the user input was committed but before the AI responded, which is the correct branching point for regeneration.

    // Before: found preceding human message, used its parent_checkpoint (one step too far back)
    // After: use the AI message's parent_checkpoint directly
    const msg = streamedMessages.value.find((m) => m.id === messageId);
    const checkpoint = getParentCheckpoint(msg); // state after user msg, before AI response
    stream.submit(undefined, { checkpoint });
  • Type corrections: Replaced the nonexistent UIMessage import from 'ai' with BaseMessage from @langchain/core/messages (the actual runtime type). Updated all function signatures accordingly. Changed the HumanMessage/AIMessage import source from 'langchain' to '@langchain/core/messages'.

  • Minor fixes: Explicit type on the .map() callback in getMessageText; msg.id ?? null to satisfy Ref<string | null> (since BaseMessage.id is string | 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.

Copilot AI and others added 2 commits March 19, 2026 19:31
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
Copilot AI requested a review from Jourdelune March 19, 2026 19:34
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