@kite-copilot/chat-panel 0.2.35 → 0.2.37
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 +66 -9
- package/dist/auto.js +1 -1
- package/dist/{chunk-YOXFN57J.js → chunk-VXXE7QO3.js} +66 -9
- package/dist/embed.global.js +22 -22
- package/dist/index.cjs +66 -9
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/auto.cjs
CHANGED
|
@@ -915,6 +915,7 @@ function TypingIndicator({ className = "" }) {
|
|
|
915
915
|
|
|
916
916
|
// src/ChatPanel.tsx
|
|
917
917
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
918
|
+
var CHAT_PANEL_VERSION = "0.2.36";
|
|
918
919
|
var DEFAULT_AGENT_URL = "http://localhost:5002";
|
|
919
920
|
var PANEL_WIDTH = 340;
|
|
920
921
|
function unescapeJsonString(str) {
|
|
@@ -1360,7 +1361,16 @@ function ChatPanel({
|
|
|
1360
1361
|
const supabaseRef = React4.useRef(null);
|
|
1361
1362
|
const typingChannelRef = React4.useRef(null);
|
|
1362
1363
|
const typingTimeoutRef = React4.useRef(null);
|
|
1364
|
+
React4.useEffect(() => {
|
|
1365
|
+
console.log(`[KiteChat] Chat Panel v${CHAT_PANEL_VERSION} loaded`);
|
|
1366
|
+
}, []);
|
|
1363
1367
|
const resetSession = React4.useCallback(() => {
|
|
1368
|
+
if (isEscalated && supabaseRef.current && sessionId) {
|
|
1369
|
+
supabaseRef.current.from("escalations").update({
|
|
1370
|
+
customer_status: "disconnected",
|
|
1371
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1372
|
+
}).eq("session_id", sessionId);
|
|
1373
|
+
}
|
|
1364
1374
|
setSessionId(crypto.randomUUID());
|
|
1365
1375
|
setIsEscalated(false);
|
|
1366
1376
|
if (escalationWsRef.current) {
|
|
@@ -1372,7 +1382,7 @@ function ChatPanel({
|
|
|
1372
1382
|
typingChannelRef.current.unsubscribe();
|
|
1373
1383
|
typingChannelRef.current = null;
|
|
1374
1384
|
}
|
|
1375
|
-
}, []);
|
|
1385
|
+
}, [isEscalated, sessionId]);
|
|
1376
1386
|
React4.useEffect(() => {
|
|
1377
1387
|
if (supabaseUrl && supabaseAnonKey && !supabaseRef.current) {
|
|
1378
1388
|
supabaseRef.current = (0, import_supabase_js.createClient)(supabaseUrl, supabaseAnonKey);
|
|
@@ -1384,9 +1394,12 @@ function ChatPanel({
|
|
|
1384
1394
|
}
|
|
1385
1395
|
const channelName = `typing:${sessionId}`;
|
|
1386
1396
|
const channel = supabaseRef.current.channel(channelName);
|
|
1397
|
+
console.log(`[KiteChat] Subscribing to typing channel: ${channelName}`);
|
|
1387
1398
|
channel.on("broadcast", { event: "typing" }, (payload) => {
|
|
1399
|
+
console.log("[KiteChat] Received typing broadcast:", payload);
|
|
1388
1400
|
const { sender, isTyping } = payload.payload;
|
|
1389
1401
|
if (sender === "agent") {
|
|
1402
|
+
console.log(`[KiteChat] Agent typing: ${isTyping}`);
|
|
1390
1403
|
setAgentIsTyping(isTyping);
|
|
1391
1404
|
if (isTyping) {
|
|
1392
1405
|
if (typingTimeoutRef.current) {
|
|
@@ -1397,8 +1410,13 @@ function ChatPanel({
|
|
|
1397
1410
|
}, 5e3);
|
|
1398
1411
|
}
|
|
1399
1412
|
}
|
|
1400
|
-
}).subscribe()
|
|
1401
|
-
|
|
1413
|
+
}).subscribe((status) => {
|
|
1414
|
+
console.log(`[KiteChat] Typing channel status: ${status}`);
|
|
1415
|
+
if (status === "SUBSCRIBED") {
|
|
1416
|
+
typingChannelRef.current = channel;
|
|
1417
|
+
console.log("[KiteChat] Typing channel ready");
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1402
1420
|
return () => {
|
|
1403
1421
|
channel.unsubscribe();
|
|
1404
1422
|
typingChannelRef.current = null;
|
|
@@ -1429,7 +1447,27 @@ function ChatPanel({
|
|
|
1429
1447
|
heartbeatIntervalRef.current = window.setInterval(() => {
|
|
1430
1448
|
updateCustomerStatus("active");
|
|
1431
1449
|
}, 6e4);
|
|
1450
|
+
const handleBeforeUnload = () => {
|
|
1451
|
+
supabase.from("escalations").update({
|
|
1452
|
+
customer_status: "disconnected",
|
|
1453
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1454
|
+
}).eq("session_id", currentSessionId);
|
|
1455
|
+
};
|
|
1456
|
+
const handleVisibilityChange = () => {
|
|
1457
|
+
if (document.visibilityState === "hidden") {
|
|
1458
|
+
supabase.from("escalations").update({
|
|
1459
|
+
customer_status: "disconnected",
|
|
1460
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1461
|
+
}).eq("session_id", currentSessionId);
|
|
1462
|
+
} else if (document.visibilityState === "visible") {
|
|
1463
|
+
updateCustomerStatus("active");
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
1467
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
1432
1468
|
return () => {
|
|
1469
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
1470
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
1433
1471
|
supabase.from("escalations").update({
|
|
1434
1472
|
customer_status: "disconnected",
|
|
1435
1473
|
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1448,7 +1486,15 @@ function ChatPanel({
|
|
|
1448
1486
|
};
|
|
1449
1487
|
}, [isEscalated, sessionId, updateCustomerStatus]);
|
|
1450
1488
|
const sendTypingIndicator = React4.useCallback((isTyping) => {
|
|
1451
|
-
if (!typingChannelRef.current
|
|
1489
|
+
if (!typingChannelRef.current) {
|
|
1490
|
+
console.log("[KiteChat] Cannot send typing - channel not ready");
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
if (!isEscalated) {
|
|
1494
|
+
console.log("[KiteChat] Cannot send typing - not escalated");
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
console.log(`[KiteChat] Sending typing indicator: ${isTyping}`);
|
|
1452
1498
|
typingChannelRef.current.send({
|
|
1453
1499
|
type: "broadcast",
|
|
1454
1500
|
event: "typing",
|
|
@@ -3011,7 +3057,18 @@ ${userText}`
|
|
|
3011
3057
|
variant: "ghost",
|
|
3012
3058
|
size: "sm",
|
|
3013
3059
|
className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
|
|
3014
|
-
onClick: () =>
|
|
3060
|
+
onClick: () => {
|
|
3061
|
+
if (isEscalated) {
|
|
3062
|
+
resetSession();
|
|
3063
|
+
setMessages([]);
|
|
3064
|
+
setPanelView("landing");
|
|
3065
|
+
setCurrentFolderId(void 0);
|
|
3066
|
+
setActiveGuide(void 0);
|
|
3067
|
+
activeGuideRef.current = void 0;
|
|
3068
|
+
setGuideComplete(false);
|
|
3069
|
+
}
|
|
3070
|
+
onClose?.();
|
|
3071
|
+
},
|
|
3015
3072
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Minus, { className: "h-3.5 w-3.5" })
|
|
3016
3073
|
}
|
|
3017
3074
|
)
|
|
@@ -3103,12 +3160,12 @@ ${userText}`
|
|
|
3103
3160
|
return null;
|
|
3104
3161
|
}
|
|
3105
3162
|
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
|
|
3163
|
+
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
3164
|
}
|
|
3108
3165
|
if (message.role === "agent") {
|
|
3109
3166
|
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
|
|
3167
|
+
isRoleChange && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[10px] text-gray-500 mb-1 ml-1", children: "Agent" }),
|
|
3168
|
+
/* @__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
3169
|
] }, message.id);
|
|
3113
3170
|
}
|
|
3114
3171
|
if (message.kind === "searchSummary") {
|
|
@@ -4161,7 +4218,7 @@ ${userText}`
|
|
|
4161
4218
|
progressSteps
|
|
4162
4219
|
}
|
|
4163
4220
|
) }),
|
|
4164
|
-
isEscalated && agentIsTyping &&
|
|
4221
|
+
isEscalated && agentIsTyping && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TypingIndicator, {}) }),
|
|
4165
4222
|
!activeGuide && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref: messagesEndRef })
|
|
4166
4223
|
] }) }) }) })
|
|
4167
4224
|
}
|
package/dist/auto.js
CHANGED
|
@@ -916,6 +916,7 @@ function TypingIndicator({ className = "" }) {
|
|
|
916
916
|
|
|
917
917
|
// src/ChatPanel.tsx
|
|
918
918
|
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
919
|
+
var CHAT_PANEL_VERSION = "0.2.36";
|
|
919
920
|
var DEFAULT_AGENT_URL = "http://localhost:5002";
|
|
920
921
|
var PANEL_WIDTH = 340;
|
|
921
922
|
function unescapeJsonString(str) {
|
|
@@ -1361,7 +1362,16 @@ function ChatPanel({
|
|
|
1361
1362
|
const supabaseRef = React4.useRef(null);
|
|
1362
1363
|
const typingChannelRef = React4.useRef(null);
|
|
1363
1364
|
const typingTimeoutRef = React4.useRef(null);
|
|
1365
|
+
React4.useEffect(() => {
|
|
1366
|
+
console.log(`[KiteChat] Chat Panel v${CHAT_PANEL_VERSION} loaded`);
|
|
1367
|
+
}, []);
|
|
1364
1368
|
const resetSession = React4.useCallback(() => {
|
|
1369
|
+
if (isEscalated && supabaseRef.current && sessionId) {
|
|
1370
|
+
supabaseRef.current.from("escalations").update({
|
|
1371
|
+
customer_status: "disconnected",
|
|
1372
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1373
|
+
}).eq("session_id", sessionId);
|
|
1374
|
+
}
|
|
1365
1375
|
setSessionId(crypto.randomUUID());
|
|
1366
1376
|
setIsEscalated(false);
|
|
1367
1377
|
if (escalationWsRef.current) {
|
|
@@ -1373,7 +1383,7 @@ function ChatPanel({
|
|
|
1373
1383
|
typingChannelRef.current.unsubscribe();
|
|
1374
1384
|
typingChannelRef.current = null;
|
|
1375
1385
|
}
|
|
1376
|
-
}, []);
|
|
1386
|
+
}, [isEscalated, sessionId]);
|
|
1377
1387
|
React4.useEffect(() => {
|
|
1378
1388
|
if (supabaseUrl && supabaseAnonKey && !supabaseRef.current) {
|
|
1379
1389
|
supabaseRef.current = createClient(supabaseUrl, supabaseAnonKey);
|
|
@@ -1385,9 +1395,12 @@ function ChatPanel({
|
|
|
1385
1395
|
}
|
|
1386
1396
|
const channelName = `typing:${sessionId}`;
|
|
1387
1397
|
const channel = supabaseRef.current.channel(channelName);
|
|
1398
|
+
console.log(`[KiteChat] Subscribing to typing channel: ${channelName}`);
|
|
1388
1399
|
channel.on("broadcast", { event: "typing" }, (payload) => {
|
|
1400
|
+
console.log("[KiteChat] Received typing broadcast:", payload);
|
|
1389
1401
|
const { sender, isTyping } = payload.payload;
|
|
1390
1402
|
if (sender === "agent") {
|
|
1403
|
+
console.log(`[KiteChat] Agent typing: ${isTyping}`);
|
|
1391
1404
|
setAgentIsTyping(isTyping);
|
|
1392
1405
|
if (isTyping) {
|
|
1393
1406
|
if (typingTimeoutRef.current) {
|
|
@@ -1398,8 +1411,13 @@ function ChatPanel({
|
|
|
1398
1411
|
}, 5e3);
|
|
1399
1412
|
}
|
|
1400
1413
|
}
|
|
1401
|
-
}).subscribe()
|
|
1402
|
-
|
|
1414
|
+
}).subscribe((status) => {
|
|
1415
|
+
console.log(`[KiteChat] Typing channel status: ${status}`);
|
|
1416
|
+
if (status === "SUBSCRIBED") {
|
|
1417
|
+
typingChannelRef.current = channel;
|
|
1418
|
+
console.log("[KiteChat] Typing channel ready");
|
|
1419
|
+
}
|
|
1420
|
+
});
|
|
1403
1421
|
return () => {
|
|
1404
1422
|
channel.unsubscribe();
|
|
1405
1423
|
typingChannelRef.current = null;
|
|
@@ -1430,7 +1448,27 @@ function ChatPanel({
|
|
|
1430
1448
|
heartbeatIntervalRef.current = window.setInterval(() => {
|
|
1431
1449
|
updateCustomerStatus("active");
|
|
1432
1450
|
}, 6e4);
|
|
1451
|
+
const handleBeforeUnload = () => {
|
|
1452
|
+
supabase.from("escalations").update({
|
|
1453
|
+
customer_status: "disconnected",
|
|
1454
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1455
|
+
}).eq("session_id", currentSessionId);
|
|
1456
|
+
};
|
|
1457
|
+
const handleVisibilityChange = () => {
|
|
1458
|
+
if (document.visibilityState === "hidden") {
|
|
1459
|
+
supabase.from("escalations").update({
|
|
1460
|
+
customer_status: "disconnected",
|
|
1461
|
+
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
1462
|
+
}).eq("session_id", currentSessionId);
|
|
1463
|
+
} else if (document.visibilityState === "visible") {
|
|
1464
|
+
updateCustomerStatus("active");
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
1468
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
1433
1469
|
return () => {
|
|
1470
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
1471
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
1434
1472
|
supabase.from("escalations").update({
|
|
1435
1473
|
customer_status: "disconnected",
|
|
1436
1474
|
customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1449,7 +1487,15 @@ function ChatPanel({
|
|
|
1449
1487
|
};
|
|
1450
1488
|
}, [isEscalated, sessionId, updateCustomerStatus]);
|
|
1451
1489
|
const sendTypingIndicator = React4.useCallback((isTyping) => {
|
|
1452
|
-
if (!typingChannelRef.current
|
|
1490
|
+
if (!typingChannelRef.current) {
|
|
1491
|
+
console.log("[KiteChat] Cannot send typing - channel not ready");
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
if (!isEscalated) {
|
|
1495
|
+
console.log("[KiteChat] Cannot send typing - not escalated");
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
console.log(`[KiteChat] Sending typing indicator: ${isTyping}`);
|
|
1453
1499
|
typingChannelRef.current.send({
|
|
1454
1500
|
type: "broadcast",
|
|
1455
1501
|
event: "typing",
|
|
@@ -3012,7 +3058,18 @@ ${userText}`
|
|
|
3012
3058
|
variant: "ghost",
|
|
3013
3059
|
size: "sm",
|
|
3014
3060
|
className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
|
|
3015
|
-
onClick: () =>
|
|
3061
|
+
onClick: () => {
|
|
3062
|
+
if (isEscalated) {
|
|
3063
|
+
resetSession();
|
|
3064
|
+
setMessages([]);
|
|
3065
|
+
setPanelView("landing");
|
|
3066
|
+
setCurrentFolderId(void 0);
|
|
3067
|
+
setActiveGuide(void 0);
|
|
3068
|
+
activeGuideRef.current = void 0;
|
|
3069
|
+
setGuideComplete(false);
|
|
3070
|
+
}
|
|
3071
|
+
onClose?.();
|
|
3072
|
+
},
|
|
3016
3073
|
children: /* @__PURE__ */ jsx10(Minus, { className: "h-3.5 w-3.5" })
|
|
3017
3074
|
}
|
|
3018
3075
|
)
|
|
@@ -3104,12 +3161,12 @@ ${userText}`
|
|
|
3104
3161
|
return null;
|
|
3105
3162
|
}
|
|
3106
3163
|
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
|
|
3164
|
+
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
3165
|
}
|
|
3109
3166
|
if (message.role === "agent") {
|
|
3110
3167
|
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
|
|
3168
|
+
isRoleChange && /* @__PURE__ */ jsx10("span", { className: "text-[10px] text-gray-500 mb-1 ml-1", children: "Agent" }),
|
|
3169
|
+
/* @__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
3170
|
] }, message.id);
|
|
3114
3171
|
}
|
|
3115
3172
|
if (message.kind === "searchSummary") {
|
|
@@ -4162,7 +4219,7 @@ ${userText}`
|
|
|
4162
4219
|
progressSteps
|
|
4163
4220
|
}
|
|
4164
4221
|
) }),
|
|
4165
|
-
isEscalated && agentIsTyping &&
|
|
4222
|
+
isEscalated && agentIsTyping && /* @__PURE__ */ jsx10("div", { className: "mt-2", children: /* @__PURE__ */ jsx10(TypingIndicator, {}) }),
|
|
4166
4223
|
!activeGuide && /* @__PURE__ */ jsx10("div", { ref: messagesEndRef })
|
|
4167
4224
|
] }) }) }) })
|
|
4168
4225
|
}
|