@copilotkit/react-ui 1.56.0 → 1.56.2-canary.pin-to-send
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 +35 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +38 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +38 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +35 -20
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +36 -20
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/chat/Markdown.tsx +24 -14
- package/src/components/chat/Messages.tsx +3 -3
- package/src/components/chat/index.tsx +2 -0
- package/src/components/dev-console/console.tsx +4 -1
- 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,
|
|
@@ -1396,17 +1397,25 @@ const defaultComponents = {
|
|
|
1396
1397
|
children
|
|
1397
1398
|
})
|
|
1398
1399
|
};
|
|
1399
|
-
const MemoizedReactMarkdown = (0, react.memo)(react_markdown.default
|
|
1400
|
-
const Markdown = ({ content, components }) => {
|
|
1400
|
+
const MemoizedReactMarkdown = (0, react.memo)(react_markdown.default);
|
|
1401
|
+
const Markdown = ({ content, components, remarkPlugins, rehypePlugins, ...rest }) => {
|
|
1402
|
+
const mergedComponents = (0, react.useMemo)(() => ({
|
|
1403
|
+
...defaultComponents,
|
|
1404
|
+
...components
|
|
1405
|
+
}), [components]);
|
|
1406
|
+
const mergedRemarkPlugins = (0, react.useMemo)(() => [
|
|
1407
|
+
remark_gfm.default,
|
|
1408
|
+
[remark_math.default, { singleDollarTextMath: false }],
|
|
1409
|
+
...remarkPlugins ?? []
|
|
1410
|
+
], [remarkPlugins]);
|
|
1411
|
+
const mergedRehypePlugins = (0, react.useMemo)(() => [rehype_raw.default, ...rehypePlugins ?? []], [rehypePlugins]);
|
|
1401
1412
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1402
1413
|
className: "copilotKitMarkdown",
|
|
1403
1414
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedReactMarkdown, {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
remarkPlugins: [remark_gfm.default, [remark_math.default, { singleDollarTextMath: false }]],
|
|
1409
|
-
rehypePlugins: [rehype_raw.default],
|
|
1415
|
+
...rest,
|
|
1416
|
+
components: mergedComponents,
|
|
1417
|
+
remarkPlugins: mergedRemarkPlugins,
|
|
1418
|
+
rehypePlugins: mergedRehypePlugins,
|
|
1410
1419
|
children: content
|
|
1411
1420
|
})
|
|
1412
1421
|
});
|
|
@@ -1701,7 +1710,7 @@ const Messages = ({ inProgress, children, RenderMessage, AssistantMessage, UserM
|
|
|
1701
1710
|
markdownTagRenderers
|
|
1702
1711
|
}, index);
|
|
1703
1712
|
}),
|
|
1704
|
-
messages[messages.length - 1]?.role === "user"
|
|
1713
|
+
inProgress && (messages[messages.length - 1]?.role === "user" || messages[messages.length - 1]?.role === "tool") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LoadingIcon, {}),
|
|
1705
1714
|
interrupt,
|
|
1706
1715
|
chatError && ErrorMessage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorMessage, {
|
|
1707
1716
|
error: chatError,
|
|
@@ -1840,13 +1849,18 @@ const startRecording = async (mediaStreamRef, mediaRecorderRef, audioContextRef,
|
|
|
1840
1849
|
};
|
|
1841
1850
|
mediaRecorderRef.current.onstop = onStop;
|
|
1842
1851
|
};
|
|
1843
|
-
const stopRecording = (mediaRecorderRef) => {
|
|
1852
|
+
const stopRecording = (mediaRecorderRef, mediaStreamRef) => {
|
|
1844
1853
|
if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") mediaRecorderRef.current.stop();
|
|
1854
|
+
if (mediaStreamRef?.current) {
|
|
1855
|
+
mediaStreamRef.current.getTracks().forEach((track) => track.stop());
|
|
1856
|
+
mediaStreamRef.current = null;
|
|
1857
|
+
}
|
|
1845
1858
|
};
|
|
1846
|
-
const transcribeAudio = async (recordedChunks, transcribeAudioUrl) => {
|
|
1847
|
-
const
|
|
1859
|
+
const transcribeAudio = async (recordedChunks, transcribeAudioUrl, mediaType = "audio/mp4") => {
|
|
1860
|
+
const extension = mediaType.split("/")[1] || "mp4";
|
|
1861
|
+
const completeBlob = new Blob(recordedChunks, { type: mediaType });
|
|
1848
1862
|
const formData = new FormData();
|
|
1849
|
-
formData.append("file", completeBlob,
|
|
1863
|
+
formData.append("file", completeBlob, `recording.${extension}`);
|
|
1850
1864
|
const response = await fetch(transcribeAudioUrl, {
|
|
1851
1865
|
method: "POST",
|
|
1852
1866
|
body: formData
|
|
@@ -1865,7 +1879,7 @@ const playAudioResponse = (text, textToSpeechUrl, audioContext) => {
|
|
|
1865
1879
|
console.error("Error with decoding audio data", error);
|
|
1866
1880
|
});
|
|
1867
1881
|
};
|
|
1868
|
-
const usePushToTalk = ({ sendFunction, inProgress }) => {
|
|
1882
|
+
const usePushToTalk = ({ sendFunction, inProgress, mediaType = "audio/mp4" }) => {
|
|
1869
1883
|
const [pushToTalkState, setPushToTalkState] = (0, react.useState)("idle");
|
|
1870
1884
|
const mediaStreamRef = (0, react.useRef)(null);
|
|
1871
1885
|
const audioContextRef = (0, react.useRef)(null);
|
|
@@ -1883,15 +1897,16 @@ const usePushToTalk = ({ sendFunction, inProgress }) => {
|
|
|
1883
1897
|
setPushToTalkState("transcribing");
|
|
1884
1898
|
});
|
|
1885
1899
|
else {
|
|
1886
|
-
stopRecording(mediaRecorderRef);
|
|
1887
|
-
if (pushToTalkState === "transcribing") transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(async (transcription) => {
|
|
1900
|
+
stopRecording(mediaRecorderRef, mediaStreamRef);
|
|
1901
|
+
if (pushToTalkState === "transcribing") transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl, mediaType).then(async (transcription) => {
|
|
1888
1902
|
recordedChunks.current = [];
|
|
1889
1903
|
setPushToTalkState("idle");
|
|
1890
|
-
|
|
1904
|
+
const message = await sendFunction(transcription);
|
|
1905
|
+
if (message) setStartReadingFromMessageId(message.id);
|
|
1891
1906
|
});
|
|
1892
1907
|
}
|
|
1893
1908
|
return () => {
|
|
1894
|
-
stopRecording(mediaRecorderRef);
|
|
1909
|
+
stopRecording(mediaRecorderRef, mediaStreamRef);
|
|
1895
1910
|
};
|
|
1896
1911
|
}, [pushToTalkState]);
|
|
1897
1912
|
(0, react.useEffect)(() => {
|
|
@@ -2969,6 +2984,7 @@ function useCopilotChatSuggestions(config, dependencies = []) {
|
|
|
2969
2984
|
exports.AssistantMessage = AssistantMessage;
|
|
2970
2985
|
exports.CopilotChat = CopilotChat;
|
|
2971
2986
|
exports.CopilotDevConsole = CopilotDevConsole;
|
|
2987
|
+
exports.CopilotModal = CopilotModal;
|
|
2972
2988
|
exports.CopilotPopup = CopilotPopup;
|
|
2973
2989
|
exports.CopilotSidebar = CopilotSidebar;
|
|
2974
2990
|
exports.ImageRenderer = ImageRenderer;
|