@gobolt/genesis 0.3.6 → 0.3.7
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/components/Chat/Chat.d.ts +1 -2
- package/dist/components/Chat/chat-util.d.ts +2 -0
- package/dist/index.cjs +20 -17
- package/dist/index.js +20 -17
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -75749,6 +75749,22 @@ const Select = ({
|
|
|
75749
75749
|
}
|
|
75750
75750
|
) });
|
|
75751
75751
|
};
|
|
75752
|
+
const getUniqueMessages = (messages2) => {
|
|
75753
|
+
const uniqueMessages = messages2.filter((msg, index2, self2) => {
|
|
75754
|
+
const duplicates = self2.filter((m) => m.id === msg.id);
|
|
75755
|
+
if (duplicates.length > 1) {
|
|
75756
|
+
if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
|
|
75757
|
+
if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
|
|
75758
|
+
return !duplicates.some(
|
|
75759
|
+
(m) => m.respondedBy === "ai" || m.respondedBy === "search"
|
|
75760
|
+
);
|
|
75761
|
+
}
|
|
75762
|
+
return false;
|
|
75763
|
+
}
|
|
75764
|
+
return true;
|
|
75765
|
+
});
|
|
75766
|
+
return uniqueMessages;
|
|
75767
|
+
};
|
|
75752
75768
|
const PROCESSING_MESSAGE = "Processing your query...";
|
|
75753
75769
|
const PREDEFINED_QUERIES = [
|
|
75754
75770
|
"What are the most recent proposals?",
|
|
@@ -75893,8 +75909,6 @@ const Chat = ({
|
|
|
75893
75909
|
const timeoutRef = React.useRef(null);
|
|
75894
75910
|
React.useEffect(() => {
|
|
75895
75911
|
if (isSimulated) return;
|
|
75896
|
-
const socketUrlToUse = window.location.hostname === "localhost" && window.location.port === "6006" ? "http://localhost:3000" : socketUrl;
|
|
75897
|
-
console.log("Connecting to socket server at:", socketUrlToUse);
|
|
75898
75912
|
const validateToken = async () => {
|
|
75899
75913
|
try {
|
|
75900
75914
|
const response = await fetch(
|
|
@@ -75908,7 +75922,7 @@ const Chat = ({
|
|
|
75908
75922
|
if (!response.ok) {
|
|
75909
75923
|
throw new Error("Invalid token");
|
|
75910
75924
|
}
|
|
75911
|
-
socketRef.current = lookup(
|
|
75925
|
+
socketRef.current = lookup(socketUrl, {
|
|
75912
75926
|
transports: ["polling", "websocket"],
|
|
75913
75927
|
reconnection: true,
|
|
75914
75928
|
reconnectionAttempts: 5,
|
|
@@ -76226,21 +76240,10 @@ const Chat = ({
|
|
|
76226
76240
|
if (serverStatus === "error") {
|
|
76227
76241
|
return /* @__PURE__ */ jsxRuntime.jsx(ErrorMessage, { children: "Network error" });
|
|
76228
76242
|
}
|
|
76229
|
-
const uniqueMessages =
|
|
76230
|
-
|
|
76231
|
-
|
|
76232
|
-
if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
|
|
76233
|
-
if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
|
|
76234
|
-
return !duplicates.some(
|
|
76235
|
-
(m) => m.respondedBy === "ai" || m.respondedBy === "search"
|
|
76236
|
-
);
|
|
76237
|
-
}
|
|
76238
|
-
return false;
|
|
76239
|
-
}
|
|
76240
|
-
return true;
|
|
76241
|
-
});
|
|
76243
|
+
const uniqueMessages = React.useMemo(() => {
|
|
76244
|
+
return getUniqueMessages(messages2);
|
|
76245
|
+
}, [messages2]);
|
|
76242
76246
|
console.log("uniqueMessages", uniqueMessages);
|
|
76243
|
-
console.log("messages", messages2);
|
|
76244
76247
|
React.useEffect(() => {
|
|
76245
76248
|
return () => {
|
|
76246
76249
|
if (timeoutRef.current) {
|
package/dist/index.js
CHANGED
|
@@ -75731,6 +75731,22 @@ const Select = ({
|
|
|
75731
75731
|
}
|
|
75732
75732
|
) });
|
|
75733
75733
|
};
|
|
75734
|
+
const getUniqueMessages = (messages2) => {
|
|
75735
|
+
const uniqueMessages = messages2.filter((msg, index2, self2) => {
|
|
75736
|
+
const duplicates = self2.filter((m) => m.id === msg.id);
|
|
75737
|
+
if (duplicates.length > 1) {
|
|
75738
|
+
if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
|
|
75739
|
+
if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
|
|
75740
|
+
return !duplicates.some(
|
|
75741
|
+
(m) => m.respondedBy === "ai" || m.respondedBy === "search"
|
|
75742
|
+
);
|
|
75743
|
+
}
|
|
75744
|
+
return false;
|
|
75745
|
+
}
|
|
75746
|
+
return true;
|
|
75747
|
+
});
|
|
75748
|
+
return uniqueMessages;
|
|
75749
|
+
};
|
|
75734
75750
|
const PROCESSING_MESSAGE = "Processing your query...";
|
|
75735
75751
|
const PREDEFINED_QUERIES = [
|
|
75736
75752
|
"What are the most recent proposals?",
|
|
@@ -75875,8 +75891,6 @@ const Chat = ({
|
|
|
75875
75891
|
const timeoutRef = useRef(null);
|
|
75876
75892
|
useEffect(() => {
|
|
75877
75893
|
if (isSimulated) return;
|
|
75878
|
-
const socketUrlToUse = window.location.hostname === "localhost" && window.location.port === "6006" ? "http://localhost:3000" : socketUrl;
|
|
75879
|
-
console.log("Connecting to socket server at:", socketUrlToUse);
|
|
75880
75894
|
const validateToken = async () => {
|
|
75881
75895
|
try {
|
|
75882
75896
|
const response = await fetch(
|
|
@@ -75890,7 +75904,7 @@ const Chat = ({
|
|
|
75890
75904
|
if (!response.ok) {
|
|
75891
75905
|
throw new Error("Invalid token");
|
|
75892
75906
|
}
|
|
75893
|
-
socketRef.current = lookup(
|
|
75907
|
+
socketRef.current = lookup(socketUrl, {
|
|
75894
75908
|
transports: ["polling", "websocket"],
|
|
75895
75909
|
reconnection: true,
|
|
75896
75910
|
reconnectionAttempts: 5,
|
|
@@ -76208,21 +76222,10 @@ const Chat = ({
|
|
|
76208
76222
|
if (serverStatus === "error") {
|
|
76209
76223
|
return /* @__PURE__ */ jsx(ErrorMessage, { children: "Network error" });
|
|
76210
76224
|
}
|
|
76211
|
-
const uniqueMessages =
|
|
76212
|
-
|
|
76213
|
-
|
|
76214
|
-
if (msg.respondedBy === "ai" || msg.respondedBy === "search") return true;
|
|
76215
|
-
if (msg.isThinking || msg.content === PROCESSING_MESSAGE) {
|
|
76216
|
-
return !duplicates.some(
|
|
76217
|
-
(m) => m.respondedBy === "ai" || m.respondedBy === "search"
|
|
76218
|
-
);
|
|
76219
|
-
}
|
|
76220
|
-
return false;
|
|
76221
|
-
}
|
|
76222
|
-
return true;
|
|
76223
|
-
});
|
|
76225
|
+
const uniqueMessages = useMemo$1(() => {
|
|
76226
|
+
return getUniqueMessages(messages2);
|
|
76227
|
+
}, [messages2]);
|
|
76224
76228
|
console.log("uniqueMessages", uniqueMessages);
|
|
76225
|
-
console.log("messages", messages2);
|
|
76226
76229
|
useEffect(() => {
|
|
76227
76230
|
return () => {
|
|
76228
76231
|
if (timeoutRef.current) {
|