Skip to content

fix: deduplicate React keys in CopilotChatMessageView#4

Open
HowieG wants to merge 1 commit into
mainfrom
fix/duplicate-react-keys-3258
Open

fix: deduplicate React keys in CopilotChatMessageView#4
HowieG wants to merge 1 commit into
mainfrom
fix/duplicate-react-keys-3258

Conversation

@HowieG

@HowieG HowieG commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Deduplicates agent.messages in CopilotChat.tsx before passing to the view, keeping the last occurrence of each message ID (most up-to-date during streaming)
  • Adds index-based keys in CopilotChatMessageView.tsx as a defensive guard against duplicate IDs from external consumers

Test plan

  • nx run @copilotkitnext/react:test passes
  • nx run @copilotkitnext/react:build succeeds
  • No bare key={message.id} remains in CopilotChatMessageView
  • Manual: verify no React key warnings during streaming in browser console

Closes CopilotKit#3258

🤖 Generated with Claude Code

…aming

During streaming, agent.messages can contain entries with duplicate IDs,
causing React key warnings and UI jank. This deduplicates messages in
CopilotChat (keeping the last occurrence) and adds index-based keys in
CopilotChatMessageView as a defensive guard.

Closes CopilotKit#3258

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

🐛 Bug: v2 Duplicate React keys in CopilotChatMessageView when agent.messages contains entries with the same id

1 participant