@smartspace/chat-ui 1.13.1-pr.247.e894322 → 1.13.1-pr.248.47bc1fb
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 +3 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3527,13 +3527,7 @@ function useSendMessage() {
|
|
|
3527
3527
|
toast.error("There was an error posting your message");
|
|
3528
3528
|
throw err;
|
|
3529
3529
|
}
|
|
3530
|
-
qc.setQueryData(messagesKeys.list(threadId),
|
|
3531
|
-
const withoutOptimistic = old.filter((m) => !m.optimistic);
|
|
3532
|
-
const alreadyPresent = withoutOptimistic.some(
|
|
3533
|
-
(m) => m.id === realMessage.id
|
|
3534
|
-
);
|
|
3535
|
-
return alreadyPresent ? withoutOptimistic : [...withoutOptimistic, realMessage];
|
|
3536
|
-
});
|
|
3530
|
+
qc.setQueryData(messagesKeys.list(threadId), [realMessage]);
|
|
3537
3531
|
qc.setQueryData(
|
|
3538
3532
|
threadsKeys.detail(workspaceId, threadId),
|
|
3539
3533
|
(old) => old ? { ...old, isFlowRunning: true } : old
|
|
@@ -4233,43 +4227,14 @@ function MessageComposer({
|
|
|
4233
4227
|
)
|
|
4234
4228
|
] });
|
|
4235
4229
|
}
|
|
4236
|
-
function getPromptSignature(m) {
|
|
4237
|
-
const prompt = m.values?.find(
|
|
4238
|
-
(v) => v.type === "Input" /* INPUT */ && v.name === "prompt"
|
|
4239
|
-
);
|
|
4240
|
-
if (!prompt) return null;
|
|
4241
|
-
try {
|
|
4242
|
-
return JSON.stringify(prompt.value ?? null);
|
|
4243
|
-
} catch {
|
|
4244
|
-
return null;
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
function mergeFetchedWithOptimistics(current, fetched) {
|
|
4248
|
-
if (!current?.length) return fetched;
|
|
4249
|
-
const optimistics = current.filter((m) => m.optimistic);
|
|
4250
|
-
if (!optimistics.length) return fetched;
|
|
4251
|
-
const fetchedPromptSigs = new Set(
|
|
4252
|
-
fetched.map((m) => getPromptSignature(m)).filter((s2) => typeof s2 === "string" && s2.length > 0)
|
|
4253
|
-
);
|
|
4254
|
-
const dedupedOptimistics = optimistics.filter((o) => {
|
|
4255
|
-
const sig = getPromptSignature(o);
|
|
4256
|
-
if (!sig) return true;
|
|
4257
|
-
return !fetchedPromptSigs.has(sig);
|
|
4258
|
-
});
|
|
4259
|
-
return [...fetched, ...dedupedOptimistics];
|
|
4260
|
-
}
|
|
4261
4230
|
var messagesListOptions = (service, threadId, opts) => queryOptions({
|
|
4262
4231
|
queryKey: threadId ? messagesKeys.list(threadId) : messagesKeys.lists(),
|
|
4263
4232
|
// NOTE: queryKey intentionally does NOT include opts. This keeps cache updates from
|
|
4264
4233
|
// message mutations (which write to messagesKeys.list(threadId)) working.
|
|
4265
4234
|
// If opts changes (e.g. user clicks "Load full history"), we manually refetch.
|
|
4266
|
-
queryFn: async (
|
|
4235
|
+
queryFn: async () => {
|
|
4267
4236
|
if (!threadId) return [];
|
|
4268
|
-
|
|
4269
|
-
const current = ctx.client.getQueryData(
|
|
4270
|
-
messagesKeys.list(threadId)
|
|
4271
|
-
);
|
|
4272
|
-
return mergeFetchedWithOptimistics(current, fetched);
|
|
4237
|
+
return (await service.fetchMessages(threadId, opts)).reverse();
|
|
4273
4238
|
},
|
|
4274
4239
|
retry: false,
|
|
4275
4240
|
refetchOnWindowFocus: false,
|