@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.
- package/dist/{copilotkit-D5JT2Pu3.cjs → copilotkit-By2G6-Zx.cjs} +22 -9
- package/dist/copilotkit-By2G6-Zx.cjs.map +1 -0
- package/dist/{copilotkit-DArT2Iuw.d.mts → copilotkit-DFaI4j2r.d.mts} +3 -1
- package/dist/copilotkit-DFaI4j2r.d.mts.map +1 -0
- package/dist/{copilotkit-KEc28l8G.d.cts → copilotkit-Dg4r4Gi_.d.cts} +3 -1
- package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -0
- package/dist/{copilotkit-BBYbekCa.mjs → copilotkit-PzJlPKcU.mjs} +22 -9
- package/dist/copilotkit-PzJlPKcU.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +15 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +21 -8
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/copilot-provider/__tests__/v1-explicit-threadid-bridge.test.tsx +107 -0
- package/src/components/copilot-provider/copilotkit.tsx +6 -1
- package/src/context/__tests__/threads-context.test.tsx +116 -3
- package/src/context/threads-context.tsx +18 -1
- package/src/v2/components/chat/CopilotChat.tsx +19 -8
- package/src/v2/components/chat/__tests__/CopilotChat.welcomeGate.test.tsx +186 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.tsx +29 -1
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +106 -0
- package/dist/copilotkit-BBYbekCa.mjs.map +0 -1
- package/dist/copilotkit-D5JT2Pu3.cjs.map +0 -1
- package/dist/copilotkit-DArT2Iuw.d.mts.map +0 -1
- package/dist/copilotkit-KEc28l8G.d.cts.map +0 -1
|
@@ -175,7 +175,7 @@ const CopilotChatDefaultLabels = {
|
|
|
175
175
|
welcomeMessageText: "How can I help you today?"
|
|
176
176
|
};
|
|
177
177
|
const CopilotChatConfiguration = (0, react.createContext)(null);
|
|
178
|
-
const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, isModalDefaultOpen }) => {
|
|
178
|
+
const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, hasExplicitThreadId, isModalDefaultOpen }) => {
|
|
179
179
|
const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
|
|
180
180
|
const stableLabels = useShallowStableRef(labels);
|
|
181
181
|
const mergedLabels = (0, react.useMemo)(() => ({
|
|
@@ -189,6 +189,7 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
189
189
|
if (parentConfig?.threadId) return parentConfig.threadId;
|
|
190
190
|
return (0, _copilotkit_shared.randomUUID)();
|
|
191
191
|
}, [threadId, parentConfig?.threadId]);
|
|
192
|
+
const resolvedHasExplicitThreadId = (hasExplicitThreadId !== void 0 ? hasExplicitThreadId : !!threadId) || !!parentConfig?.hasExplicitThreadId;
|
|
192
193
|
const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen ?? true);
|
|
193
194
|
const hasExplicitDefault = isModalDefaultOpen !== void 0;
|
|
194
195
|
const setAndSync = (0, react.useCallback)((open) => {
|
|
@@ -211,12 +212,14 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
211
212
|
labels: mergedLabels,
|
|
212
213
|
agentId: resolvedAgentId,
|
|
213
214
|
threadId: resolvedThreadId,
|
|
215
|
+
hasExplicitThreadId: resolvedHasExplicitThreadId,
|
|
214
216
|
isModalOpen: resolvedIsModalOpen,
|
|
215
217
|
setModalOpen: resolvedSetModalOpen
|
|
216
218
|
}), [
|
|
217
219
|
mergedLabels,
|
|
218
220
|
resolvedAgentId,
|
|
219
221
|
resolvedThreadId,
|
|
222
|
+
resolvedHasExplicitThreadId,
|
|
220
223
|
resolvedIsModalOpen,
|
|
221
224
|
resolvedSetModalOpen
|
|
222
225
|
]);
|
|
@@ -6796,6 +6799,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
6796
6799
|
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
6797
6800
|
const providedThreadId = threadId ?? existingConfig?.threadId;
|
|
6798
6801
|
const resolvedThreadId = (0, react.useMemo)(() => providedThreadId ?? (0, _copilotkit_shared.randomUUID)(), [providedThreadId]);
|
|
6802
|
+
const hasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
|
|
6799
6803
|
const { agent } = useAgent({
|
|
6800
6804
|
agentId: resolvedAgentId,
|
|
6801
6805
|
threadId: resolvedThreadId,
|
|
@@ -6834,9 +6838,9 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
6834
6838
|
const isMediaRecorderSupported = typeof window !== "undefined" && typeof MediaRecorder !== "undefined";
|
|
6835
6839
|
const { messageView: providedMessageView, suggestionView: providedSuggestionView, onStop: providedStopHandler, ...restProps } = props;
|
|
6836
6840
|
const [lastConnectedThreadId, setLastConnectedThreadId] = (0, react.useState)(null);
|
|
6837
|
-
const isConnecting =
|
|
6841
|
+
const isConnecting = hasExplicitThreadId && lastConnectedThreadId !== resolvedThreadId;
|
|
6838
6842
|
(0, react.useEffect)(() => {
|
|
6839
|
-
if (!
|
|
6843
|
+
if (!hasExplicitThreadId) return;
|
|
6840
6844
|
let detached = false;
|
|
6841
6845
|
const connectAbortController = new AbortController();
|
|
6842
6846
|
if (agent instanceof _ag_ui_client.HttpAgent) agent.abortController = connectAbortController;
|
|
@@ -6862,7 +6866,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
6862
6866
|
resolvedThreadId,
|
|
6863
6867
|
agent,
|
|
6864
6868
|
resolvedAgentId,
|
|
6865
|
-
|
|
6869
|
+
hasExplicitThreadId
|
|
6866
6870
|
]);
|
|
6867
6871
|
const onSubmitInput = (0, react.useCallback)(async (value) => {
|
|
6868
6872
|
if (selectedAttachments.some((a) => a.status === "uploading")) {
|
|
@@ -7051,11 +7055,12 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
7051
7055
|
onDragLeave: handleDragLeave,
|
|
7052
7056
|
onDrop: handleDrop,
|
|
7053
7057
|
isConnecting,
|
|
7054
|
-
hasExplicitThreadId
|
|
7058
|
+
hasExplicitThreadId
|
|
7055
7059
|
});
|
|
7056
7060
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfigurationProvider, {
|
|
7057
7061
|
agentId: resolvedAgentId,
|
|
7058
7062
|
threadId: resolvedThreadId,
|
|
7063
|
+
hasExplicitThreadId,
|
|
7059
7064
|
labels,
|
|
7060
7065
|
isModalDefaultOpen,
|
|
7061
7066
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -8815,12 +8820,19 @@ function useCoAgentStateRenders() {
|
|
|
8815
8820
|
//#region src/context/threads-context.tsx
|
|
8816
8821
|
const ThreadsContext = (0, react.createContext)(void 0);
|
|
8817
8822
|
function ThreadsProvider({ children, threadId: explicitThreadId }) {
|
|
8818
|
-
const [internalThreadId,
|
|
8823
|
+
const [internalThreadId, setInternalThreadId] = (0, react.useState)(() => (0, _copilotkit_shared.randomUUID)());
|
|
8824
|
+
const [internalIsExplicit, setInternalIsExplicit] = (0, react.useState)(false);
|
|
8819
8825
|
const threadId = explicitThreadId ?? internalThreadId;
|
|
8826
|
+
const isThreadIdExplicit = explicitThreadId != null || internalIsExplicit;
|
|
8827
|
+
const setThreadId = (0, react.useCallback)((value) => {
|
|
8828
|
+
setInternalThreadId(value);
|
|
8829
|
+
setInternalIsExplicit(true);
|
|
8830
|
+
}, []);
|
|
8820
8831
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadsContext.Provider, {
|
|
8821
8832
|
value: {
|
|
8822
8833
|
threadId,
|
|
8823
|
-
setThreadId
|
|
8834
|
+
setThreadId,
|
|
8835
|
+
isThreadIdExplicit
|
|
8824
8836
|
},
|
|
8825
8837
|
children
|
|
8826
8838
|
});
|
|
@@ -9522,7 +9534,7 @@ function CopilotKitInternal(cpkProps) {
|
|
|
9522
9534
|
if (props.agent) setAgentSession({ agentName: props.agent });
|
|
9523
9535
|
else setAgentSession(null);
|
|
9524
9536
|
}, [props.agent]);
|
|
9525
|
-
const { threadId, setThreadId: setInternalThreadId } = useThreads();
|
|
9537
|
+
const { threadId, setThreadId: setInternalThreadId, isThreadIdExplicit } = useThreads();
|
|
9526
9538
|
const setThreadId = (0, react.useCallback)((value) => {
|
|
9527
9539
|
if (props.threadId) throw new Error("Cannot call setThreadId() when threadId is provided via props.");
|
|
9528
9540
|
setInternalThreadId(value);
|
|
@@ -9722,6 +9734,7 @@ function CopilotKitInternal(cpkProps) {
|
|
|
9722
9734
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfigurationProvider, {
|
|
9723
9735
|
agentId: props.agent ?? "default",
|
|
9724
9736
|
threadId,
|
|
9737
|
+
hasExplicitThreadId: isThreadIdExplicit,
|
|
9725
9738
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotContext.Provider, {
|
|
9726
9739
|
value: copilotContextValue,
|
|
9727
9740
|
children: [
|
|
@@ -10191,4 +10204,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
10191
10204
|
return useToast;
|
|
10192
10205
|
}
|
|
10193
10206
|
});
|
|
10194
|
-
//# sourceMappingURL=copilotkit-
|
|
10207
|
+
//# sourceMappingURL=copilotkit-By2G6-Zx.cjs.map
|