Skip to content

Conversation

@MikeRyanDev
Copy link
Contributor

@MikeRyanDev MikeRyanDev commented Jan 13, 2026

What does this PR do?

(Describe the changes introduced in this PR)

Related PRs and Issues

  • (Direct link to related PR or issue, if relevant)

Checklist

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced public signals for runtime state visibility: runtimeConnectionStatus, runtimeUrl, runtimeTransport, and headers.
    • Enhanced runtime agent provisioning with improved error diagnostics when agents are unavailable.
  • Breaking Changes

    • injectAgentStore() return type changed from Signal<AgentStore | undefined> to Signal<AgentStore>.
    • updateRuntime() API expanded to accept runtimeTransport parameter.
  • Bug Fixes

    • Improved runtime connection handling and agent resolution logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Jan 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
copilotkit-v2-storybook Error Error Jan 16, 2026 4:03pm
docs Ready Ready Preview, Comment Jan 16, 2026 4:03pm
examples-coagents-ai-travel-app Error Error Jan 16, 2026 4:03pm
examples-coagents-research-canvas-ui Error Error Jan 16, 2026 4:03pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
examples-coagents-ai-researcher-ui Ignored Ignored Jan 16, 2026 4:03pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

⚠️ No Changeset found

Latest commit: 8afdb9d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR introduces a runtime-aware agent factory model that replaces a simple didLoadRuntime flag with comprehensive runtime connection state (status, URL, transport, headers). The agent factory now creates provisional ProxiedCopilotRuntimeAgent instances for missing agents when runtime is configured and disconnected/connecting, changing agent store return types from optional to non-optional signals.

Changes

Cohort / File(s) Summary
Test Infrastructure Updates
src/v2.x/packages/angular/src/lib/agent.spec.ts, src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
Replaced didLoadRuntime flag with rich runtime state signals (runtimeConnectionStatus, runtimeUrl, runtimeTransport, headers). Added setRuntimeConnectionStatus(), setRuntimeUrl(), setHeaders(), setRuntimeTransport() methods to stub. Updated mock to include CopilotKitCoreRuntimeConnectionStatus constant and mock transport setter.
Core Agent Factory
src/v2.x/packages/angular/src/lib/agent.ts
Introduced runtime-aware agent creation logic: when agent not found, checks runtime configuration and connection status; if runtime is configured and disconnected/connecting, creates ProxiedCopilotRuntimeAgent with current headers; otherwise throws detailed error. Changed return types from Signal<AgentStore | undefined> to Signal<AgentStore>.
CopilotKit Service
src/v2.x/packages/angular/src/lib/copilotkit.ts
Added public read-only signals for runtimeConnectionStatus, runtimeUrl, runtimeTransport, and headers. Seeded private signals from core in constructor. Extended updateRuntime() API to accept runtimeTransport and sync internal signals with core state. Integrated runtime lifecycle event handlers.
Chat Component
src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
Removed optional chaining from agentStore() calls in computed properties (messages, isRunning) and effect blocks, reflecting guarantee that agent store signal always returns a value.

Sequence Diagram(s)

sequenceDiagram
    participant CopilotKit as CopilotKit Service
    participant AgentFactory as Agent Factory
    participant Runtime as Runtime Config
    participant ProxyAgent as ProxiedCopilotRuntimeAgent
    participant Store as AgentStore

    AgentFactory->>AgentFactory: resolvedAgentId = resolve(agentId)
    AgentFactory->>AgentFactory: agent = agents.get(resolvedAgentId)
    alt Agent Found
        AgentFactory->>Store: wrap in AgentStore
    else Agent Not Found
        AgentFactory->>CopilotKit: read runtimeUrl, runtimeConnectionStatus
        alt Runtime Connected & Configured
            AgentFactory->>ProxyAgent: create ProxiedCopilotRuntimeAgent
            AgentFactory->>ProxyAgent: apply headers
            AgentFactory->>Store: wrap proxy in AgentStore
        else Runtime Not Available
            AgentFactory->>AgentFactory: throw error with known agents
        end
    end
    AgentFactory-->>CopilotKit: return Signal<AgentStore>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

