From aec15602c2015f5a5462539ff8b761d3af0b2f24 Mon Sep 17 00:00:00 2001
From: ValueOn AG
Date: Wed, 18 Feb 2026 00:12:47 +0100
Subject: [PATCH] fix: prevent chat panel toggle-off in authenticated Teams
join
Co-authored-by: Cursor
---
src/bot/chatProcedure.ts | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/bot/chatProcedure.ts b/src/bot/chatProcedure.ts
index 2710ea1..1e8e8a4 100644
--- a/src/bot/chatProcedure.ts
+++ b/src/bot/chatProcedure.ts
@@ -48,8 +48,35 @@ export class ChatProcedure {
/**
* Open the chat panel by clicking the chat button.
+ * In authenticated Teams, the chat panel may already be open (meeting loads
+ * from a chat thread). Clicking again would TOGGLE it closed.
*/
private async _openChatPanel(): Promise {
+ // Check if chat panel is already open before clicking (avoid toggle-off)
+ const alreadyOpen = await this._page.evaluate(() => {
+ const chatBtn = document.querySelector('button[id="chat-button"], button[data-tid="chat-button"]') as HTMLElement | null;
+ if (chatBtn) {
+ // Teams toggle buttons use aria-pressed="true" when active
+ if (chatBtn.getAttribute('aria-pressed') === 'true') return true;
+ }
+ // Also check if chat input or message list is visible (panel is open)
+ const chatInput = document.querySelector(
+ '[data-tid="ckeditor-replyConversation"], div[role="textbox"][data-tid*="chat"], div[role="textbox"][aria-label*="message" i]'
+ ) as HTMLElement | null;
+ if (chatInput && chatInput.offsetHeight > 0) return true;
+ // Check if message list container is visible
+ const messageList = document.querySelector(
+ '[data-tid="message-pane-list"], [data-tid="chat-pane-list"], [data-tid="chat-pane"]'
+ ) as HTMLElement | null;
+ if (messageList && messageList.offsetHeight > 50) return true;
+ return false;
+ });
+
+ if (alreadyOpen) {
+ this._logger.info('Chat panel already open - skipping toggle');
+ return;
+ }
+
const chatButtonSelectors = [
'button[id="chat-button"]',
'button[data-tid="chat-button"]',