From ff2be1347d1fbee4127df4e35bc40efa9e035055 Mon Sep 17 00:00:00 2001 From: Jakob Notland Date: Fri, 3 Apr 2026 12:45:57 +0200 Subject: [PATCH 1/2] unguard pushDappReady() --- packages/dapp/src/dapp-connection-manager.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/dapp/src/dapp-connection-manager.ts b/packages/dapp/src/dapp-connection-manager.ts index 4cace07..99fe865 100644 --- a/packages/dapp/src/dapp-connection-manager.ts +++ b/packages/dapp/src/dapp-connection-manager.ts @@ -339,11 +339,13 @@ export class DappConnectionManager extends EventEmitter - console.error("[wizardconnect/dapp] Error pushing dapp_ready:", e), - ); - } + // Always send dapp_ready when wallet_ready is received — even if the wallet + // previously saw us (dapp_discovered=true). On reconnect after sleep/wake the + // relay may not have persisted the earlier dapp_ready, so the wallet would be + // stuck waiting. Re-sending is safe: the wallet is idempotent on dapp_ready. + this.pushDappReady().catch((e) => + console.error("[wizardconnect/dapp] Error pushing dapp_ready:", e), + ); this.emit("walletready", msg); } From 3bcc242ebf3209a9438c675a8a1406489057138c Mon Sep 17 00:00:00 2001 From: Jakob Notland Date: Fri, 3 Apr 2026 14:05:16 +0200 Subject: [PATCH 2/2] Wallet implementation fix and documentation --- docs/protocol.md | 7 +++++-- packages/dapp/src/dapp-connection-manager.ts | 12 +++++------- packages/wallet/src/wallet-connection-manager.ts | 5 ++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/protocol.md b/docs/protocol.md index c862594..61499e1 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -121,8 +121,11 @@ a ready message from the other side in this runtime session." "ready" — *even if it already sent one* — because the other side has lost state and needs a fresh delivery. 4. The wallet guards against duplicate `wallet_ready` messages within a single connection cycle - via `walletReadySentThisCycle`. This resets to `false` on each new connect/reconnect. - Receiving `dapp_ready(wallet_discovered=false)` also resets this flag. + via `walletReadySentThisCycle`. Both `walletReadySentThisCycle` and `dappDiscovered` reset to + `false` on each new connect/reconnect. This ensures the wallet always sends + `wallet_ready(dapp_discovered=false)` at the start of a new connection cycle, matching the + "Wallet reconnects" scenario. Receiving `dapp_ready(wallet_discovered=false)` also resets + `walletReadySentThisCycle`. #### Scenarios diff --git a/packages/dapp/src/dapp-connection-manager.ts b/packages/dapp/src/dapp-connection-manager.ts index 99fe865..4cace07 100644 --- a/packages/dapp/src/dapp-connection-manager.ts +++ b/packages/dapp/src/dapp-connection-manager.ts @@ -339,13 +339,11 @@ export class DappConnectionManager extends EventEmitter - console.error("[wizardconnect/dapp] Error pushing dapp_ready:", e), - ); + if (!msg.dapp_discovered) { + this.pushDappReady().catch((e) => + console.error("[wizardconnect/dapp] Error pushing dapp_ready:", e), + ); + } this.emit("walletready", msg); } diff --git a/packages/wallet/src/wallet-connection-manager.ts b/packages/wallet/src/wallet-connection-manager.ts index 6c741d2..1f19eef 100644 --- a/packages/wallet/src/wallet-connection-manager.ts +++ b/packages/wallet/src/wallet-connection-manager.ts @@ -285,8 +285,11 @@ export class WalletConnectionManager extends EventEmitter