cmd_sidechat_create: Ctrl+J opens chat panel via CDP\n\nSidebar is actually the chat panel (Ctrl+J toggle).\nUse proven Input.dispatchKeyEvent like cmd_sidechat_main.
This commit is contained in:
+22
-15
@@ -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, """(() => {
|
||||
|
||||
Reference in New Issue
Block a user