@copilotkit/react-core 1.56.2-canary.pin-to-send → 1.56.2-canary.test-welcome-screen

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{copilotkit-D5JT2Pu3.cjs → copilotkit-By2G6-Zx.cjs} +22 -9
  2. package/dist/copilotkit-By2G6-Zx.cjs.map +1 -0
  3. package/dist/{copilotkit-DArT2Iuw.d.mts → copilotkit-DFaI4j2r.d.mts} +3 -1
  4. package/dist/copilotkit-DFaI4j2r.d.mts.map +1 -0
  5. package/dist/{copilotkit-KEc28l8G.d.cts → copilotkit-Dg4r4Gi_.d.cts} +3 -1
  6. package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -0
  7. package/dist/{copilotkit-BBYbekCa.mjs → copilotkit-PzJlPKcU.mjs} +22 -9
  8. package/dist/copilotkit-PzJlPKcU.mjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.cts +2 -1
  11. package/dist/index.d.cts.map +1 -1
  12. package/dist/index.d.mts +2 -1
  13. package/dist/index.d.mts.map +1 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/index.umd.js +15 -4
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/index.cjs +1 -1
  18. package/dist/v2/index.d.cts +1 -1
  19. package/dist/v2/index.d.mts +1 -1
  20. package/dist/v2/index.mjs +1 -1
  21. package/dist/v2/index.umd.js +21 -8
  22. package/dist/v2/index.umd.js.map +1 -1
  23. package/package.json +6 -6
  24. package/src/components/copilot-provider/__tests__/v1-explicit-threadid-bridge.test.tsx +107 -0
  25. package/src/components/copilot-provider/copilotkit.tsx +6 -1
  26. package/src/context/__tests__/threads-context.test.tsx +116 -3
  27. package/src/context/threads-context.tsx +18 -1
  28. package/src/v2/components/chat/CopilotChat.tsx +19 -8
  29. package/src/v2/components/chat/__tests__/CopilotChat.welcomeGate.test.tsx +186 -0
  30. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +29 -1
  31. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +106 -0
  32. package/dist/copilotkit-BBYbekCa.mjs.map +0 -1
  33. package/dist/copilotkit-D5JT2Pu3.cjs.map +0 -1
  34. package/dist/copilotkit-DArT2Iuw.d.mts.map +0 -1
  35. package/dist/copilotkit-KEc28l8G.d.cts.map +0 -1
package/dist/v2/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_copilotkit = require('../copilotkit-D5JT2Pu3.cjs');
4
+ const require_copilotkit = require('../copilotkit-By2G6-Zx.cjs');
5
5
  require("./index.css");
6
6
  let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
7
7
 
@@ -1,4 +1,4 @@
1
- import { $ as MCPAppsActivityContent, $t as AudioRecorderState, A as useAgentContext, At as CopilotChatMessageView, B as SandboxFunction, Bt as CopilotChatAssistantMessage, C as useThreads, Ct as DefaultCloseIcon, D as useSuggestions, Dt as CopilotChatView, E as useConfigureSuggestions, Et as CopilotChatProps, F as useDefaultRenderTool, Ft as CopilotChatSuggestionPillProps, G as ReactHumanInTheLoop, Gt as CopilotChatInputProps, H as InterruptHandlerProps, Ht as CopilotChatToolCallsView, I as useRenderTool, It as CopilotChatReasoningMessage, J as ReactToolCallRenderer, Jt as CopilotChatConfigurationProviderProps, K as ReactFrontendTool, Kt as ToolsMenuItem, L as useComponent, Lt as CopilotChatReasoningMessageProps, M as UseAgentUpdate, Mt as CopilotChatSuggestionView, N as useAgent, Nt as CopilotChatSuggestionViewProps, O as AgentContextInput, Ot as CopilotChatViewProps, P as useHumanInTheLoop, Pt as CopilotChatSuggestionPill, Q as useRenderToolCall, Qt as AudioRecorderError, R as useFrontendTool, Rt as CopilotChatUserMessage, S as UseThreadsResult, St as CopilotChatToggleButtonProps, T as useInterrupt, Tt as CopilotChat, U as InterruptRenderProps, Ut as CopilotChatToolCallsViewProps, V as InterruptEvent, Vt as CopilotChatAssistantMessageProps, W as defineToolCallRenderer, Wt as CopilotChatInput, X as ReactCustomMessageRenderer, Xt as CopilotChatLabels, Y as useRenderCustomMessages, Yt as CopilotChatConfigurationValue, Z as ReactCustomMessageRendererPosition, Zt as useCopilotChatConfiguration, _ as UseAttachmentsProps, _t as CopilotSidebarView, a as A2UIUserAction, at as WildcardToolCallRender, b as Thread, bt as CopilotModalHeaderProps, c as SandboxFunctionsContext, ct as AttachmentsConfig, d as CopilotKitProvider, dt as CopilotPopup, en as CopilotChatAudioRecorder, et as MCPAppsActivityContentSchema, f as CopilotKitProviderProps, ft as CopilotPopupProps, g as CopilotKitCoreReactSubscriber, gt as CopilotPopupViewProps, h as CopilotKitCoreReactConfig, ht as CopilotPopupView, i as A2UIMessageRendererOptions, it as CopilotKitInspectorProps, j as useCapabilities, jt as CopilotChatMessageViewProps, k as JsonSerializable, kt as AutoScrollMode, l as useSandboxFunctions, lt as CopilotChatAttachmentRenderer, m as CopilotKitCoreReact, mt as CopilotSidebarProps, nt as MCPAppsActivityType, o as createA2UIMessageRenderer, ot as Attachment, p as useCopilotKit, pt as CopilotSidebar, q as ReactActivityMessageRenderer, qt as CopilotChatConfigurationProvider, r as CopilotKitProps, rt as CopilotKitInspector, s as InspectorAnchor, st as AttachmentModality, t as CopilotKit, tt as MCPAppsActivityRenderer, u as CopilotKitContextValue, ut as CopilotChatAttachmentQueue, v as UseAttachmentsReturn, vt as CopilotSidebarViewProps, w as UseInterruptConfig, wt as DefaultOpenIcon, x as UseThreadsInput, xt as CopilotChatToggleButton, y as useAttachments, yt as CopilotModalHeader, z as useRenderActivityMessage, zt as CopilotChatUserMessageProps } from "../copilotkit-KEc28l8G.cjs";
1
+ import { $ as MCPAppsActivityContent, $t as AudioRecorderState, A as useAgentContext, At as CopilotChatMessageView, B as SandboxFunction, Bt as CopilotChatAssistantMessage, C as useThreads, Ct as DefaultCloseIcon, D as useSuggestions, Dt as CopilotChatView, E as useConfigureSuggestions, Et as CopilotChatProps, F as useDefaultRenderTool, Ft as CopilotChatSuggestionPillProps, G as ReactHumanInTheLoop, Gt as CopilotChatInputProps, H as InterruptHandlerProps, Ht as CopilotChatToolCallsView, I as useRenderTool, It as CopilotChatReasoningMessage, J as ReactToolCallRenderer, Jt as CopilotChatConfigurationProviderProps, K as ReactFrontendTool, Kt as ToolsMenuItem, L as useComponent, Lt as CopilotChatReasoningMessageProps, M as UseAgentUpdate, Mt as CopilotChatSuggestionView, N as useAgent, Nt as CopilotChatSuggestionViewProps, O as AgentContextInput, Ot as CopilotChatViewProps, P as useHumanInTheLoop, Pt as CopilotChatSuggestionPill, Q as useRenderToolCall, Qt as AudioRecorderError, R as useFrontendTool, Rt as CopilotChatUserMessage, S as UseThreadsResult, St as CopilotChatToggleButtonProps, T as useInterrupt, Tt as CopilotChat, U as InterruptRenderProps, Ut as CopilotChatToolCallsViewProps, V as InterruptEvent, Vt as CopilotChatAssistantMessageProps, W as defineToolCallRenderer, Wt as CopilotChatInput, X as ReactCustomMessageRenderer, Xt as CopilotChatLabels, Y as useRenderCustomMessages, Yt as CopilotChatConfigurationValue, Z as ReactCustomMessageRendererPosition, Zt as useCopilotChatConfiguration, _ as UseAttachmentsProps, _t as CopilotSidebarView, a as A2UIUserAction, at as WildcardToolCallRender, b as Thread, bt as CopilotModalHeaderProps, c as SandboxFunctionsContext, ct as AttachmentsConfig, d as CopilotKitProvider, dt as CopilotPopup, en as CopilotChatAudioRecorder, et as MCPAppsActivityContentSchema, f as CopilotKitProviderProps, ft as CopilotPopupProps, g as CopilotKitCoreReactSubscriber, gt as CopilotPopupViewProps, h as CopilotKitCoreReactConfig, ht as CopilotPopupView, i as A2UIMessageRendererOptions, it as CopilotKitInspectorProps, j as useCapabilities, jt as CopilotChatMessageViewProps, k as JsonSerializable, kt as AutoScrollMode, l as useSandboxFunctions, lt as CopilotChatAttachmentRenderer, m as CopilotKitCoreReact, mt as CopilotSidebarProps, nt as MCPAppsActivityType, o as createA2UIMessageRenderer, ot as Attachment, p as useCopilotKit, pt as CopilotSidebar, q as ReactActivityMessageRenderer, qt as CopilotChatConfigurationProvider, r as CopilotKitProps, rt as CopilotKitInspector, s as InspectorAnchor, st as AttachmentModality, t as CopilotKit, tt as MCPAppsActivityRenderer, u as CopilotKitContextValue, ut as CopilotChatAttachmentQueue, v as UseAttachmentsReturn, vt as CopilotSidebarViewProps, w as UseInterruptConfig, wt as DefaultOpenIcon, x as UseThreadsInput, xt as CopilotChatToggleButton, y as useAttachments, yt as CopilotModalHeader, z as useRenderActivityMessage, zt as CopilotChatUserMessageProps } from "../copilotkit-Dg4r4Gi_.cjs";
2
2
  import "./index.css";
3
3
  import { Theme as A2UITheme, defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
4
4
  export * from "@copilotkit/core";
@@ -1,4 +1,4 @@
1
- import { $ as MCPAppsActivityContent, $t as AudioRecorderState, A as useAgentContext, At as CopilotChatMessageView, B as SandboxFunction, Bt as CopilotChatAssistantMessage, C as useThreads, Ct as DefaultCloseIcon, D as useSuggestions, Dt as CopilotChatView, E as useConfigureSuggestions, Et as CopilotChatProps, F as useDefaultRenderTool, Ft as CopilotChatSuggestionPillProps, G as ReactHumanInTheLoop, Gt as CopilotChatInputProps, H as InterruptHandlerProps, Ht as CopilotChatToolCallsView, I as useRenderTool, It as CopilotChatReasoningMessage, J as ReactToolCallRenderer, Jt as CopilotChatConfigurationProviderProps, K as ReactFrontendTool, Kt as ToolsMenuItem, L as useComponent, Lt as CopilotChatReasoningMessageProps, M as UseAgentUpdate, Mt as CopilotChatSuggestionView, N as useAgent, Nt as CopilotChatSuggestionViewProps, O as AgentContextInput, Ot as CopilotChatViewProps, P as useHumanInTheLoop, Pt as CopilotChatSuggestionPill, Q as useRenderToolCall, Qt as AudioRecorderError, R as useFrontendTool, Rt as CopilotChatUserMessage, S as UseThreadsResult, St as CopilotChatToggleButtonProps, T as useInterrupt, Tt as CopilotChat, U as InterruptRenderProps, Ut as CopilotChatToolCallsViewProps, V as InterruptEvent, Vt as CopilotChatAssistantMessageProps, W as defineToolCallRenderer, Wt as CopilotChatInput, X as ReactCustomMessageRenderer, Xt as CopilotChatLabels, Y as useRenderCustomMessages, Yt as CopilotChatConfigurationValue, Z as ReactCustomMessageRendererPosition, Zt as useCopilotChatConfiguration, _ as UseAttachmentsProps, _t as CopilotSidebarView, a as A2UIUserAction, at as WildcardToolCallRender, b as Thread, bt as CopilotModalHeaderProps, c as SandboxFunctionsContext, ct as AttachmentsConfig, d as CopilotKitProvider, dt as CopilotPopup, en as CopilotChatAudioRecorder, et as MCPAppsActivityContentSchema, f as CopilotKitProviderProps, ft as CopilotPopupProps, g as CopilotKitCoreReactSubscriber, gt as CopilotPopupViewProps, h as CopilotKitCoreReactConfig, ht as CopilotPopupView, i as A2UIMessageRendererOptions, it as CopilotKitInspectorProps, j as useCapabilities, jt as CopilotChatMessageViewProps, k as JsonSerializable, kt as AutoScrollMode, l as useSandboxFunctions, lt as CopilotChatAttachmentRenderer, m as CopilotKitCoreReact, mt as CopilotSidebarProps, nt as MCPAppsActivityType, o as createA2UIMessageRenderer, ot as Attachment, p as useCopilotKit, pt as CopilotSidebar, q as ReactActivityMessageRenderer, qt as CopilotChatConfigurationProvider, r as CopilotKitProps, rt as CopilotKitInspector, s as InspectorAnchor, st as AttachmentModality, t as CopilotKit, tt as MCPAppsActivityRenderer, u as CopilotKitContextValue, ut as CopilotChatAttachmentQueue, v as UseAttachmentsReturn, vt as CopilotSidebarViewProps, w as UseInterruptConfig, wt as DefaultOpenIcon, x as UseThreadsInput, xt as CopilotChatToggleButton, y as useAttachments, yt as CopilotModalHeader, z as useRenderActivityMessage, zt as CopilotChatUserMessageProps } from "../copilotkit-DArT2Iuw.mjs";
1
+ import { $ as MCPAppsActivityContent, $t as AudioRecorderState, A as useAgentContext, At as CopilotChatMessageView, B as SandboxFunction, Bt as CopilotChatAssistantMessage, C as useThreads, Ct as DefaultCloseIcon, D as useSuggestions, Dt as CopilotChatView, E as useConfigureSuggestions, Et as CopilotChatProps, F as useDefaultRenderTool, Ft as CopilotChatSuggestionPillProps, G as ReactHumanInTheLoop, Gt as CopilotChatInputProps, H as InterruptHandlerProps, Ht as CopilotChatToolCallsView, I as useRenderTool, It as CopilotChatReasoningMessage, J as ReactToolCallRenderer, Jt as CopilotChatConfigurationProviderProps, K as ReactFrontendTool, Kt as ToolsMenuItem, L as useComponent, Lt as CopilotChatReasoningMessageProps, M as UseAgentUpdate, Mt as CopilotChatSuggestionView, N as useAgent, Nt as CopilotChatSuggestionViewProps, O as AgentContextInput, Ot as CopilotChatViewProps, P as useHumanInTheLoop, Pt as CopilotChatSuggestionPill, Q as useRenderToolCall, Qt as AudioRecorderError, R as useFrontendTool, Rt as CopilotChatUserMessage, S as UseThreadsResult, St as CopilotChatToggleButtonProps, T as useInterrupt, Tt as CopilotChat, U as InterruptRenderProps, Ut as CopilotChatToolCallsViewProps, V as InterruptEvent, Vt as CopilotChatAssistantMessageProps, W as defineToolCallRenderer, Wt as CopilotChatInput, X as ReactCustomMessageRenderer, Xt as CopilotChatLabels, Y as useRenderCustomMessages, Yt as CopilotChatConfigurationValue, Z as ReactCustomMessageRendererPosition, Zt as useCopilotChatConfiguration, _ as UseAttachmentsProps, _t as CopilotSidebarView, a as A2UIUserAction, at as WildcardToolCallRender, b as Thread, bt as CopilotModalHeaderProps, c as SandboxFunctionsContext, ct as AttachmentsConfig, d as CopilotKitProvider, dt as CopilotPopup, en as CopilotChatAudioRecorder, et as MCPAppsActivityContentSchema, f as CopilotKitProviderProps, ft as CopilotPopupProps, g as CopilotKitCoreReactSubscriber, gt as CopilotPopupViewProps, h as CopilotKitCoreReactConfig, ht as CopilotPopupView, i as A2UIMessageRendererOptions, it as CopilotKitInspectorProps, j as useCapabilities, jt as CopilotChatMessageViewProps, k as JsonSerializable, kt as AutoScrollMode, l as useSandboxFunctions, lt as CopilotChatAttachmentRenderer, m as CopilotKitCoreReact, mt as CopilotSidebarProps, nt as MCPAppsActivityType, o as createA2UIMessageRenderer, ot as Attachment, p as useCopilotKit, pt as CopilotSidebar, q as ReactActivityMessageRenderer, qt as CopilotChatConfigurationProvider, r as CopilotKitProps, rt as CopilotKitInspector, s as InspectorAnchor, st as AttachmentModality, t as CopilotKit, tt as MCPAppsActivityRenderer, u as CopilotKitContextValue, ut as CopilotChatAttachmentQueue, v as UseAttachmentsReturn, vt as CopilotSidebarViewProps, w as UseInterruptConfig, wt as DefaultOpenIcon, x as UseThreadsInput, xt as CopilotChatToggleButton, y as useAttachments, yt as CopilotModalHeader, z as useRenderActivityMessage, zt as CopilotChatUserMessageProps } from "../copilotkit-DFaI4j2r.mjs";
2
2
  import "./index.css";
3
3
  import { Theme as A2UITheme, defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
4
4
  export * from "@copilotkit/core";
package/dist/v2/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { $ as CopilotKitProvider, A as CopilotChatSuggestionView, B as useConfigureSuggestions, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAssistantMessage_default, G as useRenderTool, H as useCapabilities, I as CopilotChatToolCallsView, J as useRenderActivityMessage, K as useComponent, L as useAttachments, M as CopilotChatReasoningMessage_default, N as CopilotChatUserMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatAttachmentRenderer, Q as useRenderToolCall, R as useThreads, S as CopilotModalHeader, T as DefaultOpenIcon, U as useHumanInTheLoop, V as useSuggestions, W as useDefaultRenderTool, X as UseAgentUpdate, Y as useRenderCustomMessages, Z as useAgent, _ as WildcardToolCallRender, at as SandboxFunctionsContext, b as CopilotPopupView, ct as MCPAppsActivityRenderer, dt as CopilotChatInput_default, et as useCopilotKit, ft as AudioRecorderError, ht as useCopilotChatConfiguration, it as createA2UIMessageRenderer, j as CopilotChatSuggestionPill, k as CopilotChatMessageView, lt as MCPAppsActivityType, mt as CopilotChatConfigurationProvider, nt as useAgentContext, ot as useSandboxFunctions, pt as CopilotChatAudioRecorder, q as useFrontendTool, rt as defineToolCallRenderer, st as MCPAppsActivityContentSchema, t as CopilotKit, tt as CopilotKitCoreReact, ut as CopilotKitInspector, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useInterrupt } from "../copilotkit-BBYbekCa.mjs";
3
+ import { $ as CopilotKitProvider, A as CopilotChatSuggestionView, B as useConfigureSuggestions, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAssistantMessage_default, G as useRenderTool, H as useCapabilities, I as CopilotChatToolCallsView, J as useRenderActivityMessage, K as useComponent, L as useAttachments, M as CopilotChatReasoningMessage_default, N as CopilotChatUserMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatAttachmentRenderer, Q as useRenderToolCall, R as useThreads, S as CopilotModalHeader, T as DefaultOpenIcon, U as useHumanInTheLoop, V as useSuggestions, W as useDefaultRenderTool, X as UseAgentUpdate, Y as useRenderCustomMessages, Z as useAgent, _ as WildcardToolCallRender, at as SandboxFunctionsContext, b as CopilotPopupView, ct as MCPAppsActivityRenderer, dt as CopilotChatInput_default, et as useCopilotKit, ft as AudioRecorderError, ht as useCopilotChatConfiguration, it as createA2UIMessageRenderer, j as CopilotChatSuggestionPill, k as CopilotChatMessageView, lt as MCPAppsActivityType, mt as CopilotChatConfigurationProvider, nt as useAgentContext, ot as useSandboxFunctions, pt as CopilotChatAudioRecorder, q as useFrontendTool, rt as defineToolCallRenderer, st as MCPAppsActivityContentSchema, t as CopilotKit, tt as CopilotKitCoreReact, ut as CopilotKitInspector, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useInterrupt } from "../copilotkit-PzJlPKcU.mjs";
4
4
  import "./index.css";
5
5
  import { defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
6
6
 
@@ -161,7 +161,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
161
161
  welcomeMessageText: "How can I help you today?"
162
162
  };
163
163
  const CopilotChatConfiguration = (0, react.createContext)(null);
164
- const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, isModalDefaultOpen }) => {
164
+ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, hasExplicitThreadId, isModalDefaultOpen }) => {
165
165
  var _ref, _parentConfig$isModal, _parentConfig$setModa;
166
166
  const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
167
167
  const stableLabels = useShallowStableRef(labels);
@@ -176,6 +176,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
176
176
  if (parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.threadId) return parentConfig.threadId;
177
177
  return (0, _copilotkit_shared.randomUUID)();
178
178
  }, [threadId, parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.threadId]);
179
+ const resolvedHasExplicitThreadId = (hasExplicitThreadId !== void 0 ? hasExplicitThreadId : !!threadId) || !!(parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.hasExplicitThreadId);
179
180
  const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen !== null && isModalDefaultOpen !== void 0 ? isModalDefaultOpen : true);
180
181
  const hasExplicitDefault = isModalDefaultOpen !== void 0;
181
182
  const setAndSync = (0, react.useCallback)((open) => {
@@ -198,12 +199,14 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
198
199
  labels: mergedLabels,
199
200
  agentId: resolvedAgentId,
200
201
  threadId: resolvedThreadId,
202
+ hasExplicitThreadId: resolvedHasExplicitThreadId,
201
203
  isModalOpen: resolvedIsModalOpen,
202
204
  setModalOpen: resolvedSetModalOpen
203
205
  }), [
204
206
  mergedLabels,
205
207
  resolvedAgentId,
206
208
  resolvedThreadId,
209
+ resolvedHasExplicitThreadId,
207
210
  resolvedIsModalOpen,
208
211
  resolvedSetModalOpen
209
212
  ]);
@@ -6907,6 +6910,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6907
6910
  const resolvedAgentId = (_ref = agentId !== null && agentId !== void 0 ? agentId : existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.agentId) !== null && _ref !== void 0 ? _ref : _copilotkit_shared.DEFAULT_AGENT_ID;
6908
6911
  const providedThreadId = threadId !== null && threadId !== void 0 ? threadId : existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.threadId;
6909
6912
  const resolvedThreadId = (0, react.useMemo)(() => providedThreadId !== null && providedThreadId !== void 0 ? providedThreadId : (0, _copilotkit_shared.randomUUID)(), [providedThreadId]);
6913
+ const hasExplicitThreadId = !!threadId || !!(existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.hasExplicitThreadId);
6910
6914
  const { agent } = useAgent({
6911
6915
  agentId: resolvedAgentId,
6912
6916
  threadId: resolvedThreadId,
@@ -6949,9 +6953,9 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6949
6953
  const isMediaRecorderSupported = typeof window !== "undefined" && typeof MediaRecorder !== "undefined";
6950
6954
  const { messageView: providedMessageView, suggestionView: providedSuggestionView, onStop: providedStopHandler, ...restProps } = props;
6951
6955
  const [lastConnectedThreadId, setLastConnectedThreadId] = (0, react.useState)(null);
6952
- const isConnecting = !!providedThreadId && lastConnectedThreadId !== resolvedThreadId;
6956
+ const isConnecting = hasExplicitThreadId && lastConnectedThreadId !== resolvedThreadId;
6953
6957
  (0, react.useEffect)(() => {
6954
- if (!providedThreadId) return;
6958
+ if (!hasExplicitThreadId) return;
6955
6959
  let detached = false;
6956
6960
  const connectAbortController = new AbortController();
6957
6961
  if (agent instanceof _ag_ui_client.HttpAgent) agent.abortController = connectAbortController;
@@ -6977,7 +6981,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6977
6981
  resolvedThreadId,
6978
6982
  agent,
6979
6983
  resolvedAgentId,
6980
- providedThreadId
6984
+ hasExplicitThreadId
6981
6985
  ]);
6982
6986
  const onSubmitInput = (0, react.useCallback)(async (value) => {
6983
6987
  if (selectedAttachments.some((a) => a.status === "uploading")) {
@@ -7170,11 +7174,12 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7170
7174
  onDragLeave: handleDragLeave,
7171
7175
  onDrop: handleDrop,
7172
7176
  isConnecting,
7173
- hasExplicitThreadId: !!providedThreadId
7177
+ hasExplicitThreadId
7174
7178
  });
7175
7179
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfigurationProvider, {
7176
7180
  agentId: resolvedAgentId,
7177
7181
  threadId: resolvedThreadId,
7182
+ hasExplicitThreadId,
7178
7183
  labels,
7179
7184
  isModalDefaultOpen,
7180
7185
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -8833,12 +8838,19 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
8833
8838
  //#region src/context/threads-context.tsx
8834
8839
  const ThreadsContext = (0, react.createContext)(void 0);
8835
8840
  function ThreadsProvider({ children, threadId: explicitThreadId }) {
8836
- const [internalThreadId, setThreadId] = (0, react.useState)(() => (0, _copilotkit_shared.randomUUID)());
8841
+ const [internalThreadId, setInternalThreadId] = (0, react.useState)(() => (0, _copilotkit_shared.randomUUID)());
8842
+ const [internalIsExplicit, setInternalIsExplicit] = (0, react.useState)(false);
8837
8843
  const threadId = explicitThreadId !== null && explicitThreadId !== void 0 ? explicitThreadId : internalThreadId;
8844
+ const isThreadIdExplicit = explicitThreadId != null || internalIsExplicit;
8845
+ const setThreadId = (0, react.useCallback)((value) => {
8846
+ setInternalThreadId(value);
8847
+ setInternalIsExplicit(true);
8848
+ }, []);
8838
8849
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadsContext.Provider, {
8839
8850
  value: {
8840
8851
  threadId,
8841
- setThreadId
8852
+ setThreadId,
8853
+ isThreadIdExplicit
8842
8854
  },
8843
8855
  children
8844
8856
  });
@@ -9558,7 +9570,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
9558
9570
  if (props.agent) setAgentSession({ agentName: props.agent });
9559
9571
  else setAgentSession(null);
9560
9572
  }, [props.agent]);
9561
- const { threadId, setThreadId: setInternalThreadId } = useThreads$1();
9573
+ const { threadId, setThreadId: setInternalThreadId, isThreadIdExplicit } = useThreads$1();
9562
9574
  const setThreadId = (0, react.useCallback)((value) => {
9563
9575
  if (props.threadId) throw new Error("Cannot call setThreadId() when threadId is provided via props.");
9564
9576
  setInternalThreadId(value);
@@ -9764,6 +9776,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
9764
9776
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfigurationProvider, {
9765
9777
  agentId: (_props$agent2 = props.agent) !== null && _props$agent2 !== void 0 ? _props$agent2 : "default",
9766
9778
  threadId,
9779
+ hasExplicitThreadId: isThreadIdExplicit,
9767
9780
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotContext.Provider, {
9768
9781
  value: copilotContextValue,
9769
9782
  children: [