@kite-copilot/chat-panel 0.2.35 → 0.2.36
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/auto.cjs +47 -7
- package/dist/auto.js +1 -1
- package/dist/{chunk-YOXFN57J.js → chunk-GUAWNSRO.js} +47 -7
- package/dist/embed.global.js +22 -22
- package/dist/index.cjs +47 -7
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/auto.cjs
CHANGED
|
@@ -1361,6 +1361,12 @@ function ChatPanel({
|
|
|
1361
1361
|
const typingChannelRef = React4.useRef(null);
|
|
1362
1362
|
const typingTimeoutRef = React4.useRef(null);
|
|
1363
1363
|
const resetSession = React4.useCallback(() => {
|
|
1364
|
+
if (isEscalated && supabaseRef.current && sessionId) {
|
|
1365
|
+
supabaseRef.current.from("escalations").update({
|
|
1366
|
+
customer_status: "disconnected",
|
|
1367
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1368
|
+
}).eq("session_id", sessionId);
|
|
1369
|
+
}
|
|
1364
1370
|
setSessionId(crypto.randomUUID());
|
|
1365
1371
|
setIsEscalated(false);
|
|
1366
1372
|
if (escalationWsRef.current) {
|
|
@@ -1372,7 +1378,7 @@ function ChatPanel({
|
|
|
1372
1378
|
typingChannelRef.current.unsubscribe();
|
|
1373
1379
|
typingChannelRef.current = null;
|
|
1374
1380
|
}
|
|
1375
|
-
}, []);
|
|
1381
|
+
}, [isEscalated, sessionId]);
|
|
1376
1382
|
React4.useEffect(() => {
|
|
1377
1383
|
if (supabaseUrl && supabaseAnonKey && !supabaseRef.current) {
|
|
1378
1384
|
supabaseRef.current = (0, import_supabase_js.createClient)(supabaseUrl, supabaseAnonKey);
|
|
@@ -1397,8 +1403,11 @@ function ChatPanel({
|
|
|
1397
1403
|
}, 5e3);
|
|
1398
1404
|
}
|
|
1399
1405
|
}
|
|
1400
|
-
}).subscribe()
|
|
1401
|
-
|
|
1406
|
+
}).subscribe((status) => {
|
|
1407
|
+
if (status === "SUBSCRIBED") {
|
|
1408
|
+
typingChannelRef.current = channel;
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1402
1411
|
return () => {
|
|
1403
1412
|
channel.unsubscribe();
|
|
1404
1413
|
typingChannelRef.current = null;
|
|
@@ -1429,7 +1438,27 @@ function ChatPanel({
|
|
|
1429
1438
|
heartbeatIntervalRef.current = window.setInterval(() => {
|
|
1430
1439
|
updateCustomerStatus("active");
|
|
1431
1440
|
}, 6e4);
|
|
1441
|
+
const handleBeforeUnload = () => {
|
|
1442
|
+
supabase.from("escalations").update({
|
|
1443
|
+
customer_status: "disconnected",
|
|
1444
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1445
|
+
}).eq("session_id", currentSessionId);
|
|
1446
|
+
};
|
|
1447
|
+
const handleVisibilityChange = () => {
|
|
1448
|
+
if (document.visibilityState === "hidden") {
|
|
1449
|
+
supabase.from("escalations").update({
|
|
1450
|
+
customer_status: "disconnected",
|
|
1451
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1452
|
+
}).eq("session_id", currentSessionId);
|
|
1453
|
+
} else if (document.visibilityState === "visible") {
|
|
1454
|
+
updateCustomerStatus("active");
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
1458
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
1432
1459
|
return () => {
|
|
1460
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
1461
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
1433
1462
|
supabase.from("escalations").update({
|
|
1434
1463
|
customer_status: "disconnected",
|
|
1435
1464
|
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3011,7 +3040,18 @@ ${userText}`
|
|
|
3011
3040
|
variant: "ghost",
|
|
3012
3041
|
size: "sm",
|
|
3013
3042
|
className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
|
|
3014
|
-
onClick: () =>
|
|
3043
|
+
onClick: () => {
|
|
3044
|
+
if (isEscalated) {
|
|
3045
|
+
resetSession();
|
|
3046
|
+
setMessages([]);
|
|
3047
|
+
setPanelView("landing");
|
|
3048
|
+
setCurrentFolderId(void 0);
|
|
3049
|
+
setActiveGuide(void 0);
|
|
3050
|
+
activeGuideRef.current = void 0;
|
|
3051
|
+
setGuideComplete(false);
|
|
3052
|
+
}
|
|
3053
|
+
onClose?.();
|
|
3054
|
+
},
|
|
3015
3055
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Minus, { className: "h-3.5 w-3.5" })
|
|
3016
3056
|
}
|
|
3017
3057
|
)
|
|
@@ -3103,12 +3143,12 @@ ${userText}`
|
|
|
3103
3143
|
return null;
|
|
3104
3144
|
}
|
|
3105
3145
|
if (isUser) {
|
|
3106
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3
|
|
3146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3 py-2 text-xs text-white shadow-sm", children: message.content }) }, message.id);
|
|
3107
3147
|
}
|
|
3108
3148
|
if (message.role === "agent") {
|
|
3109
3149
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `flex flex-col items-start ${isRoleChange ? "mt-3" : ""}`, children: [
|
|
3110
|
-
isRoleChange && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-
|
|
3111
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-white border border-gray-200 px-3
|
|
3150
|
+
isRoleChange && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[10px] text-gray-500 mb-1 ml-1", children: "Agent" }),
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-white border border-gray-200 px-3 py-2 text-xs text-gray-800 shadow-sm", children: message.content })
|
|
3112
3152
|
] }, message.id);
|
|
3113
3153
|
}
|
|
3114
3154
|
if (message.kind === "searchSummary") {
|
package/dist/auto.js
CHANGED
|
@@ -1362,6 +1362,12 @@ function ChatPanel({
|
|
|
1362
1362
|
const typingChannelRef = React4.useRef(null);
|
|
1363
1363
|
const typingTimeoutRef = React4.useRef(null);
|
|
1364
1364
|
const resetSession = React4.useCallback(() => {
|
|
1365
|
+
if (isEscalated && supabaseRef.current && sessionId) {
|
|
1366
|
+
supabaseRef.current.from("escalations").update({
|
|
1367
|
+
customer_status: "disconnected",
|
|
1368
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1369
|
+
}).eq("session_id", sessionId);
|
|
1370
|
+
}
|
|
1365
1371
|
setSessionId(crypto.randomUUID());
|
|
1366
1372
|
setIsEscalated(false);
|
|
1367
1373
|
if (escalationWsRef.current) {
|
|
@@ -1373,7 +1379,7 @@ function ChatPanel({
|
|
|
1373
1379
|
typingChannelRef.current.unsubscribe();
|
|
1374
1380
|
typingChannelRef.current = null;
|
|
1375
1381
|
}
|
|
1376
|
-
}, []);
|
|
1382
|
+
}, [isEscalated, sessionId]);
|
|
1377
1383
|
React4.useEffect(() => {
|
|
1378
1384
|
if (supabaseUrl && supabaseAnonKey && !supabaseRef.current) {
|
|
1379
1385
|
supabaseRef.current = createClient(supabaseUrl, supabaseAnonKey);
|
|
@@ -1398,8 +1404,11 @@ function ChatPanel({
|
|
|
1398
1404
|
}, 5e3);
|
|
1399
1405
|
}
|
|
1400
1406
|
}
|
|
1401
|
-
}).subscribe()
|
|
1402
|
-
|
|
1407
|
+
}).subscribe((status) => {
|
|
1408
|
+
if (status === "SUBSCRIBED") {
|
|
1409
|
+
typingChannelRef.current = channel;
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1403
1412
|
return () => {
|
|
1404
1413
|
channel.unsubscribe();
|
|
1405
1414
|
typingChannelRef.current = null;
|
|
@@ -1430,7 +1439,27 @@ function ChatPanel({
|
|
|
1430
1439
|
heartbeatIntervalRef.current = window.setInterval(() => {
|
|
1431
1440
|
updateCustomerStatus("active");
|
|
1432
1441
|
}, 6e4);
|
|
1442
|
+
const handleBeforeUnload = () => {
|
|
1443
|
+
supabase.from("escalations").update({
|
|
1444
|
+
customer_status: "disconnected",
|
|
1445
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1446
|
+
}).eq("session_id", currentSessionId);
|
|
1447
|
+
};
|
|
1448
|
+
const handleVisibilityChange = () => {
|
|
1449
|
+
if (document.visibilityState === "hidden") {
|
|
1450
|
+
supabase.from("escalations").update({
|
|
1451
|
+
customer_status: "disconnected",
|
|
1452
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1453
|
+
}).eq("session_id", currentSessionId);
|
|
1454
|
+
} else if (document.visibilityState === "visible") {
|
|
1455
|
+
updateCustomerStatus("active");
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
1459
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
1433
1460
|
return () => {
|
|
1461
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
1462
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
1434
1463
|
supabase.from("escalations").update({
|
|
1435
1464
|
customer_status: "disconnected",
|
|
1436
1465
|
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3012,7 +3041,18 @@ ${userText}`
|
|
|
3012
3041
|
variant: "ghost",
|
|
3013
3042
|
size: "sm",
|
|
3014
3043
|
className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
|
|
3015
|
-
onClick: () =>
|
|
3044
|
+
onClick: () => {
|
|
3045
|
+
if (isEscalated) {
|
|
3046
|
+
resetSession();
|
|
3047
|
+
setMessages([]);
|
|
3048
|
+
setPanelView("landing");
|
|
3049
|
+
setCurrentFolderId(void 0);
|
|
3050
|
+
setActiveGuide(void 0);
|
|
3051
|
+
activeGuideRef.current = void 0;
|
|
3052
|
+
setGuideComplete(false);
|
|
3053
|
+
}
|
|
3054
|
+
onClose?.();
|
|
3055
|
+
},
|
|
3016
3056
|
children: /* @__PURE__ */ jsx10(Minus, { className: "h-3.5 w-3.5" })
|
|
3017
3057
|
}
|
|
3018
3058
|
)
|
|
@@ -3104,12 +3144,12 @@ ${userText}`
|
|
|
3104
3144
|
return null;
|
|
3105
3145
|
}
|
|
3106
3146
|
if (isUser) {
|
|
3107
|
-
return /* @__PURE__ */ jsx10("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx10("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3
|
|
3147
|
+
return /* @__PURE__ */ jsx10("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx10("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3 py-2 text-xs text-white shadow-sm", children: message.content }) }, message.id);
|
|
3108
3148
|
}
|
|
3109
3149
|
if (message.role === "agent") {
|
|
3110
3150
|
return /* @__PURE__ */ jsxs6("div", { className: `flex flex-col items-start ${isRoleChange ? "mt-3" : ""}`, children: [
|
|
3111
|
-
isRoleChange && /* @__PURE__ */ jsx10("span", { className: "text-
|
|
3112
|
-
/* @__PURE__ */ jsx10("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-white border border-gray-200 px-3
|
|
3151
|
+
isRoleChange && /* @__PURE__ */ jsx10("span", { className: "text-[10px] text-gray-500 mb-1 ml-1", children: "Agent" }),
|
|
3152
|
+
/* @__PURE__ */ jsx10("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-white border border-gray-200 px-3 py-2 text-xs text-gray-800 shadow-sm", children: message.content })
|
|
3113
3153
|
] }, message.id);
|
|
3114
3154
|
}
|
|
3115
3155
|
if (message.kind === "searchSummary") {
|