← Commit history

Upload 1 file(s)

John Lauer ·d2c9969526 ·2mo ago ·parent 7e47bfc
1 file changed +19−5
server.py+19−5
@@ -3906,18 +3906,32 @@ def _orchestrate_signin(args: dict) -> dict:     tdesc = next((_describe_profile(c) for c in choices if c.get("profile") == target), target)     import time as _tt     sess = "fusion-signin-%d" % int(_tt.time())   # unique per attempt (a reused id can be refused)-    r = _ad_call("nbrowser_open_window",-                 {"sessionId": sess, "url": auth["url"], "background": True,+    _open_args = {"sessionId": sess, "url": auth["url"], "background": True,                   "profile": target, "thread": "fusion-signin",-                  "purpose": "Fusion Autodesk sign-in (correct profile)"}, timeout=60)+                  "purpose": "Fusion Autodesk sign-in (correct profile)"}+    r = _ad_call("nbrowser_open_window", _open_args, timeout=60)     rd_open = r.get("data", r) if isinstance(r, dict) else {}     opened = bool(rd_open.get("sessionId") or r.get("ok") or r.get("success")                   or rd_open.get("opened") or ("opened in the BACKGROUND" in str(r.get("_hint", ""))))-    steps.append(("re-opened it in %s" % tdesc) if opened-                 else ("could not open %s (raw: %s)" % (tdesc, str(r)[:160])))+    open_via = "extension" if opened else None+    if not opened:+        # EXTENSION-FREE fallback: nbrowser_open_window needs the Adom extension installed in+        # that profile. nbrowser_open_os_window does not - it opens the URL in the real profile+        # at the OS level, which is all an OAuth consent needs. This keeps the multi-profile fix+        # working on machines with no extension (same gap as APS issue #12).+        r2 = _ad_call("nbrowser_open_os_window", _open_args, timeout=60)+        if isinstance(r2, dict) and not r2.get("_adCallError"):+            # ok:false just means the hwnd was not resolved in ~8s; the launch usually still fired+            opened = bool(r2.get("ok") or r2.get("hwnd") or "Launch fired" in str(r2.get("_hint", "")))+            if opened:+                open_via = "extension_free"+                r = r2+    steps.append((("re-opened it in %s%s" % (tdesc, " (extension-free)" if open_via == "extension_free" else ""))+                  if opened else ("could not open %s (raw: %s)" % (tdesc, str(r)[:160]))))      return {"success": True, "stage": "opened" if opened else "open_failed",             "done": False, "steps": steps, "signinWhere": tdesc, "signinProfile": target,+            "signinOpenedVia": open_via,             "signinProfileReason": reason, "signinSession": sess if opened else None,             "signinWrongBrowser": "%s / %s" % (auth["browser"], auth["sourceProfileDir"]),             "signinAuthUrl": auth["url"],