@adminide-stack/yantra-mobile 12.0.28-alpha.61 → 12.0.28-alpha.63
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/lib/components/CustomDrawer.js +147 -26
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/components/GatewayToolbarButtonMobile.js +21 -21
- package/lib/components/GatewayToolbarButtonMobile.js.map +1 -1
- package/lib/hooks/usePrerequisiteIds.js +75 -12
- package/lib/hooks/usePrerequisiteIds.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +378 -137
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/ChatHistoryLanding.js +55 -19
- package/lib/screens/Home/components/ChatHistoryLanding.js.map +1 -1
- package/lib/screens/Home/components/DeepSearchModal.js +49 -34
- package/lib/screens/Home/components/DeepSearchModal.js.map +1 -1
- package/lib/screens/NewChat/index.js +8 -4
- package/lib/screens/NewChat/index.js.map +1 -1
- package/lib/theme/mobileTokens.js +18 -0
- package/lib/theme/mobileTokens.js.map +1 -0
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx,jsxs}from'react/jsx-runtime';import React,{useState,useMemo,useCallback
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import React,{useState,useMemo,useEffect,useCallback}from'react';import {useWindowDimensions,useColorScheme,Platform,Keyboard,TouchableWithoutFeedback,View,StyleSheet,Pressable}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {getDefaultLeftItems,getDefaultRightItems,Box,Text,InputToolBar}from'@admin-layout/gluestack-ui-mobile';import {useSafeAreaInsets,SafeAreaView}from'react-native-safe-area-context';import {useNavigation,useRoute,CommonActions}from'@react-navigation/native';import {MessagesContainerUI}from'@messenger-box/platform-mobile';import {v4}from'uuid';import {ContributionSchemaId}from'common';import {useGetContextDataQuery,useGetPageSettingsQuery}from'common/graphql';import {useGatewayContext}from'../../contexts/GatewayContext.js';import {GatewayToolbarButtonMobile}from'../../components/GatewayToolbarButtonMobile.js';import {useCdecliAutoConnect}from'../../hooks/useCdecliAutoConnect.js';import {usePrerequisiteIds}from'../../hooks/usePrerequisiteIds.js';import {useChatMutations,useChatSessions}from'../../hooks/useChatApi.js';import {useChatStream}from'../../hooks/useChatStream.js';import DeepSearchModal from'./components/DeepSearchModal.js';import ChatHistoryLanding from'./components/ChatHistoryLanding.js';import {normalizeSummaryText,extractDeepSearchSources}from'./deepSearchUtils.js';import {YantraBrandLoader,YANTRA_LOADER_SIZE_COMPACT}from'../../components/YantraBrandLoader.js';import {mobileTokens}from'../../theme/mobileTokens.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -15,6 +15,7 @@ var __spreadValues = (a, b) => {
|
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
17
|
const SENDING_LOADER_COMPOSER_RESERVE_PX = 156;
|
|
18
|
+
const COMPOSER_SCROLL_RESERVE_PX = 164;
|
|
18
19
|
function organizationFromSettingsValue(settings) {
|
|
19
20
|
if (settings == null) return null;
|
|
20
21
|
if (typeof settings === "string") {
|
|
@@ -49,6 +50,115 @@ function projectFromSettingsValue(settings) {
|
|
|
49
50
|
}
|
|
50
51
|
return null;
|
|
51
52
|
}
|
|
53
|
+
const ChatContentSection = React.memo(function ChatContentSection2({
|
|
54
|
+
contentMaxWidth,
|
|
55
|
+
composerScrollBottomPadding,
|
|
56
|
+
messages,
|
|
57
|
+
response,
|
|
58
|
+
isLoading,
|
|
59
|
+
disabled,
|
|
60
|
+
isStreaming,
|
|
61
|
+
onStop,
|
|
62
|
+
cancel,
|
|
63
|
+
onSend,
|
|
64
|
+
onBackPress
|
|
65
|
+
}) {
|
|
66
|
+
return /* @__PURE__ */ jsx(Box, { flex: 1, width: "100%", alignSelf: "stretch", children: /* @__PURE__ */ jsx(MessagesContainerUI, { mode: "chat", showBackButton: false, onBackPress, compactTop: true, messagesContainerStyle: {
|
|
67
|
+
paddingHorizontal: 0,
|
|
68
|
+
paddingTop: 0,
|
|
69
|
+
paddingBottom: composerScrollBottomPadding,
|
|
70
|
+
margin: 0,
|
|
71
|
+
marginTop: 0,
|
|
72
|
+
alignSelf: "center",
|
|
73
|
+
width: contentMaxWidth
|
|
74
|
+
}, listContentStyle: {
|
|
75
|
+
paddingTop: 0,
|
|
76
|
+
paddingBottom: composerScrollBottomPadding,
|
|
77
|
+
margin: 0,
|
|
78
|
+
marginTop: 0,
|
|
79
|
+
width: contentMaxWidth,
|
|
80
|
+
alignSelf: "center",
|
|
81
|
+
justifyContent: "flex-end"
|
|
82
|
+
}, messages: messages.map((msg, index) => ({
|
|
83
|
+
id: `msg-${index}-${msg.role}`,
|
|
84
|
+
role: msg.role,
|
|
85
|
+
content: msg.content,
|
|
86
|
+
metadata: msg.metadata
|
|
87
|
+
})), streamingContent: response, currentUser: {
|
|
88
|
+
id: "user"
|
|
89
|
+
}, onSend, disabled: isLoading || disabled, isLoading, onStop: isStreaming ? cancel : onStop, renderPlanInputToolbar: () => null, renderBuildInputToolbar: () => null }) });
|
|
90
|
+
});
|
|
91
|
+
const EmptyStateSection = React.memo(function EmptyStateSection2({
|
|
92
|
+
isDark,
|
|
93
|
+
secondaryTextColor,
|
|
94
|
+
primaryTextColor,
|
|
95
|
+
activeMode,
|
|
96
|
+
onModeSwitch
|
|
97
|
+
}) {
|
|
98
|
+
return /* @__PURE__ */ jsx(Box, { flex: 1, width: "100%", children: /* @__PURE__ */ jsxs(View, { style: styles.emptyCenterTitleWrap, children: [
|
|
99
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.emptyEyebrow, {
|
|
100
|
+
color: secondaryTextColor
|
|
101
|
+
}], children: "Choose your mode" }),
|
|
102
|
+
/* @__PURE__ */ jsxs(View, { style: [styles.emptyModePillRow, {
|
|
103
|
+
backgroundColor: isDark ? "rgba(30, 41, 59, 0.9)" : "#eef2ff",
|
|
104
|
+
borderColor: isDark ? "rgba(148, 163, 184, 0.26)" : "rgba(67, 56, 202, 0.15)"
|
|
105
|
+
}], children: [
|
|
106
|
+
/* @__PURE__ */ jsxs(Pressable, { onPress: () => onModeSwitch("chat"), style: [styles.emptyModePill, activeMode === "chat" && styles.emptyModePillActive, activeMode === "chat" && {
|
|
107
|
+
backgroundColor: isDark ? "#312e81" : "#4338ca"
|
|
108
|
+
}], accessibilityRole: "button", accessibilityLabel: "Switch to chat mode", children: [
|
|
109
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "magnify", size: 14, color: activeMode === "chat" ? "#ffffff" : secondaryTextColor }),
|
|
110
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.emptyModePillLabel, {
|
|
111
|
+
color: activeMode === "chat" ? "#ffffff" : secondaryTextColor
|
|
112
|
+
}], children: "Chat" })
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ jsxs(Pressable, { onPress: () => onModeSwitch("deep-search"), style: [styles.emptyModePill, activeMode === "deep-search" && styles.emptyModePillActive, activeMode === "deep-search" && {
|
|
115
|
+
backgroundColor: isDark ? "#312e81" : "#4338ca"
|
|
116
|
+
}], accessibilityRole: "button", accessibilityLabel: "Switch to deep-search mode", children: [
|
|
117
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "lightning-bolt-outline", size: 14, color: activeMode === "deep-search" ? "#ffffff" : secondaryTextColor }),
|
|
118
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.emptyModePillLabel, {
|
|
119
|
+
color: activeMode === "deep-search" ? "#ffffff" : secondaryTextColor
|
|
120
|
+
}], children: "Deep Search" })
|
|
121
|
+
] })
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.emptyCenterTitle, {
|
|
124
|
+
color: primaryTextColor
|
|
125
|
+
}], children: "How do you want to start?" }),
|
|
126
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.emptySubtitle, {
|
|
127
|
+
color: secondaryTextColor
|
|
128
|
+
}], children: "Use Chat for quick help, or Deep Search for researched, source-backed answers." })
|
|
129
|
+
] }) });
|
|
130
|
+
});
|
|
131
|
+
const HeaderBackButton = React.memo(function HeaderBackButton2({
|
|
132
|
+
color,
|
|
133
|
+
onPress
|
|
134
|
+
}) {
|
|
135
|
+
return /* @__PURE__ */ jsx(Pressable, { onPress, style: ({
|
|
136
|
+
pressed
|
|
137
|
+
}) => [styles.backButton, pressed && styles.newChatButtonPressed], accessibilityLabel: "Back to chat", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-left", size: 24, color }) });
|
|
138
|
+
});
|
|
139
|
+
const HeaderRightActions = React.memo(function HeaderRightActions2({
|
|
140
|
+
gatewayToolbarStatus,
|
|
141
|
+
gatewayToolbarError,
|
|
142
|
+
onToggleGateway,
|
|
143
|
+
gatewayToolbarLabel,
|
|
144
|
+
gatewayToolbarTone,
|
|
145
|
+
showChatHistory,
|
|
146
|
+
onOpenChatHistory,
|
|
147
|
+
onNewChat,
|
|
148
|
+
isDark,
|
|
149
|
+
accentColor,
|
|
150
|
+
newChatIconColor
|
|
151
|
+
}) {
|
|
152
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.headerRight, children: [
|
|
153
|
+
/* @__PURE__ */ jsx(GatewayToolbarButtonMobile, { gatewayStatus: gatewayToolbarStatus, gatewayError: gatewayToolbarError, onToggleGateway, disabled: false, statusLabel: gatewayToolbarLabel, tone: gatewayToolbarTone }),
|
|
154
|
+
!showChatHistory ? /* @__PURE__ */ jsx(Pressable, { onPress: onOpenChatHistory, style: ({
|
|
155
|
+
pressed
|
|
156
|
+
}) => [styles.historyHeaderButton, pressed && styles.historyHeaderButtonPressed], accessibilityLabel: "Chat history", accessibilityRole: "button", children: /* @__PURE__ */ jsx(View, { style: [styles.historyHeaderButtonInner, isDark ? styles.historyHeaderButtonInnerDark : null], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "history", size: 19, color: accentColor }) }) }) : null,
|
|
157
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: onNewChat, style: ({
|
|
158
|
+
pressed
|
|
159
|
+
}) => [styles.newChatButton, pressed && styles.newChatButtonPressed], accessibilityLabel: "New chat", children: /* @__PURE__ */ jsx(View, { style: [styles.newChatButtonInner, isDark ? styles.newChatButtonInnerDark : null], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chat-plus-outline", size: 20, color: newChatIconColor }) }) })
|
|
160
|
+
] });
|
|
161
|
+
});
|
|
52
162
|
function HomeScreenContent({
|
|
53
163
|
initialMode = "chat",
|
|
54
164
|
onSubmit: onSubmitProp,
|
|
@@ -57,6 +167,11 @@ function HomeScreenContent({
|
|
|
57
167
|
disabled = false
|
|
58
168
|
}) {
|
|
59
169
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
170
|
+
const {
|
|
171
|
+
width: screenWidth
|
|
172
|
+
} = useWindowDimensions();
|
|
173
|
+
const colorScheme = useColorScheme();
|
|
174
|
+
const isDark = colorScheme === "dark";
|
|
60
175
|
const navigation = useNavigation();
|
|
61
176
|
const route = useRoute();
|
|
62
177
|
const hasRehydratedOrgRef = React.useRef(false);
|
|
@@ -130,7 +245,6 @@ function HomeScreenContent({
|
|
|
130
245
|
error: chatError,
|
|
131
246
|
isLoading: chatLoading,
|
|
132
247
|
isStreaming,
|
|
133
|
-
hasMessages,
|
|
134
248
|
sendMessage,
|
|
135
249
|
cancel,
|
|
136
250
|
clearMessages
|
|
@@ -148,7 +262,36 @@ function HomeScreenContent({
|
|
|
148
262
|
}, [chatLoading, isStreaming, messages]);
|
|
149
263
|
const pinSendingLoaderNearComposer = useMemo(() => messages.length > 0 || Boolean((response != null ? response : "").trim()), [messages.length, response]);
|
|
150
264
|
const showSendingLoader = !showChatHistory && (channelBootstrap || waitingForAssistant);
|
|
265
|
+
const hasRenderableConversation = messages.length > 0 || isStreaming;
|
|
151
266
|
const insets = useSafeAreaInsets();
|
|
267
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
if (Platform.OS === "ios") {
|
|
270
|
+
const frameSub = Keyboard.addListener("keyboardWillChangeFrame", (event) => {
|
|
271
|
+
var _a2, _b2;
|
|
272
|
+
return setKeyboardHeight((_b2 = (_a2 = event.endCoordinates) == null ? void 0 : _a2.height) != null ? _b2 : 0);
|
|
273
|
+
});
|
|
274
|
+
const showSub2 = Keyboard.addListener("keyboardWillShow", (event) => {
|
|
275
|
+
var _a2, _b2;
|
|
276
|
+
return setKeyboardHeight((_b2 = (_a2 = event.endCoordinates) == null ? void 0 : _a2.height) != null ? _b2 : 0);
|
|
277
|
+
});
|
|
278
|
+
const hideSub2 = Keyboard.addListener("keyboardWillHide", () => setKeyboardHeight(0));
|
|
279
|
+
return () => {
|
|
280
|
+
frameSub.remove();
|
|
281
|
+
showSub2.remove();
|
|
282
|
+
hideSub2.remove();
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
const showSub = Keyboard.addListener("keyboardDidShow", (event) => {
|
|
286
|
+
var _a2, _b2;
|
|
287
|
+
return setKeyboardHeight((_b2 = (_a2 = event.endCoordinates) == null ? void 0 : _a2.height) != null ? _b2 : 0);
|
|
288
|
+
});
|
|
289
|
+
const hideSub = Keyboard.addListener("keyboardDidHide", () => setKeyboardHeight(0));
|
|
290
|
+
return () => {
|
|
291
|
+
showSub.remove();
|
|
292
|
+
hideSub.remove();
|
|
293
|
+
};
|
|
294
|
+
}, []);
|
|
152
295
|
const handleModeSwitch = useCallback((mode) => {
|
|
153
296
|
setActiveMode(mode);
|
|
154
297
|
}, []);
|
|
@@ -235,6 +378,12 @@ function HomeScreenContent({
|
|
|
235
378
|
const gatewayToolbarTone = "default";
|
|
236
379
|
const gatewayToolbarLabel = cdecli.status === "connecting" ? "Checking..." : void 0;
|
|
237
380
|
const gatewayToolbarError = cdecli.error;
|
|
381
|
+
const surfaceColor = isDark ? "#0f172a" : mobileTokens.color.surface;
|
|
382
|
+
const primaryTextColor = isDark ? "#e5e7eb" : mobileTokens.color.text;
|
|
383
|
+
const secondaryTextColor = isDark ? "#94a3b8" : mobileTokens.color.textMuted;
|
|
384
|
+
const accentColor = isDark ? "#a5b4fc" : "#4338ca";
|
|
385
|
+
const newChatIconColor = isDark ? "#e5e7eb" : "#000000";
|
|
386
|
+
const contentMaxWidth = Math.min(720, Math.max(360, screenWidth - 24));
|
|
238
387
|
useEffect(() => {
|
|
239
388
|
var _a2, _b2, _c2;
|
|
240
389
|
const currentOrgName = ((_b2 = (_a2 = route == null ? void 0 : route.params) == null ? void 0 : _a2.orgName) == null ? void 0 : _b2.trim()) || "";
|
|
@@ -248,7 +397,6 @@ function HomeScreenContent({
|
|
|
248
397
|
const currentOrgName = ((_b2 = (_a2 = route == null ? void 0 : route.params) == null ? void 0 : _a2.orgName) == null ? void 0 : _b2.trim()) || "";
|
|
249
398
|
if (hasRehydratedOrgRef.current || currentOrgName || !effectiveOrgName) return;
|
|
250
399
|
hasRehydratedOrgRef.current = true;
|
|
251
|
-
console.log("effectiveOrgName..", effectiveOrgName);
|
|
252
400
|
(_c2 = navigation.getParent()) == null ? void 0 : _c2.dispatch(CommonActions.navigate("MainStack", {
|
|
253
401
|
screen: "MainStack.Layout.Home",
|
|
254
402
|
params: {
|
|
@@ -257,25 +405,17 @@ function HomeScreenContent({
|
|
|
257
405
|
merge: true,
|
|
258
406
|
key: Date.now().toString()
|
|
259
407
|
}));
|
|
260
|
-
}, [navigation, (_g = route == null ? void 0 : route.params) == null ? void 0 : _g.orgName, effectiveOrgName
|
|
408
|
+
}, [navigation, (_g = route == null ? void 0 : route.params) == null ? void 0 : _g.orgName, effectiveOrgName]);
|
|
261
409
|
useEffect(() => {
|
|
410
|
+
const headerLeft = showChatHistory ? () => /* @__PURE__ */ jsx(HeaderBackButton, { color: primaryTextColor, onPress: handleCloseChatHistory }) : void 0;
|
|
411
|
+
const headerRight = () => /* @__PURE__ */ jsx(HeaderRightActions, { gatewayToolbarStatus, gatewayToolbarError, onToggleGateway: handleToggleGateway, gatewayToolbarLabel, gatewayToolbarTone, showChatHistory, onOpenChatHistory: handleOpenChatHistory, onNewChat: handleNewChat, isDark, accentColor, newChatIconColor });
|
|
262
412
|
navigation.setOptions({
|
|
263
413
|
drawerLabel: "Chat",
|
|
264
414
|
headerTitle: showChatHistory ? "Chats" : "Yantra",
|
|
265
|
-
headerLeft
|
|
266
|
-
|
|
267
|
-
}) => [styles.backButton, pressed && styles.newChatButtonPressed], accessibilityLabel: "Back to chat", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-left", size: 24, color: "#111827" }) }) : void 0,
|
|
268
|
-
headerRight: () => /* @__PURE__ */ jsxs(View, { style: styles.headerRight, children: [
|
|
269
|
-
/* @__PURE__ */ jsx(GatewayToolbarButtonMobile, { gatewayStatus: gatewayToolbarStatus, gatewayError: gatewayToolbarError, onToggleGateway: handleToggleGateway, disabled: false, statusLabel: gatewayToolbarLabel, tone: gatewayToolbarTone }),
|
|
270
|
-
!showChatHistory ? /* @__PURE__ */ jsx(Pressable, { onPress: handleOpenChatHistory, style: ({
|
|
271
|
-
pressed
|
|
272
|
-
}) => [styles.historyHeaderButton, pressed && styles.historyHeaderButtonPressed], accessibilityLabel: "Chat history", accessibilityRole: "button", children: /* @__PURE__ */ jsx(View, { style: styles.historyHeaderButtonInner, children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "history", size: 19, color: "#4338ca" }) }) }) : null,
|
|
273
|
-
/* @__PURE__ */ jsx(Pressable, { onPress: handleNewChat, style: ({
|
|
274
|
-
pressed
|
|
275
|
-
}) => [styles.newChatButton, pressed && styles.newChatButtonPressed], accessibilityLabel: "New chat", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chat-plus-outline", size: 26, color: "#000" }) })
|
|
276
|
-
] })
|
|
415
|
+
headerLeft,
|
|
416
|
+
headerRight
|
|
277
417
|
});
|
|
278
|
-
}, [navigation, showChatHistory, handleCloseChatHistory, handleOpenChatHistory, handleNewChat, handleToggleGateway, gatewayToolbarStatus, gatewayToolbarError, gatewayToolbarLabel, gatewayToolbarTone]);
|
|
418
|
+
}, [navigation, showChatHistory, handleCloseChatHistory, handleOpenChatHistory, handleNewChat, handleToggleGateway, gatewayToolbarStatus, gatewayToolbarError, gatewayToolbarLabel, gatewayToolbarTone, primaryTextColor, accentColor, newChatIconColor, isDark]);
|
|
279
419
|
const handleSendMessage = useCallback(async (text) => {
|
|
280
420
|
if (!text.trim() || isLoading || disabled) return;
|
|
281
421
|
const submission = {
|
|
@@ -311,39 +451,6 @@ function HomeScreenContent({
|
|
|
311
451
|
setChannelBootstrap(false);
|
|
312
452
|
}
|
|
313
453
|
}, [isLoading, disabled, activeMode, onSubmitProp, ensureSessionId, sendMessage]);
|
|
314
|
-
const leftItems = getDefaultLeftItems({
|
|
315
|
-
search: {
|
|
316
|
-
active: activeMode === "chat",
|
|
317
|
-
onClick: () => handleModeSwitch("chat")
|
|
318
|
-
},
|
|
319
|
-
zap: {
|
|
320
|
-
active: activeMode === "deep-search",
|
|
321
|
-
onClick: () => handleModeSwitch("deep-search")
|
|
322
|
-
},
|
|
323
|
-
lightbulb: {
|
|
324
|
-
enabled: false
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
const rightItems = getDefaultRightItems({
|
|
328
|
-
tag: {
|
|
329
|
-
enabled: false
|
|
330
|
-
},
|
|
331
|
-
chip: {
|
|
332
|
-
enabled: false
|
|
333
|
-
},
|
|
334
|
-
camera: {
|
|
335
|
-
enabled: false,
|
|
336
|
-
onClick: () => console.log("camera")
|
|
337
|
-
},
|
|
338
|
-
image: {
|
|
339
|
-
enabled: false,
|
|
340
|
-
onClick: () => console.log("image")
|
|
341
|
-
},
|
|
342
|
-
attach: {
|
|
343
|
-
enabled: false,
|
|
344
|
-
onClick: () => console.log("attach")
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
454
|
const latestAssistantMessage = useMemo(() => {
|
|
348
455
|
var _a2, _b2, _c2;
|
|
349
456
|
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
@@ -376,83 +483,111 @@ function HomeScreenContent({
|
|
|
376
483
|
setChannelBootstrap(false);
|
|
377
484
|
}
|
|
378
485
|
}, [deepSearchQuery, isStreaming, ensureSessionId, sendMessage]);
|
|
486
|
+
const handleValueChange = useCallback((e) => {
|
|
487
|
+
setValue(e.nativeEvent.text);
|
|
488
|
+
}, []);
|
|
489
|
+
const handleMicPress = useCallback(() => {
|
|
490
|
+
console.log("mic");
|
|
491
|
+
}, []);
|
|
492
|
+
const handleSelectHistorySession = useCallback((channelId) => {
|
|
493
|
+
setShowChatHistory(false);
|
|
494
|
+
setActiveSessionId(channelId);
|
|
495
|
+
setActiveMode("chat");
|
|
496
|
+
}, []);
|
|
497
|
+
const handleComposeFromHistory = useCallback(() => {
|
|
498
|
+
setShowChatHistory(false);
|
|
499
|
+
setActiveSessionId(null);
|
|
500
|
+
setValue("");
|
|
501
|
+
clearMessages();
|
|
502
|
+
}, [clearMessages]);
|
|
503
|
+
const handleToggleResearchProcess = useCallback(() => {
|
|
504
|
+
setResearchProcessOpen((prev) => !prev);
|
|
505
|
+
}, []);
|
|
506
|
+
const handleToggleSourcesAccordion = useCallback(() => {
|
|
507
|
+
setSourcesAccordionOpen((prev) => !prev);
|
|
508
|
+
}, []);
|
|
509
|
+
const handleRetryDeepSearchPress = useCallback(() => {
|
|
510
|
+
void handleRetryDeepSearch();
|
|
511
|
+
}, [handleRetryDeepSearch]);
|
|
379
512
|
useEffect(() => {
|
|
380
513
|
if (!deepSearchQuery || isStreaming || !latestAssistantMessage) return;
|
|
381
514
|
setDeepSearchSummary(normalizeSummaryText(latestAssistantMessage));
|
|
382
515
|
setDeepSearchSources(extractDeepSearchSources(latestAssistantMessage));
|
|
383
516
|
}, [deepSearchQuery, isStreaming, latestAssistantMessage]);
|
|
517
|
+
const composerScrollBottomPadding = COMPOSER_SCROLL_RESERVE_PX;
|
|
518
|
+
const leftItems = useMemo(() => getDefaultLeftItems({
|
|
519
|
+
search: {
|
|
520
|
+
active: activeMode === "chat",
|
|
521
|
+
onClick: () => handleModeSwitch("chat")
|
|
522
|
+
},
|
|
523
|
+
zap: {
|
|
524
|
+
active: activeMode === "deep-search",
|
|
525
|
+
onClick: () => handleModeSwitch("deep-search")
|
|
526
|
+
},
|
|
527
|
+
lightbulb: {
|
|
528
|
+
enabled: false
|
|
529
|
+
}
|
|
530
|
+
}), [activeMode, handleModeSwitch]);
|
|
531
|
+
const rightItems = useMemo(() => getDefaultRightItems({
|
|
532
|
+
tag: {
|
|
533
|
+
enabled: false
|
|
534
|
+
},
|
|
535
|
+
chip: {
|
|
536
|
+
enabled: false
|
|
537
|
+
},
|
|
538
|
+
camera: {
|
|
539
|
+
enabled: false,
|
|
540
|
+
onClick: () => console.log("camera")
|
|
541
|
+
},
|
|
542
|
+
image: {
|
|
543
|
+
enabled: false,
|
|
544
|
+
onClick: () => console.log("image")
|
|
545
|
+
},
|
|
546
|
+
attach: {
|
|
547
|
+
enabled: false,
|
|
548
|
+
onClick: () => console.log("attach")
|
|
549
|
+
}
|
|
550
|
+
}), []);
|
|
551
|
+
const inputConfig = useMemo(() => ({
|
|
552
|
+
value,
|
|
553
|
+
onChange: handleValueChange,
|
|
554
|
+
placeholder: inputPlaceholder,
|
|
555
|
+
disabled: isLoading || disabled
|
|
556
|
+
}), [value, handleValueChange, inputPlaceholder, isLoading, disabled]);
|
|
557
|
+
const micSendButton = useMemo(() => ({
|
|
558
|
+
hasContent: canSubmit,
|
|
559
|
+
onSend: () => handleSubmit(),
|
|
560
|
+
onMic: handleMicPress,
|
|
561
|
+
disabled: isLoading || disabled,
|
|
562
|
+
isLoading,
|
|
563
|
+
onStop: isStreaming ? cancel : onStop
|
|
564
|
+
}), [canSubmit, handleSubmit, handleMicPress, isLoading, disabled, isStreaming, cancel, onStop]);
|
|
384
565
|
return /* @__PURE__ */ jsxs(SafeAreaView, { edges: ["left", "right", "bottom"], style: {
|
|
385
566
|
flex: 1,
|
|
386
|
-
backgroundColor:
|
|
567
|
+
backgroundColor: surfaceColor
|
|
387
568
|
}, children: [
|
|
388
|
-
/* @__PURE__ */ jsxs(Box, { flex: 1, width: "100%", position: "relative", children: [
|
|
389
|
-
(chatError || cdecli.error) && /* @__PURE__ */ jsx(Box, { mb: "$2", mx: "$4", p: "$3",
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
margin: 0
|
|
406
|
-
}, messages: messages.map((msg, index) => ({
|
|
407
|
-
id: `msg-${index}-${msg.role}`,
|
|
408
|
-
role: msg.role,
|
|
409
|
-
content: msg.content,
|
|
410
|
-
metadata: msg.metadata
|
|
411
|
-
})), streamingContent: response, currentUser: {
|
|
412
|
-
id: "user"
|
|
413
|
-
}, onSend: handleSendMessage, disabled: isLoading || disabled, isLoading, onStop: isStreaming ? cancel : onStop, renderPlanInputToolbar: ({
|
|
414
|
-
value: value2,
|
|
415
|
-
onChange,
|
|
416
|
-
onSend,
|
|
417
|
-
disabled: inputDisabled
|
|
418
|
-
}) => /* @__PURE__ */ jsx(InputToolBar, { inputConfig: {
|
|
419
|
-
value: value2,
|
|
420
|
-
onChange: (e) => onChange(e.nativeEvent.text),
|
|
421
|
-
placeholder: inputPlaceholder,
|
|
422
|
-
disabled: inputDisabled
|
|
423
|
-
}, leftItems, rightItems, templateButton: null, templateModalConfig: null, micSendButton: {
|
|
424
|
-
hasContent: value2.trim().length > 0,
|
|
425
|
-
onSend: () => onSend(value2.trim()),
|
|
426
|
-
onMic: () => console.log("mic"),
|
|
427
|
-
disabled: inputDisabled,
|
|
428
|
-
isLoading,
|
|
429
|
-
onStop: isStreaming ? cancel : onStop
|
|
430
|
-
} }), renderBuildInputToolbar: () => null }) }) : /* @__PURE__ */ jsxs(Box, { flex: 1, width: "100%", children: [
|
|
431
|
-
/* @__PURE__ */ jsx(View, { style: styles.emptyCenterTitleWrap, children: /* @__PURE__ */ jsx(Text, { style: styles.emptyCenterTitle, children: "What can I do for you?" }) }),
|
|
432
|
-
/* @__PURE__ */ jsx(View, { style: [styles.bottomComposerWrap, {
|
|
433
|
-
paddingBottom: Math.max(insets.bottom - 6, 2),
|
|
434
|
-
marginBottom: -Math.max(insets.bottom - 2, 0)
|
|
435
|
-
}], children: /* @__PURE__ */ jsx(InputToolBar, { inputConfig: {
|
|
436
|
-
value,
|
|
437
|
-
onChange: (e) => setValue(e.nativeEvent.text),
|
|
438
|
-
placeholder: inputPlaceholder,
|
|
439
|
-
disabled: isLoading || disabled
|
|
440
|
-
}, leftItems, rightItems, templateButton: null, templateModalConfig: null, micSendButton: {
|
|
441
|
-
hasContent: canSubmit,
|
|
442
|
-
onSend: () => handleSubmit(),
|
|
443
|
-
onMic: () => console.log("mic"),
|
|
444
|
-
disabled: isLoading || disabled,
|
|
445
|
-
isLoading,
|
|
446
|
-
onStop
|
|
447
|
-
} }) })
|
|
448
|
-
] }),
|
|
569
|
+
/* @__PURE__ */ jsx(TouchableWithoutFeedback, { onPress: Keyboard.dismiss, accessible: false, children: /* @__PURE__ */ jsxs(Box, { flex: 1, width: "100%", position: "relative", children: [
|
|
570
|
+
(chatError || cdecli.error) && /* @__PURE__ */ jsx(Box, { mb: "$2", mx: "$4", p: "$3", borderRadius: "$md", style: {
|
|
571
|
+
backgroundColor: isDark ? "#2b1a1d" : "#fef2f2",
|
|
572
|
+
borderWidth: 1,
|
|
573
|
+
borderColor: isDark ? "#7f1d1d" : "#fecaca"
|
|
574
|
+
}, children: /* @__PURE__ */ jsx(Text, { fontSize: "$sm", style: {
|
|
575
|
+
color: isDark ? "#fecaca" : "#991b1b"
|
|
576
|
+
}, children: chatError || cdecli.error }) }),
|
|
577
|
+
showChatHistory ? /* @__PURE__ */ jsx(ChatHistoryLanding, { onSelectSession: handleSelectHistorySession, onCompose: handleComposeFromHistory }) : hasRenderableConversation ? /* @__PURE__ */ jsx(ChatContentSection, { contentMaxWidth, composerScrollBottomPadding, messages, response, isLoading, disabled, isStreaming, onStop, cancel, onSend: handleSendMessage, onBackPress: handleNewChat }) : /* @__PURE__ */ jsx(EmptyStateSection, { isDark, secondaryTextColor, primaryTextColor, activeMode, onModeSwitch: handleModeSwitch }),
|
|
578
|
+
!showChatHistory ? /* @__PURE__ */ jsx(View, { style: [styles.bottomComposerWrap, {
|
|
579
|
+
bottom: Math.max(0, keyboardHeight - insets.bottom),
|
|
580
|
+
paddingBottom: Math.max(insets.bottom - 6, 2)
|
|
581
|
+
// backgroundColor: composerBarBackground,
|
|
582
|
+
// borderTopColor: composerBarBorder,
|
|
583
|
+
}], children: /* @__PURE__ */ jsx(View, { style: [styles.bottomComposerInner, {
|
|
584
|
+
width: contentMaxWidth
|
|
585
|
+
}], children: /* @__PURE__ */ jsx(InputToolBar, { inputConfig, leftItems, rightItems, templateButton: null, templateModalConfig: null, micSendButton }) }) }) : null,
|
|
449
586
|
showSendingLoader ? /* @__PURE__ */ jsx(View, { pointerEvents: "none", style: pinSendingLoaderNearComposer ? [styles.sendingLoaderAboveComposer, {
|
|
450
587
|
bottom: Math.max(insets.bottom, 12) + SENDING_LOADER_COMPOSER_RESERVE_PX
|
|
451
588
|
}] : styles.sendingLoaderEmptyState, children: /* @__PURE__ */ jsx(YantraBrandLoader, { size: YANTRA_LOADER_SIZE_COMPACT }) }) : null
|
|
452
|
-
] }),
|
|
453
|
-
/* @__PURE__ */ jsx(DeepSearchModal, { visible: isDeepSearchModalOpen, query: deepSearchQuery, summaryText: deepSearchPreviewNormalized, sources: deepSearchSources, isStreaming, researchProcessOpen, sourcesAccordionOpen, onToggleResearchProcess:
|
|
454
|
-
void handleRetryDeepSearch();
|
|
455
|
-
}, onStop: cancel, onClose: handleDeepSearchClose })
|
|
589
|
+
] }) }),
|
|
590
|
+
/* @__PURE__ */ jsx(DeepSearchModal, { visible: isDeepSearchModalOpen, query: deepSearchQuery, summaryText: deepSearchPreviewNormalized, sources: deepSearchSources, isStreaming, researchProcessOpen, sourcesAccordionOpen, onToggleResearchProcess: handleToggleResearchProcess, onToggleSourcesAccordion: handleToggleSourcesAccordion, onRetry: handleRetryDeepSearchPress, onStop: cancel, onClose: handleDeepSearchClose })
|
|
456
591
|
] });
|
|
457
592
|
}
|
|
458
593
|
const styles = StyleSheet.create({
|
|
@@ -480,39 +615,67 @@ const styles = StyleSheet.create({
|
|
|
480
615
|
headerRight: {
|
|
481
616
|
flexDirection: "row",
|
|
482
617
|
alignItems: "center",
|
|
483
|
-
marginRight:
|
|
484
|
-
gap:
|
|
618
|
+
marginRight: 6,
|
|
619
|
+
gap: 6
|
|
485
620
|
},
|
|
486
621
|
historyHeaderButton: {
|
|
487
|
-
marginHorizontal:
|
|
488
|
-
padding:
|
|
622
|
+
marginHorizontal: 0,
|
|
623
|
+
padding: 0,
|
|
489
624
|
borderRadius: 22
|
|
490
625
|
},
|
|
491
626
|
historyHeaderButtonPressed: {
|
|
492
627
|
opacity: 0.72
|
|
493
628
|
},
|
|
494
629
|
historyHeaderButtonInner: {
|
|
495
|
-
width:
|
|
496
|
-
height:
|
|
497
|
-
borderRadius:
|
|
630
|
+
width: 32,
|
|
631
|
+
height: 32,
|
|
632
|
+
borderRadius: 16,
|
|
498
633
|
alignItems: "center",
|
|
499
634
|
justifyContent: "center",
|
|
500
|
-
backgroundColor:
|
|
635
|
+
backgroundColor: mobileTokens.color.primarySoft,
|
|
501
636
|
borderWidth: StyleSheet.hairlineWidth,
|
|
502
|
-
borderColor:
|
|
503
|
-
shadowColor: "#
|
|
504
|
-
shadowOpacity: 0.
|
|
505
|
-
shadowRadius:
|
|
637
|
+
borderColor: mobileTokens.color.primaryBorder,
|
|
638
|
+
shadowColor: "#312e81",
|
|
639
|
+
shadowOpacity: 0.1,
|
|
640
|
+
shadowRadius: 5,
|
|
506
641
|
shadowOffset: {
|
|
507
642
|
width: 0,
|
|
508
643
|
height: 2
|
|
509
644
|
},
|
|
510
645
|
elevation: 2
|
|
511
646
|
},
|
|
647
|
+
historyHeaderButtonInnerDark: {
|
|
648
|
+
backgroundColor: "#1e293b",
|
|
649
|
+
borderColor: "rgba(148, 163, 184, 0.35)",
|
|
650
|
+
shadowColor: "#111827"
|
|
651
|
+
},
|
|
512
652
|
newChatButton: {
|
|
513
|
-
padding:
|
|
653
|
+
padding: 0,
|
|
514
654
|
alignItems: "center",
|
|
515
|
-
justifyContent: "center"
|
|
655
|
+
justifyContent: "center",
|
|
656
|
+
borderRadius: 22
|
|
657
|
+
},
|
|
658
|
+
newChatButtonInner: {
|
|
659
|
+
width: 32,
|
|
660
|
+
height: 32,
|
|
661
|
+
borderRadius: 16,
|
|
662
|
+
alignItems: "center",
|
|
663
|
+
justifyContent: "center",
|
|
664
|
+
backgroundColor: mobileTokens.color.surface,
|
|
665
|
+
borderWidth: 1,
|
|
666
|
+
borderColor: mobileTokens.color.border,
|
|
667
|
+
shadowColor: "#0f172a",
|
|
668
|
+
shadowOpacity: 0.08,
|
|
669
|
+
shadowRadius: 5,
|
|
670
|
+
shadowOffset: {
|
|
671
|
+
width: 0,
|
|
672
|
+
height: 2
|
|
673
|
+
},
|
|
674
|
+
elevation: 2
|
|
675
|
+
},
|
|
676
|
+
newChatButtonInnerDark: {
|
|
677
|
+
backgroundColor: "#0f172a",
|
|
678
|
+
borderColor: "#334155"
|
|
516
679
|
},
|
|
517
680
|
backButton: {
|
|
518
681
|
marginLeft: 6,
|
|
@@ -529,19 +692,97 @@ const styles = StyleSheet.create({
|
|
|
529
692
|
emptyCenterTitleWrap: {
|
|
530
693
|
flex: 1,
|
|
531
694
|
alignItems: "center",
|
|
532
|
-
justifyContent: "
|
|
695
|
+
justifyContent: "flex-start",
|
|
533
696
|
paddingHorizontal: 24,
|
|
534
|
-
paddingTop:
|
|
697
|
+
paddingTop: 88,
|
|
698
|
+
paddingBottom: 52,
|
|
699
|
+
maxWidth: 520,
|
|
700
|
+
alignSelf: "center"
|
|
701
|
+
},
|
|
702
|
+
emptyEyebrow: {
|
|
703
|
+
fontSize: 12,
|
|
704
|
+
fontWeight: "600",
|
|
705
|
+
letterSpacing: 0.4,
|
|
706
|
+
textTransform: "uppercase",
|
|
707
|
+
marginBottom: 10
|
|
535
708
|
},
|
|
536
709
|
emptyCenterTitle: {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
710
|
+
marginTop: 2,
|
|
711
|
+
fontSize: 30,
|
|
712
|
+
fontWeight: "700",
|
|
540
713
|
textAlign: "center",
|
|
541
|
-
letterSpacing: 0.
|
|
714
|
+
letterSpacing: -0.5
|
|
715
|
+
},
|
|
716
|
+
emptySubtitle: {
|
|
717
|
+
marginTop: 12,
|
|
718
|
+
fontSize: 14,
|
|
719
|
+
lineHeight: 22,
|
|
720
|
+
textAlign: "center",
|
|
721
|
+
paddingHorizontal: 16,
|
|
722
|
+
maxWidth: 360
|
|
542
723
|
},
|
|
543
724
|
bottomComposerWrap: {
|
|
544
|
-
|
|
725
|
+
position: "absolute",
|
|
726
|
+
width: "100%",
|
|
727
|
+
left: 0,
|
|
728
|
+
right: 0,
|
|
729
|
+
bottom: 0,
|
|
730
|
+
alignItems: "center",
|
|
731
|
+
justifyContent: "flex-end",
|
|
732
|
+
// borderTopWidth: 1,
|
|
733
|
+
shadowColor: "#0f172a",
|
|
734
|
+
shadowOpacity: 0.08,
|
|
735
|
+
shadowRadius: 8,
|
|
736
|
+
shadowOffset: {
|
|
737
|
+
width: 0,
|
|
738
|
+
height: -2
|
|
739
|
+
},
|
|
740
|
+
backgroundColor: "transparent",
|
|
741
|
+
elevation: 6
|
|
742
|
+
},
|
|
743
|
+
bottomComposerInner: {
|
|
744
|
+
paddingHorizontal: 14,
|
|
745
|
+
paddingTop: 10,
|
|
746
|
+
paddingBottom: 4
|
|
747
|
+
},
|
|
748
|
+
emptyModePillRow: {
|
|
749
|
+
flexDirection: "row",
|
|
750
|
+
alignItems: "center",
|
|
751
|
+
gap: 8,
|
|
752
|
+
marginBottom: 22,
|
|
753
|
+
borderRadius: 16,
|
|
754
|
+
padding: 6,
|
|
755
|
+
borderWidth: 1,
|
|
756
|
+
shadowColor: "#312e81",
|
|
757
|
+
shadowOpacity: 0.08,
|
|
758
|
+
shadowRadius: 8,
|
|
759
|
+
shadowOffset: {
|
|
760
|
+
width: 0,
|
|
761
|
+
height: 3
|
|
762
|
+
},
|
|
763
|
+
elevation: 3
|
|
764
|
+
},
|
|
765
|
+
emptyModePill: {
|
|
766
|
+
flexDirection: "row",
|
|
767
|
+
alignItems: "center",
|
|
768
|
+
gap: 4,
|
|
769
|
+
paddingHorizontal: 12,
|
|
770
|
+
paddingVertical: 7,
|
|
771
|
+
borderRadius: 11
|
|
772
|
+
},
|
|
773
|
+
emptyModePillActive: {
|
|
774
|
+
shadowColor: "#312e81",
|
|
775
|
+
shadowOpacity: 0.18,
|
|
776
|
+
shadowRadius: 6,
|
|
777
|
+
shadowOffset: {
|
|
778
|
+
width: 0,
|
|
779
|
+
height: 2
|
|
780
|
+
},
|
|
781
|
+
elevation: 2
|
|
782
|
+
},
|
|
783
|
+
emptyModePillLabel: {
|
|
784
|
+
fontSize: 12,
|
|
785
|
+
fontWeight: "600"
|
|
545
786
|
}
|
|
546
787
|
});
|
|
547
788
|
const HomeScreen = (props) => /* @__PURE__ */ jsx(HomeScreenContent, __spreadValues({}, props));export{HomeScreen as default};//# sourceMappingURL=HomeScreen.js.map
|