@copilotkit/react-core 1.56.4 → 1.56.5
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-DFaI4j2r.d.mts.map +1 -1
- package/dist/{copilotkit-tb4zqaMK.cjs → copilotkit-DMFu29Kx.cjs} +120 -79
- package/dist/copilotkit-DMFu29Kx.cjs.map +1 -0
- package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -1
- package/dist/{copilotkit-Bd0m5HFp.mjs → copilotkit-OmIUrWym.mjs} +120 -79
- package/dist/copilotkit-OmIUrWym.mjs.map +1 -0
- 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 +122 -81
- 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/use-configure-suggestions.tsx +50 -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;
|
|
@@ -5127,20 +5151,101 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5127
5151
|
CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
|
|
5128
5152
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
5129
5153
|
|
|
5154
|
+
//#endregion
|
|
5155
|
+
//#region src/v2/components/chat/Lightbox.tsx
|
|
5156
|
+
function Lightbox({ onClose, children }) {
|
|
5157
|
+
(0, react.useEffect)(() => {
|
|
5158
|
+
const handleKey = (e) => {
|
|
5159
|
+
if (e.key === "Escape") onClose();
|
|
5160
|
+
};
|
|
5161
|
+
document.addEventListener("keydown", handleKey);
|
|
5162
|
+
return () => document.removeEventListener("keydown", handleKey);
|
|
5163
|
+
}, [onClose]);
|
|
5164
|
+
if (typeof document === "undefined") return null;
|
|
5165
|
+
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5166
|
+
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",
|
|
5167
|
+
onClick: onClose,
|
|
5168
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5169
|
+
onClick: onClose,
|
|
5170
|
+
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",
|
|
5171
|
+
"aria-label": "Close preview",
|
|
5172
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
|
|
5173
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5174
|
+
onClick: (e) => e.stopPropagation(),
|
|
5175
|
+
children
|
|
5176
|
+
})]
|
|
5177
|
+
}), document.body);
|
|
5178
|
+
}
|
|
5179
|
+
/**
|
|
5180
|
+
* Hook that manages lightbox open/close and uses the View Transition API to
|
|
5181
|
+
* morph the thumbnail into fullscreen content.
|
|
5182
|
+
*
|
|
5183
|
+
* The trick: `view-transition-name` must live on exactly ONE element at a time.
|
|
5184
|
+
* - Old state (thumbnail visible): name is on the thumbnail.
|
|
5185
|
+
* - New state (lightbox visible): name moves to the lightbox content.
|
|
5186
|
+
* `flushSync` ensures React commits the DOM change synchronously inside the
|
|
5187
|
+
* `startViewTransition` callback so the API can snapshot old → new correctly.
|
|
5188
|
+
*/
|
|
5189
|
+
function useLightbox() {
|
|
5190
|
+
const thumbnailRef = (0, react.useRef)(null);
|
|
5191
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
5192
|
+
const vtName = (0, react.useId)();
|
|
5193
|
+
return {
|
|
5194
|
+
thumbnailRef,
|
|
5195
|
+
vtName,
|
|
5196
|
+
open,
|
|
5197
|
+
openLightbox: (0, react.useCallback)(() => {
|
|
5198
|
+
const thumb = thumbnailRef.current;
|
|
5199
|
+
const doc = document;
|
|
5200
|
+
if (doc.startViewTransition && thumb) {
|
|
5201
|
+
thumb.style.viewTransitionName = vtName;
|
|
5202
|
+
doc.startViewTransition(() => {
|
|
5203
|
+
thumb.style.viewTransitionName = "";
|
|
5204
|
+
(0, react_dom.flushSync)(() => setOpen(true));
|
|
5205
|
+
});
|
|
5206
|
+
} else setOpen(true);
|
|
5207
|
+
}, [vtName]),
|
|
5208
|
+
closeLightbox: (0, react.useCallback)(() => {
|
|
5209
|
+
const thumb = thumbnailRef.current;
|
|
5210
|
+
const doc = document;
|
|
5211
|
+
if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
|
|
5212
|
+
(0, react_dom.flushSync)(() => setOpen(false));
|
|
5213
|
+
thumb.style.viewTransitionName = vtName;
|
|
5214
|
+
}).finished.then(() => {
|
|
5215
|
+
thumb.style.viewTransitionName = "";
|
|
5216
|
+
}).catch(() => {
|
|
5217
|
+
thumb.style.viewTransitionName = "";
|
|
5218
|
+
});
|
|
5219
|
+
else setOpen(false);
|
|
5220
|
+
}, [vtName])
|
|
5221
|
+
};
|
|
5222
|
+
}
|
|
5223
|
+
|
|
5130
5224
|
//#endregion
|
|
5131
5225
|
//#region src/v2/components/chat/CopilotChatAttachmentRenderer.tsx
|
|
5132
5226
|
const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
|
|
5133
5227
|
const [error, setError] = (0, react.useState)(false);
|
|
5228
|
+
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
5134
5229
|
if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5135
5230
|
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
5231
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Failed to load image" })
|
|
5137
5232
|
});
|
|
5138
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5233
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5234
|
+
ref: thumbnailRef,
|
|
5139
5235
|
src,
|
|
5140
5236
|
alt: "Image attachment",
|
|
5141
|
-
className: cn("cpk:max-w-
|
|
5237
|
+
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),
|
|
5238
|
+
onClick: openLightbox,
|
|
5142
5239
|
onError: () => setError(true)
|
|
5143
|
-
})
|
|
5240
|
+
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
|
|
5241
|
+
onClose: closeLightbox,
|
|
5242
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5243
|
+
style: { viewTransitionName: vtName },
|
|
5244
|
+
src,
|
|
5245
|
+
alt: "Image attachment",
|
|
5246
|
+
className: "cpk:max-w-[90vw] cpk:max-h-[90vh] cpk:object-contain cpk:rounded-lg"
|
|
5247
|
+
})
|
|
5248
|
+
})] });
|
|
5144
5249
|
});
|
|
5145
5250
|
const AudioAttachment = (0, react.memo)(function AudioAttachment({ src, filename, className }) {
|
|
5146
5251
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -5266,15 +5371,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5266
5371
|
"data-message-id": message.id,
|
|
5267
5372
|
...props,
|
|
5268
5373
|
children: [
|
|
5269
|
-
BoundMessageRenderer,
|
|
5270
5374
|
mediaParts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5271
|
-
className: "cpk:flex cpk:flex-
|
|
5375
|
+
className: "cpk:flex cpk:flex-row cpk:flex-wrap cpk:justify-end cpk:gap-2 cpk:mb-2",
|
|
5272
5376
|
children: mediaParts.map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAttachmentRenderer, {
|
|
5273
5377
|
type: part.type,
|
|
5274
5378
|
source: part.source,
|
|
5275
5379
|
filename: getFilename(part)
|
|
5276
5380
|
}, index))
|
|
5277
5381
|
}),
|
|
5382
|
+
BoundMessageRenderer,
|
|
5278
5383
|
BoundToolbar
|
|
5279
5384
|
]
|
|
5280
5385
|
});
|
|
@@ -5992,73 +6097,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5992
6097
|
case "document": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentPreview, { attachment });
|
|
5993
6098
|
}
|
|
5994
6099
|
}
|
|
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
6100
|
function ImagePreview({ attachment }) {
|
|
6063
6101
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
6064
6102
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
@@ -6398,14 +6436,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6398
6436
|
});
|
|
6399
6437
|
}
|
|
6400
6438
|
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
|
|
6439
|
+
const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
|
|
6402
6440
|
const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
|
|
6403
6441
|
const [isResizing, setIsResizing] = (0, react.useState)(false);
|
|
6404
6442
|
const resizeTimeoutRef = (0, react.useRef)(null);
|
|
6405
6443
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
6406
6444
|
(0, react.useEffect)(() => {
|
|
6407
|
-
const element =
|
|
6408
|
-
if (!element)
|
|
6445
|
+
const element = inputContainerEl;
|
|
6446
|
+
if (!element) {
|
|
6447
|
+
setInputContainerHeight(0);
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6409
6450
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
6410
6451
|
for (const entry of entries) {
|
|
6411
6452
|
const newHeight = entry.contentRect.height;
|
|
@@ -6428,7 +6469,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6428
6469
|
resizeObserver.disconnect();
|
|
6429
6470
|
if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
|
|
6430
6471
|
};
|
|
6431
|
-
}, []);
|
|
6472
|
+
}, [inputContainerEl]);
|
|
6432
6473
|
const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {
|
|
6433
6474
|
messages,
|
|
6434
6475
|
isRunning
|
|
@@ -6539,7 +6580,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6539
6580
|
dragOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropOverlay, {}),
|
|
6540
6581
|
BoundScrollView,
|
|
6541
6582
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6542
|
-
ref:
|
|
6583
|
+
ref: setInputContainerEl,
|
|
6543
6584
|
"data-testid": "copilot-input-overlay",
|
|
6544
6585
|
className: "cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-0 cpk:z-20 cpk:pointer-events-none",
|
|
6545
6586
|
children: [attachments && attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|