fix: recover headless WalletConnect connects after a disconnect - #5728
Merged
Conversation
A headless host (no scaffold-ui) could not connect any wallet after disconnecting one: taps opened nothing and every attempt reported a connection error until the page was reloaded. - `wcError` was only cleared by a successful mobile deeplink or the headful "try again" button, so one failure left every later attempt reading as failed. A new `connectWalletConnect` attempt now clears it. - `onConnectMobile` no-ops without a pairing URI, and a disconnect clears the URI (`resetWcConnection`). The headless connect paths now reject via `assertWcUriForDeeplink` instead of resolving as if a wallet had opened, so the host can pre-fetch a URI and retry rather than wait on a redirect that never fires. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 543cfcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
Contributor
Visual Regression Test Results ✅ PassedChromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=995 👉 Please review the visual changes in Chromatic and accept or reject them. |
Contributor
📦 Bundle Size Check✅ All bundles are within size limits 📊 View detailed bundle sizes> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit > size-limit |
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tomiir
reviewed
Jul 29, 2026
tomiir
reviewed
Jul 29, 2026
tomiir
approved these changes
Jul 29, 2026
0xmkh
approved these changes
Jul 29, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`ConnectionController.setUri` has always stamped `wcPairingExpiry` four minutes out, and scaffold-ui reads it via `isPairingExpired` to decide whether to re-connect. The headless read never passed it through, so a host outside scaffold-ui had no way to tell a fresh URI from one whose pairing had lapsed — `wcUri` / `wcError` / `wcFetchingUri` read identically either way. `getWalletConnectUri()` now returns it and `subscribeWalletConnectUri` fires on it. Additive: existing readers are unaffected. This is only reachable for a host that consumes the URI later than it fetched it. Scaffold-ui generates and acts on a URI in one gesture. A headless picker that fetches on wallet select and deeplinks on a second, user-paced click can be well past four minutes by the time the user taps. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
enesozturk
enabled auto-merge (squash)
July 31, 2026 10:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a headless host (AppKit with no scaffold-ui — e.g. WalletConnect Pay's Buyer Experience), connecting a wallet after disconnecting a previous one leaves the page unusable until a reload: taps open nothing, and every subsequent attempt surfaces a connection error. Reported as WCPBX-1014.
Two gaps, both unreachable in headful mode (
w3m-connecting-wc-mobileonly firesonConnectonce it has a URI, and its "try again" clears the error):wcErroris sticky. It is set inconnectWalletConnect's catch, but cleared only by a successful mobile deeplink (onConnectMobile) or the headful "try again" button. A headless host that hit one error reads as failed for the rest of the page's life.ConnectionControllerUtil.onConnectMobileis a no-op whenwcUriis missing — which is exactly the state a disconnect leaves behind (resetWcConnectionclears the URI).connectWallet()resolved as though a wallet had been opened, so the host sat in a connecting state waiting on a redirect that never fires.Change
ConnectionController.connectWalletConnectclearswcErrorwhen a new attempt starts (same thing headful's "try again" does manually).ConnectionControllerUtil.assertWcUriForDeeplink(), called by both headless connect paths (HeadlessWalletUtil.connectanduseAppKitWallets'connect) before the mobile deeplink branch. The attempt now rejects — which also clearsconnectingWalletvia the existing catch — so the host can pre-fetch a URI and retry. It cannot be fetched here: the redirect has to happen inside the tap (iOS Safari blocks one issued after an await).Deliberately not changed:
resetWcConnectiondoes not clearwcError, becausew3m-connecting-wc-viewsets the error and then callsresetWcConnection— clearing it there would wipe the headful error UI.Tests
connectWalletConnectclears a previouswcErroron a new attempt.HeadlessWalletUtil.connectrejects and clearsconnectingWalletwhen the URI is gone, without callingonConnectMobile.packages/controllers+packages/scaffold-uisuites pass; the 5 failing files on this branch (w3m-connecting-wc-mobileuniversal-link href,ChainController, and three localStorage/OTP view files) fail identically onmain.🤖 Generated with Claude Code