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.

This commit is contained in:
operator-main
2026-10-04 02:11:41 +00:00
parent c83fb7c294
commit 5dddedb667
+11 -13
View File
@@ -207,22 +207,20 @@ def cmd_sidechat_use(ws, chat_id):
print(f"Navigated to: {result}") print(f"Navigated to: {result}")
def cmd_sidechat_main(ws): 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 # 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. # last-viewed chat which may be a side chat.
# Uses fuzzy matching like cmd_sidechat_use (substring + shortest first).
js = ( js = (
"(async()=>{" "(async()=>{"
"const ob=[...document.querySelectorAll('button')].find(" # Find the chat button - it refocuses Main Chat when pressed
"b=>b.textContent.includes('Open chat and side chats'));" "const btns=[...document.querySelectorAll('button')];"
"if(ob)ob.click();" "const chatBtn=btns.find(b=>"
"await new Promise(r=>setTimeout(r,2000));" "b.textContent.includes('Open chat and side chats')||"
"const els=[...document.querySelectorAll('*')];" "b.getAttribute('aria-label')&&b.getAttribute('aria-label').toLowerCase().includes('chat')"
"const cands=els.filter(e=>e.textContent&&e.textContent.includes('Main chat'));" ");"
"cands.sort((a,b)=>a.textContent.length-b.textContent.length);" "if(!chatBtn)return 'NOBUTTON';"
"const el=cands[0];" "chatBtn.click();"
"if(!el)return 'NOTFOUND';"
"el.click();"
"await new Promise(r=>setTimeout(r,4000));" "await new Promise(r=>setTimeout(r,4000));"
"return window.location.href;" "return window.location.href;"
"})()" "})()"