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])
|
print(chats[:500])
|
||||||
|
|
||||||
def cmd_sidechat_create(ws):
|
def cmd_sidechat_create(ws):
|
||||||
"""Create a new side chat via the 'New side chat' button. Returns the new thread URL."""
|
"""Create a new side chat via the '+' button next to 'Side chats' header.
|
||||||
# Use robust sidebar opener with retry (fixes flaky NOSIDEBAR errors)
|
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
|
import time as _time
|
||||||
if HAS_SIDECHAT_MANAGER:
|
import json as _json
|
||||||
if not ensure_sidebar(ws):
|
# Ensure chat panel is open via Ctrl+J (CDP Input.dispatchKeyEvent,
|
||||||
print("ERROR: Could not open sidebar after retries", file=sys.stderr)
|
# same proven method as cmd_sidechat_main).
|
||||||
sys.exit(1)
|
# The panel contains Main chat, Side chats, and the + button.
|
||||||
else:
|
ws.send(_json.dumps({
|
||||||
# Fallback to old method
|
"id": 20, "method": "Input.dispatchKeyEvent",
|
||||||
ev(ws, """(() => {
|
"params": {"type": "keyDown", "key": "j", "code": "KeyJ",
|
||||||
const btn = [...document.querySelectorAll("button")].find(b =>
|
"ctrlKey": True, "modifiers": 2}
|
||||||
b.textContent.includes("Open chat and side chats")
|
}))
|
||||||
);
|
_json.loads(ws.recv())
|
||||||
if (btn) btn.click();
|
ws.send(_json.dumps({
|
||||||
})()""")
|
"id": 21, "method": "Input.dispatchKeyEvent",
|
||||||
_time.sleep(2)
|
"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).
|
# 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.
|
# It's not labeled "New side chat" - find it by proximity to the header text.
|
||||||
result = ev(ws, """(() => {
|
result = ev(ws, """(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user