@copilotkit/react-core 1.79.0 → 1.79.1-canary.1792089208

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.
@@ -1655,7 +1655,7 @@ function useRenderToolCall() {
1655
1655
 
1656
1656
  //#endregion
1657
1657
  //#region package.json
1658
- var version = "1.79.0";
1658
+ var version = "1.79.1-canary.1792089208";
1659
1659
 
1660
1660
  //#endregion
1661
1661
  //#region src/v2/components/CopilotKitInspector.tsx
@@ -3779,7 +3779,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3779
3779
  (0, react.useEffect)(() => {
3780
3780
  copilotkit.setLearningConfig(learningConfig);
3781
3781
  learningContainerIdsRef.current = learningConfig?.learningContainerIds;
3782
- if (learningConfig?.sink === void 0 && !autoStart && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
3782
+ if (learningConfig?.sink === void 0 && !autoStart && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture ignores it; assign Learning Spaces on the server with getTrajectoryLearningContainerIds on CopilotKitIntelligence, and remove learningContainerIds from the capture options.");
3783
3783
  }, [
3784
3784
  copilotkit,
3785
3785
  learningConfig,
@@ -7795,6 +7795,8 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7795
7795
  (0, _copilotkit_shared.commitRowKeyStore)(rowKeyStore, renderedMessages);
7796
7796
  }, [rowKeyStore, renderedMessages]);
7797
7797
  const stableGroupKey = (key) => rowRenderKeys.get(key) ?? key;
7798
+ const rowKey = (row) => row.type === "group" ? `${GROUP_ROW_KEY_PREFIX}${stableGroupKey(row.key)}` : rowRenderKeys.get(row.message.id) ?? row.message.id;
7799
+ const rowKeys = (0, react.useMemo)(() => rows.map(rowKey), [rows, rowRenderKeys]);
7798
7800
  const groupStateRef = (0, react.useRef)(/* @__PURE__ */ new Map());
7799
7801
  const groupSettersRef = (0, react.useRef)(/* @__PURE__ */ new Map());
7800
7802
  const groupStateThreadRef = (0, react.useRef)(config?.threadId);
@@ -7868,6 +7870,8 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7868
7870
  total: 0,
7869
7871
  sizes: /* @__PURE__ */ new Map()
7870
7872
  });
7873
+ const rowKeysRef = react.default.useRef(rowKeys);
7874
+ rowKeysRef.current = rowKeys;
7871
7875
  const firstMessageId = deduplicatedMessages[0]?.id;
7872
7876
  const measuredThreadRef = react.default.useRef(firstMessageId);
7873
7877
  if (measuredThreadRef.current !== firstMessageId) {
@@ -7877,6 +7881,16 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7877
7881
  sizes: /* @__PURE__ */ new Map()
7878
7882
  };
7879
7883
  }
7884
+ const measuredKeysRef = react.default.useRef(rowKeys);
7885
+ if (measuredKeysRef.current !== rowKeys) {
7886
+ measuredKeysRef.current = rowKeys;
7887
+ const live = new Set(rowKeys);
7888
+ const measured = measuredRef.current;
7889
+ for (const [key, height] of measured.sizes) if (!live.has(key)) {
7890
+ measured.sizes.delete(key);
7891
+ measured.total -= height;
7892
+ }
7893
+ }
7880
7894
  const estimateRowSize = react.default.useCallback(() => {
7881
7895
  const { total, sizes } = measuredRef.current;
7882
7896
  return sizes.size > 0 ? Math.max(1, Math.round(total / sizes.size)) : 100;
@@ -7884,13 +7898,15 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7884
7898
  const measureRowElement = react.default.useCallback((el) => {
7885
7899
  const height = el?.getBoundingClientRect().height ?? 0;
7886
7900
  const index = Number(el?.dataset?.index);
7887
- if (height > 0 && Number.isInteger(index)) {
7901
+ const key = Number.isInteger(index) ? rowKeysRef.current[index] : void 0;
7902
+ if (height > 0 && key !== void 0) {
7888
7903
  const { total, sizes } = measuredRef.current;
7889
- measuredRef.current.total = total - (sizes.get(index) ?? 0) + height;
7890
- sizes.set(index, height);
7904
+ measuredRef.current.total = total - (sizes.get(key) ?? 0) + height;
7905
+ sizes.set(key, height);
7891
7906
  }
7892
7907
  return height;
7893
7908
  }, []);
7909
+ const getRowKey = react.default.useCallback((index) => rowKeys[index] ?? index, [rowKeys]);
7894
7910
  const isPinnedToBottomRef = react.default.useRef(isPinnedToBottom);
7895
7911
  const shouldAdjustScrollOnResize = react.default.useCallback((item, _delta, instance) => {
7896
7912
  if (isPinnedToBottomRef.current) return false;
@@ -7901,6 +7917,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7901
7917
  count: shouldVirtualize ? rows.length : 0,
7902
7918
  getScrollElement: () => scrollElement,
7903
7919
  estimateSize: estimateRowSize,
7920
+ getItemKey: getRowKey,
7904
7921
  overscan: 5,
7905
7922
  measureElement: measureRowElement,
7906
7923
  initialRect: {
@@ -7964,7 +7981,6 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7964
7981
  }, `intelligence-${intelligenceTurnId}`));
7965
7982
  return elements.filter(Boolean);
7966
7983
  };
7967
- const rowKey = (row) => row.type === "group" ? `${GROUP_ROW_KEY_PREFIX}${stableGroupKey(row.key)}` : rowRenderKeys.get(row.message.id) ?? row.message.id;
7968
7984
  const renderRow = (row) => {
7969
7985
  if (row.type === "message") return renderMessageBlock(row.message);
7970
7986
  const Wrapper = row.wrapper;
@@ -13394,4 +13410,4 @@ Object.defineProperty(exports, 'useToast', {
13394
13410
  return useToast;
13395
13411
  }
13396
13412
  });
13397
- //# sourceMappingURL=copilotkit-DjrKQjfL.cjs.map
13413
+ //# sourceMappingURL=copilotkit-CwkkqStB.cjs.map