Skip to content

fix: interrupt persistence - #2488

Merged
ranst91 merged 8 commits into
mainfrom
fix/interrupt-persistence
Sep 25, 2025
Merged

ranst91 merged 8 commits into
mainfrom
fix/interrupt-persistence

Conversation

@ranst91

@ranst91 ranst91 commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

This PR handles the interrupt events so they are bounded to a thread ID. This way, they are only fetched or displayed when the relevant threadId is set

Summary by CodeRabbit

  • New Features

    • Thread-scoped interrupt handling for chats, enabling independent interrupt control per conversation/thread.
  • Bug Fixes

    • Syntax highlighting now auto-falls back when advanced regex features aren’t supported, improving compatibility on older browsers.
    • Dynamic selection between highlighters ensures consistent rendering and reduces errors on legacy environments.
  • Chores

    • Patch release recorded for @copilotkit/react-ui to capture the compatibility fix and version bump.

@coderabbitai

coderabbitai Bot commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Implements per-thread scoping for LangGraph interrupt actions across react-core by adding a thread-keyed map and changing setter/remover signatures to accept a threadId; updates hooks and provider wiring. React-UI CodeBlock now chooses Prism or Light highlighter at runtime based on RegExp lookbehind support. Adds a patch changeset.

Changes

Cohort / File(s) Summary
Per-thread LangGraph interrupt state (react-core)
packages/react-core/src/components/copilot-provider/copilotkit.tsx, packages/react-core/src/context/copilot-context.tsx, packages/react-core/src/hooks/use-chat.ts, packages/react-core/src/hooks/use-langgraph-interrupt-render.ts, packages/react-core/src/hooks/use-langgraph-interrupt.ts, packages/react-core/src/types/interrupt-action.ts
Replace single global langGraphInterruptAction with langGraphInterruptActions: Record<string, ...> map. Change setter/remover signatures to accept (threadId, action) and (threadId). Provider exposes per-thread action via langGraphInterruptActions[internalThreadId]. Update call sites and default empty context implementations.
Dynamic syntax highlighting (react-ui)
packages/react-ui/src/components/chat/CodeBlock.tsx
Make syntax highlighter selectable at runtime: import Prism and Light separately, use state/effect to detect RegExp lookbehind support on mount, and choose Prism when supported or fall back to Light.
Release notes / changeset
CopilotKit/.changeset/loud-ways-smell.md
Add patch changeset for @copilotkit/react-ui noting fallback from Prism on older browsers; no code in changeset file.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UIHook as useLangGraphInterrupt / Render
  participant Context as CopilotContext
  participant Provider as CopilotProvider
  participant Store as langGraphInterruptActions (map)
  participant Thread as LangGraph Thread

  User->>UIHook: Trigger interrupt or render update
  UIHook->>Context: setLangGraphInterruptAction(threadId, action)
  Context->>Provider: invoke setter with threadId
  Provider->>Store: upsert map[threadId] = merged action/event
  Note over Store,Provider: Action stored per threadId

  Thread-->>Provider: read action via internalThreadId
  Provider-->>Context: expose langGraphInterruptAction = map[internalThreadId] ?? null
  Context-->>UIHook: provide per-thread action
  UIHook->>Context: removeLangGraphInterruptAction(threadId)
  Context->>Provider: invoke remover(threadId)
  Provider->>Store: clear map[threadId]
Loading
sequenceDiagram
  autonumber
  participant CodeBlock
  participant Env as Environment (RegExp lookbehind)
  participant Prism as PrismHighlighter
  participant Light as LightHighlighter

  CodeBlock->>CodeBlock: mount
  CodeBlock->>Env: check lookbehind support
  alt Supported
    CodeBlock->>CodeBlock: set SyntaxHighlighter = Prism
    CodeBlock->>Prism: render(code, language)
  else Not supported / error
    CodeBlock->>CodeBlock: set SyntaxHighlighter = Light
    CodeBlock->>Light: render(code, language)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • suhasdeshpande
  • ataibarkai

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 "fix: interrupt persistence" concisely and accurately captures the primary change — fixing how interrupt state is persisted — and aligns with the PR description and code changes that scope interrupt events by thread ID. It is short and specific enough for teammates scanning history. The wording directly maps to the implemented behavior (thread-scoped interrupt persistence).

📜 Recent 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 8553522 and 9de9cdd.

