Conversation: render WhatsApp bold markers as bold

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Yashas 2026-10-28 12:21:20 +05:30
parent 0140856583
commit 24a28dce72

View File

@ -217,6 +217,11 @@ function author(tag: string): { label: string; tone: 'ai' | 'human' | 'auto' } {
return { label: `Desk · ${tag}`, tone: 'auto' };
}
const REPLY_STATES = ['Awaiting Ops Input', 'Awaiting Offer', 'Offer Sent', 'Confirmed'];
/** WhatsApp bold markers (*text*) as the customer sees them. Email messages carry none. */
function richText(text: string): ReactNode {
const parts = text.split(/(\*[^*\n]+\*)/g);
return parts.map((p, i) => (p.length > 2 && p.startsWith('*') && p.endsWith('*') ? <strong key={i}>{p.slice(1, -1)}</strong> : <span key={i}>{p}</span>));
}
function Conversation({ e, onDone }: { e: Enquiry; onDone: () => void }) {
const { has, user } = useZino();
@ -251,7 +256,7 @@ function Conversation({ e, onDone }: { e: Enquiry; onDone: () => void }) {
{a?.tone === 'human' && <User size={12} className="text-accent" />}
{m.who === 'Customer' ? 'Customer' : a!.label}
</div>
<div className="whitespace-pre-wrap">{m.text}</div>
<div className="whitespace-pre-wrap">{richText(m.text)}</div>
</div>
</div>
);