Skip to content

fix: reliable wallet connects — account switching + returning-user state cleanup - #18

Merged
jayteemoney merged 1 commit into
mainfrom
fix/wallet-account-switching
Jul 13, 2026
Merged

fix: reliable wallet connects — account switching + returning-user state cleanup#18
jayteemoney merged 1 commit into
mainfrom
fix/wallet-account-switching

Conversation

@jayteemoney

Copy link
Copy Markdown
Owner

What

Follow-up to #17, fixing two wallet-connect failures that hit real users:

1. Account switching silently failed. connect() caches the first approval; after switching accounts in the wallet, reconnecting returned the previously approved account — looked like "not connecting" with zero feedback. Anyone who both sends and receives streams (normal payroll usage) hits this.
→ Cached approval cleared + forceWalletSelect: true on every connect; address read from the wallet's fresh response, never merged localStorage.

2. Returning visitors carried pre-v8 leftovers. The legacy UserSession blob and a persisted connected flag from before the migration made the UI claim a connection that no longer existed.
→ Legacy keys purged on mount; persisted state reset whenever there's no live v8 session.

Plus feedback on every path: success toast names the connected address (verify the right account at a glance), clear error toasts for locked wallet / missing STX address, graceful cancel when the popup is closed.

Verified

Localhost against mainnet with Leather: sender account → disconnect → switch to recipient in Leather → connect → correct second address, toast confirms. Typecheck + build clean.

…urning users

Two production UX failures after the v8 migration:

1. connect() caches the first approval, so switching accounts in the
   wallet and reconnecting silently returned the previously approved
   account. Fix: clear the cached approval and force the wallet chooser
   on every connect; read the address from the wallet's fresh response,
   never merged localStorage.

2. Returning visitors carry pre-v8 leftovers (legacy UserSession blob +
   a persisted 'connected' flag), so the UI claimed a connection that
   no longer existed. Fix: purge legacy keys on mount and reset the
   persisted state whenever there is no live v8 session.

Also adds feedback on every connect path: success toast names the
connected address so users can verify the right account; failures
explain themselves; closing the popup is a graceful cancel.

Verified on localhost against mainnet: sender -> recipient account
switch connects the correct address.
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stackstream Ready Ready Preview, Comment Jul 13, 2026 7:45am

@jayteemoney
jayteemoney merged commit 5e5fc79 into main Jul 13, 2026
2 of 4 checks passed
@jayteemoney
jayteemoney deleted the fix/wallet-account-switching branch July 13, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant