From c83fb7c29466fe0b722a1971c6bd41c28c168108 Mon Sep 17 00:00:00 2001 From: operator-main Date: Sun, 4 Oct 2026 02:04:19 +0000 Subject: [PATCH] muse-chat-api: Use fuzzy matching for Main chat button\n\nExact match was too fragile - if the UI text differs slightly,\nit returns NOTFOUND and the browser stays on the side chat.\nNow uses substring + shortest-first like cmd_sidechat_use. --- bin/muse-chat-api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/muse-chat-api.py b/bin/muse-chat-api.py index 4860fdf..cd7f49e 100755 --- a/bin/muse-chat-api.py +++ b/bin/muse-chat-api.py @@ -210,6 +210,7 @@ def cmd_sidechat_main(ws): """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. + # Uses fuzzy matching like cmd_sidechat_use (substring + shortest first). js = ( "(async()=>{" "const ob=[...document.querySelectorAll('button')].find(" @@ -217,7 +218,8 @@ def cmd_sidechat_main(ws): "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 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();"