-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat(angular): mirror React agent proxying and runtime signals #2999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis PR introduces a runtime-aware agent factory model that replaces a simple Changes
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>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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()andthis.#copilotkit.runtimeConnectionStatus()without assignment ensures the computed re-runs when these signals change. However, note that Line 86 readsruntimeConnectionStatusfromthis.#copilotkit.coredirectly 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: Avoidas anycast; use type-safe header assignment instead.The
as anycast bypasses TypeScript's type checking when settingheaderson the provisional agent. SinceProxiedCopilotRuntimeAgentextendsHttpAgentand theheadersproperty is accessed throughout the class (e.g.,{ ...this.headers }), it is a valid property. Instead of casting toany, 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
injectAgentStorenow returnsSignal<AgentStore>(non-optional) andAgentStore.agentis always assigned in the constructor, theif (!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
📒 Files selected for processing (5)
src/v2.x/packages/angular/src/lib/agent.spec.tssrc/v2.x/packages/angular/src/lib/agent.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/v2.x/packages/angular/src/lib/copilotkit.spec.tssrc/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 useCopilotProviderfrom '@copilotkit/react-core' as the main provider component at the root of your React application
UseuseCopilotChathook from '@copilotkit/react-core' for implementing chat functionality
UseuseCopilotActionhook from '@copilotkit/react-core' to define actions that agents can execute
UseuseCopilotReadablehook from '@copilotkit/react-core' to expose application state to agents
UseCopilotChatcomponent from '@copilotkit/react-ui' for implementing pre-built chat interface UI
UseCopilotPopupcomponent from '@copilotkit/react-ui' for implementing popup chat interface
UseCopilotSidebarcomponent from '@copilotkit/react-ui' for implementing sidebar chat interface
UseCopilotTextareacomponent from '@copilotkit/react-textarea' for implementing AI-enhanced textarea with auto-completion and suggestionsAlways use the provided hooks and functions to modify suggestions state - never modify suggestions state directly
Files:
src/v2.x/packages/angular/src/lib/agent.tssrc/v2.x/packages/angular/src/lib/copilotkit.spec.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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.tssrc/v2.x/packages/angular/src/lib/copilotkit.spec.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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.tssrc/v2.x/packages/angular/src/lib/copilotkit.spec.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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}: Prefertypealiases overinterfacefor data structures in TypeScript
Avoidanyin TypeScript; use explicit generics orunknownwhere necessary
Files should be named inkebab-case.tsorkebab-case.tsxwith a single export per file
Files:
src/v2.x/packages/angular/src/lib/agent.tssrc/v2.x/packages/angular/src/lib/copilotkit.spec.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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.tssrc/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
Importvifrom 'vitest' for mocking functions (usevi.fn(),vi.spyOn(), etc.)
Files:
src/v2.x/packages/angular/src/lib/copilotkit.spec.tssrc/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.tssrc/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.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/v2.x/packages/angular/src/lib/copilotkit.tssrc/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.tssrc/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.tssrc/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.tssrc/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.tssrc/v2.x/packages/angular/src/lib/components/chat/copilot-chat.tssrc/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.tssrc/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.tssrc/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
updateRuntimemethod correctly handles the newruntimeTransportparameter, 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>toSignal<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.tsdirectly accesses the signal without undefined checks, andheadless-chat.component.tsuses defensive optional chaining on property access.src/v2.x/packages/angular/src/lib/copilotkit.spec.ts (3)
22-28: LGTM!Mock enum for
CopilotKitCoreRuntimeConnectionStatusproperly mirrors the expected values. Usingas constensures type inference works correctly.
35-44: LGTM!Mock class properly extended with the new runtime-related properties and methods, aligning with the actual
CopilotKitCoreinterface changes.
225-238: LGTM!Good test coverage for the new
runtimeTransportparameter inupdateRuntime. 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
injectAgentStorereturn type (Signal<AgentStore>instead ofSignal<AgentStore | undefined>). SinceAgentStorealways hasmessages()andisRunning()signals, direct access is safe.
97-101: LGTM!Optional chaining removal is consistent with the API change. The effect correctly keeps the agent's
threadIdin sync with the input.
134-135: LGTM!The null check on
agentis retained as defensive programming, which is fine even thoughagentStore().agentshould always be defined given the updated factory behavior.src/v2.x/packages/angular/src/lib/agent.spec.ts (3)
63-108: LGTM!
CopilotKitStubis well-designed, properly mirroring the new runtime state API with signals and acoreobject. The immutable updates tocorevia 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:
- Sets up the "connecting" runtime state
- Verifies
AgentStorewraps aProxiedCopilotRuntimeAgent- Confirms
agentIdandheadersare correctly passed throughThis follows the Arrange-Act-Assert pattern as per coding guidelines.
215-234: LGTM!Test correctly verifies the error path when runtime is
Connectedbut the agent still cannot be found. The error message regex assertion confirms the diagnostic information is included.
| onRuntimeConnectionStatusChanged: ({ status }) => { | ||
| this.#runtimeConnectionStatus.set(status); | ||
| }, | ||
| onHeadersChanged: ({ headers }) => { | ||
| this.#headers.set(headers); | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if CopilotKitCore emits runtime URL change events
rg -n "onRuntimeUrlChanged|runtimeUrlChanged" --type tsRepository: 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 fRepository: 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 -100Repository: 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 -20Repository: CopilotKit/CopilotKit
Length of output: 137
🏁 Script executed:
# Check CopilotKitCore class definition and its subscribe method
rg -n "class CopilotKitCore" -A 30 --type tsRepository: 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 -5Repository: 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 tsRepository: 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/srcRepository: 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.tsRepository: 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.tsRepository: 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.tsRepository: 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/srcRepository: 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 -100Repository: 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.tsRepository: 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.tsRepository: 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 -20Repository: 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.tsRepository: 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.tsRepository: 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.tsRepository: 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.
7d07485 to
8afdb9d
Compare
What does this PR do?
(Describe the changes introduced in this PR)
Related PRs and Issues
Checklist
Summary by CodeRabbit
Release Notes
New Features
runtimeConnectionStatus,runtimeUrl,runtimeTransport, andheaders.Breaking Changes
injectAgentStore()return type changed fromSignal<AgentStore | undefined>toSignal<AgentStore>.updateRuntime()API expanded to acceptruntimeTransportparameter.Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.