preview

Suggested reviewers

  • mme
  • ataibarkai
  • ranst91
  • tylerslaton
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing agent proxying and runtime signals to the Angular package to mirror React functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/angular-proxied-agent

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @src/v2.x/packages/angular/src/lib/copilotkit.ts:
- Around line 80-85: Add a new subscriber event onRuntimeUrlChanged to the
CopilotKitCoreSubscriber interface and handle it in the Angular wrapper so the
internal #runtimeUrl signal stays in sync: update the interface to include
onRuntimeUrlChanged: ({ runtimeUrl }) => void, and in the subscription block in
CopilotKit (the same area where onHeadersChanged and
onRuntimeConnectionStatusChanged are handled) call
this.#runtimeUrl.set(runtimeUrl); also ensure updateRuntime() still performs the
same local update and document that direct calls to core.setRuntimeUrl() will
trigger the new subscriber method so signals remain consistent.
🧹 Nitpick comments (3)
src/v2.x/packages/angular/src/lib/agent.ts (2)

71-76: Signal reads for reactivity are correct, but consider consistency.

Reading this.#copilotkit.agents() and this.#copilotkit.runtimeConnectionStatus() without assignment ensures the computed re-runs when these signals change. However, note that Line 86 reads runtimeConnectionStatus from this.#copilotkit.core directly instead of using the signal value read on Line 73, which could lead to subtle timing inconsistencies if the core and signal get out of sync.

♻️ Consider using the signal value consistently
-      this.#copilotkit.runtimeConnectionStatus();
+      const runtimeConnectionStatus = this.#copilotkit.runtimeConnectionStatus();
       const runtimeUrl = this.#copilotkit.runtimeUrl();
       const runtimeTransport = this.#copilotkit.runtimeTransport();
       const headers = this.#copilotkit.headers();
       ...
-      const { runtimeConnectionStatus } = this.#copilotkit.core;
       const isRuntimeConfigured = runtimeUrl !== undefined;

       if (
         isRuntimeConfigured &&
         (runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Disconnected ||
           runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Connecting)
       ) {

99-101: Avoid as any cast; use type-safe header assignment instead.

The as any cast bypasses TypeScript's type checking when setting headers on the provisional agent. Since ProxiedCopilotRuntimeAgent extends HttpAgent and the headers property is accessed throughout the class (e.g., { ...this.headers }), it is a valid property. Instead of casting to any, consider setting headers through the constructor configuration passed to the parent class, or verify if a type-safe setter method is available.

src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts (1)

79-80: Defensive null check may now be unnecessary.

Since injectAgentStore now returns Signal<AgentStore> (non-optional) and AgentStore.agent is always assigned in the constructor, the if (!a) return; check on Line 80 may be dead code. However, keeping it as defensive programming is acceptable.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0256835 and 7d07485.

📒 Files selected for processing (5)
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend-development.mdc)

**/*.{ts,tsx}: Import and use CopilotProvider from '@copilotkit/react-core' as the main provider component at the root of your React application
Use useCopilotChat hook from '@copilotkit/react-core' for implementing chat functionality
Use useCopilotAction hook from '@copilotkit/react-core' to define actions that agents can execute
Use useCopilotReadable hook from '@copilotkit/react-core' to expose application state to agents
Use CopilotChat component from '@copilotkit/react-ui' for implementing pre-built chat interface UI
Use CopilotPopup component from '@copilotkit/react-ui' for implementing popup chat interface
Use CopilotSidebar component from '@copilotkit/react-ui' for implementing sidebar chat interface
Use CopilotTextarea component from '@copilotkit/react-textarea' for implementing AI-enhanced textarea with auto-completion and suggestions

Always use the provided hooks and functions to modify suggestions state - never modify suggestions state directly

Files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/frontend-development.mdc)

Use TypeScript for component development to ensure better type safety

Files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (.cursor/rules/quick-reference.mdc)

For building a simple Copilot, start with copilot-chat-with-your-data example, use react-core package for basic integration, and add react-ui package for pre-built components

Files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
src/v2.x/**/*.{ts,tsx}

