@copilotkit/react-ui 1.51.3-next.5 → 1.51.3-next.6
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/CHANGELOG.md +8 -0
- package/dist/{chunk-PKSW6ZMQ.mjs → chunk-7OURDQZJ.mjs} +2 -2
- package/dist/{chunk-HKZL4P3F.mjs → chunk-BVKKSSB2.mjs} +4 -4
- package/dist/{chunk-4S4ZEKE6.mjs → chunk-DI7DDMRS.mjs} +2 -2
- package/dist/{chunk-UH5GQ7QF.mjs → chunk-HIW7RXCD.mjs} +2 -2
- package/dist/{chunk-SLM2AOHF.mjs → chunk-IHFR6PYG.mjs} +2 -2
- package/dist/{chunk-XOBQLKUU.mjs → chunk-JZ3RFQQ6.mjs} +13 -3
- package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
- package/dist/{chunk-XEZ5ODJS.mjs → chunk-NCIAFFQ2.mjs} +2 -2
- package/dist/{chunk-YQOESY4Y.mjs → chunk-NSJWSIPR.mjs} +4 -4
- package/dist/{chunk-O4PPO3K3.mjs → chunk-VVCCMYGT.mjs} +2 -2
- package/dist/components/chat/Chat.js +67 -57
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +6 -6
- package/dist/components/chat/Markdown.d.ts +2 -4
- package/dist/components/chat/Markdown.js +12 -2
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +1 -1
- package/dist/components/chat/Messages.js +27 -17
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -5
- package/dist/components/chat/Modal.js +74 -64
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +7 -7
- package/dist/components/chat/Popup.js +74 -64
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +8 -8
- package/dist/components/chat/Sidebar.js +76 -66
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +8 -8
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +76 -66
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +9 -9
- package/dist/components/chat/messages/AssistantMessage.js +14 -4
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
- package/dist/components/chat/messages/ErrorMessage.js +14 -4
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
- package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.js +16 -6
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
- package/dist/components/chat/messages/RenderMessage.js +16 -6
- package/dist/components/chat/messages/RenderMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderMessage.mjs +3 -3
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +76 -66
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +76 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/package.json +8 -5
- package/src/components/chat/Markdown.tsx +17 -8
- package/dist/chunk-XOBQLKUU.mjs.map +0 -1
- /package/dist/{chunk-PKSW6ZMQ.mjs.map → chunk-7OURDQZJ.mjs.map} +0 -0
- /package/dist/{chunk-HKZL4P3F.mjs.map → chunk-BVKKSSB2.mjs.map} +0 -0
- /package/dist/{chunk-4S4ZEKE6.mjs.map → chunk-DI7DDMRS.mjs.map} +0 -0
- /package/dist/{chunk-UH5GQ7QF.mjs.map → chunk-HIW7RXCD.mjs.map} +0 -0
- /package/dist/{chunk-SLM2AOHF.mjs.map → chunk-IHFR6PYG.mjs.map} +0 -0
- /package/dist/{chunk-XEZ5ODJS.mjs.map → chunk-NCIAFFQ2.mjs.map} +0 -0
- /package/dist/{chunk-YQOESY4Y.mjs.map → chunk-NSJWSIPR.mjs.map} +0 -0
- /package/dist/{chunk-O4PPO3K3.mjs.map → chunk-VVCCMYGT.mjs.map} +0 -0
|
@@ -3,11 +3,11 @@ import "../chunk-SC6JRFAJ.mjs";
|
|
|
3
3
|
import "../chunk-WB3YULQ4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CopilotPopup
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-VVCCMYGT.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotSidebar
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-DI7DDMRS.mjs";
|
|
10
|
+
import "../chunk-BVKKSSB2.mjs";
|
|
11
11
|
import "../chunk-C3GSYRC3.mjs";
|
|
12
12
|
import "../chunk-GDSZGYCE.mjs";
|
|
13
13
|
import "../chunk-V7W6IM2V.mjs";
|
|
@@ -24,7 +24,7 @@ import "../chunk-BH6PCAAL.mjs";
|
|
|
24
24
|
import "../chunk-UFN2VWSR.mjs";
|
|
25
25
|
import {
|
|
26
26
|
CopilotChat
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-NSJWSIPR.mjs";
|
|
28
28
|
import {
|
|
29
29
|
Suggestions
|
|
30
30
|
} from "../chunk-VHKHX7GV.mjs";
|
|
@@ -35,12 +35,12 @@ import "../chunk-PLHTVHUW.mjs";
|
|
|
35
35
|
import "../chunk-3W6J75HS.mjs";
|
|
36
36
|
import "../chunk-ELGRNEAO.mjs";
|
|
37
37
|
import "../chunk-QIOJXTIQ.mjs";
|
|
38
|
-
import "../chunk-
|
|
39
|
-
import "../chunk-
|
|
40
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-HIW7RXCD.mjs";
|
|
39
|
+
import "../chunk-7OURDQZJ.mjs";
|
|
40
|
+
import "../chunk-NCIAFFQ2.mjs";
|
|
41
41
|
import {
|
|
42
42
|
AssistantMessage
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-IHFR6PYG.mjs";
|
|
44
44
|
import {
|
|
45
45
|
ImageRenderer
|
|
46
46
|
} from "../chunk-DBKRAOH7.mjs";
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
} from "../chunk-RYUCX3ZK.mjs";
|
|
50
50
|
import {
|
|
51
51
|
Markdown
|
|
52
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-JZ3RFQQ6.mjs";
|
|
53
53
|
import "../chunk-IK2BPURM.mjs";
|
|
54
54
|
import {
|
|
55
55
|
useChatContext
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -97,7 +97,7 @@ __export(src_exports, {
|
|
|
97
97
|
module.exports = __toCommonJS(src_exports);
|
|
98
98
|
|
|
99
99
|
// src/components/chat/Modal.tsx
|
|
100
|
-
var
|
|
100
|
+
var import_react16 = __toESM(require("react"));
|
|
101
101
|
|
|
102
102
|
// src/components/chat/ChatContext.tsx
|
|
103
103
|
var import_react = __toESM(require("react"));
|
|
@@ -1038,7 +1038,7 @@ var Header = ({}) => {
|
|
|
1038
1038
|
};
|
|
1039
1039
|
|
|
1040
1040
|
// src/components/chat/Messages.tsx
|
|
1041
|
-
var
|
|
1041
|
+
var import_react10 = require("react");
|
|
1042
1042
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1043
1043
|
|
|
1044
1044
|
// src/components/chat/messages/UserMessage.tsx
|
|
@@ -1070,7 +1070,8 @@ var UserMessage = (props) => {
|
|
|
1070
1070
|
};
|
|
1071
1071
|
|
|
1072
1072
|
// src/components/chat/Markdown.tsx
|
|
1073
|
-
var
|
|
1073
|
+
var import_react7 = require("react");
|
|
1074
|
+
var import_react_markdown = __toESM(require("react-markdown"));
|
|
1074
1075
|
|
|
1075
1076
|
// src/components/chat/CodeBlock.tsx
|
|
1076
1077
|
var import_react6 = require("react");
|
|
@@ -1482,6 +1483,9 @@ var highlightStyle = {
|
|
|
1482
1483
|
};
|
|
1483
1484
|
|
|
1484
1485
|
// src/components/chat/Markdown.tsx
|
|
1486
|
+
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
1487
|
+
var import_remark_math = __toESM(require("remark-math"));
|
|
1488
|
+
var import_rehype_raw = __toESM(require("rehype-raw"));
|
|
1485
1489
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1486
1490
|
var defaultComponents = {
|
|
1487
1491
|
a(_a) {
|
|
@@ -1575,18 +1579,24 @@ var defaultComponents = {
|
|
|
1575
1579
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
1576
1580
|
}
|
|
1577
1581
|
};
|
|
1582
|
+
var MemoizedReactMarkdown = (0, import_react7.memo)(
|
|
1583
|
+
import_react_markdown.default,
|
|
1584
|
+
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
|
|
1585
|
+
);
|
|
1578
1586
|
var Markdown = ({ content, components }) => {
|
|
1579
1587
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1580
|
-
|
|
1588
|
+
MemoizedReactMarkdown,
|
|
1581
1589
|
{
|
|
1582
1590
|
components: __spreadValues(__spreadValues({}, defaultComponents), components),
|
|
1591
|
+
remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
|
|
1592
|
+
rehypePlugins: [import_rehype_raw.default],
|
|
1583
1593
|
children: content
|
|
1584
1594
|
}
|
|
1585
1595
|
) });
|
|
1586
1596
|
};
|
|
1587
1597
|
|
|
1588
1598
|
// src/components/chat/messages/AssistantMessage.tsx
|
|
1589
|
-
var
|
|
1599
|
+
var import_react8 = require("react");
|
|
1590
1600
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1591
1601
|
var AssistantMessage = (props) => {
|
|
1592
1602
|
var _a;
|
|
@@ -1602,7 +1612,7 @@ var AssistantMessage = (props) => {
|
|
|
1602
1612
|
feedback,
|
|
1603
1613
|
markdownTagRenderers
|
|
1604
1614
|
} = props;
|
|
1605
|
-
const [copied, setCopied] = (0,
|
|
1615
|
+
const [copied, setCopied] = (0, import_react8.useState)(false);
|
|
1606
1616
|
const handleCopy = () => {
|
|
1607
1617
|
const content2 = (message == null ? void 0 : message.content) || "";
|
|
1608
1618
|
if (content2 && onCopy) {
|
|
@@ -1691,10 +1701,10 @@ var AssistantMessage = (props) => {
|
|
|
1691
1701
|
};
|
|
1692
1702
|
|
|
1693
1703
|
// src/components/chat/messages/ImageRenderer.tsx
|
|
1694
|
-
var
|
|
1704
|
+
var import_react9 = require("react");
|
|
1695
1705
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1696
1706
|
var ImageRenderer = ({ image, content, className = "" }) => {
|
|
1697
|
-
const [imageError, setImageError] = (0,
|
|
1707
|
+
const [imageError, setImageError] = (0, import_react9.useState)(false);
|
|
1698
1708
|
const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
|
|
1699
1709
|
const altText = content || "User uploaded image";
|
|
1700
1710
|
const handleImageError = () => {
|
|
@@ -1937,18 +1947,18 @@ var Messages = ({
|
|
|
1937
1947
|
var _a;
|
|
1938
1948
|
const { labels, icons } = useChatContext();
|
|
1939
1949
|
const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
|
|
1940
|
-
const initialMessages = (0,
|
|
1950
|
+
const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
1941
1951
|
const messages = [...initialMessages, ...visibleMessages];
|
|
1942
1952
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
1943
1953
|
const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
|
|
1944
|
-
(0,
|
|
1954
|
+
(0, import_react10.useEffect)(() => {
|
|
1945
1955
|
if (hasLegacyProps) {
|
|
1946
1956
|
console.warn(
|
|
1947
1957
|
"[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. Please use the unified 'RenderMessage' prop instead. See migration guide: https://docs.copilotkit.ai/migration/render-message"
|
|
1948
1958
|
);
|
|
1949
1959
|
}
|
|
1950
1960
|
}, [hasLegacyProps]);
|
|
1951
|
-
const legacyProps = (0,
|
|
1961
|
+
const legacyProps = (0, import_react10.useMemo)(
|
|
1952
1962
|
() => ({
|
|
1953
1963
|
RenderTextMessage,
|
|
1954
1964
|
RenderActionExecutionMessage,
|
|
@@ -2019,10 +2029,10 @@ function makeInitialMessages(initial) {
|
|
|
2019
2029
|
];
|
|
2020
2030
|
}
|
|
2021
2031
|
function useScrollToBottom(messages) {
|
|
2022
|
-
const messagesEndRef = (0,
|
|
2023
|
-
const messagesContainerRef = (0,
|
|
2024
|
-
const isProgrammaticScrollRef = (0,
|
|
2025
|
-
const isUserScrollUpRef = (0,
|
|
2032
|
+
const messagesEndRef = (0, import_react10.useRef)(null);
|
|
2033
|
+
const messagesContainerRef = (0, import_react10.useRef)(null);
|
|
2034
|
+
const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
|
|
2035
|
+
const isUserScrollUpRef = (0, import_react10.useRef)(false);
|
|
2026
2036
|
const scrollToBottom = () => {
|
|
2027
2037
|
if (messagesContainerRef.current && messagesEndRef.current) {
|
|
2028
2038
|
isProgrammaticScrollRef.current = true;
|
|
@@ -2039,7 +2049,7 @@ function useScrollToBottom(messages) {
|
|
|
2039
2049
|
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
2040
2050
|
}
|
|
2041
2051
|
};
|
|
2042
|
-
(0,
|
|
2052
|
+
(0, import_react10.useEffect)(() => {
|
|
2043
2053
|
const container = messagesContainerRef.current;
|
|
2044
2054
|
if (container) {
|
|
2045
2055
|
container.addEventListener("scroll", handleScroll);
|
|
@@ -2050,7 +2060,7 @@ function useScrollToBottom(messages) {
|
|
|
2050
2060
|
}
|
|
2051
2061
|
};
|
|
2052
2062
|
}, []);
|
|
2053
|
-
(0,
|
|
2063
|
+
(0, import_react10.useEffect)(() => {
|
|
2054
2064
|
const container = messagesContainerRef.current;
|
|
2055
2065
|
if (!container) {
|
|
2056
2066
|
return;
|
|
@@ -2069,7 +2079,7 @@ function useScrollToBottom(messages) {
|
|
|
2069
2079
|
mutationObserver.disconnect();
|
|
2070
2080
|
};
|
|
2071
2081
|
}, []);
|
|
2072
|
-
(0,
|
|
2082
|
+
(0, import_react10.useEffect)(() => {
|
|
2073
2083
|
isUserScrollUpRef.current = false;
|
|
2074
2084
|
scrollToBottom();
|
|
2075
2085
|
}, [messages.filter((m) => m.role === "user").length]);
|
|
@@ -2077,12 +2087,12 @@ function useScrollToBottom(messages) {
|
|
|
2077
2087
|
}
|
|
2078
2088
|
|
|
2079
2089
|
// src/components/chat/Input.tsx
|
|
2080
|
-
var
|
|
2090
|
+
var import_react14 = require("react");
|
|
2081
2091
|
|
|
2082
2092
|
// src/components/chat/Textarea.tsx
|
|
2083
|
-
var
|
|
2093
|
+
var import_react11 = require("react");
|
|
2084
2094
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2085
|
-
var AutoResizingTextarea = (0,
|
|
2095
|
+
var AutoResizingTextarea = (0, import_react11.forwardRef)(
|
|
2086
2096
|
({
|
|
2087
2097
|
maxRows = 1,
|
|
2088
2098
|
placeholder,
|
|
@@ -2093,10 +2103,10 @@ var AutoResizingTextarea = (0, import_react10.forwardRef)(
|
|
|
2093
2103
|
onCompositionEnd,
|
|
2094
2104
|
autoFocus
|
|
2095
2105
|
}, ref) => {
|
|
2096
|
-
const internalTextareaRef = (0,
|
|
2097
|
-
const [maxHeight, setMaxHeight] = (0,
|
|
2098
|
-
(0,
|
|
2099
|
-
(0,
|
|
2106
|
+
const internalTextareaRef = (0, import_react11.useRef)(null);
|
|
2107
|
+
const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
|
|
2108
|
+
(0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
2109
|
+
(0, import_react11.useEffect)(() => {
|
|
2100
2110
|
const calculateMaxHeight = () => {
|
|
2101
2111
|
const textarea = internalTextareaRef.current;
|
|
2102
2112
|
if (textarea) {
|
|
@@ -2110,7 +2120,7 @@ var AutoResizingTextarea = (0, import_react10.forwardRef)(
|
|
|
2110
2120
|
};
|
|
2111
2121
|
calculateMaxHeight();
|
|
2112
2122
|
}, [maxRows]);
|
|
2113
|
-
(0,
|
|
2123
|
+
(0, import_react11.useEffect)(() => {
|
|
2114
2124
|
const textarea = internalTextareaRef.current;
|
|
2115
2125
|
if (textarea) {
|
|
2116
2126
|
textarea.style.height = "auto";
|
|
@@ -2142,7 +2152,7 @@ var Textarea_default = AutoResizingTextarea;
|
|
|
2142
2152
|
// src/hooks/use-push-to-talk.tsx
|
|
2143
2153
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
2144
2154
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
2145
|
-
var
|
|
2155
|
+
var import_react12 = require("react");
|
|
2146
2156
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
2147
2157
|
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
2148
2158
|
mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
|
|
@@ -2191,16 +2201,16 @@ var usePushToTalk = ({
|
|
|
2191
2201
|
sendFunction,
|
|
2192
2202
|
inProgress
|
|
2193
2203
|
}) => {
|
|
2194
|
-
const [pushToTalkState, setPushToTalkState] = (0,
|
|
2195
|
-
const mediaStreamRef = (0,
|
|
2196
|
-
const audioContextRef = (0,
|
|
2197
|
-
const mediaRecorderRef = (0,
|
|
2198
|
-
const recordedChunks = (0,
|
|
2204
|
+
const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
|
|
2205
|
+
const mediaStreamRef = (0, import_react12.useRef)(null);
|
|
2206
|
+
const audioContextRef = (0, import_react12.useRef)(null);
|
|
2207
|
+
const mediaRecorderRef = (0, import_react12.useRef)(null);
|
|
2208
|
+
const recordedChunks = (0, import_react12.useRef)([]);
|
|
2199
2209
|
const generalContext = (0, import_react_core6.useCopilotContext)();
|
|
2200
2210
|
const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
|
|
2201
2211
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
2202
|
-
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0,
|
|
2203
|
-
(0,
|
|
2212
|
+
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
|
|
2213
|
+
(0, import_react12.useEffect)(() => {
|
|
2204
2214
|
if (pushToTalkState === "recording") {
|
|
2205
2215
|
startRecording(
|
|
2206
2216
|
mediaStreamRef,
|
|
@@ -2228,7 +2238,7 @@ var usePushToTalk = ({
|
|
|
2228
2238
|
stopRecording(mediaRecorderRef);
|
|
2229
2239
|
};
|
|
2230
2240
|
}, [pushToTalkState]);
|
|
2231
|
-
(0,
|
|
2241
|
+
(0, import_react12.useEffect)(() => {
|
|
2232
2242
|
if (inProgress === false && startReadingFromMessageId) {
|
|
2233
2243
|
const lastMessageIndex = context.messages.findIndex(
|
|
2234
2244
|
(message) => message.id === startReadingFromMessageId
|
|
@@ -2247,7 +2257,7 @@ var usePushToTalk = ({
|
|
|
2247
2257
|
var import_react_core7 = require("@copilotkit/react-core");
|
|
2248
2258
|
|
|
2249
2259
|
// src/components/chat/PoweredByTag.tsx
|
|
2250
|
-
var
|
|
2260
|
+
var import_react13 = require("react");
|
|
2251
2261
|
|
|
2252
2262
|
// src/hooks/use-dark-mode.ts
|
|
2253
2263
|
var useDarkMode = () => {
|
|
@@ -2259,9 +2269,9 @@ var useDarkMode = () => {
|
|
|
2259
2269
|
// src/components/chat/PoweredByTag.tsx
|
|
2260
2270
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2261
2271
|
function PoweredByTag({ showPoweredBy = true }) {
|
|
2262
|
-
const [mounted, setMounted] = (0,
|
|
2272
|
+
const [mounted, setMounted] = (0, import_react13.useState)(false);
|
|
2263
2273
|
const isDark = useDarkMode();
|
|
2264
|
-
(0,
|
|
2274
|
+
(0, import_react13.useEffect)(() => {
|
|
2265
2275
|
setMounted(true);
|
|
2266
2276
|
}, []);
|
|
2267
2277
|
if (!showPoweredBy) {
|
|
@@ -2295,8 +2305,8 @@ var Input = ({
|
|
|
2295
2305
|
const copilotContext = (0, import_react_core7.useCopilotContext)();
|
|
2296
2306
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
2297
2307
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
2298
|
-
const textareaRef = (0,
|
|
2299
|
-
const [isComposing, setIsComposing] = (0,
|
|
2308
|
+
const textareaRef = (0, import_react14.useRef)(null);
|
|
2309
|
+
const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
|
|
2300
2310
|
const handleDivClick = (event) => {
|
|
2301
2311
|
var _a2;
|
|
2302
2312
|
const target = event.target;
|
|
@@ -2306,7 +2316,7 @@ var Input = ({
|
|
|
2306
2316
|
return;
|
|
2307
2317
|
(_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
|
|
2308
2318
|
};
|
|
2309
|
-
const [text, setText] = (0,
|
|
2319
|
+
const [text, setText] = (0, import_react14.useState)("");
|
|
2310
2320
|
const send = () => {
|
|
2311
2321
|
var _a2;
|
|
2312
2322
|
if (inProgress)
|
|
@@ -2320,17 +2330,17 @@ var Input = ({
|
|
|
2320
2330
|
inProgress
|
|
2321
2331
|
});
|
|
2322
2332
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
2323
|
-
const { buttonIcon, buttonAlt } = (0,
|
|
2333
|
+
const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
|
|
2324
2334
|
if (!chatReady)
|
|
2325
2335
|
return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
|
|
2326
2336
|
return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
|
|
2327
2337
|
}, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
|
|
2328
2338
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
2329
2339
|
const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
|
|
2330
|
-
const canSend = (0,
|
|
2340
|
+
const canSend = (0, import_react14.useMemo)(() => {
|
|
2331
2341
|
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
|
|
2332
2342
|
}, [interrupt, isInProgress, text, pushToTalkState]);
|
|
2333
|
-
const canStop = (0,
|
|
2343
|
+
const canStop = (0, import_react14.useMemo)(() => {
|
|
2334
2344
|
return isInProgress && !hideStopButton;
|
|
2335
2345
|
}, [isInProgress, hideStopButton]);
|
|
2336
2346
|
const sendDisabled = !canSend && !canStop;
|
|
@@ -2387,7 +2397,7 @@ var Input = ({
|
|
|
2387
2397
|
};
|
|
2388
2398
|
|
|
2389
2399
|
// src/components/chat/Chat.tsx
|
|
2390
|
-
var
|
|
2400
|
+
var import_react15 = __toESM(require("react"));
|
|
2391
2401
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2392
2402
|
var import_shared3 = require("@copilotkit/shared");
|
|
2393
2403
|
|
|
@@ -2564,13 +2574,13 @@ function CopilotChat({
|
|
|
2564
2574
|
removeInternalErrorHandler
|
|
2565
2575
|
} = (0, import_react_core9.useCopilotContext)();
|
|
2566
2576
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2567
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2568
|
-
const [chatError, setChatError] = (0,
|
|
2569
|
-
const [messageFeedback, setMessageFeedback] = (0,
|
|
2577
|
+
const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
|
|
2578
|
+
const [chatError, setChatError] = (0, import_react15.useState)(null);
|
|
2579
|
+
const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
|
|
2570
2580
|
{}
|
|
2571
2581
|
);
|
|
2572
|
-
const fileInputRef = (0,
|
|
2573
|
-
const triggerObservabilityHook = (0,
|
|
2582
|
+
const fileInputRef = (0, import_react15.useRef)(null);
|
|
2583
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2574
2584
|
(hookName, ...args) => {
|
|
2575
2585
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2576
2586
|
observabilityHooks[hookName](...args);
|
|
@@ -2589,7 +2599,7 @@ function CopilotChat({
|
|
|
2589
2599
|
},
|
|
2590
2600
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2591
2601
|
);
|
|
2592
|
-
const triggerChatError = (0,
|
|
2602
|
+
const triggerChatError = (0, import_react15.useCallback)(
|
|
2593
2603
|
(error, operation, originalError) => {
|
|
2594
2604
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2595
2605
|
setChatError({
|
|
@@ -2635,7 +2645,7 @@ function CopilotChat({
|
|
|
2635
2645
|
},
|
|
2636
2646
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2637
2647
|
);
|
|
2638
|
-
(0,
|
|
2648
|
+
(0, import_react15.useEffect)(() => {
|
|
2639
2649
|
const id = "chat-component";
|
|
2640
2650
|
setInternalErrorHandler({
|
|
2641
2651
|
[id]: (error) => {
|
|
@@ -2648,7 +2658,7 @@ function CopilotChat({
|
|
|
2648
2658
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2649
2659
|
};
|
|
2650
2660
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2651
|
-
(0,
|
|
2661
|
+
(0, import_react15.useEffect)(() => {
|
|
2652
2662
|
if (!imageUploadsEnabled)
|
|
2653
2663
|
return;
|
|
2654
2664
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2694,7 +2704,7 @@ function CopilotChat({
|
|
|
2694
2704
|
document.addEventListener("paste", handlePaste);
|
|
2695
2705
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2696
2706
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2697
|
-
(0,
|
|
2707
|
+
(0, import_react15.useEffect)(() => {
|
|
2698
2708
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2699
2709
|
setChatInstructions(instructions || "");
|
|
2700
2710
|
return;
|
|
@@ -2722,8 +2732,8 @@ function CopilotChat({
|
|
|
2722
2732
|
onStopGeneration,
|
|
2723
2733
|
onReloadMessages
|
|
2724
2734
|
});
|
|
2725
|
-
const prevIsLoading = (0,
|
|
2726
|
-
(0,
|
|
2735
|
+
const prevIsLoading = (0, import_react15.useRef)(isLoading);
|
|
2736
|
+
(0, import_react15.useEffect)(() => {
|
|
2727
2737
|
if (prevIsLoading.current !== isLoading) {
|
|
2728
2738
|
if (isLoading) {
|
|
2729
2739
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2746,7 +2756,7 @@ function CopilotChat({
|
|
|
2746
2756
|
role: "user"
|
|
2747
2757
|
});
|
|
2748
2758
|
};
|
|
2749
|
-
const chatContext =
|
|
2759
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2750
2760
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2751
2761
|
const handleRegenerate = (messageId) => {
|
|
2752
2762
|
if (onRegenerate) {
|
|
@@ -2890,7 +2900,7 @@ function WrappedCopilotChat({
|
|
|
2890
2900
|
labels,
|
|
2891
2901
|
className
|
|
2892
2902
|
}) {
|
|
2893
|
-
const chatContext =
|
|
2903
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2894
2904
|
if (!chatContext) {
|
|
2895
2905
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2896
2906
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
@@ -2928,7 +2938,7 @@ var CopilotModalInner = (_a) => {
|
|
|
2928
2938
|
]);
|
|
2929
2939
|
const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
|
|
2930
2940
|
const { publicApiKey } = copilotApiConfig;
|
|
2931
|
-
const triggerObservabilityHook = (0,
|
|
2941
|
+
const triggerObservabilityHook = (0, import_react16.useCallback)(
|
|
2932
2942
|
(hookName, ...args) => {
|
|
2933
2943
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2934
2944
|
observabilityHooks[hookName](...args);
|
|
@@ -2948,8 +2958,8 @@ var CopilotModalInner = (_a) => {
|
|
|
2948
2958
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2949
2959
|
);
|
|
2950
2960
|
const { open } = useChatContext();
|
|
2951
|
-
const prevOpen = (0,
|
|
2952
|
-
(0,
|
|
2961
|
+
const prevOpen = (0, import_react16.useRef)(open);
|
|
2962
|
+
(0, import_react16.useEffect)(() => {
|
|
2953
2963
|
if (prevOpen.current !== open) {
|
|
2954
2964
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
2955
2965
|
if (open) {
|
|
@@ -2960,8 +2970,8 @@ var CopilotModalInner = (_a) => {
|
|
|
2960
2970
|
prevOpen.current = open;
|
|
2961
2971
|
}
|
|
2962
2972
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
2963
|
-
const memoizedHeader = (0,
|
|
2964
|
-
const memoizedChildren = (0,
|
|
2973
|
+
const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
|
|
2974
|
+
const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
|
|
2965
2975
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
2966
2976
|
memoizedChildren,
|
|
2967
2977
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
@@ -3041,7 +3051,7 @@ var CopilotModal = (_a) => {
|
|
|
3041
3051
|
"children",
|
|
3042
3052
|
"observabilityHooks"
|
|
3043
3053
|
]);
|
|
3044
|
-
const [openState, setOpenState] =
|
|
3054
|
+
const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
|
|
3045
3055
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3046
3056
|
CopilotModalInner,
|
|
3047
3057
|
__spreadProps(__spreadValues({
|
|
@@ -3085,13 +3095,13 @@ function CopilotPopup(props) {
|
|
|
3085
3095
|
}
|
|
3086
3096
|
|
|
3087
3097
|
// src/components/chat/Sidebar.tsx
|
|
3088
|
-
var
|
|
3098
|
+
var import_react17 = require("react");
|
|
3089
3099
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3090
3100
|
function CopilotSidebar(props) {
|
|
3091
3101
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3092
3102
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3093
3103
|
});
|
|
3094
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3104
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
|
|
3095
3105
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3096
3106
|
);
|
|
3097
3107
|
const onSetOpen = (open) => {
|