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:
+20
-8
@@ -207,14 +207,26 @@ 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."""
|
"""Navigate back to main chat by clicking the Main chat button."""
|
||||||
ws.send(json.dumps({
|
# Do NOT navigate to https://muse.ai/ (landing page) - it restores the
|
||||||
"id": 1, "method": "Page.navigate",
|
# last-viewed chat which may be a side chat. Click Main chat instead.
|
||||||
"params": {"url": "https://muse.ai/"}
|
js = (
|
||||||
}))
|
"(async()=>{"
|
||||||
json.loads(ws.recv())
|
"const ob=[...document.querySelectorAll('button')].find("
|
||||||
time.sleep(5)
|
"b=>b.textContent.includes('Open chat and side chats'));"
|
||||||
print("Back to main chat")
|
"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):
|
def cmd_sidechat_list(ws):
|
||||||
"""List side chats via DOM."""
|
"""List side chats via DOM."""
|
||||||
|
|||||||
Reference in New Issue
Block a user