@copilotkit/react-core 1.55.3-canary.1776215089 → 1.55.3-canary.1776243725
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-BzVUuD95.mjs → copilotkit-Bm4ox8G0.mjs} +52 -35
- package/dist/copilotkit-Bm4ox8G0.mjs.map +1 -0
- package/dist/{copilotkit-BZuXjQLc.cjs → copilotkit-BoOnQHlE.cjs} +51 -34
- package/dist/copilotkit-BoOnQHlE.cjs.map +1 -0
- package/dist/copilotkit-EfopO2gn.d.cts.map +1 -1
- package/dist/copilotkit-opur-20s.d.mts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +18 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +50 -34
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/copilot-provider/__tests__/error-visibility-prod.test.tsx +70 -0
- package/src/components/copilot-provider/copilot-messages.tsx +39 -24
- package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +18 -15
- package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +17 -4
- package/src/v2/components/chat/CopilotChatUserMessage.tsx +13 -10
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +131 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.tsx +241 -0
- package/dist/copilotkit-BZuXjQLc.cjs.map +0 -1
- package/dist/copilotkit-BzVUuD95.mjs.map +0 -1
|
@@ -4865,11 +4865,8 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
4865
4865
|
useKatexStyles();
|
|
4866
4866
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
4867
4867
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
4868
|
-
if (message.content)
|
|
4869
|
-
|
|
4870
|
-
} catch (err) {
|
|
4871
|
-
console.error("Failed to copy message:", err);
|
|
4872
|
-
}
|
|
4868
|
+
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
4869
|
+
return false;
|
|
4873
4870
|
} });
|
|
4874
4871
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp });
|
|
4875
4872
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown });
|
|
@@ -4967,14 +4964,17 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
4967
4964
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
4968
4965
|
};
|
|
4969
4966
|
}, []);
|
|
4970
|
-
const handleClick = (event) => {
|
|
4971
|
-
|
|
4972
|
-
if (
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4967
|
+
const handleClick = async (event) => {
|
|
4968
|
+
let success = false;
|
|
4969
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
4970
|
+
if (success) {
|
|
4971
|
+
setCopied(true);
|
|
4972
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
4973
|
+
timerRef.current = setTimeout(() => {
|
|
4974
|
+
timerRef.current = null;
|
|
4975
|
+
setCopied(false);
|
|
4976
|
+
}, 2e3);
|
|
4977
|
+
}
|
|
4978
4978
|
};
|
|
4979
4979
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
4980
4980
|
"data-testid": "copilot-copy-button",
|
|
@@ -5127,11 +5127,8 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
5127
5127
|
const mediaParts = (0, react.useMemo)(() => getMediaParts(message.content), [message.content]);
|
|
5128
5128
|
const BoundMessageRenderer = renderSlot(messageRenderer, CopilotChatUserMessage.MessageRenderer, { content: flattenedContent });
|
|
5129
5129
|
const BoundCopyButton = renderSlot(copyButton, CopilotChatUserMessage.CopyButton, { onClick: async () => {
|
|
5130
|
-
if (flattenedContent)
|
|
5131
|
-
|
|
5132
|
-
} catch (err) {
|
|
5133
|
-
console.error("Failed to copy message:", err);
|
|
5134
|
-
}
|
|
5130
|
+
if (flattenedContent) return await (0, _copilotkit_shared.copyToClipboard)(flattenedContent);
|
|
5131
|
+
return false;
|
|
5135
5132
|
} });
|
|
5136
5133
|
const BoundEditButton = renderSlot(editButton, CopilotChatUserMessage.EditButton, { onClick: () => onEditMessage?.({ message }) });
|
|
5137
5134
|
const BoundBranchNavigation = renderSlot(branchNavigation, CopilotChatUserMessage.BranchNavigation, {
|
|
@@ -5219,10 +5216,13 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
5219
5216
|
_CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
5220
5217
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
5221
5218
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
5222
|
-
const handleClick = (event) => {
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
if (
|
|
5219
|
+
const handleClick = async (event) => {
|
|
5220
|
+
let success = false;
|
|
5221
|
+
if (onClick) success = await Promise.resolve(onClick(event)) === true;
|
|
5222
|
+
if (success) {
|
|
5223
|
+
setCopied(true);
|
|
5224
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
5225
|
+
}
|
|
5226
5226
|
};
|
|
5227
5227
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
5228
5228
|
"data-testid": "copilot-user-copy-button",
|
|
@@ -5329,17 +5329,24 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, header, con
|
|
|
5329
5329
|
return () => clearInterval(timer);
|
|
5330
5330
|
}, [isStreaming]);
|
|
5331
5331
|
const [isOpen, setIsOpen] = (0, react.useState)(isStreaming);
|
|
5332
|
+
const userToggledRef = (0, react.useRef)(false);
|
|
5332
5333
|
(0, react.useEffect)(() => {
|
|
5333
|
-
if (isStreaming)
|
|
5334
|
-
|
|
5334
|
+
if (isStreaming) {
|
|
5335
|
+
userToggledRef.current = false;
|
|
5336
|
+
setIsOpen(true);
|
|
5337
|
+
} else if (!userToggledRef.current) setIsOpen(false);
|
|
5335
5338
|
}, [isStreaming]);
|
|
5339
|
+
const handleToggle = hasContent ? () => {
|
|
5340
|
+
userToggledRef.current = true;
|
|
5341
|
+
setIsOpen((prev) => !prev);
|
|
5342
|
+
} : void 0;
|
|
5336
5343
|
const label = isStreaming ? "Thinking…" : `Thought for ${formatDuration(elapsed)}`;
|
|
5337
5344
|
const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
|
|
5338
5345
|
isOpen,
|
|
5339
5346
|
label,
|
|
5340
5347
|
hasContent,
|
|
5341
5348
|
isStreaming,
|
|
5342
|
-
onClick:
|
|
5349
|
+
onClick: handleToggle
|
|
5343
5350
|
});
|
|
5344
5351
|
const boundContent = renderSlot(contentView, CopilotChatReasoningMessage.Content, {
|
|
5345
5352
|
isStreaming,
|
|
@@ -8043,6 +8050,20 @@ function shouldShowDevConsole(showDevConsole) {
|
|
|
8043
8050
|
/**
|
|
8044
8051
|
* An internal context to separate the messages state (which is constantly changing) from the rest of CopilotKit context
|
|
8045
8052
|
*/
|
|
8053
|
+
/**
|
|
8054
|
+
* Determine whether a GraphQL error should be suppressed based on its visibility
|
|
8055
|
+
* and whether the dev console is active.
|
|
8056
|
+
*
|
|
8057
|
+
* Returns `null` when the error should be surfaced to the UI, or a log prefix
|
|
8058
|
+
* string when the error should be suppressed (logged to console only).
|
|
8059
|
+
*
|
|
8060
|
+
* Exported for unit testing.
|
|
8061
|
+
*/
|
|
8062
|
+
function getErrorSuppression(visibility, isDev) {
|
|
8063
|
+
if (visibility === _copilotkit_shared.ErrorVisibility.SILENT) return "CopilotKit Silent Error:";
|
|
8064
|
+
if (!isDev && visibility === _copilotkit_shared.ErrorVisibility.DEV_ONLY) return "CopilotKit Error (hidden in production):";
|
|
8065
|
+
return null;
|
|
8066
|
+
}
|
|
8046
8067
|
const MessagesTapContext = (0, react.createContext)(null);
|
|
8047
8068
|
function useMessagesTap() {
|
|
8048
8069
|
const tap = (0, react.useContext)(MessagesTapContext);
|
|
@@ -8126,12 +8147,9 @@ function CopilotMessages({ children }) {
|
|
|
8126
8147
|
const graphQLErrors = error.graphQLErrors;
|
|
8127
8148
|
const routeError = (gqlError) => {
|
|
8128
8149
|
const visibility = gqlError.extensions?.visibility;
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
}
|
|
8133
|
-
if (visibility === _copilotkit_shared.ErrorVisibility.SILENT) {
|
|
8134
|
-
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
8150
|
+
const suppression = getErrorSuppression(visibility, shouldShowDevConsole(showDevConsole));
|
|
8151
|
+
if (suppression) {
|
|
8152
|
+
console.error(suppression, gqlError.message);
|
|
8135
8153
|
return;
|
|
8136
8154
|
}
|
|
8137
8155
|
const ckError = createStructuredError(gqlError);
|
|
@@ -8148,8 +8166,7 @@ function CopilotMessages({ children }) {
|
|
|
8148
8166
|
}
|
|
8149
8167
|
};
|
|
8150
8168
|
graphQLErrors.forEach(routeError);
|
|
8151
|
-
} else
|
|
8152
|
-
else {
|
|
8169
|
+
} else {
|
|
8153
8170
|
const fallbackError = new _copilotkit_shared.CopilotKitError({
|
|
8154
8171
|
message: error?.message || String(error),
|
|
8155
8172
|
code: _copilotkit_shared.CopilotKitErrorCode.UNKNOWN
|
|
@@ -9982,4 +9999,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
9982
9999
|
return useToast;
|
|
9983
10000
|
}
|
|
9984
10001
|
});
|
|
9985
|
-
//# sourceMappingURL=copilotkit-
|
|
10002
|
+
//# sourceMappingURL=copilotkit-BoOnQHlE.cjs.map
|