Skip to content

Commit

Permalink
feat: ignore edits with text part unchanged (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Sep 10, 2024
1 parent f72e0e5 commit 164e46c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-kids-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"assistant-ui": patch
---

feat: ignore edits with text part unchanged
3 changes: 3 additions & 0 deletions packages/react/src/context/providers/MessageProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const useMessageContext = (messageIndex: number) => {
"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.",
);

const previousText = getThreadMessageText(message);
if (previousText === text) return;

const nonTextParts = message.content.filter(
(part): part is CoreUserContentPart =>
part.type !== "text" && part.type !== "ui",
Expand Down

0 comments on commit 164e46c

Please sign in to comment.