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