feat(logout): add dot logout command#46
Merged
UtkarshBhardwaj007 merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
Sign out of the account paired via `dot init` without touching `~/.polkadot-apps/` by hand. Uses `adapter.sessions.disconnect()` so the paired mobile app's connection list updates too, falling back to a scoped local-only cleanup (files prefixed with `dot-cli_`) when the statement store is unreachable. Follows the existing SDK/TUI split: the auth SDK grows `findSession()` + `waitForLogout()` mirroring `connect()` + `waitForLogin()`, and `src/commands/logout/` mirrors `src/commands/init/` with an orchestrator screen, a presentational row, and a pure status mapper.
Contributor
|
Dev build ready — try this branch: |
| await expect(clearLocalAppStorage(missing)).resolves.toBeUndefined(); | ||
| }); | ||
|
|
||
| it("removes only files prefixed with `${DAPP_ID}_`", async () => { |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
dot logout— signs the user out of the host account paired viadot initwithout having torm -rf ~/.polkadot-apps.adapter.sessions.disconnect(session)so the paired mobile app drops its side of the connection too, not just the local CLI.dot-cli_in~/.polkadot-apps/— when the statement store is unreachable. Narrower thanrm -rf; never touches files owned by other polkadot apps on the same machine.Structure
Mirrors the repo's existing SDK/TUI split so the feature drops in cleanly and is trivial to remove later:
src/utils/auth.ts): three new exports alongsideconnect()/waitForLogin()/getSessionSigner()—findSession(),waitForLogout(), plus an@internalclearLocalAppStorage()used by the fallback.src/commands/logout/): mirrorssrc/commands/init/'s shape —index.ts(Commander wiring) +LogoutScreen.tsx(orchestrator) +LogoutStatus.tsx(presentational row) +status.ts(pure Ink-free status→row mapping) +status.test.ts.Notes
waitForLogout()ownsadapter.destroy()and wraps the whole body in atry/finally, so every control-flow path (including a throwingonStatuscallback) releases the WebSocket. Matches the CLAUDE.md invariant that long-lived terminal adapters must always be destroyed.logoutmatches the convention used bygh,docker,firebase,vercel,heroku.~/.polkadot/accounts.jsonare deliberately untouched — out of scope for "host account" logout.Test plan
pnpm test— 347 tests pass (6 new cases inauth.test.tscovering happy path, err-result fallback, thrown-error fallback, non-Error throws, missing dir, anddot-cli_prefix scoping + foreign-file preservation; 8 cases instatus.test.tscovering everyLogoutStatusvariant andisTerminal)pnpm exec tsc --noEmit— cleanpnpm run format:check— cleanpnpm run build—bun build --compilesucceeds./dist/dot --help—logoutsurfaces in the command list./dist/dot logout --help— description rendersdot logoutagainst a real paired session on Paseo, confirm the mobile app drops the connectiondot logoutwith the People chain unreachable, confirmpartialstatus fires and local files are cleareddot logoutwith no session signed in, confirmNo account is signed in.and exit 0