@copilotkit/react-core 1.56.4 → 1.56.5-canary.1777671752
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-Bd0m5HFp.mjs → copilotkit-CPe2-340.mjs} +130 -80
- package/dist/copilotkit-CPe2-340.mjs.map +1 -0
- package/dist/copilotkit-DFaI4j2r.d.mts.map +1 -1
- package/dist/{copilotkit-tb4zqaMK.cjs → copilotkit-DGbvw8n2.cjs} +130 -80
- package/dist/copilotkit-DGbvw8n2.cjs.map +1 -0
- package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +24 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +132 -82
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +3 -113
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +26 -6
- package/src/v2/components/chat/CopilotChatUserMessage.tsx +2 -2
- package/src/v2/components/chat/CopilotChatView.tsx +21 -5
- package/src/v2/components/chat/Lightbox.tsx +103 -0
- package/src/v2/components/chat/__tests__/CopilotChat.suggestionsAlways.test.tsx +183 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.tsx +92 -0
- package/src/v2/hooks/__tests__/use-threads.test.tsx +229 -27
- package/src/v2/hooks/use-configure-suggestions.tsx +50 -1
- package/src/v2/hooks/use-threads.tsx +7 -1
- package/dist/copilotkit-Bd0m5HFp.mjs.map +0 -1
- package/dist/copilotkit-tb4zqaMK.cjs.map +0 -1
package/dist/v2/index.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
(function(global, factory) {
|
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('./index.css'), require('@copilotkit/core'), require('@ag-ui/client'), require('react'), require('tailwind-merge'), require('lucide-react'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('@radix-ui/react-slot'), require('class-variance-authority'), require('clsx'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-dropdown-menu'), require('streamdown'), require('zod'), require('@lit-labs/react'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('
|
|
5
|
-
typeof define === 'function' && define.amd ? define(['exports', './index.css', '@copilotkit/core', '@ag-ui/client', 'react', 'tailwind-merge', 'lucide-react', '@copilotkit/shared', 'react/jsx-runtime', '@radix-ui/react-slot', 'class-variance-authority', 'clsx', '@radix-ui/react-tooltip', '@radix-ui/react-dropdown-menu', 'streamdown', 'zod', '@lit-labs/react', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', '
|
|
6
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCoreV2 = {}), global.src_v2_index_css,global.CopilotKitCore,global.AgUIClient,global.React,global.tailwindMerge,global.lucideReact,global.CopilotKitShared,global.ReactJsxRuntime,global.RadixReactSlot,global.classVarianceAuthority,global.clsx,global.RadixReactTooltip,global.RadixReactDropdownMenu,global.streamdown,global.Zod,global.LitLabsReact,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global.
|
|
7
|
-
})(this, function(exports, src_v2_index_css, _copilotkit_core, _ag_ui_client, react, tailwind_merge, lucide_react, _copilotkit_shared, react_jsx_runtime, _radix_ui_react_slot, class_variance_authority, clsx, _radix_ui_react_tooltip, _radix_ui_react_dropdown_menu, streamdown, zod, _lit_labs_react, _copilotkit_a2ui_renderer, zod_to_json_schema,
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('./index.css'), require('@copilotkit/core'), require('@ag-ui/client'), require('react'), require('tailwind-merge'), require('lucide-react'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('@radix-ui/react-slot'), require('class-variance-authority'), require('clsx'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-dropdown-menu'), require('streamdown'), require('zod'), require('@lit-labs/react'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('react-dom'), require('@tanstack/react-virtual'), require('use-stick-to-bottom')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', './index.css', '@copilotkit/core', '@ag-ui/client', 'react', 'tailwind-merge', 'lucide-react', '@copilotkit/shared', 'react/jsx-runtime', '@radix-ui/react-slot', 'class-variance-authority', 'clsx', '@radix-ui/react-tooltip', '@radix-ui/react-dropdown-menu', 'streamdown', 'zod', '@lit-labs/react', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', 'react-dom', '@tanstack/react-virtual', 'use-stick-to-bottom'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCoreV2 = {}), global.src_v2_index_css,global.CopilotKitCore,global.AgUIClient,global.React,global.tailwindMerge,global.lucideReact,global.CopilotKitShared,global.ReactJsxRuntime,global.RadixReactSlot,global.classVarianceAuthority,global.clsx,global.RadixReactTooltip,global.RadixReactDropdownMenu,global.streamdown,global.Zod,global.LitLabsReact,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global.ReactDOM,global._tanstack_react_virtual,global.useStickToBottom));
|
|
7
|
+
})(this, function(exports, src_v2_index_css, _copilotkit_core, _ag_ui_client, react, tailwind_merge, lucide_react, _copilotkit_shared, react_jsx_runtime, _radix_ui_react_slot, class_variance_authority, clsx, _radix_ui_react_tooltip, _radix_ui_react_dropdown_menu, streamdown, zod, _lit_labs_react, _copilotkit_a2ui_renderer, zod_to_json_schema, react_dom, _tanstack_react_virtual, use_stick_to_bottom) {
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
@@ -4393,16 +4393,20 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4393
4393
|
return consumer;
|
|
4394
4394
|
}, [normalizedConfig, resolvedConsumerAgentId]);
|
|
4395
4395
|
const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
|
|
4396
|
+
const isDynamicConfigType = (0, react.useMemo)(() => !!normalizedConfig && "instructions" in normalizedConfig, [normalizedConfig]);
|
|
4396
4397
|
const requestReload = (0, react.useCallback)(() => {
|
|
4397
4398
|
if (!normalizedConfig) return;
|
|
4398
4399
|
if (isGlobalConfig) {
|
|
4399
4400
|
var _copilotkit$agents;
|
|
4401
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4400
4402
|
const agents = Object.values((_copilotkit$agents = copilotkit.agents) !== null && _copilotkit$agents !== void 0 ? _copilotkit$agents : {});
|
|
4401
4403
|
for (const entry of agents) {
|
|
4402
4404
|
const agentId = entry.agentId;
|
|
4403
4405
|
if (!agentId) continue;
|
|
4406
|
+
seen.add(agentId);
|
|
4404
4407
|
if (!entry.isRunning) copilotkit.reloadSuggestions(agentId);
|
|
4405
4408
|
}
|
|
4409
|
+
if (targetAgentId && !seen.has(targetAgentId)) copilotkit.reloadSuggestions(targetAgentId);
|
|
4406
4410
|
return;
|
|
4407
4411
|
}
|
|
4408
4412
|
if (!targetAgentId) return;
|
|
@@ -4447,6 +4451,26 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4447
4451
|
requestReload,
|
|
4448
4452
|
...extraDeps
|
|
4449
4453
|
]);
|
|
4454
|
+
(0, react.useEffect)(() => {
|
|
4455
|
+
if (!normalizedConfig || !isDynamicConfigType) return;
|
|
4456
|
+
if (!targetAgentId) return;
|
|
4457
|
+
if (!!copilotkit.getAgent(targetAgentId)) return;
|
|
4458
|
+
const subscription = copilotkit.subscribe({ onAgentsChanged: () => {
|
|
4459
|
+
if (copilotkit.getAgent(targetAgentId)) {
|
|
4460
|
+
requestReload();
|
|
4461
|
+
subscription.unsubscribe();
|
|
4462
|
+
}
|
|
4463
|
+
} });
|
|
4464
|
+
return () => {
|
|
4465
|
+
subscription.unsubscribe();
|
|
4466
|
+
};
|
|
4467
|
+
}, [
|
|
4468
|
+
copilotkit,
|
|
4469
|
+
normalizedConfig,
|
|
4470
|
+
isDynamicConfigType,
|
|
4471
|
+
targetAgentId,
|
|
4472
|
+
requestReload
|
|
4473
|
+
]);
|
|
4450
4474
|
}
|
|
4451
4475
|
function isDynamicConfig(config) {
|
|
4452
4476
|
return "instructions" in config;
|
|
@@ -4717,6 +4741,16 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4717
4741
|
};
|
|
4718
4742
|
}, [store]);
|
|
4719
4743
|
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4744
|
+
(0, react.useEffect)(() => {
|
|
4745
|
+
copilotkit.registerThreadStore(agentId, store);
|
|
4746
|
+
return () => {
|
|
4747
|
+
copilotkit.unregisterThreadStore(agentId);
|
|
4748
|
+
};
|
|
4749
|
+
}, [
|
|
4750
|
+
copilotkit,
|
|
4751
|
+
agentId,
|
|
4752
|
+
store
|
|
4753
|
+
]);
|
|
4720
4754
|
(0, react.useEffect)(() => {
|
|
4721
4755
|
var _copilotkit$intellige;
|
|
4722
4756
|
if (!copilotkit.runtimeUrl) {
|
|
@@ -4741,7 +4775,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4741
4775
|
headersKey,
|
|
4742
4776
|
(_copilotkit$intellige2 = copilotkit.intelligence) === null || _copilotkit$intellige2 === void 0 ? void 0 : _copilotkit$intellige2.wsUrl,
|
|
4743
4777
|
agentId,
|
|
4744
|
-
copilotkit.headers,
|
|
4745
4778
|
includeArchived,
|
|
4746
4779
|
limit
|
|
4747
4780
|
]);
|
|
@@ -5127,20 +5160,101 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5127
5160
|
CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
|
|
5128
5161
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
5129
5162
|
|
|
5163
|
+
//#endregion
|
|
5164
|
+
//#region src/v2/components/chat/Lightbox.tsx
|
|
5165
|
+
function Lightbox({ onClose, children }) {
|
|
5166
|
+
(0, react.useEffect)(() => {
|
|
5167
|
+
const handleKey = (e) => {
|
|
5168
|
+
if (e.key === "Escape") onClose();
|
|
5169
|
+
};
|
|
5170
|
+
document.addEventListener("keydown", handleKey);
|
|
5171
|
+
return () => document.removeEventListener("keydown", handleKey);
|
|
5172
|
+
}, [onClose]);
|
|
5173
|
+
if (typeof document === "undefined") return null;
|
|
5174
|
+
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5175
|
+
className: "cpk:fixed cpk:inset-0 cpk:z-[9999] cpk:flex cpk:items-center cpk:justify-center cpk:bg-black/80 cpk:animate-fade-in",
|
|
5176
|
+
onClick: onClose,
|
|
5177
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5178
|
+
onClick: onClose,
|
|
5179
|
+
className: "cpk:absolute cpk:top-4 cpk:right-4 cpk:text-white cpk:bg-white/10 cpk:hover:bg-white/20 cpk:rounded-full cpk:w-10 cpk:h-10 cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer cpk:border-none cpk:z-10",
|
|
5180
|
+
"aria-label": "Close preview",
|
|
5181
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
|
|
5182
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5183
|
+
onClick: (e) => e.stopPropagation(),
|
|
5184
|
+
children
|
|
5185
|
+
})]
|
|
5186
|
+
}), document.body);
|
|
5187
|
+
}
|
|
5188
|
+
/**
|
|
5189
|
+
* Hook that manages lightbox open/close and uses the View Transition API to
|
|
5190
|
+
* morph the thumbnail into fullscreen content.
|
|
5191
|
+
*
|
|
5192
|
+
* The trick: `view-transition-name` must live on exactly ONE element at a time.
|
|
5193
|
+
* - Old state (thumbnail visible): name is on the thumbnail.
|
|
5194
|
+
* - New state (lightbox visible): name moves to the lightbox content.
|
|
5195
|
+
* `flushSync` ensures React commits the DOM change synchronously inside the
|
|
5196
|
+
* `startViewTransition` callback so the API can snapshot old → new correctly.
|
|
5197
|
+
*/
|
|
5198
|
+
function useLightbox() {
|
|
5199
|
+
const thumbnailRef = (0, react.useRef)(null);
|
|
5200
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
5201
|
+
const vtName = (0, react.useId)();
|
|
5202
|
+
return {
|
|
5203
|
+
thumbnailRef,
|
|
5204
|
+
vtName,
|
|
5205
|
+
open,
|
|
5206
|
+
openLightbox: (0, react.useCallback)(() => {
|
|
5207
|
+
const thumb = thumbnailRef.current;
|
|
5208
|
+
const doc = document;
|
|
5209
|
+
if (doc.startViewTransition && thumb) {
|
|
5210
|
+
thumb.style.viewTransitionName = vtName;
|
|
5211
|
+
doc.startViewTransition(() => {
|
|
5212
|
+
thumb.style.viewTransitionName = "";
|
|
5213
|
+
(0, react_dom.flushSync)(() => setOpen(true));
|
|
5214
|
+
});
|
|
5215
|
+
} else setOpen(true);
|
|
5216
|
+
}, [vtName]),
|
|
5217
|
+
closeLightbox: (0, react.useCallback)(() => {
|
|
5218
|
+
const thumb = thumbnailRef.current;
|
|
5219
|
+
const doc = document;
|
|
5220
|
+
if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
|
|
5221
|
+
(0, react_dom.flushSync)(() => setOpen(false));
|
|
5222
|
+
thumb.style.viewTransitionName = vtName;
|
|
5223
|
+
}).finished.then(() => {
|
|
5224
|
+
thumb.style.viewTransitionName = "";
|
|
5225
|
+
}).catch(() => {
|
|
5226
|
+
thumb.style.viewTransitionName = "";
|
|
5227
|
+
});
|
|
5228
|
+
else setOpen(false);
|
|
5229
|
+
}, [vtName])
|
|
5230
|
+
};
|
|
5231
|
+
}
|
|
5232
|
+
|
|
5130
5233
|
//#endregion
|
|
5131
5234
|
//#region src/v2/components/chat/CopilotChatAttachmentRenderer.tsx
|
|
5132
5235
|
const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
|
|
5133
5236
|
const [error, setError] = (0, react.useState)(false);
|
|
5237
|
+
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
5134
5238
|
if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5135
5239
|
className: cn("cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:rounded-lg cpk:bg-muted cpk:p-4 cpk:text-sm cpk:text-muted-foreground", className),
|
|
5136
5240
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Failed to load image" })
|
|
5137
5241
|
});
|
|
5138
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5242
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5243
|
+
ref: thumbnailRef,
|
|
5139
5244
|
src,
|
|
5140
5245
|
alt: "Image attachment",
|
|
5141
|
-
className: cn("cpk:max-w-
|
|
5246
|
+
className: cn("cpk:max-w-[80px] cpk:max-h-[80px] cpk:w-auto cpk:h-auto cpk:rounded-xl cpk:object-cover cpk:cursor-pointer cpk:bg-muted", className),
|
|
5247
|
+
onClick: openLightbox,
|
|
5142
5248
|
onError: () => setError(true)
|
|
5143
|
-
})
|
|
5249
|
+
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
|
|
5250
|
+
onClose: closeLightbox,
|
|
5251
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5252
|
+
style: { viewTransitionName: vtName },
|
|
5253
|
+
src,
|
|
5254
|
+
alt: "Image attachment",
|
|
5255
|
+
className: "cpk:max-w-[90vw] cpk:max-h-[90vh] cpk:object-contain cpk:rounded-lg"
|
|
5256
|
+
})
|
|
5257
|
+
})] });
|
|
5144
5258
|
});
|
|
5145
5259
|
const AudioAttachment = (0, react.memo)(function AudioAttachment({ src, filename, className }) {
|
|
5146
5260
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -5266,15 +5380,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5266
5380
|
"data-message-id": message.id,
|
|
5267
5381
|
...props,
|
|
5268
5382
|
children: [
|
|
5269
|
-
BoundMessageRenderer,
|
|
5270
5383
|
mediaParts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5271
|
-
className: "cpk:flex cpk:flex-
|
|
5384
|
+
className: "cpk:flex cpk:flex-row cpk:flex-wrap cpk:justify-end cpk:gap-2 cpk:mb-2",
|
|
5272
5385
|
children: mediaParts.map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAttachmentRenderer, {
|
|
5273
5386
|
type: part.type,
|
|
5274
5387
|
source: part.source,
|
|
5275
5388
|
filename: getFilename(part)
|
|
5276
5389
|
}, index))
|
|
5277
5390
|
}),
|
|
5391
|
+
BoundMessageRenderer,
|
|
5278
5392
|
BoundToolbar
|
|
5279
5393
|
]
|
|
5280
5394
|
});
|
|
@@ -5992,73 +6106,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5992
6106
|
case "document": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentPreview, { attachment });
|
|
5993
6107
|
}
|
|
5994
6108
|
}
|
|
5995
|
-
function Lightbox({ onClose, children }) {
|
|
5996
|
-
(0, react.useEffect)(() => {
|
|
5997
|
-
const handleKey = (e) => {
|
|
5998
|
-
if (e.key === "Escape") onClose();
|
|
5999
|
-
};
|
|
6000
|
-
document.addEventListener("keydown", handleKey);
|
|
6001
|
-
return () => document.removeEventListener("keydown", handleKey);
|
|
6002
|
-
}, [onClose]);
|
|
6003
|
-
if (typeof document === "undefined") return null;
|
|
6004
|
-
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6005
|
-
className: "cpk:fixed cpk:inset-0 cpk:z-[9999] cpk:flex cpk:items-center cpk:justify-center cpk:bg-black/80 cpk:animate-fade-in",
|
|
6006
|
-
onClick: onClose,
|
|
6007
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
6008
|
-
onClick: onClose,
|
|
6009
|
-
className: "cpk:absolute cpk:top-4 cpk:right-4 cpk:text-white cpk:bg-white/10 cpk:hover:bg-white/20 cpk:rounded-full cpk:w-10 cpk:h-10 cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer cpk:border-none cpk:z-10",
|
|
6010
|
-
"aria-label": "Close preview",
|
|
6011
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
|
|
6012
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6013
|
-
onClick: (e) => e.stopPropagation(),
|
|
6014
|
-
children
|
|
6015
|
-
})]
|
|
6016
|
-
}), document.body);
|
|
6017
|
-
}
|
|
6018
|
-
/**
|
|
6019
|
-
* Hook that manages lightbox open/close and uses the View Transition API to
|
|
6020
|
-
* morph the thumbnail into fullscreen content.
|
|
6021
|
-
*
|
|
6022
|
-
* The trick: `view-transition-name` must live on exactly ONE element at a time.
|
|
6023
|
-
* - Old state (thumbnail visible): name is on the thumbnail.
|
|
6024
|
-
* - New state (lightbox visible): name moves to the lightbox content.
|
|
6025
|
-
* `flushSync` ensures React commits the DOM change synchronously inside the
|
|
6026
|
-
* `startViewTransition` callback so the API can snapshot old → new correctly.
|
|
6027
|
-
*/
|
|
6028
|
-
function useLightbox() {
|
|
6029
|
-
const thumbnailRef = (0, react.useRef)(null);
|
|
6030
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
6031
|
-
const vtName = (0, react.useId)();
|
|
6032
|
-
return {
|
|
6033
|
-
thumbnailRef,
|
|
6034
|
-
vtName,
|
|
6035
|
-
open,
|
|
6036
|
-
openLightbox: (0, react.useCallback)(() => {
|
|
6037
|
-
const thumb = thumbnailRef.current;
|
|
6038
|
-
const doc = document;
|
|
6039
|
-
if (doc.startViewTransition && thumb) {
|
|
6040
|
-
thumb.style.viewTransitionName = vtName;
|
|
6041
|
-
doc.startViewTransition(() => {
|
|
6042
|
-
thumb.style.viewTransitionName = "";
|
|
6043
|
-
(0, react_dom.flushSync)(() => setOpen(true));
|
|
6044
|
-
});
|
|
6045
|
-
} else setOpen(true);
|
|
6046
|
-
}, []),
|
|
6047
|
-
closeLightbox: (0, react.useCallback)(() => {
|
|
6048
|
-
const thumb = thumbnailRef.current;
|
|
6049
|
-
const doc = document;
|
|
6050
|
-
if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
|
|
6051
|
-
(0, react_dom.flushSync)(() => setOpen(false));
|
|
6052
|
-
thumb.style.viewTransitionName = vtName;
|
|
6053
|
-
}).finished.then(() => {
|
|
6054
|
-
thumb.style.viewTransitionName = "";
|
|
6055
|
-
}).catch(() => {
|
|
6056
|
-
thumb.style.viewTransitionName = "";
|
|
6057
|
-
});
|
|
6058
|
-
else setOpen(false);
|
|
6059
|
-
}, [])
|
|
6060
|
-
};
|
|
6061
|
-
}
|
|
6062
6109
|
function ImagePreview({ attachment }) {
|
|
6063
6110
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
6064
6111
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
@@ -6398,14 +6445,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6398
6445
|
});
|
|
6399
6446
|
}
|
|
6400
6447
|
function CopilotChatView({ messageView, input, scrollView, suggestionView, welcomeScreen, messages = [], autoScroll = true, isRunning = false, suggestions, suggestionLoadingIndexes, onSelectSuggestion, onSubmitMessage, onStop, inputMode, inputValue, onInputChange, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, attachments, onRemoveAttachment, onAddFile, dragOver, onDragOver, onDragLeave, onDrop, isConnecting = false, hasExplicitThreadId = false, disclaimer, children, className, ...props }) {
|
|
6401
|
-
const
|
|
6448
|
+
const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
|
|
6402
6449
|
const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
|
|
6403
6450
|
const [isResizing, setIsResizing] = (0, react.useState)(false);
|
|
6404
6451
|
const resizeTimeoutRef = (0, react.useRef)(null);
|
|
6405
6452
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
6406
6453
|
(0, react.useEffect)(() => {
|
|
6407
|
-
const element =
|
|
6408
|
-
if (!element)
|
|
6454
|
+
const element = inputContainerEl;
|
|
6455
|
+
if (!element) {
|
|
6456
|
+
setInputContainerHeight(0);
|
|
6457
|
+
return;
|
|
6458
|
+
}
|
|
6409
6459
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
6410
6460
|
for (const entry of entries) {
|
|
6411
6461
|
const newHeight = entry.contentRect.height;
|
|
@@ -6428,7 +6478,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6428
6478
|
resizeObserver.disconnect();
|
|
6429
6479
|
if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
|
|
6430
6480
|
};
|
|
6431
|
-
}, []);
|
|
6481
|
+
}, [inputContainerEl]);
|
|
6432
6482
|
const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {
|
|
6433
6483
|
messages,
|
|
6434
6484
|
isRunning
|
|
@@ -6539,7 +6589,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6539
6589
|
dragOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropOverlay, {}),
|
|
6540
6590
|
BoundScrollView,
|
|
6541
6591
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6542
|
-
ref:
|
|
6592
|
+
ref: setInputContainerEl,
|
|
6543
6593
|
"data-testid": "copilot-input-overlay",
|
|
6544
6594
|
className: "cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-0 cpk:z-20 cpk:pointer-events-none",
|
|
6545
6595
|
children: [attachments && attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|