muse-chat-api.py: Fix sidechat create URL race\n\nPoll for /thread/ URL up to 15s instead of fixed 5s sleep.\nWas capturing base URL before navigation settled.
This commit is contained in:
+12
-2
@@ -277,8 +277,18 @@ def cmd_sidechat_create(ws):
|
|||||||
print("ERROR: 'New side chat' button not found (sidebar may be closed)", file=sys.stderr)
|
print("ERROR: 'New side chat' button not found (sidebar may be closed)", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
import time as _time
|
import time as _time
|
||||||
_time.sleep(5)
|
# Poll for URL to change to a thread URL (up to 15s)
|
||||||
url = ev(ws, "window.location.href")
|
# Fixed 2026-10-04: was sleeping 5s and reading once, often captured
|
||||||
|
# base URL before navigation settled.
|
||||||
|
url = None
|
||||||
|
for i in range(15):
|
||||||
|
_time.sleep(1)
|
||||||
|
url = ev(ws, "window.location.href")
|
||||||
|
if url and "/thread/" in url:
|
||||||
|
break
|
||||||
|
if not url or "/thread/" not in url:
|
||||||
|
print(f"ERROR: Sidechat creation did not navigate to thread URL (got: {url})", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
print(f"Created: {url}")
|
print(f"Created: {url}")
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user