📄 CodeRabbit inference engine (src/v2.x/.cursor/rules/20-typescript.auto.mdc)

src/v2.x/**/*.{ts,tsx}: Prefer type aliases over interface for data structures in TypeScript
Avoid any in TypeScript; use explicit generics or unknown where necessary
Files should be named in kebab-case.ts or kebab-case.tsx with a single export per file

Files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
src/v2.x/packages/angular/**/*.{test,spec}.ts

📄 CodeRabbit inference engine (src/v2.x/CLAUDE.md)

src/v2.x/packages/angular/**/*.{test,spec}.ts: Angular testing must handle Dependency Injection Context Issues - use TestBed.createComponent() for testing components with DI dependencies. Prefer field initializers over ngOnInit for inject() calls when possible.
Angular test components should be kept minimal and focused. Avoid declaring too many Angular components at module level to prevent 'JavaScript heap out of memory' errors. Consider declaring simple test components inside test functions.

Files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
src/v2.x/**/*.{spec,test}.{ts,tsx}

📄 CodeRabbit inference engine (src/v2.x/.cursor/rules/50-vitest.auto.mdc)

src/v2.x/**/*.{spec,test}.{ts,tsx}: Use the Arrange-Act-Assert pattern in tests
Import vi from 'vitest' for mocking functions (use vi.fn(), vi.spyOn(), etc.)

Files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
🧠 Learnings (26)
📓 Common learnings
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.663Z
Learning: Integration should follow the common pattern of a Runtime connecting frontend to backend agents
📚 Learning: 2025-12-18T18:11:58.449Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/packages/runtime/.cursor/rules/runtime.always.mdc:0-0
Timestamp: 2025-12-18T18:11:58.449Z
Learning: Applies to src/v2.x/packages/runtime/src/index.ts : Exported APIs live under `src/index.ts`

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:10:03.444Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/agent-development.mdc:0-0
Timestamp: 2025-12-18T18:10:03.444Z
Learning: Applies to **/agent-js/{package.json,tsconfig.json} : JavaScript agent setup should install `copilotkit/sdk-js` package and configure TypeScript with proper types

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:11:01.663Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.663Z
Learning: Applies to src/v1.x/packages/sdk-js/**/*.{ts,tsx,js,jsx} : For developing JavaScript agents, use sdk-js package and reference coagents-starter/agent-js for examples

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Applies to **/*.{ts,tsx} : Use `useCopilotReadable` hook from 'copilotkit/react-core' to expose application state to agents

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:11:20.367Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.367Z
Learning: Applies to **/context/copilot-context.tsx : In react-core copilot-context.tsx, store and manage the actual suggestions state as the provider/context

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.ts
📚 Learning: 2025-12-18T18:11:01.663Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.663Z
Learning: Backend agents should follow the common pattern of Python or Node.js implementation with actions and state management

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.ts
📚 Learning: 2026-01-08T19:19:08.604Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: examples/e2e/AGENTS.md:0-0
Timestamp: 2026-01-08T19:19:08.604Z
Learning: Applies to examples/e2e/tests/**/*.spec.ts : For examples that auto-open Copilot UI or trigger calls, add a query param to disable it (e.g., `/?copilotOpen=false` for travel example)

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:09:47.490Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/CLAUDE.md:0-0
Timestamp: 2025-12-18T18:09:47.490Z
Learning: Applies to src/v2.x/packages/angular/**/*.{test,spec}.ts : Angular testing must handle Dependency Injection Context Issues - use TestBed.createComponent() for testing components with DI dependencies. Prefer field initializers over ngOnInit for inject() calls when possible.

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:11:53.451Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/.cursor/rules/50-vitest.auto.mdc:0-0
Timestamp: 2025-12-18T18:11:53.451Z
Learning: Applies to src/v2.x/**/*.{spec,test}.{ts,tsx} : Import `vi` from 'vitest' for mocking functions (use `vi.fn()`, `vi.spyOn()`, etc.)

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
📚 Learning: 2025-12-18T18:11:58.449Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/packages/runtime/.cursor/rules/runtime.always.mdc:0-0
Timestamp: 2025-12-18T18:11:58.449Z
Learning: Applies to src/v2.x/packages/runtime/src/__tests__/**/*.{ts,tsx} : Vitest tests reside in `src/__tests__/` and use Node environment

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
📚 Learning: 2025-12-18T18:10:15.715Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-12-18T18:10:15.715Z
Learning: Core React components and hooks for CopilotKit should be located in the react-core package

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Applies to **/*.{ts,tsx} : Import and use `CopilotProvider` from 'copilotkit/react-core' as the main provider component at the root of your React application

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Applies to **/*.{ts,tsx} : Use `useCopilotChat` hook from 'copilotkit/react-core' for implementing chat functionality

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.spec.ts
  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:11:20.367Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.367Z
