From 45249076635c7b3681a646c6b21f92142a19d0a2 Mon Sep 17 00:00:00 2001 From: operator-main Date: Sun, 4 Oct 2026 03:20:42 +0000 Subject: [PATCH] sidechat_manager: Use data-testid for sidebar button\n\nReliable selector hatch-chat-switcher-trigger instead of\nflaky text matching. --- bin/sidechat_manager.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/sidechat_manager.py b/bin/sidechat_manager.py index fae6ab8..6f746ad 100644 --- a/bin/sidechat_manager.py +++ b/bin/sidechat_manager.py @@ -31,6 +31,8 @@ def ensure_sidebar(ws, max_retries=3): """ Ensure the sidebar is open. Returns True if open, False otherwise. Retries with backoff if the open button isn't found immediately. + Uses data-testid="hatch-chat-switcher-trigger" (reliable selector). + Fixed 2026-10-04: was using text matching which was flaky. """ for attempt in range(max_retries): # Check if sidebar is already open (Side chats text visible) @@ -40,13 +42,15 @@ def ensure_sidebar(ws, max_retries=3): if is_open: return True - # Try to open it - _ev(ws, """(() => { - const btn = [...document.querySelectorAll('button')].find(b => - (b.textContent||'').includes('Open chat and side chats') - ); - if (btn) btn.click(); - return !!btn; + # Try to open it via data-testid (reliable) + clicked = _ev(ws, """(() => { + const btn = document.querySelector('[data-testid="hatch-chat-switcher-trigger"]'); + if (btn) { btn.click(); return true; } + // Fallback: text matching + const fb = [...document.querySelectorAll('button')].find(b => + (b.textContent||'').includes('Open chat and side chats')); + if (fb) { fb.click(); return true; } + return false; })()""") time.sleep(2 * (attempt + 1)) # Exponential backoff: 2s, 4s, 6s