From 19c5b2ce17c6380627c98bfbe9e681963704d2a3 Mon Sep 17 00:00:00 2001 From: Oliver Hofmann Date: Sun, 17 May 2026 14:02:56 +0200 Subject: [PATCH] debug: check if message-author-name is inside or outside chat-pane-message --- src/teampulse/monitor.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/teampulse/monitor.py b/src/teampulse/monitor.py index 5a14c62..f20a81e 100644 --- a/src/teampulse/monitor.py +++ b/src/teampulse/monitor.py @@ -138,16 +138,25 @@ class Monitor: def poll_new_messages(self) -> list[ChatMessage]: result = self._page.evaluate(r"""() => { - const counts = { + const isVisible = el => { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0; }; + const chatMsgs = Array.from(document.querySelectorAll("[data-tid='chat-pane-message']")).filter(isVisible); + const authorNames = Array.from(document.querySelectorAll("[data-tid='message-author-name']")); + const sample = chatMsgs.slice(0, 3).map(msg => ({ + hasAuthorInside: !!msg.querySelector("[data-tid='message-author-name']"), + text: msg.innerText.trim().substring(0, 40), + })); + return { channelAll: document.querySelectorAll("[data-tid='channel-pane-message']").length, chatAll: document.querySelectorAll("[data-tid='chat-pane-message']").length, + channelVisible: Array.from(document.querySelectorAll("[data-tid='channel-pane-message']")).filter(isVisible).length, + chatVisible: chatMsgs.length, + authorNamesTotal: authorNames.length, + sample, }; - const isVisible = el => { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0; }; - counts.channelVisible = Array.from(document.querySelectorAll("[data-tid='channel-pane-message']")).filter(isVisible).length; - counts.chatVisible = Array.from(document.querySelectorAll("[data-tid='chat-pane-message']")).filter(isVisible).length; - return counts; }""") - print(f" [DOM] channel={result['channelAll']}(vis:{result['channelVisible']}) chat={result['chatAll']}(vis:{result['chatVisible']})") + print(f" [DOM] channel={result['channelAll']}(vis:{result['channelVisible']}) chat={result['chatAll']}(vis:{result['chatVisible']}) authors={result['authorNamesTotal']}") + for s in result['sample']: + print(f" msg hasAuthor={s['hasAuthorInside']} text={s['text']!r}") raw = self._page.evaluate(_POLL_JS) if raw: print(f" [POLL] {len(raw)} Elemente, davon {sum(1 for r in raw if r['id'] not in self._seen_message_ids)} neu")