Repository navigation
Fix re-rendering issues when generating suggestions - #2231
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
WalkthroughThe changes refactor the management of the Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant CopilotKit
participant CopilotMessages
participant CopilotMessagesContext
App->>CopilotKit: Wraps components with CopilotKit provider
CopilotKit->>CopilotMessages: Renders CopilotMessages
CopilotMessages->>CopilotMessagesContext: Provides messages & suggestions state
App->>CopilotMessagesContext: Consumes messages & suggestions via context
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.ts (1)
164-179: Fix stableContext memoization to track full chatSuggestionConfigurationThe dependency on
Object.keys(chatSuggestionConfiguration).lengthonly captures changes in the number of configs, not updates to their values. Replace or supplement this with the configuration object itself (or a serialized form) so that changes to its contents also retrigger the memo.• File: packages/react-core/src/hooks/use-copilot-chat_internal.ts (lines 164–179)
Suggested diff:
const stableContext = useMemo(() => { return { actions, copilotApiConfig, chatSuggestionConfiguration, messages, setMessages, getContextString, runtimeClient, }; - }, [ - JSON.stringify(Object.keys(actions)), - copilotApiConfig.chatApiEndpoint, - messages.length, - Object.keys(chatSuggestionConfiguration).length, - ]); + }, [ + JSON.stringify(Object.keys(actions)), + copilotApiConfig.chatApiEndpoint, + messages.length, + chatSuggestionConfiguration, + ]);
🧹 Nitpick comments (1)
CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx (1)
11-11: Fix misplaced comment.The comment "suggestions state" appears to be for the
setMessagesline, but should likely be moved to line 12-13 where the actual suggestions state is defined.- setMessages: React.Dispatch<React.SetStateAction<Message[]>>; // suggestions state + setMessages: React.Dispatch<React.SetStateAction<Message[]>>;Then add the comment to the suggestions lines:
+ // suggestions state suggestions: SuggestionItem[]; setSuggestions: React.Dispatch<React.SetStateAction<SuggestionItem[]>>;
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
CopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx(2 hunks)CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx(0 hunks)CopilotKit/packages/react-core/src/context/copilot-context.tsx(0 hunks)CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx(1 hunks)CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.ts(1 hunks)docs/content/docs/reference/components/chat/CopilotChat.mdx(2 hunks)docs/content/docs/reference/components/chat/CopilotPopup.mdx(2 hunks)docs/content/docs/reference/components/chat/CopilotSidebar.mdx(2 hunks)docs/content/docs/reference/hooks/useCopilotChat.mdx(2 hunks)
💤 Files with no reviewable changes (2)
- CopilotKit/packages/react-core/src/context/copilot-context.tsx
- CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
🧰 Additional context used
📓 Path-based instructions (6)
CopilotKit/packages/react-core/**
📄 CodeRabbit Inference Engine (.cursor/rules/copilotkit-architecture.mdc)
Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Files:
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.tsCopilotKit/packages/react-core/src/context/copilot-messages-context.tsxCopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/frontend-development.mdc)
Use TypeScript for better type safety
Files:
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.tsCopilotKit/packages/react-core/src/context/copilot-messages-context.tsxCopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx
{**/*.{ts,tsx},CopilotKit/utilities/tailwind-config/**}
📄 CodeRabbit Inference Engine (.cursor/rules/frontend-development.mdc)
Maintain consistent styling with Tailwind CSS
Files:
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.tsCopilotKit/packages/react-core/src/context/copilot-messages-context.tsxCopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx
CopilotKit/packages/react-core/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/quick-reference.mdc)
Use [react-core/] for basic integration when building a simple Copilot
Files:
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.tsCopilotKit/packages/react-core/src/context/copilot-messages-context.tsxCopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx
docs/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/quick-reference.mdc)
Check [docs/] for documentation site
Files:
docs/content/docs/reference/hooks/useCopilotChat.mdxdocs/content/docs/reference/components/chat/CopilotSidebar.mdxdocs/content/docs/reference/components/chat/CopilotChat.mdxdocs/content/docs/reference/components/chat/CopilotPopup.mdx
docs/content/docs/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/quick-reference.mdc)
See [docs/content/docs/] for markdown documentation files
Files:
docs/content/docs/reference/hooks/useCopilotChat.mdxdocs/content/docs/reference/components/chat/CopilotSidebar.mdxdocs/content/docs/reference/components/chat/CopilotChat.mdxdocs/content/docs/reference/components/chat/CopilotPopup.mdx
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use `suggestions="auto"` on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if `useCopilotChatSuggestions` is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify `useCopilotChatSuggestions` is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui/**/*.{ts,tsx},examples/**/ui/**/*.{ts,tsx}} : Provide clear user feedback
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-ui/** : UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.ts (12)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use static arrays for fixed suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="manual" when you want full programmatic control
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Suggestions.tsx : Handle empty states - Some configurations may not generate suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check your configurations to avoid duplicate suggestions, even though the system automatically deduplicates
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Use [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/CopilotKit.code-workspace : Use [CopilotKit.code-workspace] for VS Code workspace settings
docs/content/docs/reference/hooks/useCopilotChat.mdx (14)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Use [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-core/**/* : Use [react-core/] for basic integration when building a simple Copilot
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-ui/** : UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="manual" when you want full programmatic control
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Suggestions.tsx : Handle empty states - Some configurations may not generate suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use static arrays for fixed suggestions
CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx (10)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Suggestions.tsx : Handle empty states - Some configurations may not generate suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use static arrays for fixed suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check your configurations to avoid duplicate suggestions, even though the system automatically deduplicates
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="manual" when you want full programmatic control
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check for partial data handling to avoid console spam during streaming validation
CopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx (13)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Suggestions.tsx : Handle empty states - Some configurations may not generate suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use static arrays for fixed suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check your configurations to avoid duplicate suggestions, even though the system automatically deduplicates
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="manual" when you want full programmatic control
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check for partial data handling to avoid console spam during streaming validation
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Provide clear user feedback
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/runtime-client-gql/** : GraphQL client for runtime communication should be implemented in CopilotKit/packages/runtime-client-gql/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Use [CopilotKit/package.json] for workspace setup
docs/content/docs/reference/components/chat/CopilotSidebar.mdx (16)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Provide clear user feedback
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Use [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-core/**/* : Use [react-core/] for basic integration when building a simple Copilot
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-ui/** : UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Implement responsive design
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {/*.{ts,tsx},CopilotKit/utilities/tailwind-config/} : Maintain consistent styling with Tailwind CSS
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-ui/**/* : Add [react-ui/] for pre-built components when building a simple Copilot or customizing UI components
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/CopilotKit.code-workspace : Use [CopilotKit.code-workspace] for VS Code workspace settings
docs/content/docs/reference/components/chat/CopilotChat.mdx (16)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Provide clear user feedback
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Use [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="manual" when you want full programmatic control
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-core/**/* : Use [react-core/] for basic integration when building a simple Copilot
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-ui/** : UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Implement responsive design
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-ui/**/* : Add [react-ui/] for pre-built components when building a simple Copilot or customizing UI components
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/CopilotKit.code-workspace : Use [CopilotKit.code-workspace] for VS Code workspace settings
docs/content/docs/reference/components/chat/CopilotPopup.mdx (16)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify useCopilotChatSuggestions is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Provide clear user feedback
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Use [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-core/**/* : Use [react-core/] for basic integration when building a simple Copilot
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-ui/** : UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui//*.{ts,tsx},examples//ui/**/*.{ts,tsx}} : Implement responsive design
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-ui/**/* : Add [react-ui/] for pre-built components when building a simple Copilot or customizing UI components
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {/*.{ts,tsx},CopilotKit/utilities/tailwind-config/} : Maintain consistent styling with Tailwind CSS
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/CopilotKit.code-workspace : Use [CopilotKit.code-workspace] for VS Code workspace settings
🔇 Additional comments (16)
CopilotKit/packages/react-core/src/hooks/use-copilot-chat_internal.ts (1)
143-143: LGTM: Clean refactoring to improve re-rendering performance.Moving
suggestionsandsetSuggestionsfrom the general Copilot context to the more specific CopilotMessages context is a good architectural decision. This should reduce unnecessary re-renders in components that don't need message updates, directly addressing the PR's objective of fixing re-rendering issues.CopilotKit/packages/react-core/src/components/copilot-provider/copilot-messages.tsx (3)
23-23: LGTM: Proper import of SuggestionItem type.The import statement correctly brings in the
SuggestionItemtype needed for the new suggestions state.
250-250: LGTM: Clean state initialization for suggestions.The suggestions state is properly initialized with an empty array and follows React state management best practices.
257-258: LGTM: Proper integration with context provider.The suggestions state and setter are correctly added to the context value, completing the refactoring to move suggestions from the main Copilot context to the messages context.
docs/content/docs/reference/hooks/useCopilotChat.mdx (3)
17-18: LGTM: Clear documentation of publicApiKey requirement.The documentation clearly states the requirement for a
publicApiKeyand provides the signup URL, making it easy for developers to understand what they need to do.
25-35: LGTM: Proper example with CopilotKit wrapper.The example correctly demonstrates wrapping the component in the
CopilotKitprovider with the requiredpublicApiKey. This follows the new architectural pattern consistently.
55-64: LGTM: Consistent pattern in suggestions example.The suggestions example also properly demonstrates the
CopilotKitwrapper pattern, maintaining consistency across all usage examples in the documentation.docs/content/docs/reference/components/chat/CopilotSidebar.mdx (2)
44-64: LGTM: Comprehensive observability hooks documentation.The new section clearly explains the observability hooks feature with:
- Clear explanation of the feature's purpose
- Explicit requirement for
publicApiKey- Practical usage example with semantic hook names
- Consistent documentation pattern with other components
218-221: LGTM: Proper property reference for observabilityHooks.The property reference clearly documents the
observabilityHooksprop and its dependency onpublicApiKey, providing developers with complete API documentation.docs/content/docs/reference/components/chat/CopilotChat.mdx (2)
41-56: LGTM: Excellent consistency in observability hooks documentation.The observability hooks section follows the same high-quality pattern established in other components:
- Clear feature explanation
- Explicit
publicApiKeyrequirement- Semantic hook naming (
onMessageSentis perfect for chat)- Complete usage example
210-213: LGTM: Complete API documentation for observabilityHooks.The property reference provides clear documentation about the
observabilityHooksprop and its dependency onpublicApiKey, maintaining consistency with other component documentation.docs/content/docs/reference/components/chat/CopilotPopup.mdx (2)
42-60: Documentation looks comprehensive and follows established patterns.The new observability hooks section clearly explains the feature and properly documents the
publicApiKeyrequirement. The example code demonstrates correct usage within the<CopilotKit>wrapper.
214-217: Property reference is clear and consistent.The
observabilityHooksproperty reference properly documents the type and requirement forpublicApiKey, maintaining consistency with the usage pattern described in the example above.CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx (3)
7-7: Import addition looks correct.The
SuggestionItemimport is properly added to support the new suggestions state in the context interface.
12-13: Suggestions state properly defined.The interface extension correctly adds both the suggestions array and its setter function with appropriate TypeScript types.
19-21: Default context initialization looks correct.The suggestions state is properly initialized with empty arrays and no-op setter functions, consistent with the existing pattern for messages state.
| export interface CopilotMessagesContextParams { | ||
| messages: Message[]; | ||
| setMessages: React.Dispatch<React.SetStateAction<Message[]>>; | ||
| setMessages: React.Dispatch<React.SetStateAction<Message[]>>; // suggestions state | ||
| suggestions: SuggestionItem[]; | ||
| setSuggestions: React.Dispatch<React.SetStateAction<SuggestionItem[]>>; | ||
| } |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify this refactoring addresses the re-rendering issues.
Moving suggestions state from the general copilot context to the messages context should help isolate re-rendering concerns. This aligns with the PR objective to fix re-rendering issues when generating suggestions.
Based on retrieved learnings, ensure that:
- useEffect dependencies are properly memoized where this context is consumed
- Direct suggestions state modifications are avoided
- The refactoring doesn't introduce new re-rendering issues
🏁 Script executed:
#!/bin/bash
# Search for usages of suggestions state to verify the refactoring is complete
echo "=== Searching for old suggestions usage in copilot context ==="
rg -A 3 -B 3 "suggestions.*copilot.*context" --type tsx --type ts
echo -e "\n=== Searching for new suggestions usage in messages context ==="
rg -A 3 -B 3 "suggestions.*messages.*context" --type tsx --type ts
echo -e "\n=== Searching for direct suggestions state modifications ==="
rg -A 2 -B 2 "setSuggestions\(" --type tsx --type ts
echo -e "\n=== Searching for useEffect with suggestions dependencies ==="
rg -A 5 -B 2 "useEffect.*suggestions" --type tsx --type tsLength of output: 918
🏁 Script executed:
#!/bin/bash
set -e
echo "=== Listing all files in react-core/src/context ==="
fd -t f packages/react-core/src/context
echo -e "\n=== All createContext usages in react-core/src/context ==="
rg "createContext" -n packages/react-core/src/context
echo -e "\n=== Inspect copilot-messages-context.tsx ==="
sed -n '1,200p' packages/react-core/src/context/copilot-messages-context.tsx || echo "File not found: copilot-messages-context.tsx"
echo -e "\n=== Inspect copilot-context.tsx if it exists ==="
if [[ -f packages/react-core/src/context/copilot-context.tsx ]]; then
sed -n '1,200p' packages/react-core/src/context/copilot-context.tsx
else
echo "File not found: copilot-context.tsx"
fi
echo -e "\n=== Searching for 'suggestions' in context directory ==="
rg "suggestions" -n packages/react-core/src/context
echo -e "\n=== Searching for setSuggestions calls across the repo ==="
rg -n "setSuggestions\(" .
echo -e "\n=== Searching for useEffect with 'suggestions' dependencies across the repo ==="
rg -n "useEffect.*suggestions" .
echo -e "\n=== Searching for useContext(CopilotMessagesContext) across the repo ==="
rg -n "useContext.*CopilotMessagesContext" .Length of output: 422
🏁 Script executed:
#!/bin/bash
set -e
echo "=== Locating 'copilot-messages-context.tsx' ==="
fd -t f copilot-messages-context.tsx .
echo -e "\n=== Locating all 'context' directories under packages ==="
fd -t d context packages
echo -e "\n=== Searching for createContext usages across repo ==="
rg "createContext" -n .
echo -e "\n=== Searching for CopilotMessagesContext references ==="
rg "CopilotMessagesContext" -n .
echo -e "\n=== Searching for setSuggestions calls across repo ==="
rg "setSuggestions\(" -n .
echo -e "\n=== Searching for useEffect with suggestions dependencies ==="
rg "useEffect.*suggestions" -n .Length of output: 494
🏁 Script executed:
#!/bin/bash
set -e
echo "=== Locating all 'context' directories under CopilotKit ==="
fd -t d context CopilotKit
echo -e "\n=== Listing files in react-core context directory ==="
fd -t f CopilotKit/packages/react-core/src/context
echo -e "\n=== Inspecting copilot-messages-context.tsx ==="
sed -n '1,200p' CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx || echo "File not found"
echo -e "\n=== Searching for createContext in react-core context ==="
rg "createContext" -n CopilotKit/packages/react-core/src/context
echo -e "\n=== Searching for CopilotMessagesContext references ==="
rg -n "CopilotMessagesContext" CopilotKit
echo -e "\n=== Searching for setSuggestions calls across CopilotKit ==="
rg -n "setSuggestions\(" CopilotKit
echo -e "\n=== Searching for useEffect with 'suggestions' in dependencies ==="
rg -n "useEffect.*suggestions" CopilotKitLength of output: 956
🏁 Script executed:
#!/bin/bash
echo "=== Listing files in react-core context directory ==="
find CopilotKit/packages/react-core/src/context -type f 2>/dev/null || echo "Directory not found: react-core context"
echo -e "\n=== Inspecting copilot-messages-context.tsx ==="
sed -n '1,200p' CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx 2>/dev/null || echo "File not found: copilot-messages-context.tsx"
echo -e "\n=== Searching for createContext usage in react-core context ==="
rg -n "createContext" CopilotKit/packages/react-core/src/context || echo "No createContext usage found"
echo -e "\n=== Searching for CopilotMessagesContext references across repo ==="
rg -n "CopilotMessagesContext" CopilotKit || echo "No CopilotMessagesContext references found"
echo -e "\n=== Searching for setSuggestions calls across repo ==="
rg -n "setSuggestions\(" CopilotKit || echo "No setSuggestions calls found"
echo -e "\n=== Searching for useEffect with 'suggestions' dependencies across repo ==="
rg -n "useEffect.*suggestions" CopilotKit || echo "No useEffect with suggestions found"Length of output: 8796
🏁 Script executed:
#!/bin/bash
set -e
echo "=== Searching for `interface CopilotContextParams` in copilot-context.tsx ==="
rg -n "interface CopilotContextParams" CopilotKit/packages/react-core/src/context/copilot-context.tsx || echo "No CopilotContextParams interface found"
echo -e "\n=== Showing CopilotContextParams definition and context around it ==="
sed -n '280,360p' CopilotKit/packages/react-core/src/context/copilot-context.tsx 2>/dev/null || echo "Unable to display lines 280-360"
echo -e "\n=== Searching for `suggestions` in copilot-context.tsx ==="
rg -n "suggestions" CopilotKit/packages/react-core/src/context/copilot-context.tsx || echo "No `suggestions` references in copilot-context.tsx"Length of output: 2351
🏁 Script executed:
#!/bin/bash
set -e
echo "=== Extracting CopilotContextParams interface definition ==="
sed -n '100,200p' CopilotKit/packages/react-core/src/context/copilot-context.tsx || echo "Failed to read copilot-context.tsx"Length of output: 3532
Remove Residual Suggestions State from CopilotContext
It looks like suggestions and setSuggestions are still defined in your main CopilotContext, even though they’ve been moved into CopilotMessagesContext. To complete the refactoring and fully isolate suggestions (and prevent unintended re-renders), you’ll need to:
• In packages/react-core/src/context/copilot-context.tsx
– Remove the suggestions: SuggestionItem[] and setSuggestions: React.Dispatch<…> entries from the CopilotContextParams interface.
– Delete their default values (suggestions: [] and setSuggestions: () => {}) from emptyCopilotContext.
– Remove the import { SuggestionItem } line if it’s no longer used.
• Verify that all consumers of CopilotContext now obtain suggestions only via useCopilotMessagesContext().
• After cleanup, ensure:
- All
useEffecthooks consuming suggestions are using the messages context and have properly memoized dependencies. - No direct calls to
setSuggestionsremain in the old context.
This will complete the isolation of suggestions state and align with your goal of targeted re-renders.
🤖 Prompt for AI Agents
In packages/react-core/src/context/copilot-context.tsx, remove the suggestions
and setSuggestions properties from the CopilotContextParams interface and delete
their default values from the emptyCopilotContext object. Also, remove the
import of SuggestionItem if it is no longer used. Then, verify that all
components consuming CopilotContext now access suggestions only through
useCopilotMessagesContext(), update any useEffect hooks to depend on the
messages context with properly memoized dependencies, and ensure there are no
remaining direct calls to setSuggestions in the old context. This will fully
isolate the suggestions state into CopilotMessagesContext and prevent unintended
re-renders.
The suggestions and setSuggestions properties were moved to CopilotMessagesContext but were not removed from the emptyCopilotContext object, causing TypeScript build errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
🦋 Changeset detectedLatest commit: 567c9d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
CopilotKit/.changeset/sixty-chairs-push.md (1)
5-5: Minor copy-edit for clarity.Consider capitalizing and hyphenating “re-render” for style consistency with previous changesets:
- - fix rerender issues by moving suggestions to the messages context + - Fix re-render issues by moving suggestions to the messages context
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
CopilotKit/.changeset/sixty-chairs-push.md(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use `suggestions="auto"` on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if `useCopilotChatSuggestions` is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Verify `useCopilotChatSuggestions` is registering configuration
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-07-18T15:03:52.262Z
Learning: Applies to {CopilotKit/packages/react-ui/**/*.{ts,tsx},examples/**/ui/**/*.{ts,tsx}} : Provide clear user feedback
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-ui/** : UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/
CopilotKit/.changeset/sixty-chairs-push.md (13)
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Don't modify suggestions state directly - Always use the provided hooks and functions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if useCopilotChatSuggestions is being called in your component if there are no initial suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use suggestions="auto" on CopilotChat for most cases
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-core/**/* : Use [react-core/] for basic integration when building a simple Copilot
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-textarea/** : Textarea component with AI integration should be implemented in CopilotKit/packages/react-textarea/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-07-18T15:03:09.673Z
Learning: Applies to CopilotKit/packages/react-core/** : Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/package.json : Review [CopilotKit/package.json] for workspace setup
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/components/chat/Chat.tsx : Use static arrays for fixed suggestions
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check for partial data handling to avoid console spam during streaming validation
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Check your configurations to avoid duplicate suggestions, even though the system automatically deduplicates
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-core/src/utils/suggestions.ts : Verify abort controllers are cleaning up properly
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-ui/**/* : Add [react-ui/] for pre-built components when building a simple Copilot or customizing UI components
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Build Images (next-openai, next-openai)
- GitHub Check: Build Images (coagents-routing, ui)
- GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-native, ui)
- GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
- GitHub Check: Build Images (coagents-qa-text, ui)
- GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
- GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
- GitHub Check: Build Images (coagents-research-canvas, ui)
- GitHub Check: Test (18.x)
- GitHub Check: Test (20.x)
🔇 Additional comments (1)
CopilotKit/.changeset/sixty-chairs-push.md (1)
1-5: Changeset format is correct – no blocking issues found.The header fence, package bump declaration, and bullet-point summary follow the Changesets spec. ✅
|
Preview environments destroyed for this pull request. |
Test ResultsStatus: ❌ Failed (View Run) Commit: 91e95e2 Duration: 228.1s Total Tests: 33 Pass Rate: 93.9% Failed Tests: 2 ❌ Failed Tests
🔍 Detailed Resultscoagents-research-canvasCoAgents Research Canvas (UI) - Local Depenencies
coagents-qa-nativeCoAgents QA Native (UI) - Local
coagents-qa-textCoAgents QA Text (UI) - Local
coagents-routingCoAgents Routing (UI) - Local
next-openaiNext OpenAI - Self Hosted
|
Co-authored-by: Claude <[email protected]>
What does this PR do?
Fix re-rendering issues when generating suggestions
Checklist
Summary by CodeRabbit
Documentation
observabilityHooksprop to theCopilotChat,CopilotPopup, andCopilotSidebarcomponent docs, including usage examples and requirements.useCopilotChatdocumentation to clarify the need for apublicApiKeyand provided updated usage examples.Refactor