@copilotkit/react-core 1.56.3 → 1.56.4-canary.1777531098
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-By2G6-Zx.cjs → copilotkit-DMFu29Kx.cjs} +142 -103
- package/dist/copilotkit-DMFu29Kx.cjs.map +1 -0
- package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -1
- package/dist/{copilotkit-PzJlPKcU.mjs → copilotkit-OmIUrWym.mjs} +142 -103
- 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 +144 -105
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +7 -114
- 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 +66 -77
- 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__/CopilotChatActivityRendering.e2e.test.tsx +193 -57
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.tsx +264 -0
- package/src/v2/hooks/use-configure-suggestions.tsx +43 -0
- package/dist/copilotkit-By2G6-Zx.cjs.map +0 -1
- package/dist/copilotkit-PzJlPKcU.mjs.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
|
});
|
|
@@ -5957,6 +6062,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5957
6062
|
const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
|
|
5958
6063
|
if (attachments.length === 0) return null;
|
|
5959
6064
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6065
|
+
"data-testid": "copilot-attachment-queue",
|
|
5960
6066
|
className: cn("cpk:flex cpk:flex-wrap cpk:gap-2 cpk:p-2", className),
|
|
5961
6067
|
children: attachments.map((attachment) => {
|
|
5962
6068
|
const isMedia = attachment.type === "image" || attachment.type === "video";
|
|
@@ -5991,73 +6097,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5991
6097
|
case "document": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentPreview, { attachment });
|
|
5992
6098
|
}
|
|
5993
6099
|
}
|
|
5994
|
-
function Lightbox({ onClose, children }) {
|
|
5995
|
-
(0, react.useEffect)(() => {
|
|
5996
|
-
const handleKey = (e) => {
|
|
5997
|
-
if (e.key === "Escape") onClose();
|
|
5998
|
-
};
|
|
5999
|
-
document.addEventListener("keydown", handleKey);
|
|
6000
|
-
return () => document.removeEventListener("keydown", handleKey);
|
|
6001
|
-
}, [onClose]);
|
|
6002
|
-
if (typeof document === "undefined") return null;
|
|
6003
|
-
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6004
|
-
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",
|
|
6005
|
-
onClick: onClose,
|
|
6006
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
6007
|
-
onClick: onClose,
|
|
6008
|
-
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",
|
|
6009
|
-
"aria-label": "Close preview",
|
|
6010
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
|
|
6011
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6012
|
-
onClick: (e) => e.stopPropagation(),
|
|
6013
|
-
children
|
|
6014
|
-
})]
|
|
6015
|
-
}), document.body);
|
|
6016
|
-
}
|
|
6017
|
-
/**
|
|
6018
|
-
* Hook that manages lightbox open/close and uses the View Transition API to
|
|
6019
|
-
* morph the thumbnail into fullscreen content.
|
|
6020
|
-
*
|
|
6021
|
-
* The trick: `view-transition-name` must live on exactly ONE element at a time.
|
|
6022
|
-
* - Old state (thumbnail visible): name is on the thumbnail.
|
|
6023
|
-
* - New state (lightbox visible): name moves to the lightbox content.
|
|
6024
|
-
* `flushSync` ensures React commits the DOM change synchronously inside the
|
|
6025
|
-
* `startViewTransition` callback so the API can snapshot old → new correctly.
|
|
6026
|
-
*/
|
|
6027
|
-
function useLightbox() {
|
|
6028
|
-
const thumbnailRef = (0, react.useRef)(null);
|
|
6029
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
6030
|
-
const vtName = (0, react.useId)();
|
|
6031
|
-
return {
|
|
6032
|
-
thumbnailRef,
|
|
6033
|
-
vtName,
|
|
6034
|
-
open,
|
|
6035
|
-
openLightbox: (0, react.useCallback)(() => {
|
|
6036
|
-
const thumb = thumbnailRef.current;
|
|
6037
|
-
const doc = document;
|
|
6038
|
-
if (doc.startViewTransition && thumb) {
|
|
6039
|
-
thumb.style.viewTransitionName = vtName;
|
|
6040
|
-
doc.startViewTransition(() => {
|
|
6041
|
-
thumb.style.viewTransitionName = "";
|
|
6042
|
-
(0, react_dom.flushSync)(() => setOpen(true));
|
|
6043
|
-
});
|
|
6044
|
-
} else setOpen(true);
|
|
6045
|
-
}, []),
|
|
6046
|
-
closeLightbox: (0, react.useCallback)(() => {
|
|
6047
|
-
const thumb = thumbnailRef.current;
|
|
6048
|
-
const doc = document;
|
|
6049
|
-
if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
|
|
6050
|
-
(0, react_dom.flushSync)(() => setOpen(false));
|
|
6051
|
-
thumb.style.viewTransitionName = vtName;
|
|
6052
|
-
}).finished.then(() => {
|
|
6053
|
-
thumb.style.viewTransitionName = "";
|
|
6054
|
-
}).catch(() => {
|
|
6055
|
-
thumb.style.viewTransitionName = "";
|
|
6056
|
-
});
|
|
6057
|
-
else setOpen(false);
|
|
6058
|
-
}, [])
|
|
6059
|
-
};
|
|
6060
|
-
}
|
|
6061
6100
|
function ImagePreview({ attachment }) {
|
|
6062
6101
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
6063
6102
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
@@ -6383,13 +6422,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6383
6422
|
|
|
6384
6423
|
//#endregion
|
|
6385
6424
|
//#region src/v2/components/chat/CopilotChatView.tsx
|
|
6386
|
-
const
|
|
6387
|
-
const PIN_TO_SEND_FEATHER_HEIGHT = 48;
|
|
6388
|
-
const PinToSendSoftFeather = ({ className, style, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6389
|
-
className: cn("cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-4 cpk:h-12 cpk:pointer-events-none cpk:z-10 cpk:bg-gradient-to-t", "cpk:from-white cpk:to-transparent", "cpk:dark:from-[rgb(33,33,33)]", className),
|
|
6390
|
-
style,
|
|
6391
|
-
...props
|
|
6392
|
-
});
|
|
6425
|
+
const SCROLL_BUTTON_OFFSET = 16;
|
|
6393
6426
|
function DropOverlay() {
|
|
6394
6427
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6395
6428
|
className: cn("cpk:absolute cpk:inset-0 cpk:z-50 cpk:pointer-events-none", "cpk:flex cpk:items-center cpk:justify-center", "cpk:bg-primary/5 cpk:backdrop-blur-[2px]", "cpk:border-2 cpk:border-dashed cpk:border-primary/40 cpk:rounded-lg cpk:m-2"),
|
|
@@ -6403,14 +6436,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6403
6436
|
});
|
|
6404
6437
|
}
|
|
6405
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 }) {
|
|
6406
|
-
const
|
|
6439
|
+
const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
|
|
6407
6440
|
const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
|
|
6408
6441
|
const [isResizing, setIsResizing] = (0, react.useState)(false);
|
|
6409
6442
|
const resizeTimeoutRef = (0, react.useRef)(null);
|
|
6410
6443
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
6411
6444
|
(0, react.useEffect)(() => {
|
|
6412
|
-
const element =
|
|
6413
|
-
if (!element)
|
|
6445
|
+
const element = inputContainerEl;
|
|
6446
|
+
if (!element) {
|
|
6447
|
+
setInputContainerHeight(0);
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6414
6450
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
6415
6451
|
for (const entry of entries) {
|
|
6416
6452
|
const newHeight = entry.contentRect.height;
|
|
@@ -6433,7 +6469,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6433
6469
|
resizeObserver.disconnect();
|
|
6434
6470
|
if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
|
|
6435
6471
|
};
|
|
6436
|
-
}, []);
|
|
6472
|
+
}, [inputContainerEl]);
|
|
6437
6473
|
const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {
|
|
6438
6474
|
messages,
|
|
6439
6475
|
isRunning
|
|
@@ -6452,7 +6488,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6452
6488
|
onAddFile,
|
|
6453
6489
|
positioning: "static",
|
|
6454
6490
|
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
6455
|
-
containerRef: inputContainerRef,
|
|
6456
6491
|
showDisclaimer: true,
|
|
6457
6492
|
bottomAnchored: true,
|
|
6458
6493
|
...disclaimer !== void 0 ? { disclaimer } : {}
|
|
@@ -6469,7 +6504,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6469
6504
|
inputContainerHeight,
|
|
6470
6505
|
isResizing,
|
|
6471
6506
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6472
|
-
|
|
6507
|
+
"data-testid": "copilot-scroll-content",
|
|
6508
|
+
style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` },
|
|
6473
6509
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6474
6510
|
className: "cpk:max-w-3xl cpk:mx-auto",
|
|
6475
6511
|
children: [BoundMessageView, hasSuggestions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -6543,15 +6579,19 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6543
6579
|
children: [
|
|
6544
6580
|
dragOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropOverlay, {}),
|
|
6545
6581
|
BoundScrollView,
|
|
6546
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
className: "cpk:
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6582
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6583
|
+
ref: setInputContainerEl,
|
|
6584
|
+
"data-testid": "copilot-input-overlay",
|
|
6585
|
+
className: "cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-0 cpk:z-20 cpk:pointer-events-none",
|
|
6586
|
+
children: [attachments && attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6587
|
+
className: "cpk:max-w-3xl cpk:mx-auto cpk:w-full cpk:pointer-events-auto",
|
|
6588
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAttachmentQueue, {
|
|
6589
|
+
attachments,
|
|
6590
|
+
onRemoveAttachment: (id) => onRemoveAttachment === null || onRemoveAttachment === void 0 ? void 0 : onRemoveAttachment(id),
|
|
6591
|
+
className: "cpk:px-4"
|
|
6592
|
+
})
|
|
6593
|
+
}), BoundInput]
|
|
6594
|
+
})
|
|
6555
6595
|
]
|
|
6556
6596
|
});
|
|
6557
6597
|
}
|
|
@@ -6581,7 +6621,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6581
6621
|
BoundFeather,
|
|
6582
6622
|
!isAtBottom && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6583
6623
|
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
6584
|
-
style: { bottom: `${inputContainerHeight +
|
|
6624
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
6585
6625
|
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
6586
6626
|
})
|
|
6587
6627
|
] })
|
|
@@ -6595,7 +6635,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6595
6635
|
spacerRef,
|
|
6596
6636
|
topOffset: 16
|
|
6597
6637
|
});
|
|
6598
|
-
const BoundFeather = renderSlot(feather,
|
|
6638
|
+
const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
|
|
6599
6639
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScrollElementContext.Provider, {
|
|
6600
6640
|
value: nonAutoScrollEl,
|
|
6601
6641
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -6622,7 +6662,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6622
6662
|
BoundFeather,
|
|
6623
6663
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6624
6664
|
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
6625
|
-
style: { bottom: `${inputContainerHeight +
|
|
6665
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
6626
6666
|
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
6627
6667
|
})
|
|
6628
6668
|
]
|
|
@@ -6690,7 +6730,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6690
6730
|
BoundFeather,
|
|
6691
6731
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6692
6732
|
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
6693
|
-
style: { bottom: `${inputContainerHeight +
|
|
6733
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
6694
6734
|
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
6695
6735
|
})
|
|
6696
6736
|
]
|
|
@@ -6734,9 +6774,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6734
6774
|
...props,
|
|
6735
6775
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "cpk:w-4 cpk:h-4 cpk:text-gray-600 cpk:dark:text-white" })
|
|
6736
6776
|
});
|
|
6737
|
-
_CopilotChatView.Feather = ({ className,
|
|
6738
|
-
className
|
|
6739
|
-
style,
|
|
6777
|
+
_CopilotChatView.Feather = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6778
|
+
className,
|
|
6740
6779
|
...props
|
|
6741
6780
|
});
|
|
6742
6781
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|