muse-chat-api: Fix cmd_sidechat_main to click Main chat button\n\nWas navigating to https://muse.ai/ (landing page) which restores the\nlast-viewed chat (often a side chat like Manage Muse agents). Now opens\nthe sidebar and clicks the Main chat element directly.

This commit is contained in:
operator-main
2026-10-04 01:58:41 +00:00
parent 77d904d344
commit e5c85c7940
+20 -8
View File
@@ -207,14 +207,26 @@ def cmd_sidechat_use(ws, chat_id):
print(f"Navigated to: {result}")
def cmd_sidechat_main(ws):
"""Navigate back to main chat."""
ws.send(json.dumps({
"id": 1, "method": "Page.navigate",
"params": {"url": "https://muse.ai/"}
}))
json.loads(ws.recv())
time.sleep(5)
print("Back to main chat")
"""Navigate back to main chat by clicking the Main chat button."""
# 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.
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.trim()==='Main chat');"
"const el=cands[0];"
"if(!el)return 'NOTFOUND';"
"el.click();"
"await new Promise(r=>setTimeout(r,4000));"
"return window.location.href;"
"})()"
)
result = ev(ws, js, True)
print(f"Back to main chat: {result}")
def cmd_sidechat_list(ws):
"""List side chats via DOM."""