fix: _isChatPanelOpen false positive - [role=log] matched captions panel, not chat

Made-with: Cursor
This commit is contained in:
ValueOn AG 2026-03-07 01:27:47 +01:00
parent 6e444e83d0
commit f8bd473008

View file

@ -67,41 +67,40 @@ export class ChatProcedure {
*/
private async _isChatPanelOpen(): Promise<boolean> {
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() || '';