fix(cli-auth): ensure fallback token renders before redirect on Windows/Chrome#1486
fix(cli-auth): ensure fallback token renders before redirect on Windows/Chrome#1486Th3Ya0vi wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…ws/Chrome React batches state updates, so setToken() and window.location.assign() previously raced: the navigation could fire before React re-rendered the fallback token UI. On Chrome/Windows this means a failed http:// redirect (ERR_CONNECTION_REFUSED, HTTPS-first interference) would replace the page with an error screen before the user ever saw the token. Use flushSync() to render the token synchronously, then attempt window.location.assign(). If the redirect fails the token and a "Retry redirect to CLI" link are already painted on screen. Fixes openclaw#1469 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@Th3Ya0vi is attempting to deploy a commit to the 0xBuns Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR fixes a Windows/Chrome-specific CLI login regression where Confidence Score: 5/5Safe to merge — targeted, well-scoped fix with no logic or security regressions.
No files require special attention. Reviews (1): Last reviewed commit: "fix(cli-auth): ensure fallback token ren..." | Re-trigger Greptile |
Summary
Fixes #1469 — CLI login callback does not complete after GitHub sign-in on Windows/Chrome.
Root cause:
setToken()(a React state update, batched/async) andwindow.location.assign()(synchronous navigation) were called back-to-back in the same microtask. React's batching meant the fallback token UI was never rendered before the navigation fired.On Windows/Chrome, when
window.location.assign("http://127.0.0.1:PORT/…")fails — for example because the CLI's local server already shut down (ERR_CONNECTION_REFUSED) or Chrome's HTTPS-first mode interferes — Chrome replaces the current page with an error screen. Since the token had not rendered yet, users were left on Chrome's error page with no way to recover.Fix:
flushSync()fromreact-domto render the token and callback URL synchronously before callingwindow.location.assign(). The token is guaranteed to be on screen before any navigation attempt.callbackUrlstate so the rendered fallback also includes a "Retry redirect to CLI" link — useful if the user navigates back to the page or the auto-redirect was silently swallowed.clawhub login --token <token>.Test plan
AppProviderstests still pass (bun run test).🤖 Generated with Claude Code