Learning: Applies to **/hooks/use-copilot-chat.ts : Use React effect dependencies that include configuration to trigger suggestion generation when configuration becomes available

Applied to files:

  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
📚 Learning: 2025-12-18T18:11:20.367Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.367Z
Learning: Applies to **/hooks/use-copilot-chat.ts : In react-core use-copilot-chat.ts hook, implement and expose functions for suggestions control: suggestions getter, setSuggestions, generateSuggestions, resetSuggestions, and isLoadingSuggestions state

Applied to files:

  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Applies to **/*.{ts,tsx} : Use `CopilotChat` component from 'copilotkit/react-ui' for implementing pre-built chat interface UI

Applied to files:

  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:11:20.367Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.367Z
Learning: Applies to **/{suggestions.ts,use-copilot-chat.ts} : Handle race conditions between component mounting and configuration registration by waiting for chatSuggestionConfiguration to be populated before generating initial suggestions

Applied to files:

  • src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Applies to **/*.{ts,tsx} : Use `useCopilotAction` hook from 'copilotkit/react-core' to define actions that agents can execute

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Validate agent integration flows and communication between frontend components and backend agents

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:11:01.663Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.663Z
Learning: Frontend applications should follow the common pattern of Next.js app with CopilotProvider and CopilotChat components

Applied to files:

  • src/v2.x/packages/angular/src/lib/copilotkit.ts
📚 Learning: 2025-12-18T18:11:01.663Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.663Z
Learning: Integration should follow the common pattern of a Runtime connecting frontend to backend agents

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:10:47.805Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.805Z
Learning: Test components with different agent configurations to ensure proper integration

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:11:20.367Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.367Z
Learning: Applies to **/*.test.{ts,tsx} : Test with missing API keys to ensure your app doesn't infinite loop on network errors

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2026-01-08T19:19:08.604Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: examples/e2e/AGENTS.md:0-0
Timestamp: 2026-01-08T19:19:08.604Z
Learning: Applies to examples/e2e/tests/**/*.spec.ts : Use Playwright assertions like `await expect(page).toHaveTitle(/.../)`  and `await expect(page.getByRole("heading", { name: "..." })).toBeVisible()` in smoke tests

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.spec.ts
📚 Learning: 2025-12-18T18:09:47.490Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/CLAUDE.md:0-0
Timestamp: 2025-12-18T18:09:47.490Z
Learning: Applies to src/v2.x/**/*.directive.spec.ts : Angular directives using field injection (inject()) should be tested through host components. For directives with constructor injection, testing can be more direct. Follow existing patterns in copilotkit-agent-context.directive.spec.ts for reference.

