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)
|
- + button: [data-testid="hatch-chat-compose"] (SVG icon, no text)
|
||||||
"""
|
"""
|
||||||
import time as _time
|
import time as _time
|
||||||
# Check if panel is open via exact 'Side chats' header text node.
|
import json as _json
|
||||||
# (Not innerText.includes - the switcher button text contains "Open chat and
|
# Navigate to main chat first for known good state.
|
||||||
# side chats" which is always true. Must check for the header element.)
|
# (Previous create may have left browser on /thread/new with stripped DOM.)
|
||||||
# Then open via switcher if needed (loop up to 5 attempts).
|
# Uses Ctrl+J via CDP (proven method from cmd_sidechat_main).
|
||||||
# Fixed 2026-10-04 per chat panel investigation.
|
# Fixed 2026-10-04 per reliability test: success poisons next run.
|
||||||
def _panel_open():
|
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, """(() => {
|
return ev(ws, """(() => {
|
||||||
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
return !!document.querySelector('[data-testid="hatch-chat-compose"]');
|
||||||
let n;
|
|
||||||
while (n = walker.nextNode()) {
|
|
||||||
if (n.textContent.trim() === 'Side chats') return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
})()""")
|
})()""")
|
||||||
|
|
||||||
for _attempt in range(5):
|
if not _has_plus():
|
||||||
if _panel_open():
|
|
||||||
break
|
|
||||||
ev(ws, """(() => {
|
ev(ws, """(() => {
|
||||||
const sw = document.querySelector('[data-testid="hatch-chat-switcher-trigger"]');
|
const sw = document.querySelector('[data-testid="hatch-chat-switcher-trigger"]');
|
||||||
if (sw) sw.click();
|
if (sw) sw.click();
|
||||||
})()""")
|
})()""")
|
||||||
_time.sleep(3)
|
_time.sleep(2)
|
||||||
else:
|
|
||||||
print("Warning: panel may not be open after 5 attempts", file=sys.stderr)
|
|
||||||
# Find + button via data-testid (verified selector, SVG icon no text)
|
# Find + button via data-testid (verified selector, SVG icon no text)
|
||||||
result = ev(ws, """(() => {
|
result = ev(ws, """(() => {
|
||||||
const btn = document.querySelector('[data-testid="hatch-chat-compose"]');
|
const btn = document.querySelector('[data-testid="hatch-chat-compose"]');
|
||||||
|
|||||||
Reference in New Issue
Block a user