📒 Files selected for processing (1)
  • CopilotKit/packages/react-core/src/hooks/use-chat.ts (2 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@vercel

vercel Bot commented Sep 24, 2025 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Sep 25, 2025 11:53am
examples-coagents-ai-travel-app Ready Ready Preview Comment Sep 25, 2025 11:53am
examples-coagents-research-canvas-ui Ready Ready Preview Comment Sep 25, 2025 11:53am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
examples-coagents-ai-researcher-ui Ignored Ignored Sep 25, 2025 11:53am

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CopilotKit/packages/react-core/src/hooks/use-chat.ts (1)

875-893: Add threadId to runChatCompletion dependencies

runChatCompletion uses threadId and setLangGraphInterruptAction. Missing threadId can cause updates to the wrong thread.

   const runChatCompletion = useAsyncCallback(
     async (previousMessages: Message[]): Promise<Message[]> => {
       // ...
     },
-    [
+    [
       messages,
       setMessages,
       makeSystemMessageCallback,
       copilotConfig,
       setIsLoading,
       initialMessages,
       isLoading,
       actions,
       onFunctionCall,
       onCoAgentStateRender,
       setCoagentStatesWithRef,
       coagentStatesRef,
       agentSession,
       setAgentSession,
       disableSystemMessage,
       context,
+      threadId,
     ],
   );
🧹 Nitpick comments (6)
CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx (2)

1-2: Avoid statically importing Prism to prevent crashes/bloat on unsupported browsers

Dynamically import Prism only when lookbehind is supported so older engines never parse Prism code.

Apply this diff here:

-import { Prism, Light } from "react-syntax-highlighter";
+import { Light } from "react-syntax-highlighter";

And update the effect (outside this hunk) to lazy-load Prism:

// inside useEffect
let mounted = true;
try {
  new RegExp("(?<=#)\\w+");
  import("react-syntax-highlighter").then((mod) => {
    if (mounted) setSyntaxHighlighter(() => mod.Prism);
  });
} catch {
  setSyntaxHighlighter(() => Light);
}
return () => {
  mounted = false;
};

62-69: Guard against setState after unmount and use lazy Prism import

  • Add a mounted flag to avoid post-unmount state updates.
  • Prefer dynamic import of Prism inside this effect (see prior comment) to avoid loading Prism on unsupported browsers.

Example (outside this hunk):

useEffect(() => {
  let mounted = true;
  try {
    new RegExp("(?<=#)\\w+");
    import("react-syntax-highlighter").then((mod) => {
      if (mounted) setSyntaxHighlighter(() => mod.Prism);
    });
  } catch {
    setSyntaxHighlighter(() => Light);
  }
  return () => {
    mounted = false;
  };
}, []);
CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts (1)

12-17: Remove unused destructure and include threadId in effect deps

removeLangGraphInterruptAction isn’t used and forces an extra dependency. Also, threadId is used in the effect but isn’t in the dependency array.

-  const {
-    setLangGraphInterruptAction,
-    removeLangGraphInterruptAction,
-    langGraphInterruptAction,
-    threadId,
-  } = useContext(CopilotContext);
+  const { setLangGraphInterruptAction, langGraphInterruptAction, threadId } =
+    useContext(CopilotContext);
CopilotKit/packages/react-core/src/hooks/use-chat.ts (1)

916-947: Include threadId in composeAndFlushMetaEventsInput deps

Prevents flushing the wrong thread’s interrupt when switching threads.

-  }, [setLangGraphInterruptAction]);
+  }, [setLangGraphInterruptAction, threadId]);
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (1)

546-546: Coalesce undefined to null for context value

Ensure the context exposes null when there’s no entry for the current thread, matching its declared type.

-        langGraphInterruptAction: langGraphInterruptActions[internalThreadId],
+        langGraphInterruptAction: langGraphInterruptActions[internalThreadId] ?? null,
CopilotKit/packages/react-core/src/types/interrupt-action.ts (1)

39-42: Type change LGTM — verified call sites (no single-arg calls remain)

All usages pass (threadId, action) or (threadId, null). Optional: update the default no-op in CopilotKit/packages/react-core/src/context/copilot-context.tsx (currently setLangGraphInterruptAction: () => {}) to (threadId, action) => {} to match the setter signature.

📜 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 c75a943 and 077ebc6.