Applied to files:

  • src/v2.x/packages/angular/src/lib/agent.spec.ts
🧬 Code graph analysis (1)
src/v2.x/packages/angular/src/lib/agent.spec.ts (1)
src/v2.x/packages/angular/src/lib/agent.ts (2)
  • injectAgentStore (121-130)
  • AgentStore (15-59)
⏰ 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). (21)
  • GitHub Check: unit / v1.x (20.x)
  • GitHub Check: unit / v1.x (22.x)
  • GitHub Check: unit / v1.x (24.x)
  • GitHub Check: unit / v2.x (24.x)
  • GitHub Check: pydantic-ai
  • GitHub Check: mastra
  • GitHub Check: llama-index
  • GitHub Check: a2a-middleware
  • GitHub Check: crew-ai
  • GitHub Check: langgraph-python
  • GitHub Check: server-starter-all
  • GitHub Check: unit / v2.x (20.x)
  • GitHub Check: langgraph-fastapi
  • GitHub Check: server-starter
  • GitHub Check: mastra-agent-local
  • GitHub Check: langgraph-typescript
  • GitHub Check: agno
  • GitHub Check: aws-strands
  • GitHub Check: adk-middleware
  • GitHub Check: middleware-starter
  • GitHub Check: unit / v2.x (22.x)
🔇 Additional comments (16)
src/v2.x/packages/angular/src/lib/copilotkit.ts (4)

2-7: LGTM!

Clean imports for the new runtime-related types. The imports align with the runtime state plumbing introduced in this PR.


20-29: LGTM!

Well-structured signal declarations following Angular's pattern of private writable signals with public readonly accessors. The default values are sensible (Disconnected status, undefined URL, "rest" transport, empty headers).


48-52: LGTM!

Constructor properly initializes the Angular signals from the core's initial state, ensuring consistency at startup.


160-185: LGTM!

The updateRuntime method correctly handles the new runtimeTransport parameter, updating both the core and local signal in a consistent manner. The pattern matches the existing handling of other runtime properties.

src/v2.x/packages/angular/src/lib/agent.ts (3)

13-13: LGTM!

Appropriate imports for the new runtime-aware agent proxying functionality.


106-112: LGTM!

Excellent error message with diagnostic information including the resolved agent ID, runtime URL status, and list of known agents. This will significantly help debugging when agent resolution fails.


68-68: Breaking API change: return type is now non-optional.

The return type changed from Signal<AgentStore | undefined> to Signal<AgentStore>. This is a breaking change for consumers who previously handled the undefined case. The implementation now throws on unresolvable agents (lines 108–112) instead of returning undefined, shifting error handling from the caller to this factory. Both existing consumers in the codebase have been updated: copilot-chat.ts directly accesses the signal without undefined checks, and headless-chat.component.ts uses defensive optional chaining on property access.

src/v2.x/packages/angular/src/lib/copilotkit.spec.ts (3)

22-28: LGTM!

Mock enum for CopilotKitCoreRuntimeConnectionStatus properly mirrors the expected values. Using as const ensures type inference works correctly.


35-44: LGTM!

Mock class properly extended with the new runtime-related properties and methods, aligning with the actual CopilotKitCore interface changes.


225-238: LGTM!

Good test coverage for the new runtimeTransport parameter in updateRuntime. The test verifies the transport value is correctly propagated to the core.

src/v2.x/packages/angular/src/lib/components/chat/copilot-chat.ts (3)

67-68: LGTM!

The removal of optional chaining aligns with the updated injectAgentStore return type (Signal<AgentStore> instead of Signal<AgentStore | undefined>). Since AgentStore always has messages() and isRunning() signals, direct access is safe.


97-101: LGTM!

Optional chaining removal is consistent with the API change. The effect correctly keeps the agent's threadId in sync with the input.


134-135: LGTM!

