From f8bd4730083e1b76d7134ad6ac0c59c86deeec1c Mon Sep 17 00:00:00 2001
From: ValueOn AG
Date: Sat, 7 Mar 2026 01:27:47 +0100
Subject: [PATCH] fix: _isChatPanelOpen false positive - [role=log] matched
captions panel, not chat
Made-with: Cursor
---
src/bot/chatProcedure.ts | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/bot/chatProcedure.ts b/src/bot/chatProcedure.ts
index e96b5ec..4b8e716 100644
--- a/src/bot/chatProcedure.ts
+++ b/src/bot/chatProcedure.ts
@@ -67,41 +67,40 @@ export class ChatProcedure {
*/
private async _isChatPanelOpen(): Promise {
return this._page.evaluate(() => {
- // 1. Chat button toggle state
- const chatBtn = document.querySelector('button[id="chat-button"], button[data-tid="chat-button"]') as HTMLElement | null;
+ // 1. Chat button aria-pressed state (most reliable when available)
+ const chatBtn = document.querySelector('#chat-button, button[id="chat-button"]') as HTMLElement | null;
if (chatBtn?.getAttribute('aria-pressed') === 'true') return true;
- // 2. Chat input visible (multiple Teams UI variants)
+ // 2. Chat input / compose box visible (definitive proof the chat panel is open)
const inputSelectors = [
'[data-tid="ckeditor-replyConversation"]',
'div[role="textbox"][data-tid*="chat"]',
+ 'div[role="textbox"][data-tid*="message"]',
'div[role="textbox"][aria-label*="message" i]',
'div[role="textbox"][aria-label*="Nachricht" i]',
'[contenteditable="true"][aria-label*="message" i]',
'[contenteditable="true"][aria-label*="Nachricht" i]',
- '[placeholder*="message" i]',
- '[placeholder*="Nachricht" i]',
'div[aria-label="Type a message"]',
+ 'div[aria-label*="Neue Nachricht" i]',
];
for (const sel of inputSelectors) {
const el = document.querySelector(sel) as HTMLElement | null;
if (el && el.offsetHeight > 0) return true;
}
- // 3. Message list container visible
- const listSelectors = [
+ // 3. Chat-specific containers (NOT [role="log"] which also matches captions)
+ const chatContainerSelectors = [
'[data-tid="message-pane-list"]',
'[data-tid="chat-pane-list"]',
'[data-tid="chat-pane"]',
'.ts-message-list-container',
- '[role="log"]',
];
- for (const sel of listSelectors) {
+ for (const sel of chatContainerSelectors) {
const el = document.querySelector(sel) as HTMLElement | null;
if (el && el.offsetHeight > 50) return true;
}
- // 4. "Meeting chat" heading visible
+ // 4. "Meeting chat" / "Besprechungschat" heading visible
const headings = document.querySelectorAll('h2, h3, [role="heading"]');
for (const h of Array.from(headings)) {
const txt = (h as HTMLElement).innerText?.toLowerCase() || '';