diff --git a/bin/muse-chat-api.py b/bin/muse-chat-api.py index 65b9e86..9ae3ca1 100755 --- a/bin/muse-chat-api.py +++ b/bin/muse-chat-api.py @@ -263,22 +263,29 @@ def cmd_sidechat_list(ws): print(chats[:500]) def cmd_sidechat_create(ws): - """Create a new side chat via the 'New side chat' button. Returns the new thread URL.""" - # Use robust sidebar opener with retry (fixes flaky NOSIDEBAR errors) + """Create a new side chat via the '+' button next to 'Side chats' header. + Returns the new thread URL. + Note: Ctrl+J opens the chat panel (which contains Side chats). + Fixed 2026-10-04: sidebar is actually the chat panel, toggled by Ctrl+J. + """ import time as _time - if HAS_SIDECHAT_MANAGER: - if not ensure_sidebar(ws): - print("ERROR: Could not open sidebar after retries", file=sys.stderr) - sys.exit(1) - else: - # Fallback to old method - ev(ws, """(() => { - const btn = [...document.querySelectorAll("button")].find(b => - b.textContent.includes("Open chat and side chats") - ); - if (btn) btn.click(); - })()""") - _time.sleep(2) + import json as _json + # Ensure chat panel is open via Ctrl+J (CDP Input.dispatchKeyEvent, + # same proven method as cmd_sidechat_main). + # The panel contains Main chat, Side chats, and the + button. + ws.send(_json.dumps({ + "id": 20, "method": "Input.dispatchKeyEvent", + "params": {"type": "keyDown", "key": "j", "code": "KeyJ", + "ctrlKey": True, "modifiers": 2} + })) + _json.loads(ws.recv()) + ws.send(_json.dumps({ + "id": 21, "method": "Input.dispatchKeyEvent", + "params": {"type": "keyUp", "key": "j", "code": "KeyJ", + "ctrlKey": True, "modifiers": 2} + })) + _json.loads(ws.recv()) + _time.sleep(2) # The + button sits next to the "Side chats" header (see screenshot 2026-10-04). # It's not labeled "New side chat" - find it by proximity to the header text. result = ev(ws, """(() => {