@uipath/apollo-react 7.5.0 → 7.6.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/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.cjs +70 -17
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.d.ts +2 -2
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.d.ts.map +1 -1
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.js +70 -17
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.cjs +26 -1
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.d.ts +10 -2
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.d.ts.map +1 -1
- package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.js +9 -0
- package/dist/canvas/components/NodeVariablesPanel/index.d.ts +1 -1
- package/dist/canvas/components/NodeVariablesPanel/index.d.ts.map +1 -1
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/headless/hooks/use-suggestions.cjs +2 -1
- package/dist/chat/headless/hooks/use-suggestions.d.ts.map +1 -1
- package/dist/chat/headless/hooks/use-suggestions.js +2 -1
- package/dist/chat/headless/providers/chat-scroll-provider.cjs +13 -0
- package/dist/chat/headless/providers/chat-scroll-provider.d.ts.map +1 -1
- package/dist/chat/headless/providers/chat-scroll-provider.js +13 -0
- package/dist/chat/headless/providers/chat-state-provider.cjs +15 -17
- package/dist/chat/headless/providers/chat-state-provider.d.ts +1 -2
- package/dist/chat/headless/providers/chat-state-provider.d.ts.map +1 -1
- package/dist/chat/headless/providers/chat-state-provider.js +16 -15
- package/dist/chat/headless/providers/chat-width-provider.cjs +10 -6
- package/dist/chat/headless/providers/chat-width-provider.d.ts.map +1 -1
- package/dist/chat/headless/providers/chat-width-provider.js +10 -6
- package/dist/chat/root/ChatRoot.cjs +16 -10
- package/dist/chat/root/ChatRoot.d.ts.map +1 -1
- package/dist/chat/root/ChatRoot.js +16 -10
- package/dist/chat/service/ChatService.cjs +30 -3
- package/dist/chat/service/ChatService.d.ts +5 -0
- package/dist/chat/service/ChatService.d.ts.map +1 -1
- package/dist/chat/service/ChatService.js +30 -3
- package/dist/chat/service/suggestions-state.cjs +44 -0
- package/dist/chat/service/suggestions-state.d.ts +9 -0
- package/dist/chat/service/suggestions-state.d.ts.map +1 -0
- package/dist/chat/service/suggestions-state.js +7 -0
- package/dist/chat/stories/chat-playground.d.ts.map +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/material/components/ap-model-picker/ModelTagChip.cjs +9 -3
- package/dist/material/components/ap-model-picker/ModelTagChip.d.ts +1 -0
- package/dist/material/components/ap-model-picker/ModelTagChip.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/ModelTagChip.js +5 -2
- package/dist/material/components/ap-model-picker/locales/de.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/de.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/de.js +1 -1
- package/dist/material/components/ap-model-picker/locales/en.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/en.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/en.js +1 -1
- package/dist/material/components/ap-model-picker/locales/es-MX.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/es-MX.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/es-MX.js +1 -1
- package/dist/material/components/ap-model-picker/locales/es.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/es.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/es.js +1 -1
- package/dist/material/components/ap-model-picker/locales/fr.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/fr.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/fr.js +1 -1
- package/dist/material/components/ap-model-picker/locales/ja.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/ja.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/ja.js +1 -1
- package/dist/material/components/ap-model-picker/locales/ko.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/ko.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/ko.js +1 -1
- package/dist/material/components/ap-model-picker/locales/pt-BR.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/pt-BR.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/pt-BR.js +1 -1
- package/dist/material/components/ap-model-picker/locales/pt.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/pt.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/pt.js +1 -1
- package/dist/material/components/ap-model-picker/locales/ro.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/ro.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/ro.js +1 -1
- package/dist/material/components/ap-model-picker/locales/ru.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/ru.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/ru.js +1 -1
- package/dist/material/components/ap-model-picker/locales/tr.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/tr.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/tr.js +1 -1
- package/dist/material/components/ap-model-picker/locales/zh-CN.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/zh-CN.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/zh-CN.js +1 -1
- package/dist/material/components/ap-model-picker/locales/zh-TW.cjs +1 -1
- package/dist/material/components/ap-model-picker/locales/zh-TW.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/locales/zh-TW.js +1 -1
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.cjs +5 -20
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.js +5 -20
- package/dist/material/components/ap-model-picker/primitives/ModelTagStrip.cjs +152 -0
- package/dist/material/components/ap-model-picker/primitives/ModelTagStrip.d.ts +8 -0
- package/dist/material/components/ap-model-picker/primitives/ModelTagStrip.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/ModelTagStrip.js +108 -0
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.cjs +5 -10
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.d.ts.map +1 -1
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.js +5 -10
- package/dist/material/components/ap-model-picker/useVisibleCount.cjs +91 -0
- package/dist/material/components/ap-model-picker/useVisibleCount.d.ts +7 -0
- package/dist/material/components/ap-model-picker/useVisibleCount.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/useVisibleCount.js +57 -0
- package/package.json +3 -3
|
@@ -39,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
39
39
|
const external_react_namespaceObject = require("react");
|
|
40
40
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
41
41
|
const index_cjs_namespaceObject = require("../../service/index.cjs");
|
|
42
|
+
const suggestions_state_cjs_namespaceObject = require("../../service/suggestions-state.cjs");
|
|
42
43
|
const chat_service_provider_cjs_namespaceObject = require("../providers/chat-service.provider.cjs");
|
|
43
44
|
const chat_state_provider_cjs_namespaceObject = require("../providers/chat-state-provider.cjs");
|
|
44
45
|
function useSuggestionSelect() {
|
|
@@ -58,7 +59,7 @@ function useConversationSuggestions(messages) {
|
|
|
58
59
|
return {
|
|
59
60
|
suggestions: suggestions.items,
|
|
60
61
|
sendOnClick: suggestions.sendOnClick ?? firstRunExperience?.sendOnClick ?? false,
|
|
61
|
-
attached: suggestions.items.length > 0 && void 0 !== messages && messages.length > 0 && (0,
|
|
62
|
+
attached: suggestions.items.length > 0 && void 0 !== messages && messages.length > 0 && (0, suggestions_state_cjs_namespaceObject.countUserTurns)(messages) === suggestions.userTurns
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
exports.useConversationSuggestions = __webpack_exports__.useConversationSuggestions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-suggestions.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/hooks/use-suggestions.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"use-suggestions.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/hooks/use-suggestions.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAC;AASvB,wBAAgB,mBAAmB,iBAIlB,uBAAuB,eAAe,OAAO,UAU7D;AAQD,wBAAgB,0BAA0B,CAAC,QAAQ,CAAC,EAAE,SAAS,oBAAoB,EAAE;;;;EAapF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { AutopilotChatInternalEvent } from "../../service/index.js";
|
|
3
|
+
import { countUserTurns } from "../../service/suggestions-state.js";
|
|
3
4
|
import { useChatService } from "../providers/chat-service.provider.js";
|
|
4
|
-
import {
|
|
5
|
+
import { useChatState } from "../providers/chat-state-provider.js";
|
|
5
6
|
function useSuggestionSelect() {
|
|
6
7
|
const chatService = useChatService();
|
|
7
8
|
return react.useCallback((suggestion, sendOnClick)=>{
|
|
@@ -58,6 +58,7 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
58
58
|
const scrollHeightBeforePrependRef = external_react_default().useRef(0);
|
|
59
59
|
const [overflowContainer, setOverflowContainer] = external_react_default().useState(null);
|
|
60
60
|
const [autoScroll, setAutoScroll] = external_react_default().useState(true);
|
|
61
|
+
const serviceAutoScrollRef = external_react_default().useRef(true);
|
|
61
62
|
const [isOverflow, setIsOverflow] = external_react_default().useState(false);
|
|
62
63
|
const [isContainerWide, setIsContainerWide] = external_react_default().useState(false);
|
|
63
64
|
const checkOverflow = external_react_default().useCallback(()=>{
|
|
@@ -180,14 +181,17 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
180
181
|
external_react_default().useEffect(()=>{
|
|
181
182
|
if (!chatService) return;
|
|
182
183
|
const unsubscribeRequestIntercept = chatService.intercept(index_cjs_namespaceObject.AutopilotChatInterceptableEvent.Request, ()=>{
|
|
184
|
+
serviceAutoScrollRef.current = true;
|
|
183
185
|
setAutoScroll(true);
|
|
184
186
|
useInstantScrollRef.current = false;
|
|
185
187
|
});
|
|
186
188
|
const unsubscribeNewChat = chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.NewChat, ()=>{
|
|
189
|
+
serviceAutoScrollRef.current = true;
|
|
187
190
|
setAutoScroll(true);
|
|
188
191
|
useInstantScrollRef.current = false;
|
|
189
192
|
});
|
|
190
193
|
const unsubscribeOpenConversation = chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.OpenConversation, ()=>{
|
|
194
|
+
serviceAutoScrollRef.current = true;
|
|
191
195
|
setAutoScroll(true);
|
|
192
196
|
});
|
|
193
197
|
const unsubscribeSetConversation = chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.SetConversation, ()=>{
|
|
@@ -197,6 +201,7 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
197
201
|
useInstantScrollRef.current = true;
|
|
198
202
|
});
|
|
199
203
|
const unsubscribeToggleAutoScroll = chatService.__internalService__.on(index_cjs_namespaceObject.AutopilotChatInternalEvent.ToggleAutoScroll, (autoScrollValue)=>{
|
|
204
|
+
serviceAutoScrollRef.current = autoScrollValue;
|
|
200
205
|
setAutoScroll(autoScrollValue);
|
|
201
206
|
});
|
|
202
207
|
const unsubscribeSetIsLoadingMoreMessages = chatService.__internalService__.on(index_cjs_namespaceObject.AutopilotChatInternalEvent.SetIsLoadingMoreMessages, (value)=>{
|
|
@@ -218,6 +223,14 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
218
223
|
}, [
|
|
219
224
|
chatService
|
|
220
225
|
]);
|
|
226
|
+
external_react_default().useEffect(()=>{
|
|
227
|
+
if (!overflowContainer) return;
|
|
228
|
+
previousHeightRef.current = 0;
|
|
229
|
+
useInstantScrollRef.current = true;
|
|
230
|
+
setAutoScroll(serviceAutoScrollRef.current);
|
|
231
|
+
}, [
|
|
232
|
+
overflowContainer
|
|
233
|
+
]);
|
|
221
234
|
external_react_default().useEffect(()=>{
|
|
222
235
|
const content = contentRef.current;
|
|
223
236
|
if (!content || !overflowContainer || !chatService) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-scroll-provider.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/providers/chat-scroll-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,UAAU,8BAA8B;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;IAClG,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC,oBAAoB,EAAE,CAAC,iBAAiB,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,UAAU,gCAAgC;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,
|
|
1
|
+
{"version":3,"file":"chat-scroll-provider.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/providers/chat-scroll-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,UAAU,8BAA8B;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;IAClG,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC,oBAAoB,EAAE,CAAC,iBAAiB,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,UAAU,gCAAgC;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAwYlF,CAAC;AAEF,eAAO,MAAM,aAAa,sCAQzB,CAAC"}
|
|
@@ -19,6 +19,7 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
19
19
|
const scrollHeightBeforePrependRef = react.useRef(0);
|
|
20
20
|
const [overflowContainer, setOverflowContainer] = react.useState(null);
|
|
21
21
|
const [autoScroll, setAutoScroll] = react.useState(true);
|
|
22
|
+
const serviceAutoScrollRef = react.useRef(true);
|
|
22
23
|
const [isOverflow, setIsOverflow] = react.useState(false);
|
|
23
24
|
const [isContainerWide, setIsContainerWide] = react.useState(false);
|
|
24
25
|
const checkOverflow = react.useCallback(()=>{
|
|
@@ -141,14 +142,17 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
141
142
|
react.useEffect(()=>{
|
|
142
143
|
if (!chatService) return;
|
|
143
144
|
const unsubscribeRequestIntercept = chatService.intercept(AutopilotChatInterceptableEvent.Request, ()=>{
|
|
145
|
+
serviceAutoScrollRef.current = true;
|
|
144
146
|
setAutoScroll(true);
|
|
145
147
|
useInstantScrollRef.current = false;
|
|
146
148
|
});
|
|
147
149
|
const unsubscribeNewChat = chatService.on(AutopilotChatEvent.NewChat, ()=>{
|
|
150
|
+
serviceAutoScrollRef.current = true;
|
|
148
151
|
setAutoScroll(true);
|
|
149
152
|
useInstantScrollRef.current = false;
|
|
150
153
|
});
|
|
151
154
|
const unsubscribeOpenConversation = chatService.on(AutopilotChatEvent.OpenConversation, ()=>{
|
|
155
|
+
serviceAutoScrollRef.current = true;
|
|
152
156
|
setAutoScroll(true);
|
|
153
157
|
});
|
|
154
158
|
const unsubscribeSetConversation = chatService.on(AutopilotChatEvent.SetConversation, ()=>{
|
|
@@ -158,6 +162,7 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
158
162
|
useInstantScrollRef.current = true;
|
|
159
163
|
});
|
|
160
164
|
const unsubscribeToggleAutoScroll = chatService.__internalService__.on(AutopilotChatInternalEvent.ToggleAutoScroll, (autoScrollValue)=>{
|
|
165
|
+
serviceAutoScrollRef.current = autoScrollValue;
|
|
161
166
|
setAutoScroll(autoScrollValue);
|
|
162
167
|
});
|
|
163
168
|
const unsubscribeSetIsLoadingMoreMessages = chatService.__internalService__.on(AutopilotChatInternalEvent.SetIsLoadingMoreMessages, (value)=>{
|
|
@@ -179,6 +184,14 @@ const AutopilotChatScrollProvider = ({ children })=>{
|
|
|
179
184
|
}, [
|
|
180
185
|
chatService
|
|
181
186
|
]);
|
|
187
|
+
react.useEffect(()=>{
|
|
188
|
+
if (!overflowContainer) return;
|
|
189
|
+
previousHeightRef.current = 0;
|
|
190
|
+
useInstantScrollRef.current = true;
|
|
191
|
+
setAutoScroll(serviceAutoScrollRef.current);
|
|
192
|
+
}, [
|
|
193
|
+
overflowContainer
|
|
194
|
+
]);
|
|
182
195
|
react.useEffect(()=>{
|
|
183
196
|
const content = contentRef.current;
|
|
184
197
|
if (!content || !overflowContainer || !chatService) return;
|
|
@@ -34,8 +34,7 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
useChatState: ()=>useChatState,
|
|
37
|
-
AutopilotChatStateProvider: ()=>AutopilotChatStateProvider
|
|
38
|
-
countUserTurns: ()=>countUserTurns
|
|
37
|
+
AutopilotChatStateProvider: ()=>AutopilotChatStateProvider
|
|
39
38
|
});
|
|
40
39
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
41
40
|
const apollo_core_namespaceObject = require("@uipath/apollo-core");
|
|
@@ -44,10 +43,16 @@ const external_react_namespaceObject = require("react");
|
|
|
44
43
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
45
44
|
const index_cjs_namespaceObject = require("../../service/index.cjs");
|
|
46
45
|
const external_chat_service_provider_cjs_namespaceObject = require("./chat-service.provider.cjs");
|
|
47
|
-
const countUserTurns = (messages)=>messages.reduce((count, message)=>count + (message.role === index_cjs_namespaceObject.AutopilotChatRole.User ? 1 : 0), 0);
|
|
48
46
|
const NO_SUGGESTIONS = {
|
|
49
47
|
items: []
|
|
50
48
|
};
|
|
49
|
+
const toSuggestionsState = ({ suggestions, sendOnClick, userTurns })=>0 === suggestions.length ? NO_SUGGESTIONS : {
|
|
50
|
+
items: [
|
|
51
|
+
...suggestions
|
|
52
|
+
],
|
|
53
|
+
sendOnClick,
|
|
54
|
+
userTurns
|
|
55
|
+
};
|
|
51
56
|
const AutopilotChatStateContext = /*#__PURE__*/ external_react_default().createContext(null);
|
|
52
57
|
const calculateSpacing = (chatSpacing)=>{
|
|
53
58
|
const compactMode = chatSpacing?.compactMode ?? false;
|
|
@@ -139,7 +144,10 @@ const AutopilotChatStateProvider = ({ children, portalContainer })=>{
|
|
|
139
144
|
const [readOnly, setReadOnly] = external_react_default().useState(chatService?.getReadOnly() ?? false);
|
|
140
145
|
const [spacing, setSpacing] = external_react_default().useState(calculateSpacing(chatService?.getConfig()?.spacing));
|
|
141
146
|
const [theming, setTheming] = external_react_default().useState(chatService?.getConfig()?.theming);
|
|
142
|
-
const [
|
|
147
|
+
const [suggestionsSnapshot, setSuggestionsSnapshot] = external_react_default().useState(()=>chatService.__suggestions__);
|
|
148
|
+
const suggestions = external_react_default().useMemo(()=>toSuggestionsState(suggestionsSnapshot), [
|
|
149
|
+
suggestionsSnapshot
|
|
150
|
+
]);
|
|
143
151
|
external_react_default().useEffect(()=>{
|
|
144
152
|
if (!chatService) return;
|
|
145
153
|
const unsubscribeHistoryToggle = chatInternalService.on(index_cjs_namespaceObject.AutopilotChatInternalEvent.ToggleHistory, (isOpen)=>{
|
|
@@ -172,23 +180,15 @@ const AutopilotChatStateProvider = ({ children, portalContainer })=>{
|
|
|
172
180
|
const unsubscribeTheming = chatInternalService.on(index_cjs_namespaceObject.AutopilotChatInternalEvent.SetTheming, (themingConfig)=>{
|
|
173
181
|
setTheming(themingConfig);
|
|
174
182
|
});
|
|
175
|
-
const unsubscribeSuggestions = chatInternalService.on(index_cjs_namespaceObject.AutopilotChatInternalEvent.SetSuggestions,
|
|
176
|
-
|
|
177
|
-
items,
|
|
178
|
-
sendOnClick,
|
|
179
|
-
userTurns: countUserTurns(chatService.getConversation())
|
|
180
|
-
});
|
|
181
|
-
});
|
|
183
|
+
const unsubscribeSuggestions = chatInternalService.on(index_cjs_namespaceObject.AutopilotChatInternalEvent.SetSuggestions, setSuggestionsSnapshot);
|
|
184
|
+
setSuggestionsSnapshot(chatService.__suggestions__);
|
|
182
185
|
const unsubscribes = [
|
|
183
186
|
chatService.intercept(index_cjs_namespaceObject.AutopilotChatInterceptableEvent.Request, ()=>{
|
|
184
187
|
setHasMessages(true);
|
|
185
188
|
}),
|
|
186
189
|
chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.Response, ()=>setHasMessages(true)),
|
|
187
190
|
chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.SetConversation, (conversation)=>setHasMessages(conversation.length > 0)),
|
|
188
|
-
chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.NewChat, ()=>
|
|
189
|
-
setHasMessages(false);
|
|
190
|
-
setSuggestions(NO_SUGGESTIONS);
|
|
191
|
-
})
|
|
191
|
+
chatService.on(index_cjs_namespaceObject.AutopilotChatEvent.NewChat, ()=>setHasMessages(false))
|
|
192
192
|
];
|
|
193
193
|
return ()=>{
|
|
194
194
|
unsubscribeSuggestions();
|
|
@@ -264,11 +264,9 @@ const useChatState = ()=>{
|
|
|
264
264
|
return context;
|
|
265
265
|
};
|
|
266
266
|
exports.AutopilotChatStateProvider = __webpack_exports__.AutopilotChatStateProvider;
|
|
267
|
-
exports.countUserTurns = __webpack_exports__.countUserTurns;
|
|
268
267
|
exports.useChatState = __webpack_exports__.useChatState;
|
|
269
268
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
270
269
|
"AutopilotChatStateProvider",
|
|
271
|
-
"countUserTurns",
|
|
272
270
|
"useChatState"
|
|
273
271
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
274
272
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type AutopilotChatAllowedAttachments, type AutopilotChatConfiguration, type AutopilotChatDisabledFeatures,
|
|
2
|
+
import { type AutopilotChatAllowedAttachments, type AutopilotChatConfiguration, type AutopilotChatDisabledFeatures, AutopilotChatMode, type AutopilotChatOverrideLabels, type AutopilotChatSuggestion } from '../../service';
|
|
3
3
|
type DeepRequired<T> = {
|
|
4
4
|
[P in keyof T]-?: DeepRequired<T[P]>;
|
|
5
5
|
};
|
|
@@ -31,7 +31,6 @@ export interface ChatSuggestionsState {
|
|
|
31
31
|
sendOnClick?: boolean;
|
|
32
32
|
userTurns?: number;
|
|
33
33
|
}
|
|
34
|
-
export declare const countUserTurns: (messages: readonly AutopilotChatMessage[]) => number;
|
|
35
34
|
interface AutopilotChatStateProviderProps {
|
|
36
35
|
children: React.ReactNode;
|
|
37
36
|
portalContainer?: HTMLElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-state-provider.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/providers/chat-state-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,
|
|
1
|
+
{"version":3,"file":"chat-state-provider.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/providers/chat-state-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAKlC,iBAAiB,EACjB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAU7B,MAAM,eAAe,CAAC;AAKvB,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC,CAAC;AAEF,UAAU,6BAA6B;IACrC,oBAAoB,EAAE,WAAW,GAAG,IAAI,CAAC;IACzC,uBAAuB,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAE/D,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,wBAAwB,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAChE,mBAAmB,EAAE,WAAW,GAAG,IAAI,CAAC;IACxC,sBAAsB,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9D,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,gBAAgB,EAAE,6BAA6B,CAAC;IAChD,cAAc,EAAE,2BAA2B,CAAC;IAC5C,kBAAkB,EAAE,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IACrE,kBAAkB,EAAE,+BAA+B,CAAC;IACpD,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IAChD,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAElB,eAAe,EAAE,OAAO,CAAC;IAEzB,WAAW,EAAE,oBAAoB,CAAC;CACnC;AAGD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IAEjC,WAAW,CAAC,EAAE,OAAO,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,UAAU,+BAA+B;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,WAAW,CAAC;CAC/B;AA4ED,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,+BAA+B,CAiOhF,CAAC;AAEF,eAAO,MAAM,YAAY,qCAQxB,CAAC"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import apollo_core, { FontVariantToken } from "@uipath/apollo-core";
|
|
3
3
|
import react from "react";
|
|
4
|
-
import { AutopilotChatEvent, AutopilotChatInterceptableEvent, AutopilotChatInternalEvent, AutopilotChatMode,
|
|
4
|
+
import { AutopilotChatEvent, AutopilotChatInterceptableEvent, AutopilotChatInternalEvent, AutopilotChatMode, CHAT_COMPACT_MODE_INPUT_MAX_ROWS, CHAT_COMPACT_MODE_INPUT_MIN_ROWS, CHAT_COMPACT_MODE_MESSAGE_GROUP_GAP, CHAT_COMPACT_MODE_MESSAGE_SPACING, CHAT_INPUT_MAX_ROWS, CHAT_INPUT_MIN_ROWS, CHAT_MESSAGE_GROUP_GAP, CHAT_MESSAGE_SPACING, CHAT_SUGGESTION_SPACING } from "../../service/index.js";
|
|
5
5
|
import { useChatService } from "./chat-service.provider.js";
|
|
6
|
-
const countUserTurns = (messages)=>messages.reduce((count, message)=>count + (message.role === AutopilotChatRole.User ? 1 : 0), 0);
|
|
7
6
|
const NO_SUGGESTIONS = {
|
|
8
7
|
items: []
|
|
9
8
|
};
|
|
9
|
+
const toSuggestionsState = ({ suggestions, sendOnClick, userTurns })=>0 === suggestions.length ? NO_SUGGESTIONS : {
|
|
10
|
+
items: [
|
|
11
|
+
...suggestions
|
|
12
|
+
],
|
|
13
|
+
sendOnClick,
|
|
14
|
+
userTurns
|
|
15
|
+
};
|
|
10
16
|
const AutopilotChatStateContext = /*#__PURE__*/ react.createContext(null);
|
|
11
17
|
const calculateSpacing = (chatSpacing)=>{
|
|
12
18
|
const compactMode = chatSpacing?.compactMode ?? false;
|
|
@@ -98,7 +104,10 @@ const AutopilotChatStateProvider = ({ children, portalContainer })=>{
|
|
|
98
104
|
const [readOnly, setReadOnly] = react.useState(chatService?.getReadOnly() ?? false);
|
|
99
105
|
const [spacing, setSpacing] = react.useState(calculateSpacing(chatService?.getConfig()?.spacing));
|
|
100
106
|
const [theming, setTheming] = react.useState(chatService?.getConfig()?.theming);
|
|
101
|
-
const [
|
|
107
|
+
const [suggestionsSnapshot, setSuggestionsSnapshot] = react.useState(()=>chatService.__suggestions__);
|
|
108
|
+
const suggestions = react.useMemo(()=>toSuggestionsState(suggestionsSnapshot), [
|
|
109
|
+
suggestionsSnapshot
|
|
110
|
+
]);
|
|
102
111
|
react.useEffect(()=>{
|
|
103
112
|
if (!chatService) return;
|
|
104
113
|
const unsubscribeHistoryToggle = chatInternalService.on(AutopilotChatInternalEvent.ToggleHistory, (isOpen)=>{
|
|
@@ -131,23 +140,15 @@ const AutopilotChatStateProvider = ({ children, portalContainer })=>{
|
|
|
131
140
|
const unsubscribeTheming = chatInternalService.on(AutopilotChatInternalEvent.SetTheming, (themingConfig)=>{
|
|
132
141
|
setTheming(themingConfig);
|
|
133
142
|
});
|
|
134
|
-
const unsubscribeSuggestions = chatInternalService.on(AutopilotChatInternalEvent.SetSuggestions,
|
|
135
|
-
|
|
136
|
-
items,
|
|
137
|
-
sendOnClick,
|
|
138
|
-
userTurns: countUserTurns(chatService.getConversation())
|
|
139
|
-
});
|
|
140
|
-
});
|
|
143
|
+
const unsubscribeSuggestions = chatInternalService.on(AutopilotChatInternalEvent.SetSuggestions, setSuggestionsSnapshot);
|
|
144
|
+
setSuggestionsSnapshot(chatService.__suggestions__);
|
|
141
145
|
const unsubscribes = [
|
|
142
146
|
chatService.intercept(AutopilotChatInterceptableEvent.Request, ()=>{
|
|
143
147
|
setHasMessages(true);
|
|
144
148
|
}),
|
|
145
149
|
chatService.on(AutopilotChatEvent.Response, ()=>setHasMessages(true)),
|
|
146
150
|
chatService.on(AutopilotChatEvent.SetConversation, (conversation)=>setHasMessages(conversation.length > 0)),
|
|
147
|
-
chatService.on(AutopilotChatEvent.NewChat, ()=>
|
|
148
|
-
setHasMessages(false);
|
|
149
|
-
setSuggestions(NO_SUGGESTIONS);
|
|
150
|
-
})
|
|
151
|
+
chatService.on(AutopilotChatEvent.NewChat, ()=>setHasMessages(false))
|
|
151
152
|
];
|
|
152
153
|
return ()=>{
|
|
153
154
|
unsubscribeSuggestions();
|
|
@@ -222,4 +223,4 @@ const useChatState = ()=>{
|
|
|
222
223
|
if (!context) throw new Error('useChatState must be used within a AutopilotChatStateProvider');
|
|
223
224
|
return context;
|
|
224
225
|
};
|
|
225
|
-
export { AutopilotChatStateProvider,
|
|
226
|
+
export { AutopilotChatStateProvider, useChatState };
|
|
@@ -48,19 +48,23 @@ function AutopilotChatWidthProvider({ children }) {
|
|
|
48
48
|
const storage = index_cjs_namespaceObject.StorageService.Instance;
|
|
49
49
|
const chatService = (0, external_chat_service_provider_cjs_namespaceObject.useChatService)();
|
|
50
50
|
const { chatMode } = (0, external_chat_state_provider_cjs_namespaceObject.useChatState)();
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
return
|
|
54
|
-
}
|
|
51
|
+
const savedWidth = external_react_default().useCallback(()=>{
|
|
52
|
+
const saved = storage.get(index_cjs_namespaceObject.CHAT_WIDTH_KEY);
|
|
53
|
+
return saved ? parseInt(saved, 10) : index_cjs_namespaceObject.CHAT_WIDTH_SIDE_BY_SIDE_MIN;
|
|
54
|
+
}, [
|
|
55
|
+
storage
|
|
56
|
+
]);
|
|
57
|
+
const [width, setWidth] = external_react_default().useState(savedWidth);
|
|
55
58
|
const [shouldAnimate, setShouldAnimate] = external_react_default().useState(false);
|
|
56
59
|
external_react_default().useEffect(()=>{
|
|
57
60
|
if (chatMode === index_cjs_namespaceObject.AutopilotChatMode.Embedded) {
|
|
58
61
|
const config = chatService.getConfig();
|
|
59
62
|
if (config.embeddedContainer) setWidth(config.embeddedContainer.clientWidth);
|
|
60
|
-
}
|
|
63
|
+
} else if (chatMode !== index_cjs_namespaceObject.AutopilotChatMode.Closed) setWidth(savedWidth());
|
|
61
64
|
}, [
|
|
62
65
|
chatService,
|
|
63
|
-
chatMode
|
|
66
|
+
chatMode,
|
|
67
|
+
savedWidth
|
|
64
68
|
]);
|
|
65
69
|
const value = external_react_default().useMemo(()=>({
|
|
66
70
|
width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-width-provider.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/providers/chat-width-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,UAAU,6BAA6B;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,yBAAyB,qDAErC,CAAC;AAEF,UAAU,+BAA+B;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,+BAA+B,
|
|
1
|
+
{"version":3,"file":"chat-width-provider.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/providers/chat-width-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,UAAU,6BAA6B;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,yBAAyB,qDAErC,CAAC;AAEF,UAAU,+BAA+B;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,+BAA+B,2CAyCvF;AAED,wBAAgB,YAAY,kCAQ3B"}
|
|
@@ -8,19 +8,23 @@ function AutopilotChatWidthProvider({ children }) {
|
|
|
8
8
|
const storage = StorageService.Instance;
|
|
9
9
|
const chatService = useChatService();
|
|
10
10
|
const { chatMode } = useChatState();
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
return
|
|
14
|
-
}
|
|
11
|
+
const savedWidth = react.useCallback(()=>{
|
|
12
|
+
const saved = storage.get(CHAT_WIDTH_KEY);
|
|
13
|
+
return saved ? parseInt(saved, 10) : CHAT_WIDTH_SIDE_BY_SIDE_MIN;
|
|
14
|
+
}, [
|
|
15
|
+
storage
|
|
16
|
+
]);
|
|
17
|
+
const [width, setWidth] = react.useState(savedWidth);
|
|
15
18
|
const [shouldAnimate, setShouldAnimate] = react.useState(false);
|
|
16
19
|
react.useEffect(()=>{
|
|
17
20
|
if (chatMode === AutopilotChatMode.Embedded) {
|
|
18
21
|
const config = chatService.getConfig();
|
|
19
22
|
if (config.embeddedContainer) setWidth(config.embeddedContainer.clientWidth);
|
|
20
|
-
}
|
|
23
|
+
} else if (chatMode !== AutopilotChatMode.Closed) setWidth(savedWidth());
|
|
21
24
|
}, [
|
|
22
25
|
chatService,
|
|
23
|
-
chatMode
|
|
26
|
+
chatMode,
|
|
27
|
+
savedWidth
|
|
24
28
|
]);
|
|
25
29
|
const value = react.useMemo(()=>({
|
|
26
30
|
width,
|
|
@@ -66,9 +66,15 @@ const ChatI18n = /*#__PURE__*/ external_react_default().memo(({ children })=>{
|
|
|
66
66
|
const useEmbeddedContainer = (chatService)=>{
|
|
67
67
|
const [container, setContainer] = external_react_default().useState(null);
|
|
68
68
|
external_react_default().useEffect(()=>{
|
|
69
|
+
let sameService = false;
|
|
69
70
|
const update = ()=>{
|
|
70
71
|
const config = chatService.getConfig();
|
|
71
|
-
|
|
72
|
+
const keepWhileClosed = sameService;
|
|
73
|
+
sameService = true;
|
|
74
|
+
setContainer((previous)=>{
|
|
75
|
+
if (config.mode === external_service_index_cjs_namespaceObject.AutopilotChatMode.Embedded) return config.embeddedContainer ?? null;
|
|
76
|
+
return config.mode === external_service_index_cjs_namespaceObject.AutopilotChatMode.Closed && keepWhileClosed && previous === config.embeddedContainer ? previous : null;
|
|
77
|
+
});
|
|
72
78
|
};
|
|
73
79
|
update();
|
|
74
80
|
return chatService.on(external_service_index_cjs_namespaceObject.AutopilotChatEvent.ModeChange, update);
|
|
@@ -127,7 +133,14 @@ function ChatRoot({ chatServiceInstance, defaultRenderer, locale = 'en', theme =
|
|
|
127
133
|
configuredRenderer,
|
|
128
134
|
defaultRenderer
|
|
129
135
|
]);
|
|
130
|
-
const
|
|
136
|
+
const rendered = Renderer && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_default().Suspense, {
|
|
137
|
+
fallback: null,
|
|
138
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Renderer, {
|
|
139
|
+
...rendererProps
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
const placed = embeddedContainer && !disableEmbeddedPortal ? /*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(rendered, embeddedContainer) : rendered;
|
|
143
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(chat_service_provider_cjs_namespaceObject.AutopilotChatServiceProvider, {
|
|
131
144
|
chatServiceInstance: chatServiceInstance,
|
|
132
145
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(theme_provider_cjs_namespaceObject.ThemeProvider, {
|
|
133
146
|
initialTheme: theme,
|
|
@@ -143,12 +156,7 @@ function ChatRoot({ chatServiceInstance, defaultRenderer, locale = 'en', theme =
|
|
|
143
156
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(picker_provider_cjs_namespaceObject.AutopilotPickerProvider, {
|
|
144
157
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(resource_data_provider_cjs_namespaceObject.AutopilotResourceDataProvider, {
|
|
145
158
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(chat_width_provider_cjs_namespaceObject.AutopilotChatWidthProvider, {
|
|
146
|
-
children:
|
|
147
|
-
fallback: null,
|
|
148
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Renderer, {
|
|
149
|
-
...rendererProps
|
|
150
|
-
})
|
|
151
|
-
})
|
|
159
|
+
children: placed
|
|
152
160
|
})
|
|
153
161
|
})
|
|
154
162
|
})
|
|
@@ -162,8 +170,6 @@ function ChatRoot({ chatServiceInstance, defaultRenderer, locale = 'en', theme =
|
|
|
162
170
|
})
|
|
163
171
|
})
|
|
164
172
|
});
|
|
165
|
-
if (embeddedContainer && !disableEmbeddedPortal) return /*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(content, embeddedContainer);
|
|
166
|
-
return content;
|
|
167
173
|
}
|
|
168
174
|
exports.ChatRoot = __webpack_exports__.ChatRoot;
|
|
169
175
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatRoot.d.ts","sourceRoot":"","sources":["../../../src/chat/root/ChatRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAalE,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAI5B,mBAAmB,EAAE,oBAAoB,CAAC;IAI1C,eAAe,EAAE,qBAAqB,CAAC;IAKvC,MAAM,CAAC,EAAE,eAAe,CAAC;IAKzB,KAAK,CAAC,EAAE,WAAW,CAAC;IAKpB,eAAe,CAAC,EAAE,WAAW,CAAC;IAM9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAIhC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAKlC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;
|
|
1
|
+
{"version":3,"file":"ChatRoot.d.ts","sourceRoot":"","sources":["../../../src/chat/root/ChatRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAalE,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAI5B,mBAAmB,EAAE,oBAAoB,CAAC;IAI1C,eAAe,EAAE,qBAAqB,CAAC;IAKvC,MAAM,CAAC,EAAE,eAAe,CAAC;IAKzB,KAAK,CAAC,EAAE,WAAW,CAAC;IAKpB,eAAe,CAAC,EAAE,WAAW,CAAC;IAM9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAIhC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAKlC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AA6DD,wBAAgB,QAAQ,CAAC,EACvB,mBAAmB,EACnB,eAAe,EACf,MAAa,EACb,KAAe,EACf,eAAe,EACf,qBAA6B,EAC7B,aAAa,EACb,QAAQ,EAAE,cAAc,GACzB,EAAE,aAAa,2CAiFf"}
|
|
@@ -28,9 +28,15 @@ const ChatI18n = /*#__PURE__*/ react.memo(({ children })=>{
|
|
|
28
28
|
const useEmbeddedContainer = (chatService)=>{
|
|
29
29
|
const [container, setContainer] = react.useState(null);
|
|
30
30
|
react.useEffect(()=>{
|
|
31
|
+
let sameService = false;
|
|
31
32
|
const update = ()=>{
|
|
32
33
|
const config = chatService.getConfig();
|
|
33
|
-
|
|
34
|
+
const keepWhileClosed = sameService;
|
|
35
|
+
sameService = true;
|
|
36
|
+
setContainer((previous)=>{
|
|
37
|
+
if (config.mode === AutopilotChatMode.Embedded) return config.embeddedContainer ?? null;
|
|
38
|
+
return config.mode === AutopilotChatMode.Closed && keepWhileClosed && previous === config.embeddedContainer ? previous : null;
|
|
39
|
+
});
|
|
34
40
|
};
|
|
35
41
|
update();
|
|
36
42
|
return chatService.on(AutopilotChatEvent.ModeChange, update);
|
|
@@ -89,7 +95,14 @@ function ChatRoot({ chatServiceInstance, defaultRenderer, locale = 'en', theme =
|
|
|
89
95
|
configuredRenderer,
|
|
90
96
|
defaultRenderer
|
|
91
97
|
]);
|
|
92
|
-
const
|
|
98
|
+
const rendered = Renderer && /*#__PURE__*/ jsx(react.Suspense, {
|
|
99
|
+
fallback: null,
|
|
100
|
+
children: /*#__PURE__*/ jsx(Renderer, {
|
|
101
|
+
...rendererProps
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
const placed = embeddedContainer && !disableEmbeddedPortal ? /*#__PURE__*/ createPortal(rendered, embeddedContainer) : rendered;
|
|
105
|
+
return /*#__PURE__*/ jsx(AutopilotChatServiceProvider, {
|
|
93
106
|
chatServiceInstance: chatServiceInstance,
|
|
94
107
|
children: /*#__PURE__*/ jsx(ThemeProvider, {
|
|
95
108
|
initialTheme: theme,
|
|
@@ -105,12 +118,7 @@ function ChatRoot({ chatServiceInstance, defaultRenderer, locale = 'en', theme =
|
|
|
105
118
|
children: /*#__PURE__*/ jsx(AutopilotPickerProvider, {
|
|
106
119
|
children: /*#__PURE__*/ jsx(AutopilotResourceDataProvider, {
|
|
107
120
|
children: /*#__PURE__*/ jsx(AutopilotChatWidthProvider, {
|
|
108
|
-
children:
|
|
109
|
-
fallback: null,
|
|
110
|
-
children: /*#__PURE__*/ jsx(Renderer, {
|
|
111
|
-
...rendererProps
|
|
112
|
-
})
|
|
113
|
-
})
|
|
121
|
+
children: placed
|
|
114
122
|
})
|
|
115
123
|
})
|
|
116
124
|
})
|
|
@@ -124,7 +132,5 @@ function ChatRoot({ chatServiceInstance, defaultRenderer, locale = 'en', theme =
|
|
|
124
132
|
})
|
|
125
133
|
})
|
|
126
134
|
});
|
|
127
|
-
if (embeddedContainer && !disableEmbeddedPortal) return /*#__PURE__*/ createPortal(content, embeddedContainer);
|
|
128
|
-
return content;
|
|
129
135
|
}
|
|
130
136
|
export { ChatRoot };
|
|
@@ -33,6 +33,7 @@ const external_ContentPartBuilder_cjs_namespaceObject = require("./ContentPartBu
|
|
|
33
33
|
const external_EventBus_cjs_namespaceObject = require("./EventBus.cjs");
|
|
34
34
|
const external_LocalHistory_cjs_namespaceObject = require("./LocalHistory.cjs");
|
|
35
35
|
const external_StorageService_cjs_namespaceObject = require("./StorageService.cjs");
|
|
36
|
+
const external_suggestions_state_cjs_namespaceObject = require("./suggestions-state.cjs");
|
|
36
37
|
class AutopilotChatService {
|
|
37
38
|
static _instances = {};
|
|
38
39
|
_initialConfig = {
|
|
@@ -74,6 +75,7 @@ class AutopilotChatService {
|
|
|
74
75
|
_historyOpen = false;
|
|
75
76
|
_settingsOpen = false;
|
|
76
77
|
_activeConversationId = null;
|
|
78
|
+
_suggestions = external_suggestions_state_cjs_namespaceObject.NO_SUGGESTIONS_SNAPSHOT;
|
|
77
79
|
_hasMoreHistory = true;
|
|
78
80
|
_defaultLoadingMessages = null;
|
|
79
81
|
_loadingMessage = null;
|
|
@@ -140,6 +142,7 @@ class AutopilotChatService {
|
|
|
140
142
|
this.prependOlderMessages = this.prependOlderMessages.bind(this);
|
|
141
143
|
this.appendOlderHistoryItems = this.appendOlderHistoryItems.bind(this);
|
|
142
144
|
this.setSuggestions = this.setSuggestions.bind(this);
|
|
145
|
+
this.getSuggestions = this.getSuggestions.bind(this);
|
|
143
146
|
this.sendInputStreamEvent = this.sendInputStreamEvent.bind(this);
|
|
144
147
|
this.sendOutputStreamEvent = this.sendOutputStreamEvent.bind(this);
|
|
145
148
|
this.setShowLoading = this.setShowLoading.bind(this);
|
|
@@ -279,11 +282,23 @@ class AutopilotChatService {
|
|
|
279
282
|
return this._prompt;
|
|
280
283
|
}
|
|
281
284
|
setSuggestions(suggestions, sendOnClick) {
|
|
282
|
-
this.
|
|
283
|
-
suggestions
|
|
284
|
-
|
|
285
|
+
this._publishSuggestions({
|
|
286
|
+
suggestions: Object.freeze([
|
|
287
|
+
...suggestions
|
|
288
|
+
]),
|
|
289
|
+
sendOnClick,
|
|
290
|
+
userTurns: (0, external_suggestions_state_cjs_namespaceObject.countUserTurns)(this._conversation)
|
|
285
291
|
});
|
|
286
292
|
}
|
|
293
|
+
getSuggestions() {
|
|
294
|
+
return [
|
|
295
|
+
...this._suggestions.suggestions
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
_publishSuggestions(snapshot) {
|
|
299
|
+
this._suggestions = Object.freeze(snapshot);
|
|
300
|
+
this._internalService.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatInternalEvent.SetSuggestions, this._suggestions);
|
|
301
|
+
}
|
|
287
302
|
setConversation(messages) {
|
|
288
303
|
this._conversation = messages;
|
|
289
304
|
this._internalService.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatInternalEvent.ShowLoadingState, false);
|
|
@@ -300,6 +315,12 @@ class AutopilotChatService {
|
|
|
300
315
|
...messages,
|
|
301
316
|
...this._conversation
|
|
302
317
|
]);
|
|
318
|
+
const olderUserTurns = (0, external_suggestions_state_cjs_namespaceObject.countUserTurns)(messages);
|
|
319
|
+
const current = this._suggestions;
|
|
320
|
+
if (current.suggestions.length > 0 && olderUserTurns > 0) this._publishSuggestions({
|
|
321
|
+
...current,
|
|
322
|
+
userTurns: current.userTurns + olderUserTurns
|
|
323
|
+
});
|
|
303
324
|
}
|
|
304
325
|
appendOlderHistoryItems(items = [], done) {
|
|
305
326
|
if (done) {
|
|
@@ -400,6 +421,7 @@ class AutopilotChatService {
|
|
|
400
421
|
this._groupId = void 0;
|
|
401
422
|
this._conversation = [];
|
|
402
423
|
this._activeConversationId = null;
|
|
424
|
+
this.setSuggestions([]);
|
|
403
425
|
this._eventBus.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatEvent.NewChat);
|
|
404
426
|
this._internalService.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatInternalEvent.ShouldShowLoadingMoreMessages, true);
|
|
405
427
|
this._internalService.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatInternalEvent.SetIsLoadingMoreMessages, false);
|
|
@@ -474,7 +496,9 @@ class AutopilotChatService {
|
|
|
474
496
|
});
|
|
475
497
|
}
|
|
476
498
|
openConversation(conversationId, showLoadingState = true) {
|
|
499
|
+
const opensAnother = conversationId !== this._activeConversationId;
|
|
477
500
|
this._activeConversationId = conversationId;
|
|
501
|
+
if (opensAnother) this.setSuggestions([]);
|
|
478
502
|
this._eventBus.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatEvent.OpenConversation, conversationId);
|
|
479
503
|
this._internalService.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatInternalEvent.ShowLoadingState, showLoadingState);
|
|
480
504
|
this._internalService.publish(external_ChatModel_cjs_namespaceObject.AutopilotChatInternalEvent.ShouldShowLoadingMoreMessages, true);
|
|
@@ -566,6 +590,9 @@ class AutopilotChatService {
|
|
|
566
590
|
get __hasMoreHistory__() {
|
|
567
591
|
return this._hasMoreHistory;
|
|
568
592
|
}
|
|
593
|
+
get __suggestions__() {
|
|
594
|
+
return this._suggestions;
|
|
595
|
+
}
|
|
569
596
|
getMessagesInGroup(groupId) {
|
|
570
597
|
return this._conversation.filter((message)=>message.groupId === groupId);
|
|
571
598
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AutopilotChatInternalService } from './ChatInternalService';
|
|
2
2
|
import type { AutopilotChatAgentModeInfo, AutopilotChatAllowedAttachments, AutopilotChatConfiguration, AutopilotChatCustomHeaderAction, AutopilotChatDisabledFeatures, AutopilotChatError, AutopilotChatErrorLevel, AutopilotChatEventHandler, AutopilotChatEventInterceptor, AutopilotChatFileInfo, AutopilotChatHistory, AutopilotChatInputStreamEvent, AutopilotChatMessage, AutopilotChatMessageRenderer, AutopilotChatModelInfo, AutopilotChatOutputStreamEvent, AutopilotChatOverrideLabels, AutopilotChatPreHookAction, AutopilotChatPrompt, AutopilotChatRenderer, AutopilotChatResourceManager, AutopilotChatSuggestion, ContentPartChunk } from './ChatModel';
|
|
3
3
|
import { AutopilotChatEvent, AutopilotChatInterceptableEvent, AutopilotChatMode } from './ChatModel';
|
|
4
|
+
import { type ChatSuggestionsSnapshot } from './suggestions-state';
|
|
4
5
|
export declare class AutopilotChatService {
|
|
5
6
|
private static _instances;
|
|
6
7
|
private _initialConfig;
|
|
@@ -15,6 +16,7 @@ export declare class AutopilotChatService {
|
|
|
15
16
|
private _historyOpen;
|
|
16
17
|
private _settingsOpen;
|
|
17
18
|
private _activeConversationId;
|
|
19
|
+
private _suggestions;
|
|
18
20
|
private _hasMoreHistory;
|
|
19
21
|
private _defaultLoadingMessages;
|
|
20
22
|
private _loadingMessage;
|
|
@@ -55,6 +57,8 @@ export declare class AutopilotChatService {
|
|
|
55
57
|
setWaiting(waiting: boolean): void;
|
|
56
58
|
getPrompt(): string | AutopilotChatPrompt | undefined;
|
|
57
59
|
setSuggestions(suggestions: AutopilotChatSuggestion[], sendOnClick?: boolean): void;
|
|
60
|
+
getSuggestions(): AutopilotChatSuggestion[];
|
|
61
|
+
private _publishSuggestions;
|
|
58
62
|
setConversation(messages: AutopilotChatMessage[]): void;
|
|
59
63
|
prependOlderMessages(messages?: AutopilotChatMessage[], done?: boolean): void;
|
|
60
64
|
appendOlderHistoryItems(items?: AutopilotChatHistory[], done?: boolean): void;
|
|
@@ -112,6 +116,7 @@ export declare class AutopilotChatService {
|
|
|
112
116
|
getReadOnly(): boolean;
|
|
113
117
|
get __internalService__(): AutopilotChatInternalService;
|
|
114
118
|
get __hasMoreHistory__(): boolean;
|
|
119
|
+
get __suggestions__(): ChatSuggestionsSnapshot;
|
|
115
120
|
getMessagesInGroup(groupId: string): AutopilotChatMessage[];
|
|
116
121
|
setPreHook(action: AutopilotChatPreHookAction, hook: (data?: any) => Promise<boolean>): void;
|
|
117
122
|
getPreHook(action: AutopilotChatPreHookAction): (data?: any) => Promise<boolean>;
|