Skip to content

Fix re-rendering issues when generating suggestions - #2231

Merged
mme merged 4 commits into
mainfrom
mme/fix-rerender-issues
Jul 29, 2025
Merged

mme merged 4 commits into
mainfrom
mme/fix-rerender-issues

Conversation

@mme

@mme mme commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fix re-rendering issues when generating suggestions

Checklist

  • I have read the Contribution Guide
  • If the PR changes or adds functionality, I have updated the relevant documentation

Summary by CodeRabbit

  • Documentation

    • Added detailed information about the observabilityHooks prop to the CopilotChat, CopilotPopup, and CopilotSidebar component docs, including usage examples and requirements.
    • Updated useCopilotChat documentation to clarify the need for a publicApiKey and provided updated usage examples.
  • Refactor

    • Improved state management for chat suggestions by relocating suggestion state to a more appropriate context, resulting in a cleaner and more maintainable structure for suggestion handling.

@vercel

vercel Bot commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 3:28pm
examples-coagents-ai-travel-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 3:28pm
examples-coagents-research-canvas-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 3:28pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
examples-coagents-ai-researcher-ui ⬜️ Ignored (Inspect) Jul 28, 2025 3:28pm

@coderabbitai

coderabbitai Bot commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refactor the management of the suggestions state in the CopilotKit React library. The suggestions state is moved from the general Copilot context to the Copilot messages context, with corresponding type and interface updates. Documentation for several components and hooks is expanded to describe new observability hooks and requirements for a publicApiKey.

Changes

File(s) Change Summary
Copilot Messages State Update
copilot-provider/copilot-messages.tsx
Added suggestions state and setter to CopilotMessages context; imported SuggestionItem type.
CopilotKit Context Cleanup
copilot-provider/copilotkit.tsx
Removed suggestions state and setter from CopilotKitInternal and its context value.
Copilot Context Interface Update
context/copilot-context.tsx
Removed suggestions and setSuggestions from CopilotContextParams interface and default context values.
Copilot Messages Context Interface Update
context/copilot-messages-context.tsx
Added suggestions and setSuggestions to CopilotMessagesContextParams interface and default context values.
Hook Context Source Change
hooks/use-copilot-chat_internal.ts
Changed source of suggestions and setSuggestions from Copilot context to Copilot messages context.
CopilotChat Documentation
docs/reference/components/chat/CopilotChat.mdx
Documented new observabilityHooks prop, usage example, and requirement for publicApiKey.
CopilotPopup Documentation
docs/reference/components/chat/CopilotPopup.mdx
Added documentation for observabilityHooks prop with example usage and publicApiKey requirement.
CopilotSidebar Documentation
docs/reference/components/chat/CopilotSidebar.mdx
Added documentation for observabilityHooks prop with example usage and publicApiKey requirement.
useCopilotChat Hook Documentation
docs/reference/hooks/useCopilotChat.mdx
Updated usage examples to include wrapping with CopilotKit provider and requirement for publicApiKey.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • suhasdeshpande
  • ataibarkai
  • ranst91

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
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mme/fix-rerender-issues

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 chatSuggestionConfiguration

The dependency on Object.keys(chatSuggestionConfiguration).length only 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 setMessages line, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 350c6c6 and a2a9c20.

📒 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.ts
  • CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx
  • CopilotKit/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.ts
  • CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx
  • CopilotKit/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.ts
  • CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx
  • CopilotKit/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.ts
  • CopilotKit/packages/react-core/src/context/copilot-messages-context.tsx
  • CopilotKit/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.mdx
  • docs/content/docs/reference/components/chat/CopilotSidebar.mdx
  • docs/content/docs/reference/components/chat/CopilotChat.mdx
  • docs/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.mdx
  • docs/content/docs/reference/components/chat/CopilotSidebar.mdx
  • docs/content/docs/reference/components/chat/CopilotChat.mdx
  • docs/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 suggestions and setSuggestions from 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 SuggestionItem type 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 publicApiKey and 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 CopilotKit provider with the required publicApiKey. This follows the new architectural pattern consistently.


55-64: LGTM: Consistent pattern in suggestions example.

The suggestions example also properly demonstrates the CopilotKit wrapper 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 observabilityHooks prop and its dependency on publicApiKey, 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 publicApiKey requirement
  • Semantic hook naming (onMessageSent is perfect for chat)
  • Complete usage example

210-213: LGTM: Complete API documentation for observabilityHooks.

The property reference provides clear documentation about the observabilityHooks prop and its dependency on publicApiKey, 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 publicApiKey requirement. The example code demonstrates correct usage within the <CopilotKit> wrapper.


214-217: Property reference is clear and consistent.

The observabilityHooks property reference properly documents the type and requirement for publicApiKey, 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 SuggestionItem import 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.

Comment on lines 9 to 14
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[]>>;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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:

  1. useEffect dependencies are properly memoized where this context is consumed
  2. Direct suggestions state modifications are avoided
  3. 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 ts

Length 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" CopilotKit

Length 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:

  1. All useEffect hooks consuming suggestions are using the messages context and have properly memoized dependencies.
  2. No direct calls to setSuggestions remain 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]>
@changesets-bot-copilotkit

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 567c9d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@copilotkit/react-core Patch
@copilotkit/react-textarea Patch
@copilotkit/react-ui Patch
@copilotkit/runtime-client-gql Patch
@copilotkit/runtime Patch
@copilotkit/sdk-js Patch
@copilotkit/shared Patch

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 70cd1c8 and 567c9d3.

📒 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. ✅

@github-actions

github-actions Bot commented Jul 28, 2025 •

Copy link
Copy Markdown
Contributor

Preview environments destroyed for this pull request.

@github-actions

github-actions Bot commented Jul 28, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

Status: ❌ Failed (View Run)

Commit: 91e95e2

Duration: 228.1s

Total Tests: 33

Pass Rate: 93.9%

Failed Tests: 2

❌ Failed Tests

🔍 Detailed Results

coagents-research-canvas

CoAgents Research Canvas (UI) - Local Depenencies

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
CrewAI chromium ✅ PASSED -

coagents-qa-native

CoAgents QA Native (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -

coagents-qa-text

CoAgents QA Text (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
OpenAI (LGC Python) chromium ✅ PASSED -
Anthropic (LGC Python) chromium ✅ PASSED -
OpenAI (LGC JS) chromium ❌ FAILED Video
Anthropic (LGC JS) chromium ❌ FAILED Video

coagents-routing

CoAgents Routing (UI) - Local

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -

next-openai

Next OpenAI - Self Hosted

Model Browser Status Video
OpenAI chromium ✅ PASSED -
Anthropic chromium ✅ PASSED -
LangChain (OpenAI) chromium ✅ PASSED -
Groq chromium ✅ PASSED -

johannhartmann pushed a commit to johannhartmann/CopilotKit that referenced this pull request Oct 31, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Nov 17, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 3, 2025

This branch was successfully deployed

3 active deployments
Preview – docs — 567c9d38 Deployed Jul 28, 2025 by vercel[bot]
Preview – examples-coagents-research-canvas-ui — 567c9d38 Deployed Jul 28, 2025 by vercel[bot]
Preview – examples-coagents-ai-travel-app — 567c9d38 Deployed Jul 28, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant