@copilotkit/react-core 1.56.4-canary.1777629975 → 1.56.4-canary.1777659843

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.
@@ -6218,55 +6218,40 @@ const LastUserMessageContext = react.default.createContext({
6218
6218
 
6219
6219
  //#endregion
6220
6220
  //#region src/v2/hooks/use-pin-to-send.ts
6221
- function usePinToSend({ scrollRef, contentRef, spacerRef, topOffset = 16 }) {
6221
+ function usePinToSend({ scrollRef, contentRef, topOffset = 16 }) {
6222
6222
  const { id, sendNonce } = (0, react.useContext)(LastUserMessageContext);
6223
6223
  const lastNonceRef = (0, react.useRef)(-1);
6224
- const currentSpacerHeightRef = (0, react.useRef)(0);
6225
6224
  (0, react.useEffect)(() => {
6226
6225
  if (sendNonce === lastNonceRef.current) return;
6227
6226
  lastNonceRef.current = sendNonce;
6228
6227
  if (!id) return;
6229
6228
  const scrollEl = scrollRef.current;
6230
6229
  const contentEl = contentRef.current;
6231
- const spacerEl = spacerRef.current;
6232
- if (!scrollEl || !contentEl || !spacerEl) return;
6230
+ if (!scrollEl || !contentEl) return;
6233
6231
  const escaped = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(id) : id.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
6234
6232
  const targetEl = contentEl.querySelector(`[data-message-id="${escaped}"]`);
6235
6233
  if (!targetEl) return;
6236
6234
  const viewportHeight = scrollEl.clientHeight;
6237
- const userMessageHeight = targetEl.getBoundingClientRect().height;
6238
6235
  const paddingTop = parseFloat(getComputedStyle(targetEl).paddingTop) || 0;
6239
- const bubbleHeight = Math.max(0, userMessageHeight - paddingTop);
6240
- const spacerHeight = Math.max(0, viewportHeight - bubbleHeight - topOffset);
6241
- spacerEl.style.height = `${spacerHeight}px`;
6242
- currentSpacerHeightRef.current = spacerHeight;
6236
+ const userMsgOffsetInScroll = computeOffsetTop(targetEl, scrollEl);
6237
+ const requiredScrollHeight = userMsgOffsetInScroll + paddingTop + viewportHeight - topOffset;
6238
+ contentEl.style.minHeight = `${Math.max(0, requiredScrollHeight)}px`;
6243
6239
  const raf = requestAnimationFrame(() => {
6244
- const targetTop = computeOffsetTop(targetEl, scrollEl) + paddingTop - topOffset;
6240
+ const targetTop = userMsgOffsetInScroll + paddingTop - topOffset;
6245
6241
  scrollEl.scrollTo({
6246
6242
  top: Math.max(0, targetTop),
6247
6243
  behavior: "smooth"
6248
6244
  });
6249
6245
  });
6250
- const ro = new ResizeObserver(() => {
6251
- if (!contentEl || !spacerEl || !scrollEl) return;
6252
- const consumedBelow = contentEl.getBoundingClientRect().height - computeOffsetTop(targetEl, contentEl) - userMessageHeight;
6253
- const remaining = Math.max(0, spacerHeight - consumedBelow);
6254
- if (remaining < currentSpacerHeightRef.current) {
6255
- spacerEl.style.height = `${remaining}px`;
6256
- currentSpacerHeightRef.current = remaining;
6257
- }
6258
- });
6259
- ro.observe(contentEl);
6260
6246
  return () => {
6261
6247
  cancelAnimationFrame(raf);
6262
- ro.disconnect();
6248
+ contentEl.style.minHeight = "";
6263
6249
  };
6264
6250
  }, [
6265
6251
  id,
6266
6252
  sendNonce,
6267
6253
  scrollRef,
6268
6254
  contentRef,
6269
- spacerRef,
6270
6255
  topOffset
6271
6256
  ]);
6272
6257
  }
@@ -6480,11 +6465,9 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
6480
6465
  });
6481
6466
  };
6482
6467
  const PinToSendScrollContainer = ({ children, scrollRef, contentRef, scrollToBottom, scrollToBottomButton, feather, inputContainerHeight, isResizing, nonAutoScrollEl, nonAutoScrollRefCallback, showScrollButton, className, ...props }) => {
6483
- const spacerRef = (0, react.useRef)(null);
6484
6468
  usePinToSend({
6485
6469
  scrollRef,
6486
6470
  contentRef,
6487
- spacerRef,
6488
6471
  topOffset: 16
6489
6472
  });
6490
6473
  const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
@@ -6493,23 +6476,16 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
6493
6476
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6494
6477
  className: cn("cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:relative", className),
6495
6478
  children: [
6496
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6479
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6497
6480
  ref: nonAutoScrollRefCallback,
6498
6481
  className: "cpk:flex-1 cpk:min-h-0 cpk:overflow-y-auto cpk:overflow-x-hidden",
6499
6482
  ...props,
6500
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6483
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6501
6484
  ref: contentRef,
6485
+ "data-pin-to-send-content": true,
6502
6486
  className: "cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
6503
6487
  children
6504
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6505
- ref: spacerRef,
6506
- "data-pin-to-send-spacer": true,
6507
- "aria-hidden": "true",
6508
- style: {
6509
- height: 0,
6510
- flex: "0 0 auto"
6511
- }
6512
- })]
6488
+ })
6513
6489
  }),
6514
6490
  BoundFeather,
6515
6491
  showScrollButton && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -10202,4 +10178,4 @@ Object.defineProperty(exports, 'useToast', {
10202
10178
  return useToast;
10203
10179
  }
10204
10180
  });
10205
- //# sourceMappingURL=copilotkit-tb4zqaMK.cjs.map
10181
+ //# sourceMappingURL=copilotkit-Bn7CCpNA.cjs.map