From 5dddedb667e454012fdc4398c6b8e673514c88d2 Mon Sep 17 00:00:00 2001 From: operator-main Date: Sun, 4 Oct 2026 02:11:41 +0000 Subject: [PATCH] muse-chat-api: Press chat button to refocus Main Chat\n\nUser confirmed pressing the chat button properly refocuses Main Chat.\nSimpler and more reliable than searching for Main chat text in sidebar. --- bin/muse-chat-api.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/bin/muse-chat-api.py b/bin/muse-chat-api.py index cd7f49e..b4c71a2 100755 --- a/bin/muse-chat-api.py +++ b/bin/muse-chat-api.py @@ -207,22 +207,20 @@ def cmd_sidechat_use(ws, chat_id): print(f"Navigated to: {result}") def cmd_sidechat_main(ws): - """Navigate back to main chat by clicking the Main chat button.""" + """Navigate back to main chat by pressing the chat button.""" + # The chat button (not the sidebar search) properly refocuses Main Chat. # Do NOT navigate to https://muse.ai/ (landing page) - it restores the - # last-viewed chat which may be a side chat. Click Main chat instead. - # Uses fuzzy matching like cmd_sidechat_use (substring + shortest first). + # last-viewed chat which may be a side chat. js = ( "(async()=>{" - "const ob=[...document.querySelectorAll('button')].find(" - "b=>b.textContent.includes('Open chat and side chats'));" - "if(ob)ob.click();" - "await new Promise(r=>setTimeout(r,2000));" - "const els=[...document.querySelectorAll('*')];" - "const cands=els.filter(e=>e.textContent&&e.textContent.includes('Main chat'));" - "cands.sort((a,b)=>a.textContent.length-b.textContent.length);" - "const el=cands[0];" - "if(!el)return 'NOTFOUND';" - "el.click();" + # Find the chat button - it refocuses Main Chat when pressed + "const btns=[...document.querySelectorAll('button')];" + "const chatBtn=btns.find(b=>" + "b.textContent.includes('Open chat and side chats')||" + "b.getAttribute('aria-label')&&b.getAttribute('aria-label').toLowerCase().includes('chat')" + ");" + "if(!chatBtn)return 'NOBUTTON';" + "chatBtn.click();" "await new Promise(r=>setTimeout(r,4000));" "return window.location.href;" "})()"