@helpway/react 0.13.1 → 0.13.2
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 +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -335,7 +335,10 @@ function createWidgetStore() {
|
|
|
335
335
|
next.set(
|
|
336
336
|
conversationId,
|
|
337
337
|
existing.map(
|
|
338
|
-
(m) => m.id === oldId ? {
|
|
338
|
+
(m) => m.id === oldId ? {
|
|
339
|
+
...item,
|
|
340
|
+
_stableKey: m._stableKey ?? oldId
|
|
341
|
+
} : m
|
|
339
342
|
)
|
|
340
343
|
);
|
|
341
344
|
return { messages: next };
|
|
@@ -369,9 +372,21 @@ function createWidgetStore() {
|
|
|
369
372
|
merged.push(m);
|
|
370
373
|
if (isAgentMsg(m) && merged.length === 1) keptAgentWelcome = true;
|
|
371
374
|
}
|
|
375
|
+
const serverVisitorTs = existingItems.find((x) => x.visitorId)?.createdAt;
|
|
376
|
+
let graftedWelcome = false;
|
|
372
377
|
for (const m of existingItems) {
|
|
373
378
|
if (seen.has(m.id)) continue;
|
|
374
|
-
|
|
379
|
+
const isWelcomeEcho = isAgentMsg(m) && keptAgentWelcome && !graftedWelcome && (!serverVisitorTs || m.createdAt <= serverVisitorTs);
|
|
380
|
+
if (isWelcomeEcho) {
|
|
381
|
+
const seed = merged[0];
|
|
382
|
+
merged[0] = {
|
|
383
|
+
...m,
|
|
384
|
+
_stableKey: seed ? seed._stableKey ?? seed.id : m.id
|
|
385
|
+
};
|
|
386
|
+
seen.add(m.id);
|
|
387
|
+
graftedWelcome = true;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
375
390
|
seen.add(m.id);
|
|
376
391
|
merged.push(m);
|
|
377
392
|
}
|
|
@@ -484,9 +499,14 @@ function createWidgetStore() {
|
|
|
484
499
|
const isAgentAuthored = !!event.item.aiAgentId && !event.item.visitorId && !event.item.userId;
|
|
485
500
|
const existing = state.messages.get(event.conversationId);
|
|
486
501
|
const seedId = existing?.[0]?.id;
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
489
|
-
|
|
502
|
+
const hasSeedWelcome = typeof seedId === "string" && seedId.startsWith("seed-welcome-");
|
|
503
|
+
if (isAgentAuthored && hasSeedWelcome) {
|
|
504
|
+
const firstVisitorTs = existing?.find((m) => m.visitorId)?.createdAt;
|
|
505
|
+
const isWelcomeEcho = !firstVisitorTs || event.item.createdAt <= firstVisitorTs;
|
|
506
|
+
if (isWelcomeEcho) {
|
|
507
|
+
state.replaceMessage(event.conversationId, seedId, event.item);
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
490
510
|
}
|
|
491
511
|
state.addMessage(event.conversationId, event.item);
|
|
492
512
|
}
|
|
@@ -4954,6 +4974,7 @@ function DefaultWidget({ hideLauncher = false } = {}) {
|
|
|
4954
4974
|
onSelectEntry: (slug) => {
|
|
4955
4975
|
setContentDetailSlug(slug);
|
|
4956
4976
|
setSubView("content-detail");
|
|
4977
|
+
markEntrySeen(slug);
|
|
4957
4978
|
},
|
|
4958
4979
|
onSelectCategory: (cat) => {
|
|
4959
4980
|
setContentCategoryName(cat.title);
|