@smartspace/chat-ui 1.13.1-pr.260.2e65c1d → 1.13.1-pr.260.86538f4
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/index.js +19 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3476,6 +3476,15 @@ var messagesMutationsKeys = {
|
|
|
3476
3476
|
};
|
|
3477
3477
|
|
|
3478
3478
|
// src/domains/messages/mutations.ts
|
|
3479
|
+
function reconcileWithMessage(old, incoming, onDuplicate = "keep-existing") {
|
|
3480
|
+
const stable = old.filter((m) => !m.optimistic);
|
|
3481
|
+
const idx = stable.findIndex((m) => m.id === incoming.id);
|
|
3482
|
+
if (idx === -1) return [...stable, incoming];
|
|
3483
|
+
if (onDuplicate === "keep-existing") return stable;
|
|
3484
|
+
const copy = stable.slice();
|
|
3485
|
+
copy[idx] = incoming;
|
|
3486
|
+
return copy;
|
|
3487
|
+
}
|
|
3479
3488
|
function useSendMessage() {
|
|
3480
3489
|
const qc = useQueryClient();
|
|
3481
3490
|
const { userId, displayName: userName } = useChatIdentity();
|
|
@@ -3559,13 +3568,10 @@ function useSendMessage() {
|
|
|
3559
3568
|
toast.error("There was an error posting your message");
|
|
3560
3569
|
throw err;
|
|
3561
3570
|
}
|
|
3562
|
-
qc.setQueryData(
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
}
|
|
3567
|
-
return [...withoutOptimistic, realMessage];
|
|
3568
|
-
});
|
|
3571
|
+
qc.setQueryData(
|
|
3572
|
+
messagesKeys.list(threadId),
|
|
3573
|
+
(old = []) => reconcileWithMessage(old, realMessage)
|
|
3574
|
+
);
|
|
3569
3575
|
qc.setQueryData(
|
|
3570
3576
|
threadsKeys.detail(workspaceId, threadId),
|
|
3571
3577
|
(old) => old ? { ...old, isFlowRunning: true } : old
|
|
@@ -3621,14 +3627,10 @@ function useAddInputToMessage() {
|
|
|
3621
3627
|
});
|
|
3622
3628
|
},
|
|
3623
3629
|
onSuccess: (message, { threadId }) => {
|
|
3624
|
-
qc.setQueryData(
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
const copy = stable.slice();
|
|
3629
|
-
copy[idx] = message;
|
|
3630
|
-
return copy;
|
|
3631
|
-
});
|
|
3630
|
+
qc.setQueryData(
|
|
3631
|
+
messagesKeys.list(threadId),
|
|
3632
|
+
(old = []) => reconcileWithMessage(old, message, "replace")
|
|
3633
|
+
);
|
|
3632
3634
|
},
|
|
3633
3635
|
onError: (_e, { threadId }) => {
|
|
3634
3636
|
qc.setQueryData(
|
|
@@ -19829,10 +19831,6 @@ function MessageList({
|
|
|
19829
19831
|
const messagesEndRef = useRef(null);
|
|
19830
19832
|
const prevMessageCountRef = useRef(0);
|
|
19831
19833
|
const hasInitialScrollRef = useRef(false);
|
|
19832
|
-
const everHadMessagesRef = useRef({
|
|
19833
|
-
threadId: "",
|
|
19834
|
-
had: false
|
|
19835
|
-
});
|
|
19836
19834
|
const isMobile = useIsMobile();
|
|
19837
19835
|
const { data: activeWorkspace } = useWorkspace(workspaceId);
|
|
19838
19836
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
@@ -19905,14 +19903,8 @@ function MessageList({
|
|
|
19905
19903
|
return () => ro.disconnect();
|
|
19906
19904
|
}, [isAtBottom, scrollToBottom]);
|
|
19907
19905
|
const safeMessages = messages ?? [];
|
|
19908
|
-
if (everHadMessagesRef.current.threadId !== threadId) {
|
|
19909
|
-
everHadMessagesRef.current = { threadId, had: safeMessages.length > 0 };
|
|
19910
|
-
} else if (safeMessages.length > 0) {
|
|
19911
|
-
everHadMessagesRef.current.had = true;
|
|
19912
|
-
}
|
|
19913
|
-
const hadMessagesBefore = everHadMessagesRef.current.had;
|
|
19914
19906
|
const isLoading = isChoosingThread || (threadPending || threadFetching) && !thread || (messagesPending || messagesFetching) && messages === void 0;
|
|
19915
|
-
if (isLoading
|
|
19907
|
+
if (isLoading) {
|
|
19916
19908
|
return /* @__PURE__ */ jsx(
|
|
19917
19909
|
"div",
|
|
19918
19910
|
{
|
|
@@ -19928,7 +19920,7 @@ function MessageList({
|
|
|
19928
19920
|
}
|
|
19929
19921
|
);
|
|
19930
19922
|
}
|
|
19931
|
-
if (
|
|
19923
|
+
if (threadError || messagesError) {
|
|
19932
19924
|
return /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center p-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-md space-y-3", children: [
|
|
19933
19925
|
threadError && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive", children: [
|
|
19934
19926
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4" }),
|
|
@@ -19941,15 +19933,6 @@ function MessageList({
|
|
|
19941
19933
|
] }) });
|
|
19942
19934
|
}
|
|
19943
19935
|
if (safeMessages.length === 0) {
|
|
19944
|
-
if (hadMessagesBefore) {
|
|
19945
|
-
return /* @__PURE__ */ jsx(
|
|
19946
|
-
"div",
|
|
19947
|
-
{
|
|
19948
|
-
className: `ss-chat__body flex-shrink-10 flex-1 overflow-y-auto ${hostBg}`,
|
|
19949
|
-
"data-ss-layer": "message-list"
|
|
19950
|
-
}
|
|
19951
|
-
);
|
|
19952
|
-
}
|
|
19953
19936
|
return /* @__PURE__ */ jsxs("div", { className: "flex overflow-auto flex-shrink-10 flex-col p-8 text-center", children: [
|
|
19954
19937
|
/* @__PURE__ */ jsx("h3", { className: "text-lg font-medium mb-2", children: activeWorkspace?.name ?? "No messages yet" }),
|
|
19955
19938
|
activeWorkspace?.firstPrompt && /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto p-4", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: activeWorkspace.firstPrompt }) })
|