cmd_sidechat_create: check + first, open panel only if needed\n\nAvoids unnecessary switcher click when panel already open.
This commit is contained in:
+13
-7
@@ -270,14 +270,20 @@ def cmd_sidechat_create(ws):
|
||||
- + button: [data-testid="hatch-chat-compose"] (SVG icon, no text)
|
||||
"""
|
||||
import time as _time
|
||||
# Open chat panel via switcher trigger (idempotent - safe if already open)
|
||||
sw_result = ev(ws, """(() => {
|
||||
const sw = document.querySelector('[data-testid="hatch-chat-switcher-trigger"]');
|
||||
if (sw) sw.click();
|
||||
return sw ? 'SWITCHER_CLICKED' : 'NO_SWITCHER';
|
||||
# Check if + button already present (panel open). If not, open via switcher.
|
||||
# Fixed 2026-10-04: don't blindly click switcher, check state first.
|
||||
has_plus = ev(ws, """(() => {
|
||||
return !!document.querySelector('[data-testid="hatch-chat-compose"]');
|
||||
})()""")
|
||||
print(f"Switcher: {sw_result}", file=sys.stderr)
|
||||
_time.sleep(2) # Wait for React render
|
||||
if not has_plus:
|
||||
# Panel closed, open via switcher trigger
|
||||
sw_result = ev(ws, """(() => {
|
||||
const sw = document.querySelector('[data-testid="hatch-chat-switcher-trigger"]');
|
||||
if (sw) sw.click();
|
||||
return sw ? 'SWITCHER_CLICKED' : 'NO_SWITCHER';
|
||||
})()""")
|
||||
print(f"Switcher: {sw_result}", file=sys.stderr)
|
||||
_time.sleep(2) # Wait for React render
|
||||
# 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