@copilotkit/react-ui 1.55.3 → 1.56.1
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 +32 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +27 -20
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +36 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +36 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +33 -29
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +33 -28
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/chat/Markdown.test.ts +101 -0
- package/src/components/chat/Markdown.tsx +11 -5
- package/src/components/chat/Messages.tsx +3 -3
- package/src/components/chat/index.tsx +2 -0
- package/src/components/chat/messages/AssistantMessage.tsx +7 -8
- package/src/components/chat/messages/ErrorMessage.tsx +7 -8
- package/src/components/dev-console/console.tsx +9 -5
- package/src/css/colors.css +1 -1
- package/src/css/console.css +16 -10
- package/src/css/input.css +5 -5
- package/src/css/markdown.css +3 -3
- package/src/css/messages.css +2 -1
- package/src/hooks/__tests__/use-push-to-talk.test.ts +49 -0
- package/src/hooks/use-push-to-talk.tsx +19 -6
package/dist/index.cjs
CHANGED
|
@@ -793,10 +793,11 @@ function CopilotDevConsole() {
|
|
|
793
793
|
});
|
|
794
794
|
};
|
|
795
795
|
(0, react.useEffect)(() => {
|
|
796
|
+
if (!showDevConsole) return;
|
|
796
797
|
if (dontRunTwiceInDevMode.current === true) return;
|
|
797
798
|
dontRunTwiceInDevMode.current = true;
|
|
798
799
|
checkForUpdates();
|
|
799
|
-
}, []);
|
|
800
|
+
}, [showDevConsole]);
|
|
800
801
|
if (!showDevConsole) return null;
|
|
801
802
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
802
803
|
ref: consoleRef,
|
|
@@ -838,11 +839,11 @@ function VersionInfo({ showDevConsole, versionStatus, currentVersion, latestVers
|
|
|
838
839
|
`@copilotkit/react-textarea@${latestVersion}`,
|
|
839
840
|
`&& npm install @copilotkit/runtime@${latestVersion}`
|
|
840
841
|
].join(" ");
|
|
841
|
-
const handleCopyClick = () => {
|
|
842
|
-
|
|
842
|
+
const handleCopyClick = async () => {
|
|
843
|
+
if (await (0, _copilotkit_shared.copyToClipboard)(installCommand.trim())) {
|
|
843
844
|
setCopyStatus("Command copied to clipboard!");
|
|
844
845
|
setTimeout(() => setCopyStatus(""), 1e3);
|
|
845
|
-
}
|
|
846
|
+
}
|
|
846
847
|
};
|
|
847
848
|
if (versionStatus === "update-available" || versionStatus === "outdated") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
848
849
|
className: "copilotKitVersionInfo",
|
|
@@ -1338,7 +1339,7 @@ const defaultComponents = {
|
|
|
1338
1339
|
language: match && match[1] || "",
|
|
1339
1340
|
value: String(children).replace(/\n$/, ""),
|
|
1340
1341
|
...props
|
|
1341
|
-
}
|
|
1342
|
+
});
|
|
1342
1343
|
},
|
|
1343
1344
|
h1: ({ children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
1344
1345
|
className: "copilotKitMarkdownElement",
|
|
@@ -1370,8 +1371,8 @@ const defaultComponents = {
|
|
|
1370
1371
|
...props,
|
|
1371
1372
|
children
|
|
1372
1373
|
}),
|
|
1373
|
-
p: ({ children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
1374
|
-
className: "copilotKitMarkdownElement",
|
|
1374
|
+
p: ({ children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1375
|
+
className: "copilotKitMarkdownElement copilotKitParagraph",
|
|
1375
1376
|
...props,
|
|
1376
1377
|
children
|
|
1377
1378
|
}),
|
|
@@ -1396,8 +1397,8 @@ const defaultComponents = {
|
|
|
1396
1397
|
children
|
|
1397
1398
|
})
|
|
1398
1399
|
};
|
|
1399
|
-
const MemoizedReactMarkdown = (0, react.memo)(react_markdown.default, (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components);
|
|
1400
|
-
const Markdown = ({ content, components }) => {
|
|
1400
|
+
const MemoizedReactMarkdown = (0, react.memo)(react_markdown.default, (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components && prevProps.urlTransform === nextProps.urlTransform);
|
|
1401
|
+
const Markdown = ({ content, components, urlTransform }) => {
|
|
1401
1402
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1402
1403
|
className: "copilotKitMarkdown",
|
|
1403
1404
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedReactMarkdown, {
|
|
@@ -1407,6 +1408,7 @@ const Markdown = ({ content, components }) => {
|
|
|
1407
1408
|
}), [components]),
|
|
1408
1409
|
remarkPlugins: [remark_gfm.default, [remark_math.default, { singleDollarTextMath: false }]],
|
|
1409
1410
|
rehypePlugins: [rehype_raw.default],
|
|
1411
|
+
...urlTransform !== void 0 ? { urlTransform } : {},
|
|
1410
1412
|
children: content
|
|
1411
1413
|
})
|
|
1412
1414
|
});
|
|
@@ -1418,16 +1420,12 @@ const AssistantMessage = (props) => {
|
|
|
1418
1420
|
const { icons, labels } = useChatContext();
|
|
1419
1421
|
const { message, isLoading, onRegenerate, onCopy, onThumbsUp, onThumbsDown, isCurrentMessage, feedback, markdownTagRenderers } = props;
|
|
1420
1422
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
1421
|
-
const handleCopy = () => {
|
|
1423
|
+
const handleCopy = async () => {
|
|
1422
1424
|
const content = message?.content || "";
|
|
1423
|
-
if (content
|
|
1424
|
-
|
|
1425
|
-
setCopied(true);
|
|
1426
|
-
onCopy(content);
|
|
1427
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1428
|
-
} else if (content) {
|
|
1429
|
-
navigator.clipboard.writeText(content);
|
|
1425
|
+
if (!content) return;
|
|
1426
|
+
if (await (0, _copilotkit_shared.copyToClipboard)(content)) {
|
|
1430
1427
|
setCopied(true);
|
|
1428
|
+
if (onCopy) onCopy(content);
|
|
1431
1429
|
setTimeout(() => setCopied(false), 2e3);
|
|
1432
1430
|
}
|
|
1433
1431
|
};
|
|
@@ -1705,7 +1703,7 @@ const Messages = ({ inProgress, children, RenderMessage, AssistantMessage, UserM
|
|
|
1705
1703
|
markdownTagRenderers
|
|
1706
1704
|
}, index);
|
|
1707
1705
|
}),
|
|
1708
|
-
messages[messages.length - 1]?.role === "user"
|
|
1706
|
+
inProgress && (messages[messages.length - 1]?.role === "user" || messages[messages.length - 1]?.role === "tool") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LoadingIcon, {}),
|
|
1709
1707
|
interrupt,
|
|
1710
1708
|
chatError && ErrorMessage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
1711
1709
|
error: chatError,
|
|
@@ -1844,13 +1842,18 @@ const startRecording = async (mediaStreamRef, mediaRecorderRef, audioContextRef,
|
|
|
1844
1842
|
};
|
|
1845
1843
|
mediaRecorderRef.current.onstop = onStop;
|
|
1846
1844
|
};
|
|
1847
|
-
const stopRecording = (mediaRecorderRef) => {
|
|
1845
|
+
const stopRecording = (mediaRecorderRef, mediaStreamRef) => {
|
|
1848
1846
|
if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") mediaRecorderRef.current.stop();
|
|
1847
|
+
if (mediaStreamRef?.current) {
|
|
1848
|
+
mediaStreamRef.current.getTracks().forEach((track) => track.stop());
|
|
1849
|
+
mediaStreamRef.current = null;
|
|
1850
|
+
}
|
|
1849
1851
|
};
|
|
1850
|
-
const transcribeAudio = async (recordedChunks, transcribeAudioUrl) => {
|
|
1851
|
-
const
|
|
1852
|
+
const transcribeAudio = async (recordedChunks, transcribeAudioUrl, mediaType = "audio/mp4") => {
|
|
1853
|
+
const extension = mediaType.split("/")[1] || "mp4";
|
|
1854
|
+
const completeBlob = new Blob(recordedChunks, { type: mediaType });
|
|
1852
1855
|
const formData = new FormData();
|
|
1853
|
-
formData.append("file", completeBlob,
|
|
1856
|
+
formData.append("file", completeBlob, `recording.${extension}`);
|
|
1854
1857
|
const response = await fetch(transcribeAudioUrl, {
|
|
1855
1858
|
method: "POST",
|
|
1856
1859
|
body: formData
|
|
@@ -1869,7 +1872,7 @@ const playAudioResponse = (text, textToSpeechUrl, audioContext) => {
|
|
|
1869
1872
|
console.error("Error with decoding audio data", error);
|
|
1870
1873
|
});
|
|
1871
1874
|
};
|
|
1872
|
-
const usePushToTalk = ({ sendFunction, inProgress }) => {
|
|
1875
|
+
const usePushToTalk = ({ sendFunction, inProgress, mediaType = "audio/mp4" }) => {
|
|
1873
1876
|
const [pushToTalkState, setPushToTalkState] = (0, react.useState)("idle");
|
|
1874
1877
|
const mediaStreamRef = (0, react.useRef)(null);
|
|
1875
1878
|
const audioContextRef = (0, react.useRef)(null);
|
|
@@ -1887,15 +1890,16 @@ const usePushToTalk = ({ sendFunction, inProgress }) => {
|
|
|
1887
1890
|
setPushToTalkState("transcribing");
|
|
1888
1891
|
});
|
|
1889
1892
|
else {
|
|
1890
|
-
stopRecording(mediaRecorderRef);
|
|
1891
|
-
if (pushToTalkState === "transcribing") transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(async (transcription) => {
|
|
1893
|
+
stopRecording(mediaRecorderRef, mediaStreamRef);
|
|
1894
|
+
if (pushToTalkState === "transcribing") transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl, mediaType).then(async (transcription) => {
|
|
1892
1895
|
recordedChunks.current = [];
|
|
1893
1896
|
setPushToTalkState("idle");
|
|
1894
|
-
|
|
1897
|
+
const message = await sendFunction(transcription);
|
|
1898
|
+
if (message) setStartReadingFromMessageId(message.id);
|
|
1895
1899
|
});
|
|
1896
1900
|
}
|
|
1897
1901
|
return () => {
|
|
1898
|
-
stopRecording(mediaRecorderRef);
|
|
1902
|
+
stopRecording(mediaRecorderRef, mediaStreamRef);
|
|
1899
1903
|
};
|
|
1900
1904
|
}, [pushToTalkState]);
|
|
1901
1905
|
(0, react.useEffect)(() => {
|
|
@@ -2973,6 +2977,7 @@ function useCopilotChatSuggestions(config, dependencies = []) {
|
|
|
2973
2977
|
exports.AssistantMessage = AssistantMessage;
|
|
2974
2978
|
exports.CopilotChat = CopilotChat;
|
|
2975
2979
|
exports.CopilotDevConsole = CopilotDevConsole;
|
|
2980
|
+
exports.CopilotModal = CopilotModal;
|
|
2976
2981
|
exports.CopilotPopup = CopilotPopup;
|
|
2977
2982
|
exports.CopilotSidebar = CopilotSidebar;
|
|
2978
2983
|
exports.ImageRenderer = ImageRenderer;
|