@kite-copilot/chat-panel 0.2.27 → 0.2.28
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 +33 -9
- package/dist/auto.js +1 -1
- package/dist/{chunk-4KYS4INW.js → chunk-LYZAMTWZ.js} +33 -9
- package/dist/embed.global.js +9 -9
- package/dist/index.cjs +33 -9
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1376,6 +1376,11 @@ function ChatPanel({
|
|
|
1376
1376
|
const escalationWsRef = React4.useRef(null);
|
|
1377
1377
|
const resetSession = React4.useCallback(() => {
|
|
1378
1378
|
setSessionId(crypto.randomUUID());
|
|
1379
|
+
setIsEscalated(false);
|
|
1380
|
+
if (escalationWsRef.current) {
|
|
1381
|
+
escalationWsRef.current.close();
|
|
1382
|
+
escalationWsRef.current = null;
|
|
1383
|
+
}
|
|
1379
1384
|
}, []);
|
|
1380
1385
|
const streamIntervals = React4.useRef({});
|
|
1381
1386
|
const isEmpty = messages.length === 0;
|
|
@@ -1609,12 +1614,21 @@ function ChatPanel({
|
|
|
1609
1614
|
try {
|
|
1610
1615
|
const data = JSON.parse(event.data);
|
|
1611
1616
|
if (data.type === "agent_message") {
|
|
1612
|
-
setMessages((prev) =>
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1617
|
+
setMessages((prev) => {
|
|
1618
|
+
const content = data.content;
|
|
1619
|
+
const recentMessages = prev.slice(-5);
|
|
1620
|
+
const isDuplicate = recentMessages.some((m) => m.content === content);
|
|
1621
|
+
if (isDuplicate) {
|
|
1622
|
+
console.debug("[KiteChat] Skipping duplicate agent message");
|
|
1623
|
+
return prev;
|
|
1624
|
+
}
|
|
1625
|
+
return [...prev, {
|
|
1626
|
+
id: Date.now(),
|
|
1627
|
+
role: "agent",
|
|
1628
|
+
kind: "text",
|
|
1629
|
+
content
|
|
1630
|
+
}];
|
|
1631
|
+
});
|
|
1618
1632
|
} else if (data.type === "error") {
|
|
1619
1633
|
console.error("[KiteChat] Escalation error:", data.message);
|
|
1620
1634
|
}
|
|
@@ -1659,7 +1673,7 @@ function ChatPanel({
|
|
|
1659
1673
|
}
|
|
1660
1674
|
}, [isEscalated, sessionId, connectToEscalationWs]);
|
|
1661
1675
|
function streamAssistantMessage(messageId, fullText, followups) {
|
|
1662
|
-
let textToStream = fullText;
|
|
1676
|
+
let textToStream = fullText || "";
|
|
1663
1677
|
let extractedFollowups = followups;
|
|
1664
1678
|
if (fullText && fullText.startsWith("{") && fullText.includes('"response"')) {
|
|
1665
1679
|
try {
|
|
@@ -1959,6 +1973,12 @@ function ChatPanel({
|
|
|
1959
1973
|
if (data.status === "thinking") {
|
|
1960
1974
|
setPhase("thinking");
|
|
1961
1975
|
setProgressSteps([{ message: data.message, completed: false }]);
|
|
1976
|
+
} else if (data.status === "searching") {
|
|
1977
|
+
setPhase("thinking");
|
|
1978
|
+
setProgressSteps([{ message: data.message || "Searching knowledge base...", completed: false }]);
|
|
1979
|
+
} else if (data.status === "evaluating") {
|
|
1980
|
+
setPhase("thinking");
|
|
1981
|
+
setProgressSteps([{ message: data.message || "Evaluating sources...", completed: false }]);
|
|
1962
1982
|
} else if (data.status === "executing") {
|
|
1963
1983
|
setPhase("executing");
|
|
1964
1984
|
setProgressSteps((prev) => {
|
|
@@ -2060,7 +2080,7 @@ function ChatPanel({
|
|
|
2060
2080
|
setMessages((prev) => [...prev, assistantMessage]);
|
|
2061
2081
|
streamAssistantMessage(
|
|
2062
2082
|
assistantMessageId,
|
|
2063
|
-
agentResponse.response,
|
|
2083
|
+
agentResponse.response || "Action completed successfully.",
|
|
2064
2084
|
agentResponse.followups
|
|
2065
2085
|
);
|
|
2066
2086
|
streamCompleted = true;
|
|
@@ -2082,7 +2102,7 @@ function ChatPanel({
|
|
|
2082
2102
|
setMessages((prev) => [...prev, assistantMessage]);
|
|
2083
2103
|
streamAssistantMessage(
|
|
2084
2104
|
assistantMessageId,
|
|
2085
|
-
agentResponse.response,
|
|
2105
|
+
agentResponse.response || agentResponse.message || "",
|
|
2086
2106
|
agentResponse.followups
|
|
2087
2107
|
);
|
|
2088
2108
|
streamCompleted = true;
|
|
@@ -2118,6 +2138,10 @@ function ChatPanel({
|
|
|
2118
2138
|
content: data.message || "You've been connected to our support queue. An agent will be with you shortly."
|
|
2119
2139
|
};
|
|
2120
2140
|
setMessages((prev) => [...prev, escalationMessage]);
|
|
2141
|
+
} else if (eventType === "token") {
|
|
2142
|
+
if (process.env.NODE_ENV === "development") {
|
|
2143
|
+
console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
|
|
2144
|
+
}
|
|
2121
2145
|
}
|
|
2122
2146
|
} catch (parseError) {
|
|
2123
2147
|
console.error("Failed to parse SSE event:", parseError);
|
package/dist/index.js
CHANGED