@kite-copilot/chat-panel 0.2.28 → 0.2.32

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 CHANGED
@@ -1562,17 +1562,19 @@ function ChatPanel({
1562
1562
  if (data.type === "agent_message") {
1563
1563
  setMessages((prev) => {
1564
1564
  const content = data.content;
1565
- const recentMessages = prev.slice(-5);
1566
- const isDuplicate = recentMessages.some((m) => m.content === content);
1565
+ const messageId = data.message_id;
1566
+ const isDuplicate = messageId ? prev.some((m) => m.serverMessageId === messageId) : prev.slice(-5).some((m) => m.content === content);
1567
1567
  if (isDuplicate) {
1568
- console.debug("[KiteChat] Skipping duplicate agent message");
1568
+ console.debug("[KiteChat] Skipping duplicate agent message:", messageId || content.slice(0, 30));
1569
1569
  return prev;
1570
1570
  }
1571
1571
  return [...prev, {
1572
1572
  id: Date.now(),
1573
1573
  role: "agent",
1574
1574
  kind: "text",
1575
- content
1575
+ content,
1576
+ serverMessageId: messageId
1577
+ // Store server ID for deduplication
1576
1578
  }];
1577
1579
  });
1578
1580
  } else if (data.type === "error") {
@@ -2085,9 +2087,6 @@ function ChatPanel({
2085
2087
  };
2086
2088
  setMessages((prev) => [...prev, escalationMessage]);
2087
2089
  } else if (eventType === "token") {
2088
- if (process.env.NODE_ENV === "development") {
2089
- console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
2090
- }
2091
2090
  }
2092
2091
  } catch (parseError) {
2093
2092
  console.error("Failed to parse SSE event:", parseError);
@@ -2956,10 +2955,7 @@ ${userText}`
2956
2955
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2957
2956
  }
2958
2957
  if (message.role === "agent") {
2959
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-50 border border-blue-200 px-3.5 py-2.5 text-sm text-gray-900 shadow-sm", children: [
2960
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-xs text-blue-600 font-medium mb-1", children: "Support Agent" }),
2961
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") })
2962
- ] }) }, message.id);
2958
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-500 px-3.5 py-2.5 text-sm text-white shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") }) }) }, message.id);
2963
2959
  }
2964
2960
  if (message.kind === "searchSummary") {
2965
2961
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
package/dist/auto.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createKiteChat
3
- } from "./chunk-LYZAMTWZ.js";
3
+ } from "./chunk-5NNBNZBS.js";
4
4
 
5
5
  // src/auto.ts
6
6
  function mountKiteChat(config) {
@@ -1561,17 +1561,19 @@ function ChatPanel({
1561
1561
  if (data.type === "agent_message") {
1562
1562
  setMessages((prev) => {
1563
1563
  const content = data.content;
1564
- const recentMessages = prev.slice(-5);
1565
- const isDuplicate = recentMessages.some((m) => m.content === content);
1564
+ const messageId = data.message_id;
1565
+ const isDuplicate = messageId ? prev.some((m) => m.serverMessageId === messageId) : prev.slice(-5).some((m) => m.content === content);
1566
1566
  if (isDuplicate) {
1567
- console.debug("[KiteChat] Skipping duplicate agent message");
1567
+ console.debug("[KiteChat] Skipping duplicate agent message:", messageId || content.slice(0, 30));
1568
1568
  return prev;
1569
1569
  }
1570
1570
  return [...prev, {
1571
1571
  id: Date.now(),
1572
1572
  role: "agent",
1573
1573
  kind: "text",
1574
- content
1574
+ content,
1575
+ serverMessageId: messageId
1576
+ // Store server ID for deduplication
1575
1577
  }];
1576
1578
  });
1577
1579
  } else if (data.type === "error") {
@@ -2084,9 +2086,6 @@ function ChatPanel({
2084
2086
  };
2085
2087
  setMessages((prev) => [...prev, escalationMessage]);
2086
2088
  } else if (eventType === "token") {
2087
- if (process.env.NODE_ENV === "development") {
2088
- console.debug("[SSE] Token delta:", data.delta?.length || 0, "chars");
2089
- }
2090
2089
  }
2091
2090
  } catch (parseError) {
2092
2091
  console.error("Failed to parse SSE event:", parseError);
@@ -2955,10 +2954,7 @@ ${userText}`
2955
2954
  return /* @__PURE__ */ jsx9("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2956
2955
  }
2957
2956
  if (message.role === "agent") {
2958
- return /* @__PURE__ */ jsx9("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-50 border border-blue-200 px-3.5 py-2.5 text-sm text-gray-900 shadow-sm", children: [
2959
- /* @__PURE__ */ jsx9("div", { className: "text-xs text-blue-600 font-medium mb-1", children: "Support Agent" }),
2960
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") })
2961
- ] }) }, message.id);
2957
+ return /* @__PURE__ */ jsx9("div", { className: `flex justify-start ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[260px] rounded-2xl rounded-bl-md bg-blue-500 px-3.5 py-2.5 text-sm text-white shadow-sm", children: /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap leading-relaxed", children: renderMarkdown(message.content || "") }) }) }, message.id);
2962
2958
  }
2963
2959
  if (message.kind === "searchSummary") {
2964
2960
  return /* @__PURE__ */ jsx9(