📒 Files selected for processing (8)
  • CopilotKit/.changeset/loud-ways-smell.md (1 hunks)
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (2 hunks)
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx (2 hunks)
  • CopilotKit/packages/react-core/src/hooks/use-chat.ts (2 hunks)
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts (3 hunks)
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts (2 hunks)
  • CopilotKit/packages/react-core/src/types/interrupt-action.ts (1 hunks)
  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
CopilotKit/packages/react-core/**

📄 CodeRabbit inference engine (.cursor/rules/copilotkit-architecture.mdc)

Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/

Files:

  • CopilotKit/packages/react-core/src/types/interrupt-action.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts
  • CopilotKit/packages/react-core/src/hooks/use-chat.ts
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx
**/*.{ts,tsx}

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

Use TypeScript for better type safety

Files:

  • CopilotKit/packages/react-core/src/types/interrupt-action.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts
  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx
  • CopilotKit/packages/react-core/src/hooks/use-chat.ts
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx
{**/*.{ts,tsx},CopilotKit/utilities/tailwind-config/**}

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

Maintain consistent styling with Tailwind CSS

Files:

  • CopilotKit/packages/react-core/src/types/interrupt-action.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts
  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx
  • CopilotKit/packages/react-core/src/hooks/use-chat.ts
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx
CopilotKit/packages/react-core/**/*

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

Use [react-core/] for basic integration when building a simple Copilot

Files:

  • CopilotKit/packages/react-core/src/types/interrupt-action.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts
  • CopilotKit/packages/react-core/src/hooks/use-chat.ts
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx
CopilotKit/packages/react-ui/**

📄 CodeRabbit inference engine (.cursor/rules/copilotkit-architecture.mdc)

UI components for copilot interfaces should be placed in CopilotKit/packages/react-ui/

Files:

  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx
{CopilotKit/packages/react-ui/**/*.{ts,tsx},examples/**/ui/**/*.{ts,tsx}}

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

{CopilotKit/packages/react-ui/**/*.{ts,tsx},examples/**/ui/**/*.{ts,tsx}}: Implement responsive design
Provide clear user feedback

Files:

  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx
CopilotKit/packages/react-ui/**/*

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

Add [react-ui/] for pre-built components when building a simple Copilot or customizing UI components

Files:

  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx
🧠 Learnings (2)
📚 Learning: 2025-07-04T14:02:44.814Z
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/quick-reference.mdc:0-0
Timestamp: 2025-07-04T14:02:44.814Z
Learning: Applies to CopilotKit/packages/react-ui/**/* : Add [react-ui/] for pre-built components when building a simple Copilot or customizing UI components

Applied to files:

  • CopilotKit/.changeset/loud-ways-smell.md
📚 Learning: 2025-07-20T15:40:00.391Z
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders

Applied to files:

  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts
  • CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx
🧬 Code graph analysis (1)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (1)
CopilotKit/packages/react-core/src/types/interrupt-action.ts (2)
  • LangGraphInterruptAction (32-34)
  • LangGraphInterruptActionSetterArgs (36-38)
⏰ 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). (12)
  • GitHub Check: Build Images (next-openai, next-openai)
  • GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-routing, ui)
  • GitHub Check: Build Images (coagents-qa-native, ui)
  • GitHub Check: Build Images (coagents-research-canvas, ui)
  • GitHub Check: Build Images (coagents-qa-text, ui)
  • GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
  • GitHub Check: E2E Tests
  • GitHub Check: Test (18.x)
  • GitHub Check: Test (20.x)
🔇 Additional comments (6)
CopilotKit/packages/react-ui/src/components/chat/CodeBlock.tsx (1)

58-61: Good default to Light for SSR and first render

Using Light as the initial component avoids hydration issues and works across browsers.

CopilotKit/.changeset/loud-ways-smell.md (1)

1-5: Add a changeset for react-core API surface changes

This PR changes public types and context signatures in @copilotkit/react-core (threadId parameter). Please add at least a patch changeset for react-core to avoid publishing UI-only changes that break consumers of react-core.

CopilotKit/packages/react-core/src/context/copilot-context.tsx (1)

226-227: Signature change acknowledged

Context now requires removeLangGraphInterruptAction(threadId: string). Keep provider/defaults in sync.

CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts (1)

21-21: Context destructure LGTM

Thread-scoped setter usage is correct.

CopilotKit/packages/react-core/src/hooks/use-chat.ts (2)

490-494: Per-thread event registration looks correct

Incoming interrupt events are scoped to the current thread.


926-927: Flushing per-thread interrupt state is correct

