diff --git a/bin/muse-chat-api.py b/bin/muse-chat-api.py index e61ecab..9245b30 100755 --- a/bin/muse-chat-api.py +++ b/bin/muse-chat-api.py @@ -277,8 +277,18 @@ def cmd_sidechat_create(ws): print("ERROR: 'New side chat' button not found (sidebar may be closed)", file=sys.stderr) sys.exit(1) import time as _time - _time.sleep(5) - url = ev(ws, "window.location.href") + # Poll for URL to change to a thread URL (up to 15s) + # 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}") return url