@terryavg/neptune-ai-chatbot 1.0.2 → 1.0.3
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/README.md +2 -22
- package/dist/chat-input-2CHIBULE.mjs +510 -0
- package/dist/chat-input-G2LRENLB.mjs +512 -0
- package/dist/chat-input-IIV2HQOZ.mjs +509 -0
- package/dist/chat-input-MLF62KV7.mjs +512 -0
- package/dist/chat-input-MOPCNDRR.mjs +517 -0
- package/dist/chat-input-TYNO3J5S.mjs +519 -0
- package/dist/chat-input-VQZ3WNBT.mjs +509 -0
- package/dist/chat-input-ZAFYBUO7.mjs +507 -0
- package/dist/chat-message-EQTB6N5X.mjs +2306 -0
- package/dist/chat-message-GUOL4RZU.mjs +2306 -0
- package/dist/chat-message-HWBFOYOJ.mjs +2306 -0
- package/dist/chat-message-NZNZX6VS.mjs +2306 -0
- package/dist/chunk-VONUV37R.mjs +268 -0
- package/dist/chunk-XQVUOR36.mjs +438 -0
- package/dist/chunk-Y7QF5535.mjs +268 -0
- package/dist/index.d.mts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +319 -614
- package/dist/index.mjs +124 -246
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
chatClient,
|
|
7
7
|
configureChatClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VONUV37R.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__spreadProps,
|
|
11
11
|
__spreadValues
|
|
@@ -68,8 +68,7 @@ import {
|
|
|
68
68
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
69
69
|
function AnalyticsPanel({
|
|
70
70
|
name,
|
|
71
|
-
csvData
|
|
72
|
-
theme
|
|
71
|
+
csvData
|
|
73
72
|
}) {
|
|
74
73
|
const { headers, data } = useMemo(() => {
|
|
75
74
|
var _a;
|
|
@@ -1271,16 +1270,13 @@ function AnalyticsPanel({
|
|
|
1271
1270
|
|
|
1272
1271
|
// app/components/chat-content.tsx
|
|
1273
1272
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1274
|
-
var ChatInput = lazy(() => import("./chat-input-
|
|
1275
|
-
var DynamicChatMessage = lazy(() => import("./chat-message-
|
|
1273
|
+
var ChatInput = lazy(() => import("./chat-input-ZAFYBUO7.mjs"));
|
|
1274
|
+
var DynamicChatMessage = lazy(() => import("./chat-message-NZNZX6VS.mjs"));
|
|
1276
1275
|
var SCROLL_BOTTOM_THRESHOLD = 50;
|
|
1277
1276
|
function ChatContent({
|
|
1278
1277
|
conversation,
|
|
1279
1278
|
agentId,
|
|
1280
|
-
debug = false,
|
|
1281
|
-
onConversationUpdate,
|
|
1282
1279
|
theme,
|
|
1283
|
-
onAppStateChange,
|
|
1284
1280
|
onSidebarToggle,
|
|
1285
1281
|
isReadOnly = false,
|
|
1286
1282
|
onThreadCreated,
|
|
@@ -1314,10 +1310,10 @@ function ChatContent({
|
|
|
1314
1310
|
null
|
|
1315
1311
|
);
|
|
1316
1312
|
const streamingMessageRef = useRef(null);
|
|
1313
|
+
const previousConversationIdRef = useRef(conversation.id);
|
|
1317
1314
|
const [errorDialog, setErrorDialog] = useState2(null);
|
|
1318
1315
|
const [showScrollToBottomButton, setShowScrollToBottomButton] = useState2(false);
|
|
1319
1316
|
const [userHasScrolledUp, setUserHasScrolledUp] = useState2(false);
|
|
1320
|
-
const [openApp, setOpenApp] = useState2(null);
|
|
1321
1317
|
const [openAnalytic, setOpenAnalytic] = useState2(null);
|
|
1322
1318
|
const [chatWidth, setChatWidth] = useState2(30);
|
|
1323
1319
|
const [isResizingChatApp, setIsResizingChatApp] = useState2(false);
|
|
@@ -1326,7 +1322,7 @@ function ChatContent({
|
|
|
1326
1322
|
const minChatWidth = 20;
|
|
1327
1323
|
const maxChatWidth = 80;
|
|
1328
1324
|
const hasMessages = messages.length > 0 || !!streamingMessage;
|
|
1329
|
-
const hasOpenPanel = !!
|
|
1325
|
+
const hasOpenPanel = !!openAnalytic;
|
|
1330
1326
|
const isWaitingForInput = useMemo2(() => {
|
|
1331
1327
|
return conversation.waiting === true || messages.some((message) => message.waiting === true);
|
|
1332
1328
|
}, [conversation.waiting, messages]);
|
|
@@ -1410,16 +1406,61 @@ function ChatContent({
|
|
|
1410
1406
|
return () => clearTimeout(timeoutId);
|
|
1411
1407
|
}, [conversation.id, scrollToBottom]);
|
|
1412
1408
|
useEffect2(() => {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1409
|
+
const conversationMessages = conversation.messages || [];
|
|
1410
|
+
const previousId = previousConversationIdRef.current;
|
|
1411
|
+
const currentId = conversation.id;
|
|
1412
|
+
const isTempToRealTransition = (previousId == null ? void 0 : previousId.startsWith("temp-")) && !currentId.startsWith("temp-") && isStreaming;
|
|
1413
|
+
if (previousId !== currentId && !isTempToRealTransition) {
|
|
1414
|
+
setMessages(conversationMessages);
|
|
1415
|
+
previousConversationIdRef.current = currentId;
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
if (isTempToRealTransition) {
|
|
1419
|
+
previousConversationIdRef.current = currentId;
|
|
1420
|
+
}
|
|
1421
|
+
if (isStreaming && !isTempToRealTransition) {
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
if (conversationMessages.length > 0 || isTempToRealTransition) {
|
|
1425
|
+
setMessages((prevMessages) => {
|
|
1426
|
+
if (prevMessages.length === 0) {
|
|
1427
|
+
return conversationMessages;
|
|
1428
|
+
}
|
|
1429
|
+
const filteredLocalMessages = prevMessages.filter((localMsg) => {
|
|
1430
|
+
if (localMsg.role === "assistant") {
|
|
1431
|
+
return true;
|
|
1432
|
+
}
|
|
1433
|
+
const localTime = new Date(localMsg.createdAt).getTime();
|
|
1434
|
+
const isLocalMessage = localMsg.id.startsWith("local-");
|
|
1435
|
+
if (isLocalMessage) {
|
|
1436
|
+
const hasBackendVersion = conversationMessages.some((backendMsg) => {
|
|
1437
|
+
const backendTime = new Date(backendMsg.createdAt).getTime();
|
|
1438
|
+
const timeDiff = Math.abs(backendTime - localTime);
|
|
1439
|
+
return backendMsg.role === localMsg.role && timeDiff < 5e3;
|
|
1440
|
+
});
|
|
1441
|
+
return !hasBackendVersion;
|
|
1442
|
+
}
|
|
1443
|
+
return true;
|
|
1444
|
+
});
|
|
1445
|
+
const combined = [...filteredLocalMessages, ...conversationMessages];
|
|
1446
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1447
|
+
const deduplicated = combined.filter((msg) => {
|
|
1448
|
+
if (seen.has(msg.id)) {
|
|
1449
|
+
return false;
|
|
1450
|
+
}
|
|
1451
|
+
seen.add(msg.id);
|
|
1452
|
+
return true;
|
|
1453
|
+
});
|
|
1454
|
+
return deduplicated.sort((a, b) => {
|
|
1455
|
+
return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1418
1458
|
}
|
|
1459
|
+
}, [conversation.id, conversation.messages, isStreaming]);
|
|
1460
|
+
useEffect2(() => {
|
|
1419
1461
|
if (openAnalytic) {
|
|
1420
1462
|
setOpenAnalytic(null);
|
|
1421
1463
|
}
|
|
1422
|
-
onAppStateChange == null ? void 0 : onAppStateChange(false);
|
|
1423
1464
|
}, [conversation.id]);
|
|
1424
1465
|
useEffect2(() => {
|
|
1425
1466
|
if (messages.length > 0 && !userHasScrolledUp) {
|
|
@@ -1554,16 +1595,26 @@ function ChatContent({
|
|
|
1554
1595
|
}), metadata && {
|
|
1555
1596
|
metadata: {
|
|
1556
1597
|
logId: metadata.logId,
|
|
1557
|
-
steps: metadata.steps
|
|
1598
|
+
steps: metadata.steps,
|
|
1599
|
+
vectors: metadata.vectors
|
|
1558
1600
|
}
|
|
1559
1601
|
});
|
|
1560
1602
|
}
|
|
1561
1603
|
if (messageToAdd) {
|
|
1562
1604
|
setMessages((prev) => [...prev, messageToAdd]);
|
|
1605
|
+
streamingMessageRef.current = {
|
|
1606
|
+
id: messageToAdd.id,
|
|
1607
|
+
role: messageToAdd.role,
|
|
1608
|
+
createdAt: messageToAdd.createdAt
|
|
1609
|
+
};
|
|
1610
|
+
setTimeout(() => {
|
|
1611
|
+
streamingMessageRef.current = null;
|
|
1612
|
+
}, 1e3);
|
|
1613
|
+
} else {
|
|
1614
|
+
streamingMessageRef.current = null;
|
|
1563
1615
|
}
|
|
1564
1616
|
setIsStreaming(false);
|
|
1565
1617
|
setStreamingMessage(null);
|
|
1566
|
-
streamingMessageRef.current = null;
|
|
1567
1618
|
},
|
|
1568
1619
|
[]
|
|
1569
1620
|
);
|
|
@@ -1579,186 +1630,16 @@ function ChatContent({
|
|
|
1579
1630
|
setStreamingMessage(null);
|
|
1580
1631
|
streamingMessageRef.current = null;
|
|
1581
1632
|
}, []);
|
|
1582
|
-
const handleAppOpen = useCallback(
|
|
1583
|
-
(name, url) => {
|
|
1584
|
-
setOpenAnalytic(null);
|
|
1585
|
-
setOpenApp({ name, url });
|
|
1586
|
-
onAppStateChange == null ? void 0 : onAppStateChange(true);
|
|
1587
|
-
},
|
|
1588
|
-
[onAppStateChange]
|
|
1589
|
-
);
|
|
1590
1633
|
const handleAnalyticOpen = useCallback(
|
|
1591
1634
|
(name, data) => {
|
|
1592
|
-
setOpenApp(null);
|
|
1593
1635
|
setOpenAnalytic({ name, data });
|
|
1594
|
-
onAppStateChange == null ? void 0 : onAppStateChange(true);
|
|
1595
1636
|
onSidebarToggle == null ? void 0 : onSidebarToggle();
|
|
1596
1637
|
},
|
|
1597
|
-
[
|
|
1638
|
+
[onSidebarToggle]
|
|
1598
1639
|
);
|
|
1599
1640
|
const handlePanelClose = useCallback(() => {
|
|
1600
|
-
setOpenApp(null);
|
|
1601
1641
|
setOpenAnalytic(null);
|
|
1602
|
-
|
|
1603
|
-
}, [onAppStateChange]);
|
|
1604
|
-
const handleWidgetSubmit = useCallback(
|
|
1605
|
-
async (data, actionId, messageId, widgetId) => {
|
|
1606
|
-
try {
|
|
1607
|
-
setMessages(
|
|
1608
|
-
(prev) => prev.map(
|
|
1609
|
-
(message) => message.id === messageId ? __spreadProps(__spreadValues({}, message), { waiting: false }) : message
|
|
1610
|
-
)
|
|
1611
|
-
);
|
|
1612
|
-
if (conversation.waiting === true) {
|
|
1613
|
-
}
|
|
1614
|
-
const stepData = {
|
|
1615
|
-
action: actionId,
|
|
1616
|
-
data,
|
|
1617
|
-
id: widgetId,
|
|
1618
|
-
// Use the actual widget ID passed from the form
|
|
1619
|
-
messageId
|
|
1620
|
-
// Backend will use this to update message.waiting = false
|
|
1621
|
-
};
|
|
1622
|
-
if (agentId) {
|
|
1623
|
-
handleStreamStart();
|
|
1624
|
-
const { stream } = await chatClient.messages.sendMessage(
|
|
1625
|
-
agentId,
|
|
1626
|
-
conversation.id,
|
|
1627
|
-
"",
|
|
1628
|
-
//`Processing form submission...`, // Simple processing message
|
|
1629
|
-
messages,
|
|
1630
|
-
new AbortController().signal,
|
|
1631
|
-
debug,
|
|
1632
|
-
stepData,
|
|
1633
|
-
conversation.isTemporary
|
|
1634
|
-
// Pass isTemporary flag
|
|
1635
|
-
);
|
|
1636
|
-
const reader = stream.getReader();
|
|
1637
|
-
const decoder = new TextDecoder();
|
|
1638
|
-
let done = false;
|
|
1639
|
-
let accumulatedResponse = "";
|
|
1640
|
-
while (!done) {
|
|
1641
|
-
const { value, done: readerDone } = await reader.read();
|
|
1642
|
-
done = readerDone;
|
|
1643
|
-
if (value) {
|
|
1644
|
-
const chunk = decoder.decode(value, {
|
|
1645
|
-
stream: !done
|
|
1646
|
-
});
|
|
1647
|
-
if (chunk) {
|
|
1648
|
-
accumulatedResponse += chunk;
|
|
1649
|
-
handleStreamUpdate(chunk);
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
handleStreamEnd(accumulatedResponse);
|
|
1654
|
-
if (onConversationUpdate) {
|
|
1655
|
-
try {
|
|
1656
|
-
await onConversationUpdate();
|
|
1657
|
-
} catch (error) {
|
|
1658
|
-
console.error(
|
|
1659
|
-
"Failed to refresh conversation after form submission:",
|
|
1660
|
-
error
|
|
1661
|
-
);
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
} catch (error) {
|
|
1666
|
-
console.error("Error submitting form:", error);
|
|
1667
|
-
handleError({
|
|
1668
|
-
title: "Form Submission Error",
|
|
1669
|
-
message: "Failed to submit form data. Please try again."
|
|
1670
|
-
});
|
|
1671
|
-
}
|
|
1672
|
-
},
|
|
1673
|
-
[
|
|
1674
|
-
agentId,
|
|
1675
|
-
conversation.id,
|
|
1676
|
-
messages,
|
|
1677
|
-
debug,
|
|
1678
|
-
handleStreamStart,
|
|
1679
|
-
handleStreamUpdate,
|
|
1680
|
-
handleStreamEnd,
|
|
1681
|
-
handleError
|
|
1682
|
-
]
|
|
1683
|
-
);
|
|
1684
|
-
const handleWidgetCancel = useCallback(
|
|
1685
|
-
async (messageId, widgetId) => {
|
|
1686
|
-
try {
|
|
1687
|
-
setMessages(
|
|
1688
|
-
(prev) => prev.map(
|
|
1689
|
-
(message) => message.id === messageId ? __spreadProps(__spreadValues({}, message), { waiting: false }) : message
|
|
1690
|
-
)
|
|
1691
|
-
);
|
|
1692
|
-
const stepData = {
|
|
1693
|
-
action: "cancel",
|
|
1694
|
-
data: null,
|
|
1695
|
-
// No form data for cancellation
|
|
1696
|
-
id: widgetId,
|
|
1697
|
-
messageId
|
|
1698
|
-
};
|
|
1699
|
-
if (agentId) {
|
|
1700
|
-
handleStreamStart();
|
|
1701
|
-
const { stream } = await chatClient.messages.sendMessage(
|
|
1702
|
-
agentId,
|
|
1703
|
-
conversation.id,
|
|
1704
|
-
"",
|
|
1705
|
-
//cancelMessage.content,
|
|
1706
|
-
messages,
|
|
1707
|
-
new AbortController().signal,
|
|
1708
|
-
debug,
|
|
1709
|
-
stepData,
|
|
1710
|
-
conversation.isTemporary
|
|
1711
|
-
// Pass isTemporary flag
|
|
1712
|
-
);
|
|
1713
|
-
const reader = stream.getReader();
|
|
1714
|
-
const decoder = new TextDecoder();
|
|
1715
|
-
let done = false;
|
|
1716
|
-
let accumulatedResponse = "";
|
|
1717
|
-
while (!done) {
|
|
1718
|
-
const { value, done: readerDone } = await reader.read();
|
|
1719
|
-
done = readerDone;
|
|
1720
|
-
if (value) {
|
|
1721
|
-
const chunk = decoder.decode(value, {
|
|
1722
|
-
stream: !done
|
|
1723
|
-
});
|
|
1724
|
-
if (chunk) {
|
|
1725
|
-
accumulatedResponse += chunk;
|
|
1726
|
-
handleStreamUpdate(chunk);
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
handleStreamEnd(accumulatedResponse);
|
|
1731
|
-
if (onConversationUpdate) {
|
|
1732
|
-
try {
|
|
1733
|
-
await onConversationUpdate();
|
|
1734
|
-
} catch (error) {
|
|
1735
|
-
console.error(
|
|
1736
|
-
"Failed to refresh conversation after form cancellation:",
|
|
1737
|
-
error
|
|
1738
|
-
);
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
} catch (error) {
|
|
1743
|
-
console.error("Error cancelling form:", error);
|
|
1744
|
-
handleError({
|
|
1745
|
-
title: "Form Cancellation Error",
|
|
1746
|
-
message: "Failed to cancel form. Please try again."
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1749
|
-
},
|
|
1750
|
-
[
|
|
1751
|
-
agentId,
|
|
1752
|
-
conversation.id,
|
|
1753
|
-
messages,
|
|
1754
|
-
debug,
|
|
1755
|
-
handleStreamStart,
|
|
1756
|
-
handleStreamUpdate,
|
|
1757
|
-
handleStreamEnd,
|
|
1758
|
-
handleError,
|
|
1759
|
-
onConversationUpdate
|
|
1760
|
-
]
|
|
1761
|
-
);
|
|
1642
|
+
}, []);
|
|
1762
1643
|
const startResizingChatApp = useCallback(
|
|
1763
1644
|
(e) => {
|
|
1764
1645
|
e.preventDefault();
|
|
@@ -1917,7 +1798,6 @@ function ChatContent({
|
|
|
1917
1798
|
{
|
|
1918
1799
|
conversationId: conversation.id,
|
|
1919
1800
|
agentId,
|
|
1920
|
-
debug,
|
|
1921
1801
|
onAddUserMessage: handleAddUserMessage,
|
|
1922
1802
|
onStreamStart: handleStreamStart,
|
|
1923
1803
|
onStreamUpdate: handleStreamUpdate,
|
|
@@ -1962,15 +1842,17 @@ function ChatContent({
|
|
|
1962
1842
|
className: "space-y-2",
|
|
1963
1843
|
children: [
|
|
1964
1844
|
allMessages.map((message, index) => {
|
|
1845
|
+
var _a;
|
|
1965
1846
|
const isCurrentlyStreaming = isStreaming && (streamingMessage == null ? void 0 : streamingMessage.id) === message.id;
|
|
1847
|
+
const wasJustStreamed = ((_a = streamingMessageRef.current) == null ? void 0 : _a.id) === message.id;
|
|
1966
1848
|
return /* @__PURE__ */ jsx2(
|
|
1967
1849
|
motion.div,
|
|
1968
1850
|
{
|
|
1969
|
-
initial: { opacity: 0, x: -20 },
|
|
1851
|
+
initial: { opacity: wasJustStreamed ? 1 : 0, x: wasJustStreamed ? 0 : -20 },
|
|
1970
1852
|
animate: { opacity: 1, x: 0 },
|
|
1971
1853
|
transition: {
|
|
1972
|
-
duration: isCurrentlyStreaming ? 0 : 0.3,
|
|
1973
|
-
delay: isCurrentlyStreaming ? 0 : index * 0.05,
|
|
1854
|
+
duration: isCurrentlyStreaming || wasJustStreamed ? 0 : 0.3,
|
|
1855
|
+
delay: isCurrentlyStreaming || wasJustStreamed ? 0 : index * 0.05,
|
|
1974
1856
|
ease: "easeOut"
|
|
1975
1857
|
},
|
|
1976
1858
|
children: /* @__PURE__ */ jsx2(
|
|
@@ -2075,7 +1957,6 @@ function ChatContent({
|
|
|
2075
1957
|
{
|
|
2076
1958
|
conversationId: conversation.id,
|
|
2077
1959
|
agentId,
|
|
2078
|
-
debug,
|
|
2079
1960
|
onAddUserMessage: handleAddUserMessage,
|
|
2080
1961
|
onStreamStart: handleStreamStart,
|
|
2081
1962
|
onStreamUpdate: handleStreamUpdate,
|
|
@@ -2127,8 +2008,8 @@ function ChatContent({
|
|
|
2127
2008
|
/* @__PURE__ */ jsx2(
|
|
2128
2009
|
"div",
|
|
2129
2010
|
{
|
|
2130
|
-
className: `w-8 h-8 rounded-lg flex items-center justify-center ${
|
|
2131
|
-
children:
|
|
2011
|
+
className: `w-8 h-8 rounded-lg flex items-center justify-center ${false ? "bg-blue-500" : "bg-emerald-500"}`,
|
|
2012
|
+
children: false ? /* @__PURE__ */ jsx2(
|
|
2132
2013
|
"svg",
|
|
2133
2014
|
{
|
|
2134
2015
|
className: "w-5 h-5 text-white",
|
|
@@ -2168,7 +2049,7 @@ function ChatContent({
|
|
|
2168
2049
|
}
|
|
2169
2050
|
),
|
|
2170
2051
|
/* @__PURE__ */ jsxs2("div", { children: [
|
|
2171
|
-
/* @__PURE__ */ jsx2("h3", { className: "font-semibold text-gray-800 dark:text-gray-200", children:
|
|
2052
|
+
/* @__PURE__ */ jsx2("h3", { className: "font-semibold text-gray-800 dark:text-gray-200", children: false ? "openApp" : "Analytics Dashboard" }),
|
|
2172
2053
|
openAnalytic && /* @__PURE__ */ jsx2("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: openAnalytic.name })
|
|
2173
2054
|
] })
|
|
2174
2055
|
] }),
|
|
@@ -2190,12 +2071,10 @@ function ChatContent({
|
|
|
2190
2071
|
] }),
|
|
2191
2072
|
/* @__PURE__ */ jsxs2("div", { className: "flex-1 relative h-full", children: [
|
|
2192
2073
|
isResizingChatApp && /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 z-50 bg-transparent cursor-col-resize" }),
|
|
2193
|
-
|
|
2074
|
+
false ? /* @__PURE__ */ jsx2(
|
|
2194
2075
|
"iframe",
|
|
2195
2076
|
{
|
|
2196
|
-
src: openApp.url,
|
|
2197
2077
|
className: "w-full h-full border-0",
|
|
2198
|
-
title: openApp.name,
|
|
2199
2078
|
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
|
2200
2079
|
sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation"
|
|
2201
2080
|
}
|
|
@@ -2277,7 +2156,6 @@ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-run
|
|
|
2277
2156
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect4;
|
|
2278
2157
|
function NeptuneChatBot({
|
|
2279
2158
|
agentId: propAgentId,
|
|
2280
|
-
debug: propDebug = false,
|
|
2281
2159
|
theme: propTheme = "light",
|
|
2282
2160
|
localDebug: propLocalDebug,
|
|
2283
2161
|
title: propTitle = "Naia",
|
|
@@ -2323,14 +2201,12 @@ function NeptuneChatBot({
|
|
|
2323
2201
|
const [conversationToRename, setConversationToRename] = useState4(null);
|
|
2324
2202
|
const [theme, setTheme] = useState4(propTheme);
|
|
2325
2203
|
const [agentId] = useState4(propAgentId);
|
|
2326
|
-
const [debug] = useState4(propDebug);
|
|
2327
2204
|
const [initialAssistantIdChecked] = useState4(true);
|
|
2328
2205
|
const [initialLoadComplete, setInitialLoadComplete] = useState4(false);
|
|
2329
2206
|
const [openMenuId, setOpenMenuId] = useState4(null);
|
|
2330
2207
|
const [isCreatingConversation, setIsCreatingConversation] = useState4(false);
|
|
2331
2208
|
const [sidebarWidth, setSidebarWidth] = useState4(250);
|
|
2332
2209
|
const [isResizing, setIsResizing] = useState4(false);
|
|
2333
|
-
const [hasOpenApp, setHasOpenApp] = useState4(false);
|
|
2334
2210
|
const titleInputRef = useRef2(null);
|
|
2335
2211
|
const resizeHandleRef = useRef2(null);
|
|
2336
2212
|
const hasFetchedRef = useRef2(false);
|
|
@@ -2352,9 +2228,6 @@ function NeptuneChatBot({
|
|
|
2352
2228
|
useEffect4(() => {
|
|
2353
2229
|
applyTheme(theme);
|
|
2354
2230
|
}, [theme, applyTheme]);
|
|
2355
|
-
const handleAppStateChange = useCallback2((hasApp) => {
|
|
2356
|
-
setHasOpenApp(hasApp);
|
|
2357
|
-
}, []);
|
|
2358
2231
|
const toggleTheme = () => {
|
|
2359
2232
|
const newTheme = theme === "dark" ? "light" : "dark";
|
|
2360
2233
|
setTheme(newTheme);
|
|
@@ -2459,17 +2332,15 @@ function NeptuneChatBot({
|
|
|
2459
2332
|
return;
|
|
2460
2333
|
}
|
|
2461
2334
|
setConversations(data);
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
setSelectedConversation(tempConversation);
|
|
2472
|
-
}
|
|
2335
|
+
const tempConversation = {
|
|
2336
|
+
id: `temp-${Date.now()}`,
|
|
2337
|
+
title: "New Chat",
|
|
2338
|
+
messages: [],
|
|
2339
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2340
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2341
|
+
isTemporary: true
|
|
2342
|
+
};
|
|
2343
|
+
setSelectedConversation(tempConversation);
|
|
2473
2344
|
} catch (error) {
|
|
2474
2345
|
console.error("Failed to fetch conversations:", error);
|
|
2475
2346
|
} finally {
|
|
@@ -2522,7 +2393,6 @@ function NeptuneChatBot({
|
|
|
2522
2393
|
} else {
|
|
2523
2394
|
loadConversationData(id);
|
|
2524
2395
|
}
|
|
2525
|
-
setHasOpenApp(false);
|
|
2526
2396
|
}, []);
|
|
2527
2397
|
const createNewConversation = async () => {
|
|
2528
2398
|
try {
|
|
@@ -2544,39 +2414,49 @@ function NeptuneChatBot({
|
|
|
2544
2414
|
};
|
|
2545
2415
|
setSelectedConversationId(tempConversation.id);
|
|
2546
2416
|
setSelectedConversation(tempConversation);
|
|
2547
|
-
setHasOpenApp(false);
|
|
2548
2417
|
} catch (error) {
|
|
2549
2418
|
console.error("Failed to create new conversation:", error);
|
|
2550
2419
|
}
|
|
2551
2420
|
};
|
|
2552
2421
|
const handleThreadCreated = useCallback2(
|
|
2553
|
-
async (oldId, newId) => {
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2422
|
+
async (oldId, newId, backendConversation) => {
|
|
2423
|
+
startTransition2(() => {
|
|
2424
|
+
if (backendConversation) {
|
|
2425
|
+
const updatedConv = __spreadProps(__spreadValues({}, backendConversation), {
|
|
2426
|
+
isTemporary: false
|
|
2427
|
+
});
|
|
2557
2428
|
setConversations((prev) => {
|
|
2558
|
-
const
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2429
|
+
const filtered = prev.filter((conv) => conv.id !== oldId);
|
|
2430
|
+
return [updatedConv, ...filtered];
|
|
2431
|
+
});
|
|
2432
|
+
setSelectedConversationId(newId);
|
|
2433
|
+
setSelectedConversation(updatedConv);
|
|
2434
|
+
} else {
|
|
2435
|
+
setSelectedConversation((currentSelected) => {
|
|
2436
|
+
if (currentSelected && currentSelected.id === oldId) {
|
|
2437
|
+
const updatedConv = __spreadProps(__spreadValues({}, currentSelected), {
|
|
2438
|
+
id: newId,
|
|
2564
2439
|
isTemporary: false
|
|
2565
2440
|
});
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2441
|
+
setConversations((prev) => {
|
|
2442
|
+
const existingIndex = prev.findIndex(
|
|
2443
|
+
(conv) => conv.id === oldId || conv.id === newId
|
|
2444
|
+
);
|
|
2445
|
+
if (existingIndex !== -1) {
|
|
2446
|
+
const updated = [...prev];
|
|
2447
|
+
updated[existingIndex] = updatedConv;
|
|
2448
|
+
return updated;
|
|
2449
|
+
} else {
|
|
2450
|
+
return [updatedConv, ...prev];
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2453
|
+
setSelectedConversationId(newId);
|
|
2454
|
+
return updatedConv;
|
|
2572
2455
|
}
|
|
2456
|
+
return currentSelected;
|
|
2573
2457
|
});
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
});
|
|
2577
|
-
} catch (error) {
|
|
2578
|
-
console.error("Failed to fetch updated conversation:", error);
|
|
2579
|
-
}
|
|
2458
|
+
}
|
|
2459
|
+
});
|
|
2580
2460
|
},
|
|
2581
2461
|
[]
|
|
2582
2462
|
);
|
|
@@ -2997,11 +2877,11 @@ function NeptuneChatBot({
|
|
|
2997
2877
|
/* @__PURE__ */ jsx4(
|
|
2998
2878
|
"div",
|
|
2999
2879
|
{
|
|
3000
|
-
className: `flex-1 overflow-hidden bg-white dark:bg-gray-900 text-lg transition-all duration-300 ${
|
|
2880
|
+
className: `flex-1 overflow-hidden bg-white dark:bg-gray-900 text-lg transition-all duration-300 ${false ? "flex" : "flex justify-center"}`,
|
|
3001
2881
|
children: /* @__PURE__ */ jsx4(
|
|
3002
2882
|
"div",
|
|
3003
2883
|
{
|
|
3004
|
-
className: `flex flex-col transition-all duration-300 ${
|
|
2884
|
+
className: `flex flex-col transition-all duration-300 ${false ? "w-full" : "w-full max-w-6xl"}`,
|
|
3005
2885
|
children: isLoading || !initialAssistantIdChecked ? /* @__PURE__ */ jsx4("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsx4("div", { className: "animate-pulse text-gray-500", children: isLoading ? "Loading conversations..." : "Initializing Assistant..." }) }) : !agentId ? /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-col items-center justify-center p-4 text-center", children: [
|
|
3006
2886
|
/* @__PURE__ */ jsx4("h2", { className: "text-xl font-semibold text-red-600 dark:text-red-400 mb-2", children: "Agent Not Configured" }),
|
|
3007
2887
|
/* @__PURE__ */ jsxs4("p", { className: "text-gray-700 dark:text-gray-300 max-w-md", children: [
|
|
@@ -3016,10 +2896,8 @@ function NeptuneChatBot({
|
|
|
3016
2896
|
{
|
|
3017
2897
|
conversation: selectedConversation,
|
|
3018
2898
|
agentId,
|
|
3019
|
-
debug,
|
|
3020
2899
|
onConversationUpdate: refreshSelectedConversation,
|
|
3021
2900
|
theme,
|
|
3022
|
-
onAppStateChange: handleAppStateChange,
|
|
3023
2901
|
onSidebarToggle: () => setSidebarOpen(false),
|
|
3024
2902
|
onThreadCreated: handleThreadCreated,
|
|
3025
2903
|
messageBubbleColor: theme === "dark" ? messageBubbleColorDark : messageBubbleColor,
|