@copilotkit/react-core 1.56.3 → 1.56.4-canary.1777529757
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-By2G6-Zx.cjs → copilotkit-BAkj3zUc.cjs} +119 -104
- package/dist/copilotkit-BAkj3zUc.cjs.map +1 -0
- package/dist/{copilotkit-PzJlPKcU.mjs → copilotkit-DAatqMh2.mjs} +119 -104
- package/dist/copilotkit-DAatqMh2.mjs.map +1 -0
- package/dist/copilotkit-DFaI4j2r.d.mts.map +1 -1
- package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +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 +121 -106
- 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 +68 -85
- package/src/v2/components/chat/Lightbox.tsx +103 -0
- package/src/v2/components/chat/__tests__/CopilotChat.suggestionsAlways.test.tsx +189 -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/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;
|
|
@@ -5127,20 +5127,101 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5127
5127
|
CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
|
|
5128
5128
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
5129
5129
|
|
|
5130
|
+
//#endregion
|
|
5131
|
+
//#region src/v2/components/chat/Lightbox.tsx
|
|
5132
|
+
function Lightbox({ onClose, children }) {
|
|
5133
|
+
(0, react.useEffect)(() => {
|
|
5134
|
+
const handleKey = (e) => {
|
|
5135
|
+
if (e.key === "Escape") onClose();
|
|
5136
|
+
};
|
|
5137
|
+
document.addEventListener("keydown", handleKey);
|
|
5138
|
+
return () => document.removeEventListener("keydown", handleKey);
|
|
5139
|
+
}, [onClose]);
|
|
5140
|
+
if (typeof document === "undefined") return null;
|
|
5141
|
+
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5142
|
+
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",
|
|
5143
|
+
onClick: onClose,
|
|
5144
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
5145
|
+
onClick: onClose,
|
|
5146
|
+
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",
|
|
5147
|
+
"aria-label": "Close preview",
|
|
5148
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
|
|
5149
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5150
|
+
onClick: (e) => e.stopPropagation(),
|
|
5151
|
+
children
|
|
5152
|
+
})]
|
|
5153
|
+
}), document.body);
|
|
5154
|
+
}
|
|
5155
|
+
/**
|
|
5156
|
+
* Hook that manages lightbox open/close and uses the View Transition API to
|
|
5157
|
+
* morph the thumbnail into fullscreen content.
|
|
5158
|
+
*
|
|
5159
|
+
* The trick: `view-transition-name` must live on exactly ONE element at a time.
|
|
5160
|
+
* - Old state (thumbnail visible): name is on the thumbnail.
|
|
5161
|
+
* - New state (lightbox visible): name moves to the lightbox content.
|
|
5162
|
+
* `flushSync` ensures React commits the DOM change synchronously inside the
|
|
5163
|
+
* `startViewTransition` callback so the API can snapshot old → new correctly.
|
|
5164
|
+
*/
|
|
5165
|
+
function useLightbox() {
|
|
5166
|
+
const thumbnailRef = (0, react.useRef)(null);
|
|
5167
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
5168
|
+
const vtName = (0, react.useId)();
|
|
5169
|
+
return {
|
|
5170
|
+
thumbnailRef,
|
|
5171
|
+
vtName,
|
|
5172
|
+
open,
|
|
5173
|
+
openLightbox: (0, react.useCallback)(() => {
|
|
5174
|
+
const thumb = thumbnailRef.current;
|
|
5175
|
+
const doc = document;
|
|
5176
|
+
if (doc.startViewTransition && thumb) {
|
|
5177
|
+
thumb.style.viewTransitionName = vtName;
|
|
5178
|
+
doc.startViewTransition(() => {
|
|
5179
|
+
thumb.style.viewTransitionName = "";
|
|
5180
|
+
(0, react_dom.flushSync)(() => setOpen(true));
|
|
5181
|
+
});
|
|
5182
|
+
} else setOpen(true);
|
|
5183
|
+
}, [vtName]),
|
|
5184
|
+
closeLightbox: (0, react.useCallback)(() => {
|
|
5185
|
+
const thumb = thumbnailRef.current;
|
|
5186
|
+
const doc = document;
|
|
5187
|
+
if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
|
|
5188
|
+
(0, react_dom.flushSync)(() => setOpen(false));
|
|
5189
|
+
thumb.style.viewTransitionName = vtName;
|
|
5190
|
+
}).finished.then(() => {
|
|
5191
|
+
thumb.style.viewTransitionName = "";
|
|
5192
|
+
}).catch(() => {
|
|
5193
|
+
thumb.style.viewTransitionName = "";
|
|
5194
|
+
});
|
|
5195
|
+
else setOpen(false);
|
|
5196
|
+
}, [vtName])
|
|
5197
|
+
};
|
|
5198
|
+
}
|
|
5199
|
+
|
|
5130
5200
|
//#endregion
|
|
5131
5201
|
//#region src/v2/components/chat/CopilotChatAttachmentRenderer.tsx
|
|
5132
5202
|
const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
|
|
5133
5203
|
const [error, setError] = (0, react.useState)(false);
|
|
5204
|
+
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
5134
5205
|
if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5135
5206
|
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
5207
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Failed to load image" })
|
|
5137
5208
|
});
|
|
5138
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5209
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5210
|
+
ref: thumbnailRef,
|
|
5139
5211
|
src,
|
|
5140
5212
|
alt: "Image attachment",
|
|
5141
|
-
className: cn("cpk:max-w-
|
|
5213
|
+
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),
|
|
5214
|
+
onClick: openLightbox,
|
|
5142
5215
|
onError: () => setError(true)
|
|
5143
|
-
})
|
|
5216
|
+
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
|
|
5217
|
+
onClose: closeLightbox,
|
|
5218
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
5219
|
+
style: { viewTransitionName: vtName },
|
|
5220
|
+
src,
|
|
5221
|
+
alt: "Image attachment",
|
|
5222
|
+
className: "cpk:max-w-[90vw] cpk:max-h-[90vh] cpk:object-contain cpk:rounded-lg"
|
|
5223
|
+
})
|
|
5224
|
+
})] });
|
|
5144
5225
|
});
|
|
5145
5226
|
const AudioAttachment = (0, react.memo)(function AudioAttachment({ src, filename, className }) {
|
|
5146
5227
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -5266,15 +5347,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5266
5347
|
"data-message-id": message.id,
|
|
5267
5348
|
...props,
|
|
5268
5349
|
children: [
|
|
5269
|
-
BoundMessageRenderer,
|
|
5270
5350
|
mediaParts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5271
|
-
className: "cpk:flex cpk:flex-
|
|
5351
|
+
className: "cpk:flex cpk:flex-row cpk:flex-wrap cpk:justify-end cpk:gap-2 cpk:mb-2",
|
|
5272
5352
|
children: mediaParts.map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAttachmentRenderer, {
|
|
5273
5353
|
type: part.type,
|
|
5274
5354
|
source: part.source,
|
|
5275
5355
|
filename: getFilename(part)
|
|
5276
5356
|
}, index))
|
|
5277
5357
|
}),
|
|
5358
|
+
BoundMessageRenderer,
|
|
5278
5359
|
BoundToolbar
|
|
5279
5360
|
]
|
|
5280
5361
|
});
|
|
@@ -5957,6 +6038,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5957
6038
|
const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
|
|
5958
6039
|
if (attachments.length === 0) return null;
|
|
5959
6040
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6041
|
+
"data-testid": "copilot-attachment-queue",
|
|
5960
6042
|
className: cn("cpk:flex cpk:flex-wrap cpk:gap-2 cpk:p-2", className),
|
|
5961
6043
|
children: attachments.map((attachment) => {
|
|
5962
6044
|
const isMedia = attachment.type === "image" || attachment.type === "video";
|
|
@@ -5991,73 +6073,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5991
6073
|
case "document": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentPreview, { attachment });
|
|
5992
6074
|
}
|
|
5993
6075
|
}
|
|
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
6076
|
function ImagePreview({ attachment }) {
|
|
6062
6077
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
6063
6078
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
@@ -6383,13 +6398,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6383
6398
|
|
|
6384
6399
|
//#endregion
|
|
6385
6400
|
//#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
|
-
});
|
|
6401
|
+
const SCROLL_BUTTON_OFFSET = 16;
|
|
6393
6402
|
function DropOverlay() {
|
|
6394
6403
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6395
6404
|
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 +6412,17 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6403
6412
|
});
|
|
6404
6413
|
}
|
|
6405
6414
|
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
|
|
6415
|
+
const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
|
|
6407
6416
|
const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
|
|
6408
6417
|
const [isResizing, setIsResizing] = (0, react.useState)(false);
|
|
6409
6418
|
const resizeTimeoutRef = (0, react.useRef)(null);
|
|
6410
6419
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
6411
6420
|
(0, react.useEffect)(() => {
|
|
6412
|
-
const element =
|
|
6413
|
-
if (!element)
|
|
6421
|
+
const element = inputContainerEl;
|
|
6422
|
+
if (!element) {
|
|
6423
|
+
setInputContainerHeight(0);
|
|
6424
|
+
return;
|
|
6425
|
+
}
|
|
6414
6426
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
6415
6427
|
for (const entry of entries) {
|
|
6416
6428
|
const newHeight = entry.contentRect.height;
|
|
@@ -6433,7 +6445,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6433
6445
|
resizeObserver.disconnect();
|
|
6434
6446
|
if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
|
|
6435
6447
|
};
|
|
6436
|
-
}, []);
|
|
6448
|
+
}, [inputContainerEl]);
|
|
6437
6449
|
const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {
|
|
6438
6450
|
messages,
|
|
6439
6451
|
isRunning
|
|
@@ -6452,12 +6464,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6452
6464
|
onAddFile,
|
|
6453
6465
|
positioning: "static",
|
|
6454
6466
|
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
6455
|
-
containerRef: inputContainerRef,
|
|
6456
6467
|
showDisclaimer: true,
|
|
6457
6468
|
bottomAnchored: true,
|
|
6458
6469
|
...disclaimer !== void 0 ? { disclaimer } : {}
|
|
6459
6470
|
});
|
|
6460
|
-
const hasSuggestions = !isConnecting &&
|
|
6471
|
+
const hasSuggestions = !isConnecting && Array.isArray(suggestions) && suggestions.length > 0;
|
|
6461
6472
|
const BoundSuggestionView = hasSuggestions ? renderSlot(suggestionView, CopilotChatSuggestionView, {
|
|
6462
6473
|
suggestions,
|
|
6463
6474
|
loadingIndexes: suggestionLoadingIndexes,
|
|
@@ -6469,7 +6480,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6469
6480
|
inputContainerHeight,
|
|
6470
6481
|
isResizing,
|
|
6471
6482
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6472
|
-
|
|
6483
|
+
"data-testid": "copilot-scroll-content",
|
|
6484
|
+
style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` },
|
|
6473
6485
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6474
6486
|
className: "cpk:max-w-3xl cpk:mx-auto",
|
|
6475
6487
|
children: [BoundMessageView, hasSuggestions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -6543,15 +6555,19 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6543
6555
|
children: [
|
|
6544
6556
|
dragOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropOverlay, {}),
|
|
6545
6557
|
BoundScrollView,
|
|
6546
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
className: "cpk:
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6558
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6559
|
+
ref: setInputContainerEl,
|
|
6560
|
+
"data-testid": "copilot-input-overlay",
|
|
6561
|
+
className: "cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-0 cpk:z-20 cpk:pointer-events-none",
|
|
6562
|
+
children: [attachments && attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6563
|
+
className: "cpk:max-w-3xl cpk:mx-auto cpk:w-full cpk:pointer-events-auto",
|
|
6564
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAttachmentQueue, {
|
|
6565
|
+
attachments,
|
|
6566
|
+
onRemoveAttachment: (id) => onRemoveAttachment === null || onRemoveAttachment === void 0 ? void 0 : onRemoveAttachment(id),
|
|
6567
|
+
className: "cpk:px-4"
|
|
6568
|
+
})
|
|
6569
|
+
}), BoundInput]
|
|
6570
|
+
})
|
|
6555
6571
|
]
|
|
6556
6572
|
});
|
|
6557
6573
|
}
|
|
@@ -6581,7 +6597,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6581
6597
|
BoundFeather,
|
|
6582
6598
|
!isAtBottom && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6583
6599
|
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
6584
|
-
style: { bottom: `${inputContainerHeight +
|
|
6600
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
6585
6601
|
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
6586
6602
|
})
|
|
6587
6603
|
] })
|
|
@@ -6595,7 +6611,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6595
6611
|
spacerRef,
|
|
6596
6612
|
topOffset: 16
|
|
6597
6613
|
});
|
|
6598
|
-
const BoundFeather = renderSlot(feather,
|
|
6614
|
+
const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
|
|
6599
6615
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScrollElementContext.Provider, {
|
|
6600
6616
|
value: nonAutoScrollEl,
|
|
6601
6617
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -6622,7 +6638,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6622
6638
|
BoundFeather,
|
|
6623
6639
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6624
6640
|
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
6625
|
-
style: { bottom: `${inputContainerHeight +
|
|
6641
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
6626
6642
|
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
6627
6643
|
})
|
|
6628
6644
|
]
|
|
@@ -6690,7 +6706,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6690
6706
|
BoundFeather,
|
|
6691
6707
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6692
6708
|
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
6693
|
-
style: { bottom: `${inputContainerHeight +
|
|
6709
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
6694
6710
|
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
6695
6711
|
})
|
|
6696
6712
|
]
|
|
@@ -6734,9 +6750,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6734
6750
|
...props,
|
|
6735
6751
|
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
6752
|
});
|
|
6737
|
-
_CopilotChatView.Feather = ({ className,
|
|
6738
|
-
className
|
|
6739
|
-
style,
|
|
6753
|
+
_CopilotChatView.Feather = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6754
|
+
className,
|
|
6740
6755
|
...props
|
|
6741
6756
|
});
|
|
6742
6757
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|