@smartspace/chat-ui 1.13.1-pr.260.2e65c1d → 1.13.1-pr.260.c7ba243
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 +18 -25
- 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(
|
|
@@ -19940,16 +19942,7 @@ function MessageList({
|
|
|
19940
19942
|
] })
|
|
19941
19943
|
] }) });
|
|
19942
19944
|
}
|
|
19943
|
-
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
|
-
}
|
|
19945
|
+
if (safeMessages.length === 0 && !hadMessagesBefore) {
|
|
19953
19946
|
return /* @__PURE__ */ jsxs("div", { className: "flex overflow-auto flex-shrink-10 flex-col p-8 text-center", children: [
|
|
19954
19947
|
/* @__PURE__ */ jsx("h3", { className: "text-lg font-medium mb-2", children: activeWorkspace?.name ?? "No messages yet" }),
|
|
19955
19948
|
activeWorkspace?.firstPrompt && /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto p-4", children: /* @__PURE__ */ jsx(MessageMarkdown, { value: activeWorkspace.firstPrompt }) })
|