diff --git a/src/components/call-desk/ai-chat-panel.tsx b/src/components/call-desk/ai-chat-panel.tsx index 4e0b70f..3598bc1 100644 --- a/src/components/call-desk/ai-chat-panel.tsx +++ b/src/components/call-desk/ai-chat-panel.tsx @@ -120,22 +120,25 @@ export const AiChatPanel = ({ callerContext, callerSummary, onChatStart }: AiCha }); }, [append]); - const displayMessages = messages.map(msg => { - if (msg.role === 'assistant') { - const parsed = parseAiResponse(msg.content); - return { ...msg, content: parsed.message }; - } - return msg; - }); + // Filter out the currently-streaming assistant message (shows raw JSON). + // Only display completed assistant messages with parsed content. + const displayMessages = messages + .filter((msg, i) => { + if (msg.role === 'assistant' && isLoading && i === messages.length - 1) return false; + return true; + }) + .map(msg => { + if (msg.role === 'assistant') { + const parsed = parseAiResponse(msg.content); + return { ...msg, content: parsed.message }; + } + return msg; + }); return (
{!isSupervisor && } - {!isSupervisor && suggestions.length > 0 && ( - - )} -
{displayMessages.length === 0 && (
@@ -187,6 +190,10 @@ export const AiChatPanel = ({ callerContext, callerSummary, onChatStart }: AiCha
+ {!isSupervisor && suggestions.length > 0 && ( + + )} +