@copilotkit/react-ui 1.10.5-next.9 → 1.10.6-next.0
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 +34 -0
- package/dist/{chunk-QPONDGDJ.mjs → chunk-5HQD6ZPA.mjs} +2 -2
- package/dist/{chunk-DSNTTAJX.mjs → chunk-7HAFY2YK.mjs} +3 -3
- package/dist/{chunk-CGEAG65D.mjs → chunk-ELGRNEAO.mjs} +7 -2
- package/dist/chunk-ELGRNEAO.mjs.map +1 -0
- package/dist/{chunk-K2FLPUR5.mjs → chunk-G7VB7A4O.mjs} +2 -2
- package/dist/{chunk-SDQTGCT2.mjs → chunk-SNGWNZNH.mjs} +2 -2
- package/dist/{chunk-DTRPPNSA.mjs → chunk-ZJCHKHE4.mjs} +2 -2
- package/dist/components/chat/Chat.js +36 -29
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +3 -3
- package/dist/components/chat/Input.js +14 -7
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Modal.js +43 -36
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +4 -4
- package/dist/components/chat/Popup.js +43 -36
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +5 -5
- package/dist/components/chat/PoweredByTag.js +6 -1
- package/dist/components/chat/PoweredByTag.js.map +1 -1
- package/dist/components/chat/PoweredByTag.mjs +1 -1
- package/dist/components/chat/Sidebar.js +45 -38
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +5 -5
- package/dist/components/chat/index.js +45 -38
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +6 -6
- package/dist/components/index.js +45 -38
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -6
- package/dist/index.js +47 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/package.json +4 -4
- package/src/components/chat/PoweredByTag.tsx +15 -2
- package/dist/chunk-CGEAG65D.mjs.map +0 -1
- /package/dist/{chunk-QPONDGDJ.mjs.map → chunk-5HQD6ZPA.mjs.map} +0 -0
- /package/dist/{chunk-DSNTTAJX.mjs.map → chunk-7HAFY2YK.mjs.map} +0 -0
- /package/dist/{chunk-K2FLPUR5.mjs.map → chunk-G7VB7A4O.mjs.map} +0 -0
- /package/dist/{chunk-SDQTGCT2.mjs.map → chunk-SNGWNZNH.mjs.map} +0 -0
- /package/dist/{chunk-DTRPPNSA.mjs.map → chunk-ZJCHKHE4.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.10.6-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0cc9ec2: - fix(react-ui): address hydration issue
|
|
8
|
+
|
|
9
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
10
|
+
|
|
11
|
+
- @copilotkit/react-core@1.10.6-next.0
|
|
12
|
+
- @copilotkit/runtime-client-gql@1.10.6-next.0
|
|
13
|
+
- @copilotkit/shared@1.10.6-next.0
|
|
14
|
+
|
|
15
|
+
## 1.10.5
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- c2de25d: - fix: refrain from using prismjs for syntax highlighting on older browsers
|
|
20
|
+
- Updated dependencies [b7bc3a0]
|
|
21
|
+
- Updated dependencies [f3fdd7a]
|
|
22
|
+
- Updated dependencies [32c163e]
|
|
23
|
+
- Updated dependencies [6112a67]
|
|
24
|
+
- @copilotkit/react-core@1.10.5
|
|
25
|
+
- @copilotkit/runtime-client-gql@1.10.5
|
|
26
|
+
- @copilotkit/shared@1.10.5
|
|
27
|
+
|
|
28
|
+
## 1.10.5-next.10
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [b79ed5c]
|
|
33
|
+
- @copilotkit/react-core@1.10.5-next.10
|
|
34
|
+
- @copilotkit/runtime-client-gql@1.10.5-next.10
|
|
35
|
+
- @copilotkit/shared@1.10.5-next.10
|
|
36
|
+
|
|
3
37
|
## 1.10.5-next.9
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HAFY2YK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
|
|
|
18
18
|
export {
|
|
19
19
|
CopilotPopup
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-5HQD6ZPA.mjs.map
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "./chunk-UFN2VWSR.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-G7VB7A4O.mjs";
|
|
13
13
|
import {
|
|
14
14
|
Input
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZJCHKHE4.mjs";
|
|
16
16
|
import {
|
|
17
17
|
Messages
|
|
18
18
|
} from "./chunk-W7ONZTSW.mjs";
|
|
@@ -219,4 +219,4 @@ var CopilotModal = (_a) => {
|
|
|
219
219
|
export {
|
|
220
220
|
CopilotModal
|
|
221
221
|
};
|
|
222
|
-
//# sourceMappingURL=chunk-
|
|
222
|
+
//# sourceMappingURL=chunk-7HAFY2YK.mjs.map
|
|
@@ -3,9 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-JGMFJZMG.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/PoweredByTag.tsx
|
|
6
|
+
import { useState, useEffect } from "react";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
function PoweredByTag({ showPoweredBy = true }) {
|
|
9
|
+
const [mounted, setMounted] = useState(false);
|
|
8
10
|
const isDark = useDarkMode();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setMounted(true);
|
|
13
|
+
}, []);
|
|
9
14
|
if (!showPoweredBy) {
|
|
10
15
|
return null;
|
|
11
16
|
}
|
|
@@ -16,7 +21,7 @@ function PoweredByTag({ showPoweredBy = true }) {
|
|
|
16
21
|
textAlign: "center",
|
|
17
22
|
fontSize: "12px",
|
|
18
23
|
padding: "3px 0",
|
|
19
|
-
color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
24
|
+
color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
20
25
|
};
|
|
21
26
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
|
|
22
27
|
}
|
|
@@ -24,4 +29,4 @@ function PoweredByTag({ showPoweredBy = true }) {
|
|
|
24
29
|
export {
|
|
25
30
|
PoweredByTag
|
|
26
31
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-ELGRNEAO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/PoweredByTag.tsx"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport { useDarkMode } from \"../../hooks/use-dark-mode\";\n\nexport function PoweredByTag({ showPoweredBy = true }: { showPoweredBy?: boolean }) {\n const [mounted, setMounted] = useState(false);\n const isDark = useDarkMode();\n\n /*\n note(tylerslaton):\n\n Ensure we only use the isDark computed value after client-side mount.\n This prevents hydration mismatches by using a default color on the\n server and initial client render, then updating to the correct\n dark mode color after hydration is complete.\n */\n useEffect(() => {\n setMounted(true);\n }, []);\n\n if (!showPoweredBy) {\n return null;\n }\n\n const poweredByStyle = {\n visibility: \"visible\",\n display: \"block\",\n position: \"static\",\n textAlign: \"center\",\n fontSize: \"12px\",\n padding: \"3px 0\",\n color: mounted && isDark ? \"rgb(69, 69, 69)\" : \"rgb(214, 214, 214)\",\n };\n\n return (\n <div>\n {/*@ts-expect-error -- expecting position not to be a string, but it can be.*/}\n <p className=\"poweredBy\" style={poweredByStyle}>\n Powered by CopilotKit\n </p>\n </div>\n );\n}\n"],"mappings":";;;;;AAAA,SAAgB,UAAU,iBAAiB;AAoCrC;AAjCC,SAAS,aAAa,EAAE,gBAAgB,KAAK,GAAgC;AAClF,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,SAAS,YAAY;AAU3B,YAAU,MAAM;AACd,eAAW,IAAI;AAAA,EACjB,GAAG,CAAC,CAAC;AAEL,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAEA,QAAM,iBAAiB;AAAA,IACrB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO,WAAW,SAAS,oBAAoB;AAAA,EACjD;AAEA,SACE,oBAAC,SAEC,8BAAC,OAAE,WAAU,aAAY,OAAO,gBAAgB,mCAEhD,GACF;AAEJ;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-PLHTVHUW.mjs";
|
|
7
7
|
import {
|
|
8
8
|
Input
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZJCHKHE4.mjs";
|
|
10
10
|
import {
|
|
11
11
|
Messages
|
|
12
12
|
} from "./chunk-W7ONZTSW.mjs";
|
|
@@ -652,4 +652,4 @@ export {
|
|
|
652
652
|
WrappedCopilotChat,
|
|
653
653
|
useCopilotChatLogic
|
|
654
654
|
};
|
|
655
|
-
//# sourceMappingURL=chunk-
|
|
655
|
+
//# sourceMappingURL=chunk-G7VB7A4O.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HAFY2YK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
|
|
|
27
27
|
export {
|
|
28
28
|
CopilotSidebar
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-SNGWNZNH.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PoweredByTag
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ELGRNEAO.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Textarea_default
|
|
6
6
|
} from "./chunk-QIOJXTIQ.mjs";
|
|
@@ -120,4 +120,4 @@ var Input = ({
|
|
|
120
120
|
export {
|
|
121
121
|
Input
|
|
122
122
|
};
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-ZJCHKHE4.mjs.map
|
|
@@ -1406,7 +1406,7 @@ function useScrollToBottom(messages) {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
1408
1408
|
// src/components/chat/Input.tsx
|
|
1409
|
-
var
|
|
1409
|
+
var import_react10 = require("react");
|
|
1410
1410
|
|
|
1411
1411
|
// src/components/chat/Textarea.tsx
|
|
1412
1412
|
var import_react7 = require("react");
|
|
@@ -1575,6 +1575,9 @@ var usePushToTalk = ({
|
|
|
1575
1575
|
// src/components/chat/Input.tsx
|
|
1576
1576
|
var import_react_core3 = require("@copilotkit/react-core");
|
|
1577
1577
|
|
|
1578
|
+
// src/components/chat/PoweredByTag.tsx
|
|
1579
|
+
var import_react9 = require("react");
|
|
1580
|
+
|
|
1578
1581
|
// src/hooks/use-dark-mode.ts
|
|
1579
1582
|
var useDarkMode = () => {
|
|
1580
1583
|
if (typeof window === "undefined")
|
|
@@ -1585,7 +1588,11 @@ var useDarkMode = () => {
|
|
|
1585
1588
|
// src/components/chat/PoweredByTag.tsx
|
|
1586
1589
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1587
1590
|
function PoweredByTag({ showPoweredBy = true }) {
|
|
1591
|
+
const [mounted, setMounted] = (0, import_react9.useState)(false);
|
|
1588
1592
|
const isDark = useDarkMode();
|
|
1593
|
+
(0, import_react9.useEffect)(() => {
|
|
1594
|
+
setMounted(true);
|
|
1595
|
+
}, []);
|
|
1589
1596
|
if (!showPoweredBy) {
|
|
1590
1597
|
return null;
|
|
1591
1598
|
}
|
|
@@ -1596,7 +1603,7 @@ function PoweredByTag({ showPoweredBy = true }) {
|
|
|
1596
1603
|
textAlign: "center",
|
|
1597
1604
|
fontSize: "12px",
|
|
1598
1605
|
padding: "3px 0",
|
|
1599
|
-
color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
1606
|
+
color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
1600
1607
|
};
|
|
1601
1608
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
|
|
1602
1609
|
}
|
|
@@ -1617,8 +1624,8 @@ var Input = ({
|
|
|
1617
1624
|
const copilotContext = (0, import_react_core3.useCopilotContext)();
|
|
1618
1625
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
1619
1626
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1620
|
-
const textareaRef = (0,
|
|
1621
|
-
const [isComposing, setIsComposing] = (0,
|
|
1627
|
+
const textareaRef = (0, import_react10.useRef)(null);
|
|
1628
|
+
const [isComposing, setIsComposing] = (0, import_react10.useState)(false);
|
|
1622
1629
|
const handleDivClick = (event) => {
|
|
1623
1630
|
var _a2;
|
|
1624
1631
|
const target = event.target;
|
|
@@ -1628,7 +1635,7 @@ var Input = ({
|
|
|
1628
1635
|
return;
|
|
1629
1636
|
(_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
|
|
1630
1637
|
};
|
|
1631
|
-
const [text, setText] = (0,
|
|
1638
|
+
const [text, setText] = (0, import_react10.useState)("");
|
|
1632
1639
|
const send = () => {
|
|
1633
1640
|
var _a2;
|
|
1634
1641
|
if (inProgress)
|
|
@@ -1644,13 +1651,13 @@ var Input = ({
|
|
|
1644
1651
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
1645
1652
|
const buttonIcon = isInProgress && !hideStopButton ? context.icons.stopIcon : context.icons.sendIcon;
|
|
1646
1653
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
1647
|
-
const canSend = (0,
|
|
1654
|
+
const canSend = (0, import_react10.useMemo)(() => {
|
|
1648
1655
|
var _a2;
|
|
1649
1656
|
const interruptEvent = (_a2 = copilotContext.langGraphInterruptAction) == null ? void 0 : _a2.event;
|
|
1650
1657
|
const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
|
|
1651
1658
|
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interruptInProgress;
|
|
1652
1659
|
}, [(_b = copilotContext.langGraphInterruptAction) == null ? void 0 : _b.event, isInProgress, text, pushToTalkState]);
|
|
1653
|
-
const canStop = (0,
|
|
1660
|
+
const canStop = (0, import_react10.useMemo)(() => {
|
|
1654
1661
|
return isInProgress && !hideStopButton;
|
|
1655
1662
|
}, [isInProgress, hideStopButton]);
|
|
1656
1663
|
const sendDisabled = !canSend && !canStop;
|
|
@@ -1706,7 +1713,7 @@ var Input = ({
|
|
|
1706
1713
|
};
|
|
1707
1714
|
|
|
1708
1715
|
// src/components/chat/Chat.tsx
|
|
1709
|
-
var
|
|
1716
|
+
var import_react11 = __toESM(require("react"));
|
|
1710
1717
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1711
1718
|
var import_shared = require("@copilotkit/shared");
|
|
1712
1719
|
var import_shared2 = require("@copilotkit/shared");
|
|
@@ -1877,10 +1884,10 @@ function CopilotChat({
|
|
|
1877
1884
|
removeInternalErrorHandler
|
|
1878
1885
|
} = (0, import_react_core5.useCopilotContext)();
|
|
1879
1886
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
1880
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
1881
|
-
const [chatError, setChatError] = (0,
|
|
1882
|
-
const fileInputRef = (0,
|
|
1883
|
-
const triggerObservabilityHook = (0,
|
|
1887
|
+
const [selectedImages, setSelectedImages] = (0, import_react11.useState)([]);
|
|
1888
|
+
const [chatError, setChatError] = (0, import_react11.useState)(null);
|
|
1889
|
+
const fileInputRef = (0, import_react11.useRef)(null);
|
|
1890
|
+
const triggerObservabilityHook = (0, import_react11.useCallback)(
|
|
1884
1891
|
(hookName, ...args) => {
|
|
1885
1892
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
1886
1893
|
observabilityHooks[hookName](...args);
|
|
@@ -1899,7 +1906,7 @@ function CopilotChat({
|
|
|
1899
1906
|
},
|
|
1900
1907
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
1901
1908
|
);
|
|
1902
|
-
const triggerChatError = (0,
|
|
1909
|
+
const triggerChatError = (0, import_react11.useCallback)(
|
|
1903
1910
|
(error, operation, originalError) => {
|
|
1904
1911
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
1905
1912
|
setChatError({
|
|
@@ -1945,7 +1952,7 @@ function CopilotChat({
|
|
|
1945
1952
|
},
|
|
1946
1953
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
1947
1954
|
);
|
|
1948
|
-
(0,
|
|
1955
|
+
(0, import_react11.useEffect)(() => {
|
|
1949
1956
|
const id = "chat-component";
|
|
1950
1957
|
setInternalErrorHandler({
|
|
1951
1958
|
[id]: (error) => {
|
|
@@ -1958,7 +1965,7 @@ function CopilotChat({
|
|
|
1958
1965
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
1959
1966
|
};
|
|
1960
1967
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
1961
|
-
(0,
|
|
1968
|
+
(0, import_react11.useEffect)(() => {
|
|
1962
1969
|
if (!imageUploadsEnabled)
|
|
1963
1970
|
return;
|
|
1964
1971
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2004,7 +2011,7 @@ function CopilotChat({
|
|
|
2004
2011
|
document.addEventListener("paste", handlePaste);
|
|
2005
2012
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2006
2013
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2007
|
-
(0,
|
|
2014
|
+
(0, import_react11.useEffect)(() => {
|
|
2008
2015
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2009
2016
|
setChatInstructions(instructions || "");
|
|
2010
2017
|
return;
|
|
@@ -2032,8 +2039,8 @@ function CopilotChat({
|
|
|
2032
2039
|
onStopGeneration,
|
|
2033
2040
|
onReloadMessages
|
|
2034
2041
|
);
|
|
2035
|
-
const prevIsLoading = (0,
|
|
2036
|
-
(0,
|
|
2042
|
+
const prevIsLoading = (0, import_react11.useRef)(isLoading);
|
|
2043
|
+
(0, import_react11.useEffect)(() => {
|
|
2037
2044
|
if (prevIsLoading.current !== isLoading) {
|
|
2038
2045
|
if (isLoading) {
|
|
2039
2046
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2052,7 +2059,7 @@ function CopilotChat({
|
|
|
2052
2059
|
triggerObservabilityHook("onMessageSent", text);
|
|
2053
2060
|
return sendMessage(text, images);
|
|
2054
2061
|
};
|
|
2055
|
-
const chatContext =
|
|
2062
|
+
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2056
2063
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2057
2064
|
const handleRegenerate = (messageId) => {
|
|
2058
2065
|
if (onRegenerate) {
|
|
@@ -2187,7 +2194,7 @@ function WrappedCopilotChat({
|
|
|
2187
2194
|
labels,
|
|
2188
2195
|
className
|
|
2189
2196
|
}) {
|
|
2190
|
-
const chatContext =
|
|
2197
|
+
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2191
2198
|
if (!chatContext) {
|
|
2192
2199
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2193
2200
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
@@ -2216,15 +2223,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2216
2223
|
const generalContext = (0, import_react_core5.useCopilotContext)();
|
|
2217
2224
|
const messagesContext = (0, import_react_core5.useCopilotMessagesContext)();
|
|
2218
2225
|
const { actions } = generalContext;
|
|
2219
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2220
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2221
|
-
(0,
|
|
2226
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react11.useState)(false);
|
|
2227
|
+
const hasGeneratedInitialSuggestions = (0, import_react11.useRef)(false);
|
|
2228
|
+
(0, import_react11.useEffect)(() => {
|
|
2222
2229
|
if (Array.isArray(chatSuggestions)) {
|
|
2223
2230
|
setSuggestions(chatSuggestions);
|
|
2224
2231
|
hasGeneratedInitialSuggestions.current = true;
|
|
2225
2232
|
}
|
|
2226
2233
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2227
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2234
|
+
const generateSuggestionsWithErrorHandling = (0, import_react11.useCallback)(
|
|
2228
2235
|
(context) => __async(void 0, null, function* () {
|
|
2229
2236
|
try {
|
|
2230
2237
|
yield generateSuggestions();
|
|
@@ -2235,7 +2242,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2235
2242
|
}),
|
|
2236
2243
|
[generateSuggestions]
|
|
2237
2244
|
);
|
|
2238
|
-
(0,
|
|
2245
|
+
(0, import_react11.useEffect)(() => {
|
|
2239
2246
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2240
2247
|
return;
|
|
2241
2248
|
}
|
|
@@ -2265,13 +2272,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2265
2272
|
// Use stable string instead of object reference
|
|
2266
2273
|
generateSuggestionsWithErrorHandling
|
|
2267
2274
|
]);
|
|
2268
|
-
(0,
|
|
2275
|
+
(0, import_react11.useEffect)(() => {
|
|
2269
2276
|
if (chatSuggestions !== "auto") {
|
|
2270
2277
|
hasGeneratedInitialSuggestions.current = false;
|
|
2271
2278
|
setSuggestionsFailed(false);
|
|
2272
2279
|
}
|
|
2273
2280
|
}, [chatSuggestions]);
|
|
2274
|
-
const stableContext = (0,
|
|
2281
|
+
const stableContext = (0, import_react11.useMemo)(
|
|
2275
2282
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2276
2283
|
[
|
|
2277
2284
|
// Only include stable dependencies
|
|
@@ -2280,12 +2287,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2280
2287
|
generalContext.isLoading
|
|
2281
2288
|
]
|
|
2282
2289
|
);
|
|
2283
|
-
const resetSuggestions = (0,
|
|
2290
|
+
const resetSuggestions = (0, import_react11.useCallback)(() => {
|
|
2284
2291
|
resetSuggestionsFromHook();
|
|
2285
2292
|
setSuggestionsFailed(false);
|
|
2286
2293
|
hasGeneratedInitialSuggestions.current = false;
|
|
2287
2294
|
}, [resetSuggestionsFromHook]);
|
|
2288
|
-
(0,
|
|
2295
|
+
(0, import_react11.useEffect)(() => {
|
|
2289
2296
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2290
2297
|
}, [onInProgress, isLoading]);
|
|
2291
2298
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|