diff --git a/src/teampulse/monitor.py b/src/teampulse/monitor.py index 047df5e..117a856 100644 --- a/src/teampulse/monitor.py +++ b/src/teampulse/monitor.py @@ -53,8 +53,14 @@ _POLL_JS = """() => { const senderEl = msg.querySelector("[data-tid='message-author-name']"); const sender = senderEl ? senderEl.innerText.trim() : ''; if (!sender) return; - const id = msg.getAttribute('id') || (idx + '_' + msg.innerText.substring(0, 40)); - msgs.push({ sender, text: msg.innerText.trim(), id }); + // Extract only the message text (p elements), not the full innerText + // which includes sender name and timestamp + const pEls = msg.querySelectorAll('p'); + const text = pEls.length > 0 + ? Array.from(pEls).map(p => p.innerText.trim()).filter(t => t).join('\n') + : msg.innerText.trim(); + const id = msg.getAttribute('id') || (sender + '_' + text.substring(0, 40)); + msgs.push({ sender, text, id }); }); return msgs; }"""