@copilotkit/react-ui 0.0.0-fix-debug-infosys-20251107151227 → 0.0.0-fix-restore-handle-method-node-http-20251222114321
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 +331 -5
- package/dist/{chunk-ZJCHKHE4.mjs → chunk-3W6J75HS.mjs} +13 -10
- package/dist/chunk-3W6J75HS.mjs.map +1 -0
- package/dist/{chunk-RKULVDQO.mjs → chunk-7OURDQZJ.mjs} +9 -2
- package/dist/chunk-7OURDQZJ.mjs.map +1 -0
- package/dist/{chunk-TZNQJ3NA.mjs → chunk-7PR2KJDO.mjs} +6 -6
- package/dist/{chunk-FK3XMHLY.mjs → chunk-ELUJRANC.mjs} +2 -2
- package/dist/{chunk-OWX6YJZH.mjs → chunk-HIW7RXCD.mjs} +9 -5
- package/dist/chunk-HIW7RXCD.mjs.map +1 -0
- package/dist/{chunk-KX44MLR6.mjs → chunk-IHFR6PYG.mjs} +1 -1
- package/dist/chunk-IHFR6PYG.mjs.map +1 -0
- package/dist/{chunk-52RQLNFB.mjs → chunk-LQEFRHRT.mjs} +2 -2
- package/dist/{chunk-2XARU6EY.mjs → chunk-NCIAFFQ2.mjs} +7 -3
- package/dist/chunk-NCIAFFQ2.mjs.map +1 -0
- package/dist/{chunk-W26XFBEG.mjs → chunk-NGJ32FAP.mjs} +3 -3
- package/dist/chunk-NGJ32FAP.mjs.map +1 -0
- package/dist/chunk-QB3GUN2N.mjs +31 -0
- package/dist/chunk-QB3GUN2N.mjs.map +1 -0
- package/dist/{chunk-MJEYL3FK.mjs → chunk-QPQRLXN3.mjs} +25 -255
- package/dist/chunk-QPQRLXN3.mjs.map +1 -0
- package/dist/chunk-RYUCX3ZK.mjs +32 -0
- package/dist/chunk-RYUCX3ZK.mjs.map +1 -0
- package/dist/chunk-Y4FKRAKJ.mjs +12 -0
- package/dist/chunk-Y4FKRAKJ.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +3 -140
- package/dist/components/chat/Chat.js +80 -270
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +12 -14
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +11 -8
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +1 -1
- package/dist/components/chat/Messages.d.ts +3 -3
- package/dist/components/chat/Messages.js +35 -4
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +6 -6
- package/dist/components/chat/Modal.d.ts +1 -6
- package/dist/components/chat/Modal.js +86 -274
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +11 -11
- package/dist/components/chat/Popup.d.ts +1 -6
- package/dist/components/chat/Popup.js +86 -274
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +12 -12
- package/dist/components/chat/Sidebar.d.ts +1 -6
- package/dist/components/chat/Sidebar.js +86 -274
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +12 -12
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/Suggestions.d.ts +1 -1
- package/dist/components/chat/Suggestions.js +19 -12
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +2 -2
- package/dist/components/chat/index.d.ts +0 -5
- package/dist/components/chat/index.js +86 -274
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +15 -15
- 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.mjs +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.js +30 -3
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +5 -5
- package/dist/components/chat/messages/RenderMessage.d.ts +1 -1
- package/dist/components/chat/messages/RenderMessage.js +23 -3
- package/dist/components/chat/messages/RenderMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderMessage.mjs +4 -4
- package/dist/components/chat/messages/UserMessage.js +19 -3
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/chat/props.d.ts +4 -0
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.js +86 -274
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +15 -15
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -24
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +4 -26
- package/dist/hooks/use-copilot-chat-suggestions.js +2 -24
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +89 -299
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -16
- package/dist/types/suggestions.d.ts +1 -0
- package/dist/types/suggestions.js.map +1 -1
- package/dist/v2/index.css +4 -0
- package/dist/v2/index.css.map +1 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +2 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +2 -0
- package/dist/v2/index.mjs.map +1 -0
- package/package.json +8 -7
- package/src/components/chat/Chat.tsx +21 -374
- package/src/components/chat/Input.tsx +13 -12
- package/src/components/chat/Messages.tsx +8 -4
- package/src/components/chat/Suggestion.tsx +2 -2
- package/src/components/chat/Suggestions.tsx +6 -2
- package/src/components/chat/messages/AssistantMessage.tsx +1 -0
- package/src/components/chat/messages/LegacyRenderMessage.tsx +7 -0
- package/src/components/chat/messages/RenderMessage.tsx +4 -0
- package/src/components/chat/messages/UserMessage.tsx +32 -6
- package/src/components/chat/props.ts +4 -0
- package/src/css/messages.css +1 -1
- package/src/hooks/use-copilot-chat-suggestions.tsx +6 -57
- package/src/types/suggestions.ts +1 -0
- package/src/v2/index.ts +1 -0
- package/src/v2/styles.css +1 -0
- package/tsup.config.ts +1 -1
- package/dist/chunk-226ZMOE3.mjs +0 -24
- package/dist/chunk-226ZMOE3.mjs.map +0 -1
- package/dist/chunk-2XARU6EY.mjs.map +0 -1
- package/dist/chunk-EYRKZDP5.mjs +0 -32
- package/dist/chunk-EYRKZDP5.mjs.map +0 -1
- package/dist/chunk-KX44MLR6.mjs.map +0 -1
- package/dist/chunk-MJEYL3FK.mjs.map +0 -1
- package/dist/chunk-OWX6YJZH.mjs.map +0 -1
- package/dist/chunk-RKULVDQO.mjs.map +0 -1
- package/dist/chunk-VVL6JFCJ.mjs +0 -16
- package/dist/chunk-VVL6JFCJ.mjs.map +0 -1
- package/dist/chunk-W26XFBEG.mjs.map +0 -1
- package/dist/chunk-ZJCHKHE4.mjs.map +0 -1
- /package/dist/{chunk-TZNQJ3NA.mjs.map → chunk-7PR2KJDO.mjs.map} +0 -0
- /package/dist/{chunk-FK3XMHLY.mjs.map → chunk-ELUJRANC.mjs.map} +0 -0
- /package/dist/{chunk-52RQLNFB.mjs.map → chunk-LQEFRHRT.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import "./chunk-EFZPSZWO.mjs";
|
|
3
3
|
import "./chunk-MMVDU6DF.mjs";
|
|
4
4
|
import "./chunk-SC6JRFAJ.mjs";
|
|
5
|
-
import {
|
|
6
|
-
CopilotSidebar
|
|
7
|
-
} from "./chunk-52RQLNFB.mjs";
|
|
8
5
|
import "./chunk-WB3YULQ4.mjs";
|
|
9
6
|
import {
|
|
10
7
|
CopilotPopup
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import
|
|
8
|
+
} from "./chunk-ELUJRANC.mjs";
|
|
9
|
+
import {
|
|
10
|
+
CopilotSidebar
|
|
11
|
+
} from "./chunk-LQEFRHRT.mjs";
|
|
12
|
+
import "./chunk-7PR2KJDO.mjs";
|
|
13
13
|
import "./chunk-C3GSYRC3.mjs";
|
|
14
14
|
import "./chunk-GDSZGYCE.mjs";
|
|
15
15
|
import "./chunk-V7W6IM2V.mjs";
|
|
@@ -26,42 +26,42 @@ import "./chunk-BH6PCAAL.mjs";
|
|
|
26
26
|
import "./chunk-UFN2VWSR.mjs";
|
|
27
27
|
import {
|
|
28
28
|
CopilotChat
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-QPQRLXN3.mjs";
|
|
30
30
|
import {
|
|
31
31
|
Suggestions
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-QB3GUN2N.mjs";
|
|
33
33
|
import {
|
|
34
34
|
Suggestion
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-NGJ32FAP.mjs";
|
|
36
36
|
import "./chunk-PLHTVHUW.mjs";
|
|
37
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-3W6J75HS.mjs";
|
|
38
38
|
import "./chunk-ELGRNEAO.mjs";
|
|
39
39
|
import "./chunk-QIOJXTIQ.mjs";
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-
|
|
42
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-HIW7RXCD.mjs";
|
|
41
|
+
import "./chunk-7OURDQZJ.mjs";
|
|
42
|
+
import "./chunk-NCIAFFQ2.mjs";
|
|
43
43
|
import {
|
|
44
44
|
AssistantMessage
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-IHFR6PYG.mjs";
|
|
46
46
|
import {
|
|
47
47
|
ImageRenderer
|
|
48
48
|
} from "./chunk-DBKRAOH7.mjs";
|
|
49
49
|
import {
|
|
50
50
|
UserMessage
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-RYUCX3ZK.mjs";
|
|
52
52
|
import {
|
|
53
53
|
Markdown
|
|
54
54
|
} from "./chunk-JZ3RFQQ6.mjs";
|
|
55
|
+
import "./chunk-IK2BPURM.mjs";
|
|
55
56
|
import {
|
|
56
57
|
useChatContext
|
|
57
58
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
58
|
-
import "./chunk-IK2BPURM.mjs";
|
|
59
59
|
import "./chunk-XWG3L6QC.mjs";
|
|
60
60
|
import "./chunk-IU3WTXLQ.mjs";
|
|
61
61
|
import "./chunk-T26KLXLH.mjs";
|
|
62
62
|
import {
|
|
63
63
|
useCopilotChatSuggestions
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-Y4FKRAKJ.mjs";
|
|
65
65
|
import "./chunk-54JAUBUJ.mjs";
|
|
66
66
|
import "./chunk-JGMFJZMG.mjs";
|
|
67
67
|
import "./chunk-O72ZB5V3.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/suggestions.ts"],"sourcesContent":["export interface CopilotChatSuggestion {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/suggestions.ts"],"sourcesContent":["export interface CopilotChatSuggestion {\n title: string;\n message: string;\n partial?: boolean;\n isLoading?: boolean;\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/v2/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.0.0-fix-
|
|
12
|
+
"version": "0.0.0-fix-restore-handle-method-node-http-20251222114321",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"require": "./dist/index.js",
|
|
22
22
|
"types": "./dist/index.d.ts"
|
|
23
23
|
},
|
|
24
|
-
"./styles.css": "./dist/index.css"
|
|
24
|
+
"./styles.css": "./dist/index.css",
|
|
25
|
+
"./v2/styles.css": "./dist/v2/index.css"
|
|
25
26
|
},
|
|
26
27
|
"types": "./dist/index.d.ts",
|
|
27
28
|
"license": "MIT",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/jest": "^29.5.4",
|
|
33
|
-
"@types/react": "^
|
|
34
|
+
"@types/react": "^19.1.0",
|
|
34
35
|
"@types/react-syntax-highlighter": "^15.5.7",
|
|
35
36
|
"eslint": "^8.56.0",
|
|
36
37
|
"jest": "^29.6.4",
|
|
@@ -45,15 +46,15 @@
|
|
|
45
46
|
"tsconfig": "1.4.6"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@headlessui/react": "^2.
|
|
49
|
+
"@headlessui/react": "^2.2.9",
|
|
49
50
|
"react-markdown": "^10.1.0",
|
|
50
51
|
"react-syntax-highlighter": "^15.6.1",
|
|
51
52
|
"rehype-raw": "^7.0.0",
|
|
52
53
|
"remark-gfm": "^4.0.1",
|
|
53
54
|
"remark-math": "^6.0.0",
|
|
54
|
-
"@copilotkit/react-core": "0.0.0-fix-
|
|
55
|
-
"@copilotkit/runtime-client-gql": "0.0.0-fix-
|
|
56
|
-
"@copilotkit/shared": "0.0.0-fix-
|
|
55
|
+
"@copilotkit/react-core": "0.0.0-fix-restore-handle-method-node-http-20251222114321",
|
|
56
|
+
"@copilotkit/runtime-client-gql": "0.0.0-fix-restore-handle-method-node-http-20251222114321",
|
|
57
|
+
"@copilotkit/shared": "0.0.0-fix-restore-handle-method-node-http-20251222114321"
|
|
57
58
|
},
|
|
58
59
|
"keywords": [
|
|
59
60
|
"copilotkit",
|
|
@@ -74,14 +74,15 @@ import { RenderMessage as DefaultRenderMessage } from "./messages/RenderMessage"
|
|
|
74
74
|
import { AssistantMessage as DefaultAssistantMessage } from "./messages/AssistantMessage";
|
|
75
75
|
import { UserMessage as DefaultUserMessage } from "./messages/UserMessage";
|
|
76
76
|
import { ImageRenderer as DefaultImageRenderer } from "./messages/ImageRenderer";
|
|
77
|
-
import React, { useEffect, useRef, useState, useCallback
|
|
77
|
+
import React, { useEffect, useRef, useState, useCallback } from "react";
|
|
78
78
|
import {
|
|
79
79
|
SystemMessageFunction,
|
|
80
|
-
useCopilotChatInternal as useCopilotChat,
|
|
81
80
|
useCopilotContext,
|
|
82
|
-
|
|
81
|
+
useCopilotChatInternal,
|
|
82
|
+
type OnStopGeneration,
|
|
83
|
+
type OnReloadMessages,
|
|
84
|
+
type ChatSuggestions,
|
|
83
85
|
} from "@copilotkit/react-core";
|
|
84
|
-
import type { SuggestionItem } from "@copilotkit/react-core";
|
|
85
86
|
import {
|
|
86
87
|
CopilotKitError,
|
|
87
88
|
CopilotKitErrorCode,
|
|
@@ -91,8 +92,8 @@ import {
|
|
|
91
92
|
ErrorVisibility,
|
|
92
93
|
styledConsole,
|
|
93
94
|
CopilotErrorHandler,
|
|
95
|
+
randomUUID,
|
|
94
96
|
} from "@copilotkit/shared";
|
|
95
|
-
import { randomId } from "@copilotkit/shared";
|
|
96
97
|
import {
|
|
97
98
|
AssistantMessageProps,
|
|
98
99
|
ChatError,
|
|
@@ -107,19 +108,9 @@ import {
|
|
|
107
108
|
UserMessageProps,
|
|
108
109
|
} from "./props";
|
|
109
110
|
|
|
110
|
-
import { HintFunction, runAgent, stopAgent } from "@copilotkit/react-core";
|
|
111
111
|
import { ImageUploadQueue } from "./ImageUploadQueue";
|
|
112
112
|
import { Suggestions as DefaultRenderSuggestionsList } from "./Suggestions";
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
* The type of suggestions to use in the chat.
|
|
116
|
-
*
|
|
117
|
-
* `auto` - Suggestions are generated automatically.
|
|
118
|
-
* `manual` - Suggestions are controlled programmatically.
|
|
119
|
-
* `SuggestionItem[]` - Static suggestions array.
|
|
120
|
-
*/
|
|
121
|
-
export type ChatSuggestions = "auto" | "manual" | SuggestionItem[];
|
|
122
|
-
|
|
123
114
|
/**
|
|
124
115
|
* Props for CopilotChat component.
|
|
125
116
|
*/
|
|
@@ -339,59 +330,6 @@ export interface CopilotChatProps {
|
|
|
339
330
|
onError?: CopilotErrorHandler;
|
|
340
331
|
}
|
|
341
332
|
|
|
342
|
-
interface OnStopGenerationArguments {
|
|
343
|
-
/**
|
|
344
|
-
* The name of the currently executing agent.
|
|
345
|
-
*/
|
|
346
|
-
currentAgentName: string | undefined;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* The messages in the chat.
|
|
350
|
-
*/
|
|
351
|
-
messages: Message[];
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Set the messages in the chat.
|
|
355
|
-
*/
|
|
356
|
-
setMessages: (messages: Message[]) => void;
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Stop chat generation.
|
|
360
|
-
*/
|
|
361
|
-
stopGeneration: () => void;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Restart the currently executing agent.
|
|
365
|
-
*/
|
|
366
|
-
restartCurrentAgent: () => void;
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Stop the currently executing agent.
|
|
370
|
-
*/
|
|
371
|
-
stopCurrentAgent: () => void;
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Run the currently executing agent.
|
|
375
|
-
*/
|
|
376
|
-
runCurrentAgent: (hint?: HintFunction) => Promise<void>;
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Set the state of the currently executing agent.
|
|
380
|
-
*/
|
|
381
|
-
setCurrentAgentState: (state: any) => void;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
export type OnReloadMessagesArguments = OnStopGenerationArguments & {
|
|
385
|
-
/**
|
|
386
|
-
* The message on which "regenerate" was pressed
|
|
387
|
-
*/
|
|
388
|
-
messageId: string;
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
export type OnStopGeneration = (args: OnStopGenerationArguments) => void;
|
|
392
|
-
|
|
393
|
-
export type OnReloadMessages = (args: OnReloadMessagesArguments) => void;
|
|
394
|
-
|
|
395
333
|
export type ImageUpload = {
|
|
396
334
|
contentType: string;
|
|
397
335
|
bytes: string;
|
|
@@ -625,15 +563,17 @@ export function CopilotChat({
|
|
|
625
563
|
stopGeneration,
|
|
626
564
|
reloadMessages,
|
|
627
565
|
suggestions: currentSuggestions,
|
|
628
|
-
|
|
566
|
+
isLoadingSuggestions,
|
|
567
|
+
agent,
|
|
568
|
+
} = useCopilotChatInternal({
|
|
629
569
|
suggestions,
|
|
630
|
-
makeSystemMessage,
|
|
631
|
-
disableSystemMessage,
|
|
632
570
|
onInProgress,
|
|
633
571
|
onSubmitMessage,
|
|
634
572
|
onStopGeneration,
|
|
635
573
|
onReloadMessages,
|
|
636
|
-
);
|
|
574
|
+
});
|
|
575
|
+
// makeSystemMessage,
|
|
576
|
+
// disableSystemMessage,
|
|
637
577
|
|
|
638
578
|
// Track loading state changes for chat start/stop events
|
|
639
579
|
const prevIsLoading = useRef(isLoading);
|
|
@@ -659,7 +599,12 @@ export function CopilotChat({
|
|
|
659
599
|
// Trigger message sent event
|
|
660
600
|
triggerObservabilityHook("onMessageSent", text);
|
|
661
601
|
|
|
662
|
-
|
|
602
|
+
// TODO: send images?
|
|
603
|
+
return sendMessage({
|
|
604
|
+
id: randomUUID(),
|
|
605
|
+
content: text,
|
|
606
|
+
role: "user",
|
|
607
|
+
});
|
|
663
608
|
};
|
|
664
609
|
|
|
665
610
|
const chatContext = React.useContext(ChatContext);
|
|
@@ -795,6 +740,7 @@ export function CopilotChat({
|
|
|
795
740
|
<RenderSuggestionsList
|
|
796
741
|
onSuggestionClick={handleSendMessage}
|
|
797
742
|
suggestions={currentSuggestions}
|
|
743
|
+
isLoading={isLoadingSuggestions}
|
|
798
744
|
/>
|
|
799
745
|
)}
|
|
800
746
|
</Messages>
|
|
@@ -814,6 +760,8 @@ export function CopilotChat({
|
|
|
814
760
|
)}
|
|
815
761
|
<Input
|
|
816
762
|
inProgress={isLoading}
|
|
763
|
+
chatReady={Boolean(agent)}
|
|
764
|
+
// @ts-ignore
|
|
817
765
|
onSend={handleSendMessage}
|
|
818
766
|
isVisible={isVisible}
|
|
819
767
|
onStop={stopGeneration}
|
|
@@ -845,304 +793,3 @@ export function WrappedCopilotChat({
|
|
|
845
793
|
}
|
|
846
794
|
return <>{children}</>;
|
|
847
795
|
}
|
|
848
|
-
|
|
849
|
-
export const useCopilotChatLogic = (
|
|
850
|
-
chatSuggestions: ChatSuggestions,
|
|
851
|
-
makeSystemMessage?: SystemMessageFunction,
|
|
852
|
-
disableSystemMessage?: boolean,
|
|
853
|
-
onInProgress?: (isLoading: boolean) => void,
|
|
854
|
-
onSubmitMessage?: (messageContent: string) => Promise<void> | void,
|
|
855
|
-
onStopGeneration?: OnStopGeneration,
|
|
856
|
-
onReloadMessages?: OnReloadMessages,
|
|
857
|
-
) => {
|
|
858
|
-
const {
|
|
859
|
-
messages,
|
|
860
|
-
sendMessage,
|
|
861
|
-
setMessages,
|
|
862
|
-
reloadMessages: defaultReloadMessages,
|
|
863
|
-
stopGeneration: defaultStopGeneration,
|
|
864
|
-
runChatCompletion,
|
|
865
|
-
isLoading,
|
|
866
|
-
suggestions,
|
|
867
|
-
setSuggestions,
|
|
868
|
-
generateSuggestions,
|
|
869
|
-
resetSuggestions: resetSuggestionsFromHook,
|
|
870
|
-
isLoadingSuggestions,
|
|
871
|
-
} = useCopilotChat({
|
|
872
|
-
makeSystemMessage,
|
|
873
|
-
disableSystemMessage,
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
const generalContext = useCopilotContext();
|
|
877
|
-
const messagesContext = useCopilotMessagesContext();
|
|
878
|
-
|
|
879
|
-
// Get actions from context for message conversion
|
|
880
|
-
const { actions } = generalContext;
|
|
881
|
-
|
|
882
|
-
// Suggestion state management
|
|
883
|
-
const [suggestionsFailed, setSuggestionsFailed] = useState(false);
|
|
884
|
-
const hasGeneratedInitialSuggestions = useRef<boolean>(false);
|
|
885
|
-
|
|
886
|
-
// Handle static suggestions (when suggestions prop is an array)
|
|
887
|
-
useEffect(() => {
|
|
888
|
-
if (Array.isArray(chatSuggestions)) {
|
|
889
|
-
setSuggestions(chatSuggestions);
|
|
890
|
-
hasGeneratedInitialSuggestions.current = true;
|
|
891
|
-
}
|
|
892
|
-
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
893
|
-
|
|
894
|
-
// Error handling wrapper
|
|
895
|
-
const generateSuggestionsWithErrorHandling = useCallback(
|
|
896
|
-
async (context: string) => {
|
|
897
|
-
try {
|
|
898
|
-
await generateSuggestions();
|
|
899
|
-
} catch (error) {
|
|
900
|
-
console.error("Failed to generate suggestions:", error);
|
|
901
|
-
setSuggestionsFailed(true);
|
|
902
|
-
}
|
|
903
|
-
},
|
|
904
|
-
[generateSuggestions],
|
|
905
|
-
);
|
|
906
|
-
|
|
907
|
-
// Automatic suggestion generation logic
|
|
908
|
-
useEffect(() => {
|
|
909
|
-
// Only proceed if in auto mode, not currently loading, and not failed
|
|
910
|
-
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
// Don't run during chat loading (when the assistant is responding)
|
|
915
|
-
if (isLoading) {
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Check if we have any configurations
|
|
920
|
-
if (Object.keys(generalContext.chatSuggestionConfiguration).length === 0) {
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// Generate initial suggestions when chat is empty
|
|
925
|
-
if (messages.length === 0 && !hasGeneratedInitialSuggestions.current) {
|
|
926
|
-
hasGeneratedInitialSuggestions.current = true;
|
|
927
|
-
generateSuggestionsWithErrorHandling("initial");
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
// Generate post-message suggestions after assistant responds
|
|
932
|
-
if (messages.length > 0 && suggestions.length === 0) {
|
|
933
|
-
generateSuggestionsWithErrorHandling("post-message");
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
}, [
|
|
937
|
-
chatSuggestions,
|
|
938
|
-
isLoadingSuggestions,
|
|
939
|
-
suggestionsFailed,
|
|
940
|
-
messages.length,
|
|
941
|
-
isLoading,
|
|
942
|
-
suggestions.length,
|
|
943
|
-
Object.keys(generalContext.chatSuggestionConfiguration).join(","), // Use stable string instead of object reference
|
|
944
|
-
generateSuggestionsWithErrorHandling,
|
|
945
|
-
]);
|
|
946
|
-
|
|
947
|
-
// Reset suggestion state when switching away from auto mode
|
|
948
|
-
useEffect(() => {
|
|
949
|
-
if (chatSuggestions !== "auto") {
|
|
950
|
-
hasGeneratedInitialSuggestions.current = false;
|
|
951
|
-
setSuggestionsFailed(false);
|
|
952
|
-
}
|
|
953
|
-
}, [chatSuggestions]);
|
|
954
|
-
|
|
955
|
-
// Memoize context to prevent infinite re-renders
|
|
956
|
-
const stableContext = useMemo(
|
|
957
|
-
() => ({
|
|
958
|
-
...generalContext,
|
|
959
|
-
...messagesContext,
|
|
960
|
-
}),
|
|
961
|
-
[
|
|
962
|
-
// Only include stable dependencies
|
|
963
|
-
generalContext.actions,
|
|
964
|
-
messagesContext.messages.length,
|
|
965
|
-
generalContext.isLoading,
|
|
966
|
-
],
|
|
967
|
-
);
|
|
968
|
-
|
|
969
|
-
// Wrapper for resetSuggestions that also resets local state
|
|
970
|
-
const resetSuggestions = useCallback(() => {
|
|
971
|
-
resetSuggestionsFromHook();
|
|
972
|
-
setSuggestionsFailed(false);
|
|
973
|
-
hasGeneratedInitialSuggestions.current = false;
|
|
974
|
-
}, [resetSuggestionsFromHook]);
|
|
975
|
-
|
|
976
|
-
useEffect(() => {
|
|
977
|
-
onInProgress?.(isLoading);
|
|
978
|
-
}, [onInProgress, isLoading]);
|
|
979
|
-
|
|
980
|
-
const safelySendMessage = async (
|
|
981
|
-
messageContent: string,
|
|
982
|
-
imagesToUse?: Array<{ contentType: string; bytes: string }>,
|
|
983
|
-
) => {
|
|
984
|
-
const images = imagesToUse || [];
|
|
985
|
-
|
|
986
|
-
// Clear existing suggestions when user sends a message
|
|
987
|
-
// This prevents stale suggestions from remaining visible during new conversation flow
|
|
988
|
-
if (chatSuggestions === "auto" || chatSuggestions === "manual") {
|
|
989
|
-
setSuggestions([]);
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
let firstMessage: Message | null = null;
|
|
993
|
-
|
|
994
|
-
// Send text message if content provided
|
|
995
|
-
if (messageContent.trim().length > 0) {
|
|
996
|
-
const textMessage: Message = {
|
|
997
|
-
id: randomId(),
|
|
998
|
-
role: "user",
|
|
999
|
-
content: messageContent,
|
|
1000
|
-
};
|
|
1001
|
-
|
|
1002
|
-
// Call user-provided submit handler if available
|
|
1003
|
-
if (onSubmitMessage) {
|
|
1004
|
-
try {
|
|
1005
|
-
await onSubmitMessage(messageContent);
|
|
1006
|
-
} catch (error) {
|
|
1007
|
-
console.error("Error in onSubmitMessage:", error);
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// Send the message and clear suggestions for auto/manual modes
|
|
1012
|
-
await sendMessage(textMessage, {
|
|
1013
|
-
followUp: images.length === 0,
|
|
1014
|
-
clearSuggestions: chatSuggestions === "auto" || chatSuggestions === "manual",
|
|
1015
|
-
});
|
|
1016
|
-
|
|
1017
|
-
if (!firstMessage) {
|
|
1018
|
-
firstMessage = textMessage;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
// Send image messages
|
|
1023
|
-
if (images.length > 0) {
|
|
1024
|
-
for (let i = 0; i < images.length; i++) {
|
|
1025
|
-
const imageMessage = {
|
|
1026
|
-
id: randomId(),
|
|
1027
|
-
role: "user" as const,
|
|
1028
|
-
image: {
|
|
1029
|
-
format: images[i].contentType.replace("image/", ""),
|
|
1030
|
-
bytes: images[i].bytes,
|
|
1031
|
-
},
|
|
1032
|
-
} as unknown as Message;
|
|
1033
|
-
await sendMessage(imageMessage, { followUp: i === images.length - 1 });
|
|
1034
|
-
if (!firstMessage) {
|
|
1035
|
-
firstMessage = imageMessage;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
if (!firstMessage) {
|
|
1041
|
-
// Should not happen if send button is properly disabled, but handle just in case
|
|
1042
|
-
return { role: "user", content: "", id: randomId() } as Message; // Return a dummy message
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
// The hook implicitly triggers API call on appendMessage.
|
|
1046
|
-
// We return the first message sent (either text or first image)
|
|
1047
|
-
return firstMessage;
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
const currentAgentName = generalContext.agentSession?.agentName;
|
|
1051
|
-
const restartCurrentAgent = async (hint?: HintFunction) => {
|
|
1052
|
-
if (generalContext.agentSession) {
|
|
1053
|
-
generalContext.setAgentSession({
|
|
1054
|
-
...generalContext.agentSession,
|
|
1055
|
-
nodeName: undefined,
|
|
1056
|
-
threadId: undefined,
|
|
1057
|
-
});
|
|
1058
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
1059
|
-
return {
|
|
1060
|
-
...prevAgentStates,
|
|
1061
|
-
[generalContext.agentSession!.agentName]: {
|
|
1062
|
-
...prevAgentStates[generalContext.agentSession!.agentName],
|
|
1063
|
-
threadId: undefined,
|
|
1064
|
-
nodeName: undefined,
|
|
1065
|
-
runId: undefined,
|
|
1066
|
-
},
|
|
1067
|
-
};
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
const runCurrentAgent = async (hint?: HintFunction) => {
|
|
1072
|
-
if (generalContext.agentSession) {
|
|
1073
|
-
await runAgent(
|
|
1074
|
-
generalContext.agentSession.agentName,
|
|
1075
|
-
stableContext,
|
|
1076
|
-
messagesContext.messages,
|
|
1077
|
-
sendMessage,
|
|
1078
|
-
runChatCompletion,
|
|
1079
|
-
);
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
const stopCurrentAgent = () => {
|
|
1083
|
-
if (generalContext.agentSession) {
|
|
1084
|
-
stopAgent(generalContext.agentSession.agentName, stableContext);
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
const setCurrentAgentState = (state: any) => {
|
|
1088
|
-
if (generalContext.agentSession) {
|
|
1089
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
1090
|
-
return {
|
|
1091
|
-
...prevAgentStates,
|
|
1092
|
-
[generalContext.agentSession!.agentName]: {
|
|
1093
|
-
state,
|
|
1094
|
-
},
|
|
1095
|
-
} as any;
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
function stopGeneration() {
|
|
1101
|
-
// Clear suggestions when stopping generation
|
|
1102
|
-
setSuggestions([]);
|
|
1103
|
-
|
|
1104
|
-
if (onStopGeneration) {
|
|
1105
|
-
onStopGeneration({
|
|
1106
|
-
messages: messages,
|
|
1107
|
-
setMessages,
|
|
1108
|
-
stopGeneration: defaultStopGeneration,
|
|
1109
|
-
currentAgentName,
|
|
1110
|
-
restartCurrentAgent,
|
|
1111
|
-
stopCurrentAgent,
|
|
1112
|
-
runCurrentAgent,
|
|
1113
|
-
setCurrentAgentState,
|
|
1114
|
-
});
|
|
1115
|
-
} else {
|
|
1116
|
-
defaultStopGeneration();
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
function reloadMessages(messageId: string) {
|
|
1120
|
-
if (onReloadMessages) {
|
|
1121
|
-
onReloadMessages({
|
|
1122
|
-
messages: messages,
|
|
1123
|
-
setMessages,
|
|
1124
|
-
stopGeneration: defaultStopGeneration,
|
|
1125
|
-
currentAgentName,
|
|
1126
|
-
restartCurrentAgent,
|
|
1127
|
-
stopCurrentAgent,
|
|
1128
|
-
runCurrentAgent,
|
|
1129
|
-
setCurrentAgentState,
|
|
1130
|
-
messageId,
|
|
1131
|
-
});
|
|
1132
|
-
} else {
|
|
1133
|
-
defaultReloadMessages(messageId);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
return {
|
|
1138
|
-
messages,
|
|
1139
|
-
isLoading,
|
|
1140
|
-
suggestions,
|
|
1141
|
-
sendMessage: safelySendMessage,
|
|
1142
|
-
stopGeneration,
|
|
1143
|
-
reloadMessages,
|
|
1144
|
-
resetSuggestions,
|
|
1145
|
-
context: stableContext,
|
|
1146
|
-
actions,
|
|
1147
|
-
};
|
|
1148
|
-
};
|
|
@@ -3,7 +3,7 @@ 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 { useCopilotContext } from "@copilotkit/react-core";
|
|
6
|
+
import { useCopilotContext, useCopilotChatInternal } from "@copilotkit/react-core";
|
|
7
7
|
import { PoweredByTag } from "./PoweredByTag";
|
|
8
8
|
|
|
9
9
|
const MAX_NEWLINES = 6;
|
|
@@ -11,7 +11,7 @@ const MAX_NEWLINES = 6;
|
|
|
11
11
|
export const Input = ({
|
|
12
12
|
inProgress,
|
|
13
13
|
onSend,
|
|
14
|
-
|
|
14
|
+
chatReady = false,
|
|
15
15
|
onStop,
|
|
16
16
|
onUpload,
|
|
17
17
|
hideStopButton = false,
|
|
@@ -71,22 +71,22 @@ export const Input = ({
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
74
|
-
const buttonIcon =
|
|
75
|
-
|
|
74
|
+
const { buttonIcon, buttonAlt } = useMemo(() => {
|
|
75
|
+
if (!chatReady) return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
|
|
76
|
+
return isInProgress && !hideStopButton && chatReady
|
|
77
|
+
? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" }
|
|
78
|
+
: { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
|
|
79
|
+
}, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
|
|
76
80
|
const showPushToTalk =
|
|
77
81
|
pushToTalkConfigured &&
|
|
78
82
|
(pushToTalkState === "idle" || pushToTalkState === "recording") &&
|
|
79
83
|
!inProgress;
|
|
80
84
|
|
|
81
|
-
const
|
|
82
|
-
const interruptEvent = copilotContext.langGraphInterruptAction?.event;
|
|
83
|
-
const interruptInProgress =
|
|
84
|
-
interruptEvent?.name === "LangGraphInterruptEvent" && !interruptEvent?.response;
|
|
85
|
+
const { interrupt } = useCopilotChatInternal();
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, [copilotContext.langGraphInterruptAction?.event, isInProgress, text, pushToTalkState]);
|
|
87
|
+
const canSend = useMemo(() => {
|
|
88
|
+
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
|
|
89
|
+
}, [interrupt, isInProgress, text, pushToTalkState]);
|
|
90
90
|
|
|
91
91
|
const canStop = useMemo(() => {
|
|
92
92
|
return isInProgress && !hideStopButton;
|
|
@@ -144,6 +144,7 @@ export const Input = ({
|
|
|
144
144
|
data-copilotkit-in-progress={inProgress}
|
|
145
145
|
data-test-id={inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready"}
|
|
146
146
|
className="copilotKitInputControlButton"
|
|
147
|
+
aria-label={buttonAlt}
|
|
147
148
|
>
|
|
148
149
|
{buttonIcon}
|
|
149
150
|
</button>
|