The null check on agent is retained as defensive programming, which is fine even though agentStore().agent should always be defined given the updated factory behavior.

src/v2.x/packages/angular/src/lib/agent.spec.ts (3)

63-108: LGTM!

CopilotKitStub is well-designed, properly mirroring the new runtime state API with signals and a core object. The immutable updates to core via spread operator ensure predictable test behavior. The stub covers all the new setters needed for testing runtime-aware agent creation.


191-213: LGTM!

Excellent test case covering the proxied agent creation path. The test properly:

  1. Sets up the "connecting" runtime state
  2. Verifies AgentStore wraps a ProxiedCopilotRuntimeAgent
  3. Confirms agentId and headers are correctly passed through

This follows the Arrange-Act-Assert pattern as per coding guidelines.


215-234: LGTM!

Test correctly verifies the error path when runtime is Connected but the agent still cannot be found. The error message regex assertion confirms the diagnostic information is included.

Comment on lines +80 to +85
onRuntimeConnectionStatusChanged: ({ status }) => {
this.#runtimeConnectionStatus.set(status);
},
onHeadersChanged: ({ headers }) => {
this.#headers.set(headers);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if CopilotKitCore emits runtime URL change events
rg -n "onRuntimeUrlChanged|runtimeUrlChanged" --type ts

Repository: CopilotKit/CopilotKit

Length of output: 47


🏁 Script executed:

# Find and examine the copilotkit.ts file
find . -path "*/v2.x/packages/angular/src/lib/copilotkit.ts" -type f

Repository: CopilotKit/CopilotKit

Length of output: 114


🏁 Script executed:

# Get the full context of the subscription setup around lines 80-85
cat -n src/v2.x/packages/angular/src/lib/copilotkit.ts | head -100

Repository: CopilotKit/CopilotKit

Length of output: 4647


🏁 Script executed:

# Search for CopilotKitCore subscribe method definition
rg -n "subscribe\s*\(" src/v2.x/packages/react-core/src --type ts | head -20

Repository: CopilotKit/CopilotKit

Length of output: 137


🏁 Script executed:

# Check CopilotKitCore class definition and its subscribe method
rg -n "class CopilotKitCore" -A 30 --type ts

Repository: CopilotKit/CopilotKit

Length of output: 11661


🏁 Script executed:

# Search for subscribe type definition in core package
find . -path "*/react-core/src*" -name "*.ts" -type f | xargs grep -l "subscribe" | head -5

Repository: CopilotKit/CopilotKit

Length of output: 336


🏁 Script executed:

# Look for runtime URL related event handlers in core
rg -n "onRuntimeUrl|runtimeUrl.*Change|runtimeUrl.*event" --type ts

Repository: CopilotKit/CopilotKit

Length of output: 47


🏁 Script executed:

# Find the CopilotKitCoreSubscriber type definition
rg -n "CopilotKitCoreSubscriber" -A 10 --type ts src/v2.x/packages/core/src

Repository: CopilotKit/CopilotKit

Length of output: 4230


🏁 Script executed:

# Look for the subscribe method implementation in CopilotKitCore
rg -n "subscribe\s*\(" -A 10 src/v2.x/packages/core/src/core/core.ts

Repository: CopilotKit/CopilotKit

Length of output: 1008


🏁 Script executed:

# Check for runtimeUrl property and how it's managed in CopilotKitCore
rg -n "runtimeUrl" -B 2 -A 2 src/v2.x/packages/core/src/core/core.ts

Repository: CopilotKit/CopilotKit

Length of output: 859


🏁 Script executed:

# Get the full CopilotKitCoreSubscriber interface definition
rg -n "export interface CopilotKitCoreSubscriber" -A 50 src/v2.x/packages/core/src/core/core.ts

Repository: CopilotKit/CopilotKit

Length of output: 2040


🏁 Script executed:

# Check if there's any place where runtimeUrl changes are emitted/broadcast
rg -n "setRuntimeUrl\|onRuntimeUrl" -B 3 -A 3 src/v2.x/packages/core/src

Repository: CopilotKit/CopilotKit

Length of output: 47


🏁 Script executed:

# Get the complete CopilotKitCoreSubscriber interface to see if it continues
rg -n "export interface CopilotKitCoreSubscriber" -A 80 src/v2.x/packages/core/src/core/core.ts | head -100

Repository: CopilotKit/CopilotKit

Length of output: 3053


🏁 Script executed:

# Check the AgentRegistry to see how setRuntimeUrl is implemented
rg -n "class AgentRegistry" -A 50 src/v2.x/packages/core/src | grep -A 20 "setRuntimeUrl"

Repository: CopilotKit/CopilotKit

Length of output: 369


🏁 Script executed:

# Search for any event emitters or notifySubscribers calls related to runtimeUrl
rg -n "notifySubscribers" src/v2.x/packages/core/src/core/core.ts

Repository: CopilotKit/CopilotKit

Length of output: 242


🏁 Script executed:

# Check the complete AgentRegistry setRuntimeUrl implementation
rg -n "setRuntimeUrl" -A 10 src/v2.x/packages/core/src/core/agent-registry.ts

Repository: CopilotKit/CopilotKit

Length of output: 408


🏁 Script executed:

# Verify if there's any method to notify subscribers of runtimeUrl changes
rg -n "runtimeUrl" src/v2.x/packages/core/src/core/agent-registry.ts | head -20

Repository: CopilotKit/CopilotKit

Length of output: 841


🏁 Script executed:

# Check if there are any other places in angular copilotkit.ts that might handle URL changes
rg -n "runtimeUrl" src/v2.x/packages/angular/src/lib/copilotkit.ts

Repository: CopilotKit/CopilotKit

Length of output: 468


🏁 Script executed:

# Check if setRuntimeUrl is ever called after initialization
rg -n "setRuntimeUrl" src/v2.x/packages/angular/src/lib/copilotkit.ts

Repository: CopilotKit/CopilotKit

Length of output: 119


🏁 Script executed:

# Check if there's a setRuntimeUrl public method in Angular copilotkit.ts
cat -n src/v2.x/packages/angular/src/lib/copilotkit.ts | sed -n '155,175p'

Repository: CopilotKit/CopilotKit

Length of output: 920


🏁 Script executed:

# Check what calls setRuntimeUrl to understand the usage pattern
rg -n "setRuntimeUrl" -B 5 -A 2 src/v2.x/packages/angular/src/lib/copilotkit.ts

Repository: CopilotKit/CopilotKit

Length of output: 382


Add subscription handler for runtime URL changes or document the expected immutability.

The CopilotKitCoreSubscriber interface doesn't provide an onRuntimeUrlChanged event (unlike onHeadersChanged for headers or onAgentsChanged for agents). While the Angular wrapper manually syncs the signal in updateRuntime(), calling core.setRuntimeUrl() directly bypasses this synchronization, leaving the #runtimeUrl signal stale. Either add onRuntimeUrlChanged to the core's subscription event interface for consistency, or document that runtime URL changes should only occur through the updateRuntime() method.

🤖 Prompt for AI Agents
In @src/v2.x/packages/angular/src/lib/copilotkit.ts around lines 80 - 85, Add a
new subscriber event onRuntimeUrlChanged to the CopilotKitCoreSubscriber
interface and handle it in the Angular wrapper so the internal #runtimeUrl
signal stays in sync: update the interface to include onRuntimeUrlChanged: ({
runtimeUrl }) => void, and in the subscription block in CopilotKit (the same
area where onHeadersChanged and onRuntimeConnectionStatusChanged are handled)
call this.#runtimeUrl.set(runtimeUrl); also ensure updateRuntime() still
performs the same local update and document that direct calls to
core.setRuntimeUrl() will trigger the new subscriber method so signals remain
consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants