Repository navigation
fix hitl bug after reconnect - #2900
Conversation
⏭️ Changeset Not RequiredLatest commit: a7e790e No changes in this PR affected the Changeset is not required for this PR. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
WalkthroughAdds HITL thread reconnection support via Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Suite
participant Agent as MockReconnectableAgent
participant Provider as CopilotKitProvider
participant Hook as use-render-tool-call
Test->>Agent: Emit RUN_STARTED event
Agent->>Agent: Store event, update isRunning=true
Agent->>Provider: Propagate event
Provider->>Provider: Subscribe to onToolExecutionStart
Provider->>Provider: Update executingToolCallIds (add ID)
Test->>Agent: Emit tool execution events
Agent->>Agent: Store events
Agent->>Provider: Propagate events
Test->>Agent: Emit RUN_FINISHED event
Agent->>Agent: Store event, update isRunning=false
Agent->>Provider: Propagate event
Provider->>Provider: Subscribe to onToolExecutionEnd
Provider->>Provider: Update executingToolCallIds (remove ID)
rect rgb(220, 240, 250)
Note over Test,Agent: Reconnection scenario
Test->>Agent: Call connect() (replay)
Agent->>Agent: Retrieve storedEvents
Agent->>Agent: Return Observable with delay(10)
Agent->>Provider: Stream replayed events
end
Provider->>Hook: Provide executingToolCallIds via context
Hook->>Hook: useCopilotKit() retrieves executingToolCallIds
Hook->>Hook: Render based on isExecuting from context
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx (1)
964-1049: Consider test isolation for mutable outer variables.The test uses mutable outer variables (
showTool,setShowTool) that are assigned inside the component. While functional, this pattern can cause test isolation issues if tests run in parallel or if the component re-renders unexpectedly.🔎 Alternative using React ref pattern
Consider using a ref or state pattern that's more explicit about the control flow:
- let showTool = false; - let setShowTool: (show: boolean) => void; + const setShowToolRef = { current: (_: boolean) => {} }; const ToggleableHITL: React.FC = () => { const [show, setShow] = useState(false); - showTool = show; - setShowTool = setShow; + setShowToolRef.current = setShow; // ... }; // Later in test: - act(() => { - setShowTool(true); - }); + act(() => { + setShowToolRef.current(true); + });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/v2.x/packages/react/src/__tests__/utils/test-helpers.tsx(2 hunks)src/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx(1 hunks)src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx(3 hunks)src/v2.x/packages/react/src/hooks/use-render-tool-call.tsx(3 hunks)src/v2.x/packages/react/src/providers/CopilotKitProvider.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
src/v2.x/packages/react/**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (src/v2.x/CLAUDE.md)
React components must be tested with @testing-library/react using Vitest with jsdom environment. Runtime code must use Node environment for testing.
Files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
**/*.{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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsxsrc/v2.x/packages/react/src/__tests__/utils/test-helpers.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
**/*.{tsx,jsx,html}
📄 CodeRabbit inference engine (.cursor/rules/frontend-development.mdc)
Use Tailwind CSS for styling UI components and maintain consistent styling across the application
Files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsxsrc/v2.x/packages/react/src/__tests__/utils/test-helpers.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
**/*.{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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsxsrc/v2.x/packages/react/src/__tests__/utils/test-helpers.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/suggestions-development.mdc)
Test with missing API keys to ensure your app doesn't infinite loop on network errors
Files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsxsrc/v2.x/packages/react/src/__tests__/utils/test-helpers.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
🧠 Learnings (26)
📓 Common learnings
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
Learning: Test components with different agent configurations to ensure proper integration
📚 Learning: 2025-12-18T18:09:47.478Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/CLAUDE.md:0-0
Timestamp: 2025-12-18T18:09:47.478Z
Learning: Applies to src/v2.x/packages/react/**/*.{test,spec}.{ts,tsx} : React components must be tested with testing-library/react using Vitest with jsdom environment. Runtime code must use Node environment for testing.
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:53.444Z
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.444Z
Learning: Applies to src/v2.x/**/*.{spec,test}.{ts,tsx} : Use the Arrange-Act-Assert pattern in tests
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:53.444Z
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.444Z
Learning: Applies to src/v2.x/**/vitest.config.{js,mjs,ts} : Use Vitest for all testing; see `packages/react/vitest.config.mjs` and `packages/runtime/vitest.config.mjs` for examples
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:20.345Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.345Z
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsxsrc/v2.x/packages/react/src/__tests__/utils/test-helpers.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:01.653Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.653Z
Learning: Applies to examples/e2e/**/*.{ts,tsx,js} : For running tests, use examples/e2e for end-to-end testing and configure Playwright with playwright.config.ts
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:58.438Z
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.438Z
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:20.345Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.345Z
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:09:47.478Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: src/v2.x/CLAUDE.md:0-0
Timestamp: 2025-12-18T18:09:47.478Z
Learning: Always verify UI changes with Playwright when available, especially when matching behavior between frameworks (React/Angular). Continue working on UI issues until they are fully resolved and verified with Playwright or other testing tools.
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:10:31.160Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/development-workflow.mdc:0-0
Timestamp: 2025-12-18T18:10:31.160Z
Learning: End-to-end testing uses Playwright with configuration at examples/e2e/playwright.config.ts and test results stored in examples/e2e/test-results/
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx
📚 Learning: 2025-12-18T18:11:01.653Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.653Z
Learning: Applies to {registry,src/v1.x/packages/react-ui}/**/*.{tsx,ts} : For customizing UI components, browse registry for reusable components, check docs/components/react for documentation, and use react-ui for pre-built components
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:11:01.653Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.653Z
Learning: Applies to **/*.{tsx,ts,jsx,js} : 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
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
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/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
Learning: Applies to **/*.{ts,tsx} : Use `useCopilotChat` hook from 'copilotkit/react-core' for implementing chat functionality
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:11:01.653Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-12-18T18:11:01.653Z
Learning: Frontend applications should follow the common pattern of Next.js app with CopilotProvider and CopilotChat components
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
Learning: Applies to **/*.{ts,tsx} : Use `CopilotPopup` component from 'copilotkit/react-ui' for implementing popup chat interface
Applied to files:
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsxsrc/v2.x/packages/react/src/hooks/use-render-tool-call.tsx
📚 Learning: 2025-12-18T18:11:20.345Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.345Z
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/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:11:20.345Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.345Z
Learning: Applies to **/*.{ts,tsx} : Always use the provided hooks and functions to modify suggestions state - never modify suggestions state directly
Applied to files:
src/v2.x/packages/react/src/hooks/use-render-tool-call.tsx
📚 Learning: 2025-12-18T18:11:20.345Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.345Z
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/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
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/react/src/hooks/use-render-tool-call.tsxsrc/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:10:15.706Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/copilotkit-architecture.mdc:0-0
Timestamp: 2025-12-18T18:10:15.706Z
Learning: Core React components and hooks for CopilotKit should be located in the react-core package
Applied to files:
src/v2.x/packages/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:11:20.345Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-12-18T18:11:20.345Z
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/react/src/providers/CopilotKitProvider.tsx
📚 Learning: 2025-12-18T18:11:53.444Z
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.444Z
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/react/src/__tests__/utils/test-helpers.tsx
📚 Learning: 2025-12-18T18:10:47.795Z
Learnt from: CR
Repo: CopilotKit/CopilotKit PR: 0
File: .cursor/rules/frontend-development.mdc:0-0
Timestamp: 2025-12-18T18:10:47.795Z
Learning: Test components with different agent configurations to ensure proper integration
Applied to files:
src/v2.x/packages/react/src/__tests__/utils/test-helpers.tsx
🧬 Code graph analysis (2)
src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx (1)
src/v2.x/packages/react/src/__tests__/utils/test-helpers.tsx (6)
MockReconnectableAgent(66-118)renderWithCopilotKit(123-171)testId(309-311)runStartedEvent(176-178)toolCallChunkEvent(266-284)runFinishedEvent(183-185)
src/v2.x/packages/react/src/hooks/use-render-tool-call.tsx (1)
src/v2.x/packages/react/src/providers/CopilotKitProvider.tsx (1)
useCopilotKit(372-392)
⏰ 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). (31)
- GitHub Check: mastra-agent-local
- GitHub Check: build (coagents-routing, agent, python, local-deps)
- GitHub Check: build (coagents-qa-text, agent, python, local-deps)
- GitHub Check: llama-index
- GitHub Check: build (coagents-research-canvas, agent, python, local-deps)
- GitHub Check: langgraph-python
- GitHub Check: aws-strands
- GitHub Check: build (coagents-qa-native, agent, python, local-deps)
- GitHub Check: build (coagents-routing, ui)
- GitHub Check: a2a-middleware
- GitHub Check: mastra
- GitHub Check: build (next-openai, next-openai)
- GitHub Check: crew-ai
- GitHub Check: build (coagents-routing, agent, js, local-deps)
- GitHub Check: pydantic-ai
- GitHub Check: middleware-starter
- GitHub Check: langgraph-typescript
- GitHub Check: agno
- GitHub Check: langgraph-fastapi
- GitHub Check: build (coagents-research-canvas, ui)
- GitHub Check: adk-middleware
- GitHub Check: server-starter
- GitHub Check: build (coagents-qa-text, ui)
- GitHub Check: server-starter-all
- GitHub Check: build (coagents-qa-native, ui)
- GitHub Check: unit / v2.x (20.x)
- GitHub Check: unit / v2.x (22.x)
- GitHub Check: unit / v1.x (22.x)
- GitHub Check: unit / v2.x (24.x)
- GitHub Check: unit / v1.x (20.x)
- GitHub Check: unit / v1.x (24.x)
🔇 Additional comments (17)
src/v2.x/packages/react/src/hooks/__tests__/use-frontend-tool.e2e.test.tsx (1)
1031-1048: LGTM! Async waiting aligns with provider-level state tracking.The added
waitForassertion correctly accounts for the React re-render cycle whenToolCallStatus.Completepropagates through the provider context. The 3-second timeout is reasonable for test stability, and the subsequent order verification ensures the state machine transitions correctly (InProgress → Executing → Complete).src/v2.x/packages/react/src/hooks/use-render-tool-call.tsx (4)
1-1: Clean import adjustment.Correctly removed
useStateanduseEffectsince the local state tracking is now handled at the provider level.
104-104: Provider-level state access is correct.Destructuring
executingToolCallIdsfromuseCopilotKit()aligns with the provider changes and ensures this hook receives the centralized execution state.
120-124: Excellent documentation of the design rationale.This comment clearly explains why the execution state is tracked at the provider level rather than locally. This is valuable context for future maintainers understanding the HITL reconnection timing requirements.
153-166: Correct dependency array update.The
useCallbacknow correctly includesexecutingToolCallIdsin its dependencies, ensuring the callback is recreated when the executing state changes. This is necessary for accurateisExecutingderivation.src/v2.x/packages/react/src/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx (6)
2-2: Correct import addition.The
actimport from@testing-library/reactis needed for wrapping state updates in the new reconnection tests, ensuring React batches updates correctly.
12-12: Test utility import for reconnection scenarios.
MockReconnectableAgentis properly imported to support the new HITL reconnection test cases.
654-769: Well-documented reconnection test case.This test clearly documents the timing challenge (events firing before child components mount) and verifies the fix works across unmount/remount cycles. The two-phase approach (initial render → unmount → remount with replay) effectively simulates a page reload scenario.
771-850: Good regression test for normal flow.This test ensures the reconnection fix doesn't break the standard HITL flow (InProgress → Executing → Complete transitions during a fresh run). Important for preventing regressions.
852-962: Sequential HITL execution test is thorough.Validates that HITL tools execute one at a time (second tool stays InProgress until first completes), which is the expected behavior for
followUp: truetools. The test effectively covers the entire state machine for both tools.
1051-1142: Key test for provider-level state persistence.This test directly validates the core fix:
executingToolCallIdssurvives component remounts because it's tracked at the provider level. Thekeyprop remount approach is a clean way to force component recreation while keeping the provider stable.src/v2.x/packages/react/src/providers/CopilotKitProvider.tsx (4)
25-31: Good type extension with clear documentation.The JSDoc comment explains why this is tracked at the provider level, which is crucial context for understanding the HITL reconnection fix.
33-39: Proper default value initialization.Using a module-level
EMPTY_SETconstant avoids creating new Set instances on every render for the default context value. TheReadonlySettype correctly prevents mutation by consumers.
318-348: Correct subscription pattern with proper cleanup.The implementation correctly:
- Uses functional state updates to avoid stale closure issues (
prev => ...)- Avoids unnecessary re-renders by checking
prev.has()before creating new Sets- Creates new Set instances for immutability
- Properly cleans up the subscription on unmount
The dependency on
copilotkitin the effect ensures the subscription is recreated if the core instance changes.
358-368: Context value correctly exposes new state.The
executingToolCallIdsis properly passed to the context provider, making it available to all child components viauseCopilotKit().src/v2.x/packages/react/src/__tests__/utils/test-helpers.tsx (2)
13-13: Correct rxjs imports for replay functionality.The
fromanddelayoperators are needed for theconnect()method's event replay behavior.
61-118: Well-designed test helper for reconnection scenarios.The
MockReconnectableAgenteffectively simulates HITL reconnection by:
- Storing events during
run()for later replay- Replaying stored events with a 10ms delay in
connect()to simulate async transport- Providing
reset()to reinitialize the subject between test phasesThe comment on line 114-115 clearly explains the purpose of the delay. The implementation mirrors
MockStepwiseAgentpatterns for consistency.One consideration: the 10ms delay is hardcoded. If tests become flaky, you might need to make this configurable, but it's fine for now.
Based on learnings, this test helper follows the pattern of testing with different agent configurations to ensure proper integration.
|
Preview environments destroyed for this pull request. |
Test ResultsStatus: ❌ Failed (View Run) Commit: f2ee4cf Duration: 1582.4s Total Tests: 37 Pass Rate: 5.4% Failed Tests: 35 ❌ Failed Tests
🔍 Detailed Resultscoagents-research-canvasCoAgents Research Canvas (UI) - Local Depenencies
coagents-qa-nativeCoAgents QA Native (UI) - Local
coagents-qa-textCoAgents QA Text (UI) - Local
coagents-routingCoAgents Routing (UI) - Local
next-openaiNext OpenAI - Self Hosted
|
What does this PR do?
(Describe the changes introduced in this PR)
Related PRs and Issues
Checklist
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.