@copilotkit/react-core 1.71.2 → 1.72.1-canary.sp-longthread-perf
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-qK-Q3rmE.mjs → copilotkit-B2TZRWwp.mjs} +80 -26
- package/dist/copilotkit-B2TZRWwp.mjs.map +1 -0
- package/dist/{copilotkit-DsMFLrpY.d.mts → copilotkit-BRPxLJnI.d.mts} +3 -3
- package/dist/{copilotkit-DsMFLrpY.d.mts.map → copilotkit-BRPxLJnI.d.mts.map} +1 -1
- package/dist/{copilotkit-gopQXrTQ.cjs → copilotkit-BV7MguMm.cjs} +80 -26
- package/dist/copilotkit-BV7MguMm.cjs.map +1 -0
- package/dist/{copilotkit-DoHSqB_u.d.cts → copilotkit-D5fPO8hJ.d.cts} +3 -3
- package/dist/{copilotkit-DoHSqB_u.d.cts.map → copilotkit-D5fPO8hJ.d.cts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +9 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +79 -25
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +9 -9
- package/dist/copilotkit-gopQXrTQ.cjs.map +0 -1
- package/dist/copilotkit-qK-Q3rmE.mjs.map +0 -1
|
@@ -3825,8 +3825,8 @@ function useRenderCustomMessages() {
|
|
|
3825
3825
|
if (aHasAgent === (b.agentId !== void 0)) return 0;
|
|
3826
3826
|
return aHasAgent ? -1 : 1;
|
|
3827
3827
|
});
|
|
3828
|
+
if (!customMessageRenderers.length) return null;
|
|
3828
3829
|
return function(params) {
|
|
3829
|
-
if (!customMessageRenderers.length) return null;
|
|
3830
3830
|
const { message, position } = params;
|
|
3831
3831
|
const resolvedRunId = copilotkit.getRunIdForMessage(agentId, threadId, message.id) ?? copilotkit.getRunIdsForThread(agentId, threadId).slice(-1)[0];
|
|
3832
3832
|
const runId = resolvedRunId ?? `missing-run-id:${message.id}`;
|
|
@@ -6999,6 +6999,32 @@ CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
|
|
|
6999
6999
|
*/
|
|
7000
7000
|
const ScrollElementContext = React.createContext(null);
|
|
7001
7001
|
|
|
7002
|
+
//#endregion
|
|
7003
|
+
//#region src/v2/components/chat/scroll-pinned-context.ts
|
|
7004
|
+
/**
|
|
7005
|
+
* True while the pin-to-bottom behaviour is actively following the bottom of
|
|
7006
|
+
* the thread — i.e. `use-stick-to-bottom` will animate the scroll position to
|
|
7007
|
+
* the bottom the next time the content grows.
|
|
7008
|
+
*
|
|
7009
|
+
* Only CopilotChatView's pin-to-bottom branch provides this. The other scroll
|
|
7010
|
+
* modes leave it `false`, which is correct: nothing else writes the scroll
|
|
7011
|
+
* position on its own, so no one is competing with the virtualizer.
|
|
7012
|
+
*
|
|
7013
|
+
* Why this exists: the virtualizer and `use-stick-to-bottom` both write
|
|
7014
|
+
* `scrollTop` on the same element. The virtualizer writes it to compensate
|
|
7015
|
+
* when a row above the viewport turns out taller than its estimate, so that
|
|
7016
|
+
* what the reader is looking at does not shift. That compensation is essential
|
|
7017
|
+
* while the reader is scrolled up — and pointless while pinned to the bottom,
|
|
7018
|
+
* because the pin is about to move the scroll position anyway. Worse than
|
|
7019
|
+
* pointless: the compensation changes the virtual container's height, the pin
|
|
7020
|
+
* reads that as content growth and animates, the animation brings unmeasured
|
|
7021
|
+
* rows into view, they measure, and the two keep shoving each other.
|
|
7022
|
+
*
|
|
7023
|
+
* Consumed by CopilotChatMessageView to stand the virtualizer down while the
|
|
7024
|
+
* pin owns the scroll position.
|
|
7025
|
+
*/
|
|
7026
|
+
const ScrollPinnedContext = React.createContext(false);
|
|
7027
|
+
|
|
7002
7028
|
//#endregion
|
|
7003
7029
|
//#region src/v2/components/intelligence-indicator/IntelligenceIndicatorView.tsx
|
|
7004
7030
|
/**
|
|
@@ -7464,6 +7490,7 @@ function deduplicateMessages(messages) {
|
|
|
7464
7490
|
}
|
|
7465
7491
|
const VIRTUALIZE_THRESHOLD = 50;
|
|
7466
7492
|
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, isRunning = false, children, className, ...props }) {
|
|
7493
|
+
const isPinnedToBottom = useContext(ScrollPinnedContext);
|
|
7467
7494
|
const renderCustomMessage = useRenderCustomMessages();
|
|
7468
7495
|
const { renderActivityMessage } = useRenderActivityMessage();
|
|
7469
7496
|
const { copilotkit } = useCopilotKit$1();
|
|
@@ -7529,17 +7556,36 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7529
7556
|
if (process.env.NODE_ENV !== "production" && scrollElementFromCtx && scrollElementFromCtx.clientHeight === 0) console.warn("[CopilotKit] Chat scroll container has clientHeight=0 — virtualization disabled. Ensure the chat is rendered in a visible container with a non-zero height.");
|
|
7530
7557
|
}, [scrollElementFromCtx]);
|
|
7531
7558
|
const shouldVirtualize = !!scrollElement && !children && deduplicatedMessages.length > VIRTUALIZE_THRESHOLD;
|
|
7559
|
+
const measuredRef = React.useRef({
|
|
7560
|
+
count: 0,
|
|
7561
|
+
total: 0
|
|
7562
|
+
});
|
|
7563
|
+
const isPinnedToBottomRef = React.useRef(isPinnedToBottom);
|
|
7564
|
+
const shouldAdjustScrollOnResize = React.useCallback(() => !isPinnedToBottomRef.current, []);
|
|
7565
|
+
const estimateRowSize = React.useCallback(() => {
|
|
7566
|
+
const { count, total } = measuredRef.current;
|
|
7567
|
+
return count > 0 ? Math.max(1, Math.round(total / count)) : 100;
|
|
7568
|
+
}, []);
|
|
7532
7569
|
const virtualizer = useVirtualizer({
|
|
7533
7570
|
count: shouldVirtualize ? deduplicatedMessages.length : 0,
|
|
7534
7571
|
getScrollElement: () => scrollElement,
|
|
7535
|
-
estimateSize:
|
|
7572
|
+
estimateSize: estimateRowSize,
|
|
7536
7573
|
overscan: 5,
|
|
7537
|
-
measureElement: (el) =>
|
|
7574
|
+
measureElement: (el) => {
|
|
7575
|
+
const height = el?.getBoundingClientRect().height ?? 0;
|
|
7576
|
+
if (height > 0) {
|
|
7577
|
+
measuredRef.current.count += 1;
|
|
7578
|
+
measuredRef.current.total += height;
|
|
7579
|
+
}
|
|
7580
|
+
return height;
|
|
7581
|
+
},
|
|
7538
7582
|
initialRect: {
|
|
7539
7583
|
width: 0,
|
|
7540
7584
|
height: 600
|
|
7541
7585
|
}
|
|
7542
7586
|
});
|
|
7587
|
+
isPinnedToBottomRef.current = isPinnedToBottom;
|
|
7588
|
+
virtualizer.shouldAdjustScrollPositionOnItemSizeChange = shouldAdjustScrollOnResize;
|
|
7543
7589
|
const firstMessageId = deduplicatedMessages[0]?.id;
|
|
7544
7590
|
useLayoutEffect(() => {
|
|
7545
7591
|
if (!shouldVirtualize || !deduplicatedMessages.length) return;
|
|
@@ -7548,7 +7594,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7548
7594
|
const intelligenceTurnAnchors = useMemo(() => getIntelligenceTurnAnchors(deduplicatedMessages), [deduplicatedMessages]);
|
|
7549
7595
|
const renderMessageBlock = (message) => {
|
|
7550
7596
|
const elements = [];
|
|
7551
|
-
const stateSnapshot = getStateSnapshotForMessage(message.id);
|
|
7597
|
+
const stateSnapshot = renderCustomMessage ? getStateSnapshotForMessage(message.id) : void 0;
|
|
7552
7598
|
if (renderCustomMessage) elements.push(/* @__PURE__ */ jsx(MemoizedCustomMessage, {
|
|
7553
7599
|
message,
|
|
7554
7600
|
position: "before",
|
|
@@ -8192,25 +8238,28 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
8192
8238
|
const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
|
|
8193
8239
|
return /* @__PURE__ */ jsx(ScrollElementContext.Provider, {
|
|
8194
8240
|
value: scrollEl,
|
|
8195
|
-
children: /* @__PURE__ */
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
children
|
|
8241
|
+
children: /* @__PURE__ */ jsx(ScrollPinnedContext.Provider, {
|
|
8242
|
+
value: isAtBottom,
|
|
8243
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
8244
|
+
/* @__PURE__ */ jsx(StickToBottom.Content, {
|
|
8245
|
+
className: "cpk:overflow-y-auto cpk:overflow-x-hidden",
|
|
8246
|
+
style: {
|
|
8247
|
+
flex: "1 1 0%",
|
|
8248
|
+
minHeight: 0
|
|
8249
|
+
},
|
|
8250
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
8251
|
+
className: "cpk:px-4 cpk:@3xl:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
|
|
8252
|
+
children
|
|
8253
|
+
})
|
|
8254
|
+
}),
|
|
8255
|
+
BoundFeather,
|
|
8256
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ jsx("div", {
|
|
8257
|
+
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
8258
|
+
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
8259
|
+
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
8205
8260
|
})
|
|
8206
|
-
})
|
|
8207
|
-
|
|
8208
|
-
!isAtBottom && !isResizing && /* @__PURE__ */ jsx("div", {
|
|
8209
|
-
className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
|
|
8210
|
-
style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
|
|
8211
|
-
children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
|
|
8212
|
-
})
|
|
8213
|
-
] })
|
|
8261
|
+
] })
|
|
8262
|
+
})
|
|
8214
8263
|
});
|
|
8215
8264
|
};
|
|
8216
8265
|
const PinToSendScrollContainer = ({ children, scrollRef, contentRef, scrollToBottom, scrollToBottomButton, feather, inputContainerHeight, isResizing, nonAutoScrollEl, nonAutoScrollRefCallback, showScrollButton, className, ...props }) => {
|
|
@@ -11944,6 +11993,7 @@ function CopilotKitErrorBridge() {
|
|
|
11944
11993
|
}
|
|
11945
11994
|
function CopilotKitInternal(cpkProps) {
|
|
11946
11995
|
const { children, ...props } = cpkProps;
|
|
11996
|
+
const { copilotkit } = useCopilotKit$1();
|
|
11947
11997
|
/**
|
|
11948
11998
|
* This will throw an error if the props are invalid.
|
|
11949
11999
|
*/
|
|
@@ -11979,10 +12029,14 @@ function CopilotKitInternal(cpkProps) {
|
|
|
11979
12029
|
});
|
|
11980
12030
|
}, []);
|
|
11981
12031
|
const getContextString = useCallback((documents, categories) => {
|
|
11982
|
-
|
|
12032
|
+
const documentsString = documents.map((document) => {
|
|
11983
12033
|
return `${document.name} (${document.sourceApplication}):\n${document.getContents()}`;
|
|
11984
|
-
}).join("\n\n")
|
|
11985
|
-
|
|
12034
|
+
}).join("\n\n");
|
|
12035
|
+
const nonDocumentStrings = printTree(categories);
|
|
12036
|
+
const readableContextString = copilotkit.getContextForAgent().map(({ description, value }) => `${description}:\n${value}`).join("\n\n");
|
|
12037
|
+
const existingContextString = `${documentsString}\n\n${nonDocumentStrings}`;
|
|
12038
|
+
return readableContextString ? `${existingContextString}\n\n${readableContextString}` : existingContextString;
|
|
12039
|
+
}, [copilotkit, printTree]);
|
|
11986
12040
|
const addContext = useCallback((context, parentId, categories = defaultCopilotContextCategories) => {
|
|
11987
12041
|
return addElement(context, categories, parentId);
|
|
11988
12042
|
}, [addElement]);
|
|
@@ -12367,4 +12421,4 @@ function validateProps(props) {
|
|
|
12367
12421
|
|
|
12368
12422
|
//#endregion
|
|
12369
12423
|
export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
|
|
12370
|
-
//# sourceMappingURL=copilotkit-
|
|
12424
|
+
//# sourceMappingURL=copilotkit-B2TZRWwp.mjs.map
|