From 39e47ab2efe62db87471d28b10b6c818bd11a15d Mon Sep 17 00:00:00 2001 From: operator-main Date: Sun, 4 Oct 2026 03:10:52 +0000 Subject: [PATCH] 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. --- bin/muse-chat-api.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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