@copilotkit/react-ui 1.51.4-next.7 → 1.51.4-next.8
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 +9 -0
- package/README.md +18 -12
- package/dist/{chunk-O72ZB5V3.mjs → chunk-2QEDCM6H.mjs} +22 -12
- package/dist/chunk-2QEDCM6H.mjs.map +1 -0
- package/dist/{chunk-54JAUBUJ.mjs → chunk-6SMTHXVA.mjs} +4 -2
- package/dist/chunk-6SMTHXVA.mjs.map +1 -0
- package/dist/{chunk-IEMQ2SQW.mjs → chunk-6TLDRWAD.mjs} +5 -3
- package/dist/{chunk-IEMQ2SQW.mjs.map → chunk-6TLDRWAD.mjs.map} +1 -1
- package/dist/{chunk-UFN2VWSR.mjs → chunk-72FQQMQ2.mjs} +2 -2
- package/dist/chunk-72FQQMQ2.mjs.map +1 -0
- package/dist/{chunk-ELGRNEAO.mjs → chunk-AOUHT4JR.mjs} +4 -2
- package/dist/chunk-AOUHT4JR.mjs.map +1 -0
- package/dist/{chunk-C3GSYRC3.mjs → chunk-BNJX66OH.mjs} +2 -2
- package/dist/{chunk-NRA3CFEE.mjs → chunk-C27LZFA5.mjs} +2 -2
- package/dist/{chunk-FFJHOZX6.mjs → chunk-C7WM7GM3.mjs} +44 -11
- package/dist/chunk-C7WM7GM3.mjs.map +1 -0
- package/dist/{chunk-6TWQUA2Q.mjs → chunk-CNIC5HO5.mjs} +8 -3
- package/dist/chunk-CNIC5HO5.mjs.map +1 -0
- package/dist/chunk-CQCXH5LY.mjs +143 -0
- package/dist/chunk-CQCXH5LY.mjs.map +1 -0
- package/dist/{chunk-RYUCX3ZK.mjs → chunk-DM2V5WTG.mjs} +4 -2
- package/dist/chunk-DM2V5WTG.mjs.map +1 -0
- package/dist/{chunk-JZ3RFQQ6.mjs → chunk-DSHTRV2R.mjs} +16 -4
- package/dist/chunk-DSHTRV2R.mjs.map +1 -0
- package/dist/{chunk-GDSZGYCE.mjs → chunk-EACIYBQH.mjs} +3 -3
- package/dist/{chunk-XWG3L6QC.mjs → chunk-GBAPANZE.mjs} +76 -11
- package/dist/chunk-GBAPANZE.mjs.map +1 -0
- package/dist/{chunk-Q5V6S67N.mjs → chunk-GFE5ZSPV.mjs} +15 -6
- package/dist/chunk-GFE5ZSPV.mjs.map +1 -0
- package/dist/{chunk-VHKHX7GV.mjs → chunk-HHLX4MQN.mjs} +2 -2
- package/dist/{chunk-WNX755OE.mjs → chunk-ICA2EXIX.mjs} +7 -4
- package/dist/chunk-ICA2EXIX.mjs.map +1 -0
- package/dist/{chunk-QIOJXTIQ.mjs → chunk-IWOCQACI.mjs} +12 -3
- package/dist/chunk-IWOCQACI.mjs.map +1 -0
- package/dist/{chunk-BH6PCAAL.mjs → chunk-JYHRHKV5.mjs} +12 -3
- package/dist/chunk-JYHRHKV5.mjs.map +1 -0
- package/dist/{chunk-IK2BPURM.mjs → chunk-LIXN3OVQ.mjs} +12 -7
- package/dist/chunk-LIXN3OVQ.mjs.map +1 -0
- package/dist/{chunk-PD36EMOZ.mjs → chunk-MC6PY7XH.mjs} +75 -54
- package/dist/chunk-MC6PY7XH.mjs.map +1 -0
- package/dist/{chunk-LYYDXL2G.mjs → chunk-OQWEOBRX.mjs} +3 -3
- package/dist/chunk-OQWEOBRX.mjs.map +1 -0
- package/dist/{chunk-LBR23XXF.mjs → chunk-P34CL4LC.mjs} +4 -4
- package/dist/{chunk-F2CDEOFX.mjs → chunk-PF3QBO7V.mjs} +2 -2
- package/dist/chunk-PF3QBO7V.mjs.map +1 -0
- package/dist/{chunk-7CMZ7YPQ.mjs → chunk-PP2A5RP6.mjs} +2 -2
- package/dist/{chunk-7CMZ7YPQ.mjs.map → chunk-PP2A5RP6.mjs.map} +1 -1
- package/dist/{chunk-RKQM2AE5.mjs → chunk-Q64GLWPQ.mjs} +2 -2
- package/dist/{chunk-RKQM2AE5.mjs.map → chunk-Q64GLWPQ.mjs.map} +1 -1
- package/dist/{chunk-OHGUQZJT.mjs → chunk-T4NNQG6T.mjs} +50 -41
- package/dist/chunk-T4NNQG6T.mjs.map +1 -0
- package/dist/{chunk-DBKRAOH7.mjs → chunk-TGM5PKBF.mjs} +16 -6
- package/dist/chunk-TGM5PKBF.mjs.map +1 -0
- package/dist/{chunk-JY2CSDKN.mjs → chunk-YDJ4YUUF.mjs} +22 -16
- package/dist/chunk-YDJ4YUUF.mjs.map +1 -0
- package/dist/components/chat/Button.js +3 -1
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +3 -3
- package/dist/components/chat/Chat.js +285 -132
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +18 -18
- package/dist/components/chat/ChatContext.js +63 -9
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +2 -2
- package/dist/components/chat/CodeBlock.js +20 -6
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +3 -3
- package/dist/components/chat/Header.js +88 -28
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +8 -8
- package/dist/components/chat/Icons.js +75 -10
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +1 -1
- package/dist/components/chat/Input.js +90 -62
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +6 -6
- package/dist/components/chat/Markdown.js +34 -8
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +4 -4
- package/dist/components/chat/Messages.js +59 -16
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +11 -11
- package/dist/components/chat/Modal.js +403 -189
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +27 -27
- package/dist/components/chat/Popup.js +403 -189
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +28 -28
- package/dist/components/chat/PoweredByTag.d.ts +1 -1
- package/dist/components/chat/PoweredByTag.js +3 -1
- package/dist/components/chat/PoweredByTag.js.map +1 -1
- package/dist/components/chat/PoweredByTag.mjs +1 -1
- package/dist/components/chat/Sidebar.js +403 -189
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +28 -28
- package/dist/components/chat/Suggestion.d.ts +1 -1
- package/dist/components/chat/Suggestion.js +13 -2
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +2 -2
- package/dist/components/chat/Suggestions.js +13 -2
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +3 -3
- package/dist/components/chat/Textarea.js +4 -1
- package/dist/components/chat/Textarea.js.map +1 -1
- package/dist/components/chat/Textarea.mjs +1 -1
- package/dist/components/chat/Window.js +3 -1
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +3 -3
- package/dist/components/chat/index.js +403 -189
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +29 -29
- package/dist/components/chat/messages/AssistantMessage.js +37 -9
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +6 -6
- package/dist/components/chat/messages/ErrorMessage.js +65 -31
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
- package/dist/components/chat/messages/ErrorMessage.mjs +33 -27
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
- package/dist/components/chat/messages/ImageRenderer.js +15 -5
- package/dist/components/chat/messages/ImageRenderer.js.map +1 -1
- package/dist/components/chat/messages/ImageRenderer.mjs +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.js +55 -15
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +10 -10
- package/dist/components/chat/messages/RenderMessage.js +55 -15
- package/dist/components/chat/messages/RenderMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderMessage.mjs +9 -9
- package/dist/components/chat/messages/UserMessage.js +3 -1
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.js +85 -27
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +6 -6
- package/dist/components/dev-console/icons.js +14 -5
- package/dist/components/dev-console/icons.js.map +1 -1
- package/dist/components/dev-console/icons.mjs +1 -1
- package/dist/components/dev-console/index.js +85 -27
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +6 -6
- package/dist/components/dev-console/utils.js +21 -15
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/help-modal/icons.d.ts +1 -1
- package/dist/components/help-modal/icons.js +11 -2
- package/dist/components/help-modal/icons.js.map +1 -1
- package/dist/components/help-modal/icons.mjs +1 -1
- package/dist/components/help-modal/index.js +8 -1
- package/dist/components/help-modal/index.js.map +1 -1
- package/dist/components/help-modal/index.mjs +2 -2
- package/dist/components/help-modal/modal.js +8 -1
- package/dist/components/help-modal/modal.js.map +1 -1
- package/dist/components/help-modal/modal.mjs +2 -2
- package/dist/components/index.js +403 -189
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +29 -29
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +3 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +1 -1
- package/dist/hooks/use-push-to-talk.js +17 -10
- package/dist/hooks/use-push-to-talk.js.map +1 -1
- package/dist/hooks/use-push-to-talk.mjs +1 -1
- package/dist/index.js +403 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -34
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs.map +1 -1
- package/package.json +4 -5
- package/src/components/chat/Button.tsx +6 -2
- package/src/components/chat/Chat.tsx +75 -48
- package/src/components/chat/ChatContext.tsx +6 -2
- package/src/components/chat/CodeBlock.tsx +11 -6
- package/src/components/chat/Icons.tsx +45 -10
- package/src/components/chat/Input.tsx +30 -7
- package/src/components/chat/Markdown.tsx +12 -3
- package/src/components/chat/Messages.tsx +24 -8
- package/src/components/chat/Modal.tsx +12 -2
- package/src/components/chat/Popup.tsx +3 -1
- package/src/components/chat/PoweredByTag.tsx +5 -1
- package/src/components/chat/Sidebar.tsx +3 -1
- package/src/components/chat/Suggestion.tsx +6 -1
- package/src/components/chat/Textarea.tsx +15 -3
- package/src/components/chat/messages/AssistantMessage.tsx +12 -4
- package/src/components/chat/messages/ErrorMessage.tsx +3 -1
- package/src/components/chat/messages/ImageRenderer.tsx +17 -5
- package/src/components/chat/messages/LegacyRenderMessage.tsx +4 -1
- package/src/components/chat/messages/UserMessage.tsx +12 -4
- package/src/components/chat/props.ts +13 -3
- package/src/components/dev-console/console.tsx +35 -9
- package/src/components/dev-console/icons.tsx +6 -1
- package/src/components/dev-console/utils.ts +23 -15
- package/src/components/help-modal/icons.tsx +10 -2
- package/src/hooks/use-copy-to-clipboard.tsx +3 -1
- package/src/hooks/use-push-to-talk.tsx +45 -18
- package/src/lib/utils.ts +4 -1
- package/tsconfig.json +1 -1
- package/tsup.config.ts +5 -1
- package/dist/chunk-3W6J75HS.mjs +0 -126
- package/dist/chunk-3W6J75HS.mjs.map +0 -1
- package/dist/chunk-54JAUBUJ.mjs.map +0 -1
- package/dist/chunk-6TWQUA2Q.mjs.map +0 -1
- package/dist/chunk-BH6PCAAL.mjs.map +0 -1
- package/dist/chunk-DBKRAOH7.mjs.map +0 -1
- package/dist/chunk-ELGRNEAO.mjs.map +0 -1
- package/dist/chunk-F2CDEOFX.mjs.map +0 -1
- package/dist/chunk-FFJHOZX6.mjs.map +0 -1
- package/dist/chunk-IK2BPURM.mjs.map +0 -1
- package/dist/chunk-JY2CSDKN.mjs.map +0 -1
- package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
- package/dist/chunk-LYYDXL2G.mjs.map +0 -1
- package/dist/chunk-O72ZB5V3.mjs.map +0 -1
- package/dist/chunk-OHGUQZJT.mjs.map +0 -1
- package/dist/chunk-PD36EMOZ.mjs.map +0 -1
- package/dist/chunk-Q5V6S67N.mjs.map +0 -1
- package/dist/chunk-QIOJXTIQ.mjs.map +0 -1
- package/dist/chunk-RYUCX3ZK.mjs.map +0 -1
- package/dist/chunk-UFN2VWSR.mjs.map +0 -1
- package/dist/chunk-WNX755OE.mjs.map +0 -1
- package/dist/chunk-XWG3L6QC.mjs.map +0 -1
- /package/dist/{chunk-C3GSYRC3.mjs.map → chunk-BNJX66OH.mjs.map} +0 -0
- /package/dist/{chunk-NRA3CFEE.mjs.map → chunk-C27LZFA5.mjs.map} +0 -0
- /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-EACIYBQH.mjs.map} +0 -0
- /package/dist/{chunk-VHKHX7GV.mjs.map → chunk-HHLX4MQN.mjs.map} +0 -0
- /package/dist/{chunk-LBR23XXF.mjs.map → chunk-P34CL4LC.mjs.map} +0 -0
package/dist/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["export async function fetcher<JSON = any>(input: RequestInfo
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["export async function fetcher<JSON = any>(\n input: RequestInfo,\n init?: RequestInit,\n): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAsB,QACpB,OACA,MACe;AAAA;AACf,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH;","names":[]}
|
package/dist/lib/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["export async function fetcher<JSON = any>(input: RequestInfo
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["export async function fetcher<JSON = any>(\n input: RequestInfo,\n init?: RequestInit,\n): Promise<JSON> {\n const res = await fetch(input, init);\n\n if (!res.ok) {\n const json = await res.json();\n if (json.error) {\n const error = new Error(json.error) as Error & {\n status: number;\n };\n error.status = res.status;\n throw error;\n } else {\n throw new Error(\"An unexpected error occurred\");\n }\n }\n\n return res.json();\n}\n\nexport function formatDate(input: string | number | Date): string {\n const date = new Date(input);\n return date.toLocaleDateString(\"en-US\", {\n month: \"long\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n"],"mappings":";;;;;AAAA,SAAsB,QACpB,OACA,MACe;AAAA;AACf,UAAM,MAAM,MAAM,MAAM,OAAO,IAAI;AAEnC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI,KAAK,OAAO;AACd,cAAM,QAAQ,IAAI,MAAM,KAAK,KAAK;AAGlC,cAAM,SAAS,IAAI;AACnB,cAAM;AAAA,MACR,OAAO;AACL,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAChD;AAAA,IACF;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AAAA;AAEO,SAAS,WAAW,OAAuC;AAChE,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,KAAK,mBAAmB,SAAS;AAAA,IACtC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,MAAM;AAAA,EACR,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.51.4-next.
|
|
12
|
+
"version": "1.51.4-next.8",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"rehype-raw": "^7.0.0",
|
|
55
55
|
"remark-gfm": "^4.0.1",
|
|
56
56
|
"remark-math": "^6.0.0",
|
|
57
|
-
"@copilotkit/react-core": "1.51.4-next.
|
|
58
|
-
"@copilotkit/runtime-client-gql": "1.51.4-next.
|
|
59
|
-
"@copilotkit/shared": "1.51.4-next.
|
|
57
|
+
"@copilotkit/react-core": "1.51.4-next.8",
|
|
58
|
+
"@copilotkit/runtime-client-gql": "1.51.4-next.8",
|
|
59
|
+
"@copilotkit/shared": "1.51.4-next.8"
|
|
60
60
|
},
|
|
61
61
|
"keywords": [
|
|
62
62
|
"copilotkit",
|
|
@@ -75,7 +75,6 @@
|
|
|
75
75
|
"dev": "tsup --watch --no-splitting",
|
|
76
76
|
"test": "jest",
|
|
77
77
|
"check-types": "tsc --noEmit",
|
|
78
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
79
78
|
"link:global": "pnpm link --global",
|
|
80
79
|
"unlink:global": "pnpm unlink --global"
|
|
81
80
|
}
|
|
@@ -10,8 +10,12 @@ export const Button = ({}: ButtonProps) => {
|
|
|
10
10
|
className={`copilotKitButton ${open ? "open" : ""}`}
|
|
11
11
|
aria-label={open ? "Close Chat" : "Open Chat"}
|
|
12
12
|
>
|
|
13
|
-
<div className="copilotKitButtonIcon copilotKitButtonIconOpen">
|
|
14
|
-
|
|
13
|
+
<div className="copilotKitButtonIcon copilotKitButtonIconOpen">
|
|
14
|
+
{icons.openIcon}
|
|
15
|
+
</div>
|
|
16
|
+
<div className="copilotKitButtonIcon copilotKitButtonIconClose">
|
|
17
|
+
{icons.closeIcon}
|
|
18
|
+
</div>
|
|
15
19
|
</button>
|
|
16
20
|
</div>
|
|
17
21
|
);
|
|
@@ -386,9 +386,9 @@ export function CopilotChat({
|
|
|
386
386
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
387
387
|
const [selectedImages, setSelectedImages] = useState<Array<ImageUpload>>([]);
|
|
388
388
|
const [chatError, setChatError] = useState<ChatError | null>(null);
|
|
389
|
-
const [messageFeedback, setMessageFeedback] = useState<
|
|
390
|
-
|
|
391
|
-
);
|
|
389
|
+
const [messageFeedback, setMessageFeedback] = useState<
|
|
390
|
+
Record<string, "thumbsUp" | "thumbsDown">
|
|
391
|
+
>({});
|
|
392
392
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
393
393
|
|
|
394
394
|
// Helper function to trigger event hooks only if publicApiKey is provided
|
|
@@ -415,7 +415,8 @@ export function CopilotChat({
|
|
|
415
415
|
// Helper function to trigger chat error and render error UI
|
|
416
416
|
const triggerChatError = useCallback(
|
|
417
417
|
(error: any, operation: string, originalError?: any) => {
|
|
418
|
-
const errorMessage =
|
|
418
|
+
const errorMessage =
|
|
419
|
+
error?.message || error?.toString() || "An error occurred";
|
|
419
420
|
|
|
420
421
|
// Set chat error state for rendering
|
|
421
422
|
setChatError({
|
|
@@ -436,8 +437,12 @@ export function CopilotChat({
|
|
|
436
437
|
},
|
|
437
438
|
technical: {
|
|
438
439
|
environment: "browser",
|
|
439
|
-
userAgent:
|
|
440
|
-
|
|
440
|
+
userAgent:
|
|
441
|
+
typeof navigator !== "undefined"
|
|
442
|
+
? navigator.userAgent
|
|
443
|
+
: undefined,
|
|
444
|
+
stackTrace:
|
|
445
|
+
originalError instanceof Error ? originalError.stack : undefined,
|
|
441
446
|
},
|
|
442
447
|
},
|
|
443
448
|
error,
|
|
@@ -456,7 +461,8 @@ export function CopilotChat({
|
|
|
456
461
|
if (observabilityHooks?.onError && !publicApiKey) {
|
|
457
462
|
setBannerError(
|
|
458
463
|
new CopilotKitError({
|
|
459
|
-
message:
|
|
464
|
+
message:
|
|
465
|
+
"observabilityHooks.onError requires a publicApiKey to function.",
|
|
460
466
|
code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
461
467
|
severity: Severity.CRITICAL,
|
|
462
468
|
visibility: ErrorVisibility.BANNER,
|
|
@@ -497,30 +503,34 @@ export function CopilotChat({
|
|
|
497
503
|
|
|
498
504
|
e.preventDefault(); // Prevent default paste behavior for images
|
|
499
505
|
|
|
500
|
-
const imagePromises: Promise<ImageUpload | null>[] = imageItems.map(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
506
|
+
const imagePromises: Promise<ImageUpload | null>[] = imageItems.map(
|
|
507
|
+
(item) => {
|
|
508
|
+
const file = item.getAsFile();
|
|
509
|
+
if (!file) return Promise.resolve(null);
|
|
510
|
+
|
|
511
|
+
return new Promise<ImageUpload | null>((resolve, reject) => {
|
|
512
|
+
const reader = new FileReader();
|
|
513
|
+
reader.onload = (e) => {
|
|
514
|
+
const base64String = (e.target?.result as string)?.split(",")[1];
|
|
515
|
+
if (base64String) {
|
|
516
|
+
resolve({
|
|
517
|
+
contentType: file.type,
|
|
518
|
+
bytes: base64String,
|
|
519
|
+
});
|
|
520
|
+
} else {
|
|
521
|
+
resolve(null);
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
reader.onerror = reject;
|
|
525
|
+
reader.readAsDataURL(file);
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
);
|
|
521
529
|
|
|
522
530
|
try {
|
|
523
|
-
const loadedImages = (await Promise.all(imagePromises)).filter(
|
|
531
|
+
const loadedImages = (await Promise.all(imagePromises)).filter(
|
|
532
|
+
(img) => img !== null,
|
|
533
|
+
);
|
|
524
534
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
525
535
|
} catch (error) {
|
|
526
536
|
// Trigger chat-level error handler
|
|
@@ -630,29 +640,36 @@ export function CopilotChat({
|
|
|
630
640
|
triggerObservabilityHook("onMessageCopied", message);
|
|
631
641
|
};
|
|
632
642
|
|
|
633
|
-
const handleImageUpload = async (
|
|
643
|
+
const handleImageUpload = async (
|
|
644
|
+
event: React.ChangeEvent<HTMLInputElement>,
|
|
645
|
+
) => {
|
|
634
646
|
if (!event.target.files || event.target.files.length === 0) {
|
|
635
647
|
return;
|
|
636
648
|
}
|
|
637
649
|
|
|
638
|
-
const files = Array.from(event.target.files).filter((file) =>
|
|
650
|
+
const files = Array.from(event.target.files).filter((file) =>
|
|
651
|
+
file.type.startsWith("image/"),
|
|
652
|
+
);
|
|
639
653
|
if (files.length === 0) return;
|
|
640
654
|
|
|
641
655
|
const fileReadPromises = files.map((file) => {
|
|
642
|
-
return new Promise<{ contentType: string; bytes: string }>(
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
+
return new Promise<{ contentType: string; bytes: string }>(
|
|
657
|
+
(resolve, reject) => {
|
|
658
|
+
const reader = new FileReader();
|
|
659
|
+
reader.onload = (e) => {
|
|
660
|
+
const base64String =
|
|
661
|
+
(e.target?.result as string)?.split(",")[1] || "";
|
|
662
|
+
if (base64String) {
|
|
663
|
+
resolve({
|
|
664
|
+
contentType: file.type,
|
|
665
|
+
bytes: base64String,
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
reader.onerror = reject;
|
|
670
|
+
reader.readAsDataURL(file);
|
|
671
|
+
},
|
|
672
|
+
);
|
|
656
673
|
});
|
|
657
674
|
|
|
658
675
|
try {
|
|
@@ -747,7 +764,10 @@ export function CopilotChat({
|
|
|
747
764
|
|
|
748
765
|
{imageUploadsEnabled && (
|
|
749
766
|
<>
|
|
750
|
-
<ImageUploadQueue
|
|
767
|
+
<ImageUploadQueue
|
|
768
|
+
images={selectedImages}
|
|
769
|
+
onRemoveImage={removeSelectedImage}
|
|
770
|
+
/>
|
|
751
771
|
<input
|
|
752
772
|
type="file"
|
|
753
773
|
multiple
|
|
@@ -765,7 +785,9 @@ export function CopilotChat({
|
|
|
765
785
|
onSend={handleSendMessage}
|
|
766
786
|
isVisible={isVisible}
|
|
767
787
|
onStop={stopGeneration}
|
|
768
|
-
onUpload={
|
|
788
|
+
onUpload={
|
|
789
|
+
imageUploadsEnabled ? () => fileInputRef.current?.click() : undefined
|
|
790
|
+
}
|
|
769
791
|
hideStopButton={hideStopButton}
|
|
770
792
|
/>
|
|
771
793
|
</WrappedCopilotChat>
|
|
@@ -786,7 +808,12 @@ export function WrappedCopilotChat({
|
|
|
786
808
|
const chatContext = React.useContext(ChatContext);
|
|
787
809
|
if (!chatContext) {
|
|
788
810
|
return (
|
|
789
|
-
<ChatContextProvider
|
|
811
|
+
<ChatContextProvider
|
|
812
|
+
icons={icons}
|
|
813
|
+
labels={labels}
|
|
814
|
+
open={true}
|
|
815
|
+
setOpen={() => {}}
|
|
816
|
+
>
|
|
790
817
|
<div className={`copilotKitChat ${className ?? ""}`}>{children}</div>
|
|
791
818
|
</ChatContextProvider>
|
|
792
819
|
);
|
|
@@ -160,7 +160,9 @@ interface ChatContext {
|
|
|
160
160
|
setOpen: (open: boolean) => void;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export const ChatContext = React.createContext<ChatContext | undefined>(
|
|
163
|
+
export const ChatContext = React.createContext<ChatContext | undefined>(
|
|
164
|
+
undefined,
|
|
165
|
+
);
|
|
164
166
|
|
|
165
167
|
export function useChatContext(): ChatContext {
|
|
166
168
|
const context = React.useContext(ChatContext);
|
|
@@ -244,5 +246,7 @@ export const ChatContextProvider = ({
|
|
|
244
246
|
[memoizedLabels, memoizedIcons, open, setOpen],
|
|
245
247
|
);
|
|
246
248
|
|
|
247
|
-
return
|
|
249
|
+
return (
|
|
250
|
+
<ChatContext.Provider value={context}>{children}</ChatContext.Provider>
|
|
251
|
+
);
|
|
248
252
|
};
|
|
@@ -55,9 +55,9 @@ export const generateRandomString = (length: number, lowercase = false) => {
|
|
|
55
55
|
|
|
56
56
|
const CodeBlock: FC<Props> = memo(({ language, value }) => {
|
|
57
57
|
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
|
|
58
|
-
const [SyntaxHighlighter, setSyntaxHighlighter] = useState<
|
|
59
|
-
|
|
60
|
-
);
|
|
58
|
+
const [SyntaxHighlighter, setSyntaxHighlighter] = useState<
|
|
59
|
+
typeof Light | typeof Prism
|
|
60
|
+
>(() => Light);
|
|
61
61
|
|
|
62
62
|
useEffect(() => {
|
|
63
63
|
try {
|
|
@@ -103,7 +103,10 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
|
|
|
103
103
|
<div className="copilotKitCodeBlockToolbar">
|
|
104
104
|
<span className="copilotKitCodeBlockToolbarLanguage">{language}</span>
|
|
105
105
|
<div className="copilotKitCodeBlockToolbarButtons">
|
|
106
|
-
<button
|
|
106
|
+
<button
|
|
107
|
+
className="copilotKitCodeBlockToolbarButton"
|
|
108
|
+
onClick={downloadAsFile}
|
|
109
|
+
>
|
|
107
110
|
{DownloadIcon}
|
|
108
111
|
</button>
|
|
109
112
|
<button className="copilotKitCodeBlockToolbarButton" onClick={onCopy}>
|
|
@@ -139,7 +142,8 @@ const highlightStyle: any = {
|
|
|
139
142
|
color: "#d4d4d4",
|
|
140
143
|
fontSize: "13px",
|
|
141
144
|
textShadow: "none",
|
|
142
|
-
fontFamily:
|
|
145
|
+
fontFamily:
|
|
146
|
+
'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
143
147
|
direction: "ltr",
|
|
144
148
|
textAlign: "left",
|
|
145
149
|
whiteSpace: "pre",
|
|
@@ -162,7 +166,8 @@ const highlightStyle: any = {
|
|
|
162
166
|
color: "#d4d4d4",
|
|
163
167
|
fontSize: "13px",
|
|
164
168
|
textShadow: "none",
|
|
165
|
-
fontFamily:
|
|
169
|
+
fontFamily:
|
|
170
|
+
'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
166
171
|
direction: "ltr",
|
|
167
172
|
textAlign: "left",
|
|
168
173
|
whiteSpace: "pre",
|
|
@@ -28,7 +28,11 @@ export const CloseIcon = (
|
|
|
28
28
|
width="24"
|
|
29
29
|
height="24"
|
|
30
30
|
>
|
|
31
|
-
<path
|
|
31
|
+
<path
|
|
32
|
+
strokeLinecap="round"
|
|
33
|
+
strokeLinejoin="round"
|
|
34
|
+
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
|
|
35
|
+
/>
|
|
32
36
|
</svg>
|
|
33
37
|
);
|
|
34
38
|
|
|
@@ -42,7 +46,11 @@ export const HeaderCloseIcon = (
|
|
|
42
46
|
width="24"
|
|
43
47
|
height="24"
|
|
44
48
|
>
|
|
45
|
-
<path
|
|
49
|
+
<path
|
|
50
|
+
strokeLinecap="round"
|
|
51
|
+
strokeLinejoin="round"
|
|
52
|
+
d="M6 18L18 6M6 6l12 12"
|
|
53
|
+
/>
|
|
46
54
|
</svg>
|
|
47
55
|
);
|
|
48
56
|
|
|
@@ -56,7 +64,11 @@ export const SendIcon = (
|
|
|
56
64
|
width="24"
|
|
57
65
|
height="24"
|
|
58
66
|
>
|
|
59
|
-
<path
|
|
67
|
+
<path
|
|
68
|
+
strokeLinecap="round"
|
|
69
|
+
strokeLinejoin="round"
|
|
70
|
+
d="M12 19V5m0 0l-7 7m7-7l7 7"
|
|
71
|
+
/>
|
|
60
72
|
</svg>
|
|
61
73
|
);
|
|
62
74
|
|
|
@@ -135,18 +147,33 @@ export const CopyIcon = (
|
|
|
135
147
|
);
|
|
136
148
|
|
|
137
149
|
export const SmallSpinnerIcon = (
|
|
138
|
-
<span
|
|
150
|
+
<span
|
|
151
|
+
className="copilotKitSpinner"
|
|
152
|
+
style={{ width: "13px", height: "13px" }}
|
|
153
|
+
></span>
|
|
139
154
|
);
|
|
140
155
|
|
|
141
156
|
export const SpinnerIcon = (
|
|
142
|
-
<span
|
|
157
|
+
<span
|
|
158
|
+
className="copilotKitSpinner"
|
|
159
|
+
style={{ width: "24px", height: "24px" }}
|
|
160
|
+
></span>
|
|
143
161
|
);
|
|
144
162
|
|
|
145
163
|
export const ActivityIcon = (
|
|
146
164
|
<div style={{ display: "flex", alignItems: "center", gap: "4px" }}>
|
|
147
|
-
<span
|
|
148
|
-
|
|
149
|
-
|
|
165
|
+
<span
|
|
166
|
+
className="copilotKitActivityDot"
|
|
167
|
+
style={{ animationDelay: "0s" }}
|
|
168
|
+
></span>
|
|
169
|
+
<span
|
|
170
|
+
className="copilotKitActivityDot"
|
|
171
|
+
style={{ animationDelay: "0.2s" }}
|
|
172
|
+
></span>
|
|
173
|
+
<span
|
|
174
|
+
className="copilotKitActivityDot"
|
|
175
|
+
style={{ animationDelay: "0.4s" }}
|
|
176
|
+
></span>
|
|
150
177
|
</div>
|
|
151
178
|
);
|
|
152
179
|
|
|
@@ -217,7 +244,11 @@ export const UploadIcon = (
|
|
|
217
244
|
width="24"
|
|
218
245
|
height="24"
|
|
219
246
|
>
|
|
220
|
-
<path
|
|
247
|
+
<path
|
|
248
|
+
strokeLinecap="round"
|
|
249
|
+
strokeLinejoin="round"
|
|
250
|
+
d="M12 4.5v15m7.5-7.5h-15"
|
|
251
|
+
/>
|
|
221
252
|
</svg>
|
|
222
253
|
);
|
|
223
254
|
|
|
@@ -232,6 +263,10 @@ export const CheckIcon = (
|
|
|
232
263
|
height="16"
|
|
233
264
|
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
234
265
|
>
|
|
235
|
-
<path
|
|
266
|
+
<path
|
|
267
|
+
strokeLinecap="round"
|
|
268
|
+
strokeLinejoin="round"
|
|
269
|
+
d="M4.5 12.75l6 6 9-13.5"
|
|
270
|
+
/>
|
|
236
271
|
</svg>
|
|
237
272
|
);
|
|
@@ -3,7 +3,10 @@ import { InputProps } from "./props";
|
|
|
3
3
|
import { useChatContext } from "./ChatContext";
|
|
4
4
|
import AutoResizingTextarea from "./Textarea";
|
|
5
5
|
import { usePushToTalk } from "../../hooks/use-push-to-talk";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useCopilotContext,
|
|
8
|
+
useCopilotChatInternal,
|
|
9
|
+
} from "@copilotkit/react-core";
|
|
7
10
|
import { PoweredByTag } from "./PoweredByTag";
|
|
8
11
|
|
|
9
12
|
const MAX_NEWLINES = 6;
|
|
@@ -72,11 +75,18 @@ export const Input = ({
|
|
|
72
75
|
|
|
73
76
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
74
77
|
const { buttonIcon, buttonAlt } = useMemo(() => {
|
|
75
|
-
if (!chatReady)
|
|
78
|
+
if (!chatReady)
|
|
79
|
+
return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
|
|
76
80
|
return isInProgress && !hideStopButton && chatReady
|
|
77
81
|
? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" }
|
|
78
82
|
: { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
|
|
79
|
-
}, [
|
|
83
|
+
}, [
|
|
84
|
+
isInProgress,
|
|
85
|
+
chatReady,
|
|
86
|
+
hideStopButton,
|
|
87
|
+
context.icons.stopIcon,
|
|
88
|
+
context.icons.sendIcon,
|
|
89
|
+
]);
|
|
80
90
|
const showPushToTalk =
|
|
81
91
|
pushToTalkConfigured &&
|
|
82
92
|
(pushToTalkState === "idle" || pushToTalkState === "recording") &&
|
|
@@ -85,7 +95,12 @@ export const Input = ({
|
|
|
85
95
|
const { interrupt } = useCopilotChatInternal();
|
|
86
96
|
|
|
87
97
|
const canSend = useMemo(() => {
|
|
88
|
-
return
|
|
98
|
+
return (
|
|
99
|
+
!isInProgress &&
|
|
100
|
+
text.trim().length > 0 &&
|
|
101
|
+
pushToTalkState === "idle" &&
|
|
102
|
+
!interrupt
|
|
103
|
+
);
|
|
89
104
|
}, [interrupt, isInProgress, text, pushToTalkState]);
|
|
90
105
|
|
|
91
106
|
const canStop = useMemo(() => {
|
|
@@ -95,7 +110,9 @@ export const Input = ({
|
|
|
95
110
|
const sendDisabled = !canSend && !canStop;
|
|
96
111
|
|
|
97
112
|
return (
|
|
98
|
-
<div
|
|
113
|
+
<div
|
|
114
|
+
className={`copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`}
|
|
115
|
+
>
|
|
99
116
|
<div className="copilotKitInput" onClick={handleDivClick}>
|
|
100
117
|
<AutoResizingTextarea
|
|
101
118
|
ref={textareaRef}
|
|
@@ -127,7 +144,9 @@ export const Input = ({
|
|
|
127
144
|
{showPushToTalk && (
|
|
128
145
|
<button
|
|
129
146
|
onClick={() =>
|
|
130
|
-
setPushToTalkState(
|
|
147
|
+
setPushToTalkState(
|
|
148
|
+
pushToTalkState === "idle" ? "recording" : "transcribing",
|
|
149
|
+
)
|
|
131
150
|
}
|
|
132
151
|
className={
|
|
133
152
|
pushToTalkState === "recording"
|
|
@@ -142,7 +161,11 @@ export const Input = ({
|
|
|
142
161
|
disabled={sendDisabled}
|
|
143
162
|
onClick={isInProgress && !hideStopButton ? onStop : send}
|
|
144
163
|
data-copilotkit-in-progress={inProgress}
|
|
145
|
-
data-test-id={
|
|
164
|
+
data-test-id={
|
|
165
|
+
inProgress
|
|
166
|
+
? "copilot-chat-request-in-progress"
|
|
167
|
+
: "copilot-chat-ready"
|
|
168
|
+
}
|
|
146
169
|
className="copilotKitInputControlButton"
|
|
147
170
|
aria-label={buttonAlt}
|
|
148
171
|
>
|
|
@@ -8,7 +8,12 @@ import rehypeRaw from "rehype-raw";
|
|
|
8
8
|
const defaultComponents: Components = {
|
|
9
9
|
a({ children, ...props }) {
|
|
10
10
|
return (
|
|
11
|
-
<a
|
|
11
|
+
<a
|
|
12
|
+
className="copilotKitMarkdownElement"
|
|
13
|
+
{...props}
|
|
14
|
+
target="_blank"
|
|
15
|
+
rel="noopener noreferrer"
|
|
16
|
+
>
|
|
12
17
|
{children}
|
|
13
18
|
</a>
|
|
14
19
|
);
|
|
@@ -121,7 +126,8 @@ const defaultComponents: Components = {
|
|
|
121
126
|
const MemoizedReactMarkdown: FC<Options> = memo(
|
|
122
127
|
ReactMarkdown,
|
|
123
128
|
(prevProps, nextProps) =>
|
|
124
|
-
prevProps.children === nextProps.children &&
|
|
129
|
+
prevProps.children === nextProps.children &&
|
|
130
|
+
prevProps.components === nextProps.components,
|
|
125
131
|
);
|
|
126
132
|
|
|
127
133
|
type MarkdownProps = {
|
|
@@ -134,7 +140,10 @@ export const Markdown = ({ content, components }: MarkdownProps) => {
|
|
|
134
140
|
<div className="copilotKitMarkdown">
|
|
135
141
|
<MemoizedReactMarkdown
|
|
136
142
|
components={{ ...defaultComponents, ...components }}
|
|
137
|
-
remarkPlugins={[
|
|
143
|
+
remarkPlugins={[
|
|
144
|
+
remarkGfm,
|
|
145
|
+
[remarkMath, { singleDollarTextMath: false }],
|
|
146
|
+
]}
|
|
138
147
|
rehypePlugins={[rehypeRaw]}
|
|
139
148
|
>
|
|
140
149
|
{content}
|
|
@@ -3,7 +3,10 @@ import { MessagesProps } from "./props";
|
|
|
3
3
|
import { useChatContext } from "./ChatContext";
|
|
4
4
|
import { Message } from "@copilotkit/shared";
|
|
5
5
|
import { useCopilotChatInternal } from "@copilotkit/react-core";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
LegacyRenderMessage,
|
|
8
|
+
LegacyRenderProps,
|
|
9
|
+
} from "./messages/LegacyRenderMessage";
|
|
7
10
|
|
|
8
11
|
export const Messages = ({
|
|
9
12
|
inProgress,
|
|
@@ -30,7 +33,10 @@ export const Messages = ({
|
|
|
30
33
|
}: MessagesProps) => {
|
|
31
34
|
const { labels, icons } = useChatContext();
|
|
32
35
|
const { messages: visibleMessages, interrupt } = useCopilotChatInternal();
|
|
33
|
-
const initialMessages = useMemo(
|
|
36
|
+
const initialMessages = useMemo(
|
|
37
|
+
() => makeInitialMessages(labels.initial),
|
|
38
|
+
[labels.initial],
|
|
39
|
+
);
|
|
34
40
|
const messages = [...initialMessages, ...visibleMessages];
|
|
35
41
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
36
42
|
|
|
@@ -74,7 +80,9 @@ export const Messages = ({
|
|
|
74
80
|
|
|
75
81
|
// Determine which render component to use
|
|
76
82
|
const MessageRenderer = hasLegacyProps
|
|
77
|
-
? (props: any) =>
|
|
83
|
+
? (props: any) => (
|
|
84
|
+
<LegacyRenderMessage {...props} legacyProps={legacyProps} />
|
|
85
|
+
)
|
|
78
86
|
: RenderMessage;
|
|
79
87
|
|
|
80
88
|
const LoadingIcon = () => <span>{icons.activityIcon}</span>;
|
|
@@ -104,9 +112,13 @@ export const Messages = ({
|
|
|
104
112
|
/>
|
|
105
113
|
);
|
|
106
114
|
})}
|
|
107
|
-
{messages[messages.length - 1]?.role === "user" && inProgress &&
|
|
115
|
+
{messages[messages.length - 1]?.role === "user" && inProgress && (
|
|
116
|
+
<LoadingIcon />
|
|
117
|
+
)}
|
|
108
118
|
{interrupt}
|
|
109
|
-
{chatError && ErrorMessage &&
|
|
119
|
+
{chatError && ErrorMessage && (
|
|
120
|
+
<ErrorMessage error={chatError} isCurrentMessage />
|
|
121
|
+
)}
|
|
110
122
|
</div>
|
|
111
123
|
<footer className="copilotKitMessagesFooter" ref={messagesEndRef}>
|
|
112
124
|
{children}
|
|
@@ -115,7 +127,9 @@ export const Messages = ({
|
|
|
115
127
|
);
|
|
116
128
|
};
|
|
117
129
|
|
|
118
|
-
function makeInitialMessages(
|
|
130
|
+
function makeInitialMessages(
|
|
131
|
+
initial: string | string[] | undefined,
|
|
132
|
+
): Message[] {
|
|
119
133
|
if (!initial) return [];
|
|
120
134
|
|
|
121
135
|
if (Array.isArray(initial)) {
|
|
@@ -146,7 +160,8 @@ export function useScrollToBottom(messages: Message[]) {
|
|
|
146
160
|
const scrollToBottom = () => {
|
|
147
161
|
if (messagesContainerRef.current && messagesEndRef.current) {
|
|
148
162
|
isProgrammaticScrollRef.current = true;
|
|
149
|
-
messagesContainerRef.current.scrollTop =
|
|
163
|
+
messagesContainerRef.current.scrollTop =
|
|
164
|
+
messagesContainerRef.current.scrollHeight;
|
|
150
165
|
}
|
|
151
166
|
};
|
|
152
167
|
|
|
@@ -157,7 +172,8 @@ export function useScrollToBottom(messages: Message[]) {
|
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
if (messagesContainerRef.current) {
|
|
160
|
-
const { scrollTop, scrollHeight, clientHeight } =
|
|
175
|
+
const { scrollTop, scrollHeight, clientHeight } =
|
|
176
|
+
messagesContainerRef.current;
|
|
161
177
|
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
162
178
|
}
|
|
163
179
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React, { useMemo, useCallback, useEffect, useRef } from "react";
|
|
2
2
|
import { ChatContextProvider, useChatContext } from "./ChatContext";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ButtonProps,
|
|
5
|
+
HeaderProps,
|
|
6
|
+
WindowProps,
|
|
7
|
+
CopilotObservabilityHooks,
|
|
8
|
+
} from "./props";
|
|
4
9
|
import { Window as DefaultWindow } from "./Window";
|
|
5
10
|
import { Button as DefaultButton } from "./Button";
|
|
6
11
|
import { Header as DefaultHeader } from "./Header";
|
|
@@ -185,7 +190,12 @@ export const CopilotModal = ({
|
|
|
185
190
|
const [openState, setOpenState] = React.useState(defaultOpen);
|
|
186
191
|
|
|
187
192
|
return (
|
|
188
|
-
<ChatContextProvider
|
|
193
|
+
<ChatContextProvider
|
|
194
|
+
icons={icons}
|
|
195
|
+
labels={labels}
|
|
196
|
+
open={openState}
|
|
197
|
+
setOpen={setOpenState}
|
|
198
|
+
>
|
|
189
199
|
<CopilotModalInner
|
|
190
200
|
observabilityHooks={observabilityHooks}
|
|
191
201
|
onSetOpen={onSetOpen}
|
|
@@ -71,7 +71,9 @@ import { CopilotModal, CopilotModalProps } from "./Modal";
|
|
|
71
71
|
export function CopilotPopup(props: CopilotModalProps) {
|
|
72
72
|
props = {
|
|
73
73
|
...props,
|
|
74
|
-
className: props.className
|
|
74
|
+
className: props.className
|
|
75
|
+
? props.className + " copilotKitPopup"
|
|
76
|
+
: "copilotKitPopup",
|
|
75
77
|
};
|
|
76
78
|
return <CopilotModal {...props}>{props.children}</CopilotModal>;
|
|
77
79
|
}
|