keystone-design-bootstrap 1.0.37 → 1.0.39
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/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { cx } from '../../utils/cx';
|
|
|
7
7
|
|
|
8
8
|
interface Message {
|
|
9
9
|
id: string;
|
|
10
|
-
body: string;
|
|
10
|
+
body: string | null;
|
|
11
11
|
sender_type: 'contact' | 'agent' | 'human';
|
|
12
12
|
sender_display_name: string;
|
|
13
13
|
created_at: string;
|
|
@@ -126,13 +126,13 @@ export function ChatWidget({
|
|
|
126
126
|
const newMessages = await loadMessages();
|
|
127
127
|
console.log(`[ChatWidget] Poll attempt ${attempts}: got ${newMessages.length} messages (initial: ${initialCount})`);
|
|
128
128
|
|
|
129
|
-
// Check if we got a new agent message
|
|
129
|
+
// Check if we got a new agent message with actual content (ignore pending placeholder with empty body)
|
|
130
130
|
if (newMessages.length > initialCount) {
|
|
131
131
|
const latestMessage = newMessages[newMessages.length - 1];
|
|
132
|
-
console.log(`[ChatWidget]
|
|
133
|
-
|
|
134
|
-
if (latestMessage.sender_type === 'agent') {
|
|
135
|
-
console.log('[ChatWidget] ✓ Received agent reply
|
|
132
|
+
console.log(`[ChatWidget] Poll attempt ${attempts}: latest sender_type=${latestMessage.sender_type}, body=${latestMessage.body != null ? `${String(latestMessage.body).substring(0, 50)}` : 'null'}`);
|
|
133
|
+
|
|
134
|
+
if (latestMessage.sender_type === 'agent' && (latestMessage.body != null && String(latestMessage.body).trim() !== '')) {
|
|
135
|
+
console.log('[ChatWidget] ✓ Received agent reply with content');
|
|
136
136
|
clearInterval(pollInterval);
|
|
137
137
|
setWaitingForReply(false);
|
|
138
138
|
setIsLoading(false);
|
|
@@ -188,7 +188,8 @@ export function ChatWidget({
|
|
|
188
188
|
|
|
189
189
|
// Message sent successfully
|
|
190
190
|
if (result.data?.job_id) {
|
|
191
|
-
//
|
|
191
|
+
// Sync with server so outbound message is in the list, then poll for reply
|
|
192
|
+
await loadMessages();
|
|
192
193
|
pollForAgentReply();
|
|
193
194
|
} else if (result.data?.status === 'agent_unavailable' || result.data?.status === 'no_auto_reply') {
|
|
194
195
|
// No agent reply expected
|
|
@@ -309,10 +310,14 @@ export function ChatWidget({
|
|
|
309
310
|
Start a conversation! We're here to help.
|
|
310
311
|
</li>
|
|
311
312
|
)}
|
|
312
|
-
|
|
313
|
-
{
|
|
313
|
+
{/* Don't show pending agent messages (empty body) - keeps typing indicator until real reply */}
|
|
314
|
+
{(() => {
|
|
315
|
+
const toShow = messages.filter(
|
|
316
|
+
(m) => m.sender_type !== 'agent' || (m.body != null && String(m.body).trim() !== '')
|
|
317
|
+
);
|
|
318
|
+
return toShow.map((message, index) => {
|
|
314
319
|
const isUser = message.sender_type === 'contact';
|
|
315
|
-
const prevMessage = index > 0 ?
|
|
320
|
+
const prevMessage = index > 0 ? toShow[index - 1] : null;
|
|
316
321
|
const showAvatar = !isUser && (!prevMessage || prevMessage.sender_type === 'contact');
|
|
317
322
|
|
|
318
323
|
return (
|
|
@@ -369,12 +374,13 @@ export function ChatWidget({
|
|
|
369
374
|
: "rounded-tl-none bg-secondary text-primary ring-secondary"
|
|
370
375
|
)}
|
|
371
376
|
>
|
|
372
|
-
{message.body}
|
|
377
|
+
{message.body ?? ''}
|
|
373
378
|
</div>
|
|
374
379
|
</article>
|
|
375
380
|
</li>
|
|
376
381
|
);
|
|
377
|
-
})
|
|
382
|
+
});
|
|
383
|
+
})()}
|
|
378
384
|
|
|
379
385
|
{/* Typing indicator */}
|
|
380
386
|
{waitingForReply && (
|