From e5c85c7940e4c32ea9f6245c0b0bcafed44525bf Mon Sep 17 00:00:00 2001 From: operator-main Date: Sun, 4 Oct 2026 01:58:41 +0000 Subject: [PATCH] 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. --- bin/muse-chat-api.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/bin/muse-chat-api.py b/bin/muse-chat-api.py index e64ab2e..4860fdf 100755 --- a/bin/muse-chat-api.py +++ b/bin/muse-chat-api.py @@ -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."""