cmd_sidechat_create: navigate to main first\n\nReliability test found success poisons next run (browser left on\n/thread/new with stripped DOM). Now navigates to main via Ctrl+J\nat start for known good state.
This commit is contained in:
+24
-18
@@ -270,31 +270,37 @@ def cmd_sidechat_create(ws):
|
||||
- + button: [data-testid="hatch-chat-compose"] (SVG icon, no text)
|
||||
"""
|
||||
import time as _time
|
||||
# Check if panel is open via exact 'Side chats' header text node.
|
||||
# (Not innerText.includes - the switcher button text contains "Open chat and
|
||||
# side chats" which is always true. Must check for the header element.)
|
||||
# Then open via switcher if needed (loop up to 5 attempts).
|
||||
# Fixed 2026-10-04 per chat panel investigation.
|
||||
def _panel_open():
|
||||
import json as _json
|
||||
# Navigate to main chat first for known good state.
|
||||
# (Previous create may have left browser on /thread/new with stripped DOM.)
|
||||
# Uses Ctrl+J via CDP (proven method from cmd_sidechat_main).
|
||||
# Fixed 2026-10-04 per reliability test: success poisons next run.
|
||||
ws.send(_json.dumps({
|
||||
"id": 30, "method": "Input.dispatchKeyEvent",
|
||||
"params": {"type": "keyDown", "key": "j", "code": "KeyJ",
|
||||
"ctrlKey": True, "modifiers": 2}
|
||||
}))
|
||||
_json.loads(ws.recv())
|
||||
ws.send(_json.dumps({
|
||||
"id": 31, "method": "Input.dispatchKeyEvent",
|
||||
"params": {"type": "keyUp", "key": "j", "code": "KeyJ",
|
||||
"ctrlKey": True, "modifiers": 2}
|
||||
}))
|
||||
_json.loads(ws.recv())
|
||||
_time.sleep(3)
|
||||
# Now open panel via switcher (should be on main chat with panel available)
|
||||
# Check for + button; if not present, click switcher.
|
||||
def _has_plus():
|
||||
return ev(ws, """(() => {
|
||||
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
||||
let n;
|
||||
while (n = walker.nextNode()) {
|
||||
if (n.textContent.trim() === 'Side chats') return true;
|
||||
}
|
||||
return false;
|
||||
return !!document.querySelector('[data-testid="hatch-chat-compose"]');
|
||||
})()""")
|
||||
|
||||
for _attempt in range(5):
|
||||
if _panel_open():
|
||||
break
|
||||
if not _has_plus():
|
||||
ev(ws, """(() => {
|
||||
const sw = document.querySelector('[data-testid="hatch-chat-switcher-trigger"]');
|
||||
if (sw) sw.click();
|
||||
})()""")
|
||||
_time.sleep(3)
|
||||
else:
|
||||
print("Warning: panel may not be open after 5 attempts", file=sys.stderr)
|
||||
_time.sleep(2)
|
||||
# Find + button via data-testid (verified selector, SVG icon no text)
|
||||
result = ev(ws, """(() => {
|
||||
const btn = document.querySelector('[data-testid="hatch-chat-compose"]');
|
||||
|
||||
Reference in New Issue
Block a user