Clearing the interrupt after response is serialized is aligned with the new model.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (1)

451-453: Include stable dependency to satisfy exhaustive-deps.

Add the setter to the dependency array (it’s stable).

-  const removeLangGraphInterruptAction = useCallback((threadId: string): void => {
-    setLangGraphInterruptAction(threadId, null);
-  }, []);
+  const removeLangGraphInterruptAction = useCallback((threadId: string): void => {
+    setLangGraphInterruptAction(threadId, null);
+  }, [setLangGraphInterruptAction]);
📜 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 077ebc6 and 7a42f03.

📒 Files selected for processing (4)
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (2 hunks)
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx (2 hunks)
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts (3 hunks)
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt.ts
  • CopilotKit/packages/react-core/src/context/copilot-context.tsx
  • CopilotKit/packages/react-core/src/hooks/use-langgraph-interrupt-render.ts
🧰 Additional context used
📓 Path-based instructions (4)
CopilotKit/packages/react-core/**

📄 CodeRabbit inference engine (.cursor/rules/copilotkit-architecture.mdc)

Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
**/*.{ts,tsx}

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

Use TypeScript for better type safety

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
{**/*.{ts,tsx},CopilotKit/utilities/tailwind-config/**}

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

Maintain consistent styling with Tailwind CSS

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
CopilotKit/packages/react-core/**/*

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

Use [react-core/] for basic integration when building a simple Copilot

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
🧬 Code graph analysis (1)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (1)
CopilotKit/packages/react-core/src/types/interrupt-action.ts (2)
  • LangGraphInterruptAction (32-34)
  • LangGraphInterruptActionSetterArgs (36-38)
⏰ 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). (12)
  • GitHub Check: Test (20.x)
  • GitHub Check: Test (18.x)
  • GitHub Check: E2E Tests
  • GitHub Check: Build Images (next-openai, next-openai)
  • GitHub Check: Build Images (coagents-research-canvas, ui)
  • GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-qa-text, ui)
  • GitHub Check: Build Images (coagents-qa-native, ui)
  • GitHub Check: Build Images (coagents-routing, ui)
🔇 Additional comments (2)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (2)

427-430: Good move to per‑thread storage.

Scoping interrupt actions by threadId via a Record keeps concurrent threads isolated as intended.


431-449: Remove ts-ignore and type the merged event safely.

The ts-ignore masks real type issues. Merge the event with proper typing and set it conditionally.

Apply this diff:

   const setLangGraphInterruptAction = useCallback(
     (threadId: string, action: LangGraphInterruptActionSetterArgs) => {
       _setLangGraphInterruptAction((prev) => {
         if (action == null)
           return {
             ...prev,
             [threadId]: null,
           };
-        let event = prev[threadId]?.event;
-        if (action.event) {
-          // @ts-ignore
-          event = { ...(prev[threadId]?.event || {}), ...action.event };
-        }
+        const mergedEvent: LangGraphInterruptAction["event"] = action.event
+          ? ({ ...(prev[threadId]?.event ?? {}), ...action.event } as LangGraphInterruptAction["event"])
+          : prev[threadId]?.event;
         return {
           ...prev,
-          [threadId]: { ...(prev[threadId] ?? {}), ...action, event } as LangGraphInterruptAction,
+          [threadId]: {
+            ...(prev[threadId] ?? {}),
+            ...action,
+            ...(mergedEvent ? { event: mergedEvent } : {}),
+          } as LangGraphInterruptAction,
         };
       });
     },
     [],
   );

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (1)

451-453: Add dependency to useCallback to satisfy exhaustive-deps.

Include setLangGraphInterruptAction in the dependency array to avoid lint noise and ensure correctness if it ever changes.

-  const removeLangGraphInterruptAction = useCallback((threadId: string): void => {
-    setLangGraphInterruptAction(threadId, null);
-  }, []);
+  const removeLangGraphInterruptAction = useCallback((threadId: string): void => {
+    setLangGraphInterruptAction(threadId, null);
+  }, [setLangGraphInterruptAction]);
📜 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 7a42f03 and 8553522.

📒 Files selected for processing (1)
  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
CopilotKit/packages/react-core/**

📄 CodeRabbit inference engine (.cursor/rules/copilotkit-architecture.mdc)

Core React components and hooks for CopilotKit should be placed in CopilotKit/packages/react-core/

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
**/*.{ts,tsx}

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

Use TypeScript for better type safety

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
{**/*.{ts,tsx},CopilotKit/utilities/tailwind-config/**}

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

Maintain consistent styling with Tailwind CSS

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
CopilotKit/packages/react-core/**/*

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

Use [react-core/] for basic integration when building a simple Copilot

Files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
🧠 Learnings (2)
📚 Learning: 2025-07-20T15:40:00.391Z
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check useEffect dependencies and ensure they're properly memoized to avoid infinite re-renders

Applied to files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
📚 Learning: 2025-07-20T15:40:00.391Z
Learnt from: CR
PR: CopilotKit/CopilotKit#0
File: .cursor/rules/suggestions-development.mdc:0-0
Timestamp: 2025-07-20T15:40:00.391Z
Learning: Applies to packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx : Check if `useCopilotChatSuggestions` is being called in your component if there are no initial suggestions

Applied to files:

  • CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx
🧬 Code graph analysis (1)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (1)
CopilotKit/packages/react-core/src/types/interrupt-action.ts (2)
  • LangGraphInterruptAction (32-34)
  • LangGraphInterruptActionSetterArgs (36-38)
⏰ 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). (12)
  • GitHub Check: Build Images (coagents-qa-native, ui)
  • GitHub Check: Build Images (next-openai, next-openai)
  • GitHub Check: Build Images (coagents-qa-text, ui)
  • GitHub Check: Build Images (coagents-routing, ui)
  • GitHub Check: Build Images (coagents-research-canvas, ui)
  • GitHub Check: Build Images (coagents-qa-text, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-qa-native, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-routing, agent, python, local-deps)
  • GitHub Check: Build Images (coagents-research-canvas, agent, python, local-deps)
  • GitHub Check: E2E Tests
  • GitHub Check: Test (20.x)
  • GitHub Check: Test (18.x)
🔇 Additional comments (3)
CopilotKit/packages/react-core/src/components/copilot-provider/copilotkit.tsx (3)

427-430: Good: per-thread interrupt state introduced.

The state shape and initialization look correct for scoping by threadId.


439-446: Remove ts-ignore and perform a typed event merge.

Avoid suppressing type checks; merge the event patch explicitly and keep the final assignment typed.

Apply this diff:

-        let event = prev[threadId]?.event;
-        if (action.event) {
-          // @ts-ignore
-          event = { ...(prev[threadId]?.event || {}), ...action.event };
-        }
-        return {
-          ...prev,
-          [threadId]: { ...(prev[threadId] ?? {}), ...action, event } as LangGraphInterruptAction,
-        };
+        const prevEntry = prev[threadId];
+        const { event: eventPatch, ...rest } = action;
+        const nextEvent = eventPatch
+          ? { ...(prevEntry?.event ?? {}), ...eventPatch }
+          : prevEntry?.event;
+        return {
+          ...prev,
+          [threadId]: {
+            ...(prevEntry ?? {}),
+            ...rest,
+            ...(nextEvent ? { event: nextEvent } : {}),
+          } as LangGraphInterruptAction,
+        };

546-546: LGTM: coalescing to null prevents undefined leaking through context.

Matches the context type contract.

@github-actions

Copy link
Copy Markdown
Contributor

Previews

Commit SHA: d663345

Name Preview
coagents-research-canvas Preview • Preview with LGC Python • Preview with LGC JS
coagents-qa-native Preview • Preview with LGC Python • Preview with LGC JS
coagents-routing Preview • Preview with LGC Python • Preview with LGC JS
coagents-qa-text Preview • Preview with LGC Python • Preview with LGC JS
next-openai Preview

@github-actions

github-actions Bot commented Sep 25, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

Status: ✅ Passed (View Run)

Commit: d663345

Duration: 232.4s

Total Tests: 37

Pass Rate: 100.0%

Failed Tests: 0

🔍 Detailed Results

coagents-research-canvas

CoAgents Research Canvas (UI) - Local Depenencies

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

coagents-qa-native

CoAgents QA Native (UI) - Local

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

coagents-qa-text

CoAgents QA Text (UI) - Local

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

coagents-routing

CoAgents Routing (UI) - Local

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

next-openai

Next OpenAI - Self Hosted

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

@changesets-bot-copilotkit

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9de9cdd

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

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

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

@ranst91
ranst91 merged commit c2de25d into main Sep 25, 2025
@ranst91
ranst91 deleted the fix/interrupt-persistence branch September 25, 2025 11:50

This branch was successfully deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant