Skip to content

feat: show Sign in CTA when dotli has no session#7

Merged
todortodorovic merged 1 commit into
paritytech:mainfrom
tallesborges:feat/sign-in-cta
May 20, 2026
Merged

feat: show Sign in CTA when dotli has no session#7
todortodorovic merged 1 commit into
paritytech:mainfrom
tallesborges:feat/sign-in-cta

Conversation

@tallesborges
Copy link
Copy Markdown
Contributor

Why

Cold-start (fresh browser, RevX/WebContainer preview, any session where dotli isn't paired) shows this raw error before the user can do anything:

Failed to connect: Unknown: RequestCredentialsErr::NotConnected: RequestCredentials: not connected

That's dotli's correct behavior — its handleAccountGet returns NotConnected whenever there's no authenticated session. The SPA just wasn't surfacing it as a normal UI state.

What

  • Catch RequestCredentialsErr.NotConnected (instanceof — the codec-error class defines Symbol.hasInstance) and route to a new signed-out status instead of error.
  • New signIn() helper: calls accountsProvider.requestLogin(...) then re-runs connectAccount(). On rejected, the next accountGet returns NotConnected again and the UI lands back on the sign-in screen — no special-case branch needed.
  • App.tsx renders "Sign in to dotli to play Rock Paper Scissors." + a Sign in button when status === "signed-out". Other states (idle, connecting, ready, error) unchanged.

24 insertions, 2 deletions across two files.

Flow

  1. Open SPA → accountGet returns NotConnected → state goes to signed-out → CTA renders.
  2. Click Sign inrequestLogin opens dotli's QR / PAPP pairing UI → user pairs → connectAccount retries → game loads.

Not in scope

No accountConnectionStatusSubscribe subscription. Two edge cases that gracefully degrade without it:

  • User signs in via dotli's topbar instead of clicking our button → SPA stays on the sign-in screen until they click; requestLogin then returns alreadyConnected instantly.
  • User signs out of dotli mid-session → SPA keeps the ready UI until next call fails; recovers on retry.

Easy to add the subscription later if either becomes a real friction point.

Verified

  • Vite build clean (bunx vite build).
  • Note: bun run build:frontend is currently red on main because of a pre-existing TS2554 in the 9aea38a fix sign tx commit (getProductAccountSigner(productAccount, "createTransaction") — the second arg requires @novasamatech/product-sdk ≥ 0.7.9-5, but package.json pins 0.7.8-2). Unrelated to this PR, worth raising separately.

Catch RequestCredentialsErr::NotConnected from accountGet and route to a
new 'signed-out' state instead of the raw error screen. App.tsx renders
a 'Sign in to dotli to play' message with a button that calls
accountsProvider.requestLogin() and re-runs connectAccount on resolve.

Skipped the connection-status subscription on purpose — primary flow
(click button -> pair -> game) doesn't need it. Edge cases (user signs
in via dotli topbar instead of our button, or signs out mid-session)
recover on the next user action.
@todortodorovic todortodorovic merged commit 40f0347 into paritytech:main May 20, 2026
3 checks passed
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.

2 participants