@copilotkit/react-core 2.0.0-rc.15 → 2.0.0-rc.16

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/index.cjs CHANGED
@@ -1242,7 +1242,7 @@ function useRenderToolCall() {
1242
1242
 
1243
1243
  //#endregion
1244
1244
  //#region package.json
1245
- var version$1 = "2.0.0-rc.15";
1245
+ var version$1 = "2.0.0-rc.16";
1246
1246
 
1247
1247
  //#endregion
1248
1248
  //#region src/components/CopilotKitInspector.tsx
@@ -2807,7 +2807,7 @@ function buildGenerativeUIManifest(runtime, threadId) {
2807
2807
  * includeCatalog: true,
2808
2808
  * contextSent: false,
2809
2809
  * });
2810
- * envelope["v1.0"].supportedCatalogIds; // [runtime.ui.id]
2810
+ * envelope["1.0"].supportedCatalogIds; // [runtime.ui.id]
2811
2811
  * ```
2812
2812
  */
2813
2813
  function buildGenerativeUIEnvelope(runtime, threadId, options) {
@@ -2816,7 +2816,7 @@ function buildGenerativeUIEnvelope(runtime, threadId, options) {
2816
2816
  const instructions = options.instructions ?? (transport === "markdown" ? (0, _copilotkit_shared.buildGenerativeUIMarkdownGuidelines)((0, _copilotkit_shared.generativeUIGuideFeatures)(manifest)) : void 0);
2817
2817
  const omitComponents = transport === "markdown" && !includeCatalog;
2818
2818
  return {
2819
- "v1.0": {
2819
+ "1.0": {
2820
2820
  supportedCatalogIds: manifest.catalogIds ?? [manifest.catalogId],
2821
2821
  inlineCatalogs: [{
2822
2822
  catalogId: manifest.catalogId,
@@ -10809,6 +10809,7 @@ function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
10809
10809
  const lastNonceRef = (0, react.useRef)(-1);
10810
10810
  (0, react.useEffect)(() => {
10811
10811
  if (sendNonce === lastNonceRef.current) return;
10812
+ const previousNonce = lastNonceRef.current;
10812
10813
  lastNonceRef.current = sendNonce;
10813
10814
  if (!id) return;
10814
10815
  const scrollEl = scrollRef.current;
@@ -10824,7 +10825,9 @@ function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
10824
10825
  const bubbleHeight = Math.max(0, userMessageHeight - paddingTop);
10825
10826
  const spacerHeight = Math.max(0, viewportHeight - bubbleHeight - topOffset);
10826
10827
  spacerEl.style.height = `${spacerHeight}px`;
10828
+ let pinned = false;
10827
10829
  const raf = requestAnimationFrame(() => {
10830
+ pinned = true;
10828
10831
  const targetTop = computeOffsetTop(targetEl, scrollEl) + paddingTop - topOffset;
10829
10832
  scrollEl.scrollTo({
10830
10833
  top: Math.max(0, targetTop),
@@ -10841,6 +10844,7 @@ function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
10841
10844
  return () => {
10842
10845
  cancelAnimationFrame(raf);
10843
10846
  ro.disconnect();
10847
+ if (!pinned) lastNonceRef.current = previousNonce;
10844
10848
  };
10845
10849
  }, [
10846
10850
  id,
@@ -10876,7 +10880,7 @@ function DropOverlay() {
10876
10880
  })
10877
10881
  });
10878
10882
  }
10879
- 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, intelligenceIndicator, children, className, ...props }) {
10883
+ 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, connectingIndicator, hasExplicitThreadId = false, intelligenceIndicator, children, className, ...props }) {
10880
10884
  const configuredThreadId = require_MarkdownSurfaces.useCopilotChatConfiguration()?.threadId;
10881
10885
  const [fallbackThreadId, setFallbackThreadId] = (0, react.useState)(messages[0]?.id);
10882
10886
  const previousMessageIds = (0, react.useRef)(/* @__PURE__ */ new Set());
@@ -10951,6 +10955,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
10951
10955
  onSelectSuggestion,
10952
10956
  className: "cpk-chat-view-suggestion-view"
10953
10957
  }) : null;
10958
+ const BoundConnectingIndicator = isConnecting && messages.length === 0 && connectingIndicator !== false ? require_MarkdownSurfaces.renderSlot(connectingIndicator === true ? void 0 : connectingIndicator, CopilotChatView.ConnectingIndicator, {}) : null;
10954
10959
  const BoundScrollView = require_MarkdownSurfaces.renderSlot(scrollView, CopilotChatView.ScrollView, {
10955
10960
  autoScroll,
10956
10961
  scrollThreadId,
@@ -10961,10 +10966,14 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
10961
10966
  style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` },
10962
10967
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10963
10968
  className: "cpk-chat-view-feed",
10964
- children: [BoundMessageView, hasSuggestions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10965
- className: "cpk-chat-view-suggestions",
10966
- children: BoundSuggestionView
10967
- }) : null]
10969
+ children: [
10970
+ BoundConnectingIndicator,
10971
+ BoundMessageView,
10972
+ hasSuggestions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10973
+ className: "cpk-chat-view-suggestions",
10974
+ children: BoundSuggestionView
10975
+ }) : null
10976
+ ]
10968
10977
  })
10969
10978
  })
10970
10979
  });
@@ -11001,6 +11010,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11001
11010
  "data-copilotkit": true,
11002
11011
  "data-testid": "copilot-chat",
11003
11012
  "data-copilot-running": isRunning ? "true" : "false",
11013
+ "data-copilot-connecting": isConnecting ? "true" : "false",
11004
11014
  onDragOver,
11005
11015
  onDragLeave,
11006
11016
  onDrop,
@@ -11011,6 +11021,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11011
11021
  }
11012
11022
  if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11013
11023
  "data-copilotkit": true,
11024
+ "data-copilot-connecting": isConnecting ? "true" : "false",
11014
11025
  style: { display: "contents" },
11015
11026
  children: children({
11016
11027
  messageView: BoundMessageView,
@@ -11023,6 +11034,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11023
11034
  "data-copilotkit": true,
11024
11035
  "data-testid": "copilot-chat",
11025
11036
  "data-copilot-running": isRunning ? "true" : "false",
11037
+ "data-copilot-connecting": isConnecting ? "true" : "false",
11026
11038
  onDragOver,
11027
11039
  onDragLeave,
11028
11040
  onDrop,
@@ -11238,13 +11250,15 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11238
11250
  if (mode === "pin-to-bottom") return;
11239
11251
  const scrollElement = nonAutoScrollEl;
11240
11252
  if (!scrollElement) return;
11253
+ const contentElement = contentRef.current;
11241
11254
  const checkScroll = () => {
11242
- setShowScrollButton(!(scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight < 10));
11255
+ setShowScrollButton((contentElement ? contentElement.getBoundingClientRect().bottom - scrollElement.getBoundingClientRect().bottom : scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight) >= 10);
11243
11256
  };
11244
11257
  checkScroll();
11245
11258
  scrollElement.addEventListener("scroll", checkScroll);
11246
11259
  const resizeObserver = new ResizeObserver(checkScroll);
11247
11260
  resizeObserver.observe(scrollElement);
11261
+ if (contentElement) resizeObserver.observe(contentElement);
11248
11262
  return () => {
11249
11263
  scrollElement.removeEventListener("scroll", checkScroll);
11250
11264
  resizeObserver.disconnect();
@@ -11330,6 +11344,22 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11330
11344
  className,
11331
11345
  ...props
11332
11346
  });
11347
+ _CopilotChatView.ConnectingIndicator = ({ className, ...props }) => {
11348
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11349
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11350
+ "data-testid": "copilot-connecting-indicator",
11351
+ role: "status",
11352
+ className: require_MarkdownSurfaces.cn("cpk-chat-view-connecting-indicator", className),
11353
+ ...props,
11354
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
11355
+ name: "Loader2",
11356
+ className: "cpk-chat-view-connecting-spinner"
11357
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11358
+ className: "cpk-chat-view-connecting-label",
11359
+ children: labels.chatConnectingLabel
11360
+ })]
11361
+ });
11362
+ };
11333
11363
  _CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
11334
11364
  const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11335
11365
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {