@copilotkit/react-core 1.70.1 → 1.70.2
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-DsWuxPUQ.d.mts → copilotkit--Jyzm6hS.d.mts} +31 -1
- package/dist/{copilotkit-DsWuxPUQ.d.mts.map → copilotkit--Jyzm6hS.d.mts.map} +1 -1
- package/dist/{copilotkit-DiUK2Bhq.mjs → copilotkit-B1jSvZeb.mjs} +251 -81
- package/dist/copilotkit-B1jSvZeb.mjs.map +1 -0
- package/dist/{copilotkit-CtF2clxZ.d.cts → copilotkit-BLYaCGcz.d.cts} +31 -1
- package/dist/{copilotkit-CtF2clxZ.d.cts.map → copilotkit-BLYaCGcz.d.cts.map} +1 -1
- package/dist/{copilotkit-CxLT6zFx.cjs → copilotkit-DcFo270Y.cjs} +251 -81
- package/dist/copilotkit-DcFo270Y.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +56 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +56 -0
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +57 -1
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +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 +251 -81
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/attachments.md +20 -0
- package/dist/copilotkit-CxLT6zFx.cjs.map +0 -1
- package/dist/copilotkit-DiUK2Bhq.mjs.map +0 -1
package/dist/v2/headless.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CopilotKitCoreReact, useCopilotKit, useCopilotKit as useCopilotKit$1 } from "@copilotkit/react-core/v2/context";
|
|
2
2
|
import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { DEFAULT_AGENT_ID, partialJSONParse, randomUUID } from "@copilotkit/shared";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
5
|
import { HttpAgent, randomUUID as randomUUID$1 } from "@ag-ui/client";
|
|
6
6
|
import { CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, ɵInterruptState, ɵcreateThreadStore, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
7
7
|
import { z } from "zod";
|
|
@@ -252,6 +252,62 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
252
252
|
const useCopilotChatConfiguration = () => {
|
|
253
253
|
return useContext(CopilotChatConfiguration);
|
|
254
254
|
};
|
|
255
|
+
/**
|
|
256
|
+
* Reports modal open/close requests to the host, and — when `open` is
|
|
257
|
+
* supplied — makes the modal state of an already-established chat
|
|
258
|
+
* configuration **controlled** for the subtree it wraps.
|
|
259
|
+
*
|
|
260
|
+
* This is deliberately a scope component rather than another mode inside
|
|
261
|
+
* {@link CopilotChatConfigurationProvider}. The provider resolves modal state
|
|
262
|
+
* across a nested chain (own state, parent sync, drawer mutual-exclusion, the
|
|
263
|
+
* modal-closer registry); a controlled branch inside that resolution would add
|
|
264
|
+
* a fourth interacting mode. Overriding the context for the subtree instead
|
|
265
|
+
* leaves every one of those paths untouched:
|
|
266
|
+
*
|
|
267
|
+
* - `isModalOpen` is replaced with the host's `open`, so the rendered surface
|
|
268
|
+
* follows the prop from the very first frame (no open-then-close flash).
|
|
269
|
+
* - `setModalOpen` still calls the underlying setter, so the existing
|
|
270
|
+
* parent-sync and drawer mutual-exclusion side effects continue to run, and
|
|
271
|
+
* *then* reports the request through `onOpenChange`.
|
|
272
|
+
* - The wrapped setter is registered as the modal closer, so the drawer's
|
|
273
|
+
* mobile mutual-exclusion reaches the host instead of silently flipping
|
|
274
|
+
* state that nothing displays.
|
|
275
|
+
*
|
|
276
|
+
* A host that supplies `open` and ignores `onOpenChange` gets a modal pinned
|
|
277
|
+
* to `open`, which is the standard controlled-component contract. A host that
|
|
278
|
+
* supplies only `onOpenChange` is notified while the modal keeps managing
|
|
279
|
+
* itself.
|
|
280
|
+
*
|
|
281
|
+
* Renders `children` unchanged when no chat configuration is in scope.
|
|
282
|
+
*/
|
|
283
|
+
const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
|
|
284
|
+
const parentConfig = useContext(CopilotChatConfiguration);
|
|
285
|
+
const parentSetModalOpen = parentConfig?.setModalOpen;
|
|
286
|
+
const registerModalCloser = parentConfig?.ɵregisterModalCloser;
|
|
287
|
+
const setModalOpen = useCallback((next) => {
|
|
288
|
+
parentSetModalOpen?.(next);
|
|
289
|
+
onOpenChange?.(next);
|
|
290
|
+
}, [parentSetModalOpen, onOpenChange]);
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
if (!registerModalCloser) return;
|
|
293
|
+
return registerModalCloser(setModalOpen);
|
|
294
|
+
}, [registerModalCloser, setModalOpen]);
|
|
295
|
+
const configurationValue = useMemo(() => parentConfig ? {
|
|
296
|
+
...parentConfig,
|
|
297
|
+
isModalOpen: open ?? parentConfig.isModalOpen,
|
|
298
|
+
setModalOpen
|
|
299
|
+
} : null, [
|
|
300
|
+
parentConfig,
|
|
301
|
+
open,
|
|
302
|
+
setModalOpen
|
|
303
|
+
]);
|
|
304
|
+
if (!configurationValue) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
305
|
+
return /* @__PURE__ */ jsx(CopilotChatConfiguration.Provider, {
|
|
306
|
+
value: configurationValue,
|
|
307
|
+
children
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
255
311
|
|
|
256
312
|
//#endregion
|
|
257
313
|
//#region src/v2/hooks/use-agent.tsx
|