Skip to content

feat(logout): add dot logout command#46

Merged
UtkarshBhardwaj007 merged 1 commit intomainfrom
feat/dot-logout
Apr 23, 2026
Merged

feat(logout): add dot logout command#46
UtkarshBhardwaj007 merged 1 commit intomainfrom
feat/dot-logout

Conversation

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member

Summary

  • Adds dot logout — signs the user out of the host account paired via dot init without having to rm -rf ~/.polkadot-apps.
  • Uses the terminal SDK's adapter.sessions.disconnect(session) so the paired mobile app drops its side of the connection too, not just the local CLI.
  • Falls back to a best-effort local cleanup — scoped strictly to files prefixed with dot-cli_ in ~/.polkadot-apps/ — when the statement store is unreachable. Narrower than rm -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:

  • SDK (src/utils/auth.ts): three new exports alongside connect()/waitForLogin()/getSessionSigner()findSession(), waitForLogout(), plus an @internal clearLocalAppStorage() used by the fallback.
  • TUI (src/commands/logout/): mirrors src/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

  • Adapter lifecycle: waitForLogout() owns adapter.destroy() and wraps the whole body in a try/finally, so every control-flow path (including a throwing onStatus callback) releases the WebSocket. Matches the CLAUDE.md invariant that long-lived terminal adapters must always be destroyed.
  • No new flags, no confirmation prompt, no alias. logout matches the convention used by gh, docker, firebase, vercel, heroku.
  • Dev-mode session keys in ~/.polkadot/accounts.json are deliberately untouched — out of scope for "host account" logout.

Test plan

  • pnpm test — 347 tests pass (6 new cases in auth.test.ts covering happy path, err-result fallback, thrown-error fallback, non-Error throws, missing dir, and dot-cli_ prefix scoping + foreign-file preservation; 8 cases in status.test.ts covering every LogoutStatus variant and isTerminal)
  • pnpm exec tsc --noEmit — clean
  • pnpm run format:check — clean
  • pnpm run buildbun build --compile succeeds
  • ./dist/dot --helplogout surfaces in the command list
  • ./dist/dot logout --help — description renders
  • Manual: run dot logout against a real paired session on Paseo, confirm the mobile app drops the connection
  • Manual: run dot logout with the People chain unreachable, confirm partial status fires and local files are cleared
  • Manual: run dot logout with no session signed in, confirm No account is signed in. and exit 0

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.
@github-actions
Copy link
Copy Markdown
Contributor

Dev build ready — try this branch:

curl -fsSL https://raw.githubusercontent.com/paritytech/playground-cli/main/install.sh | VERSION=dev/feat/dot-logout bash

Comment thread src/utils/auth.test.ts
await expect(clearLocalAppStorage(missing)).resolves.toBeUndefined();
});

it("removes only files prefixed with `${DAPP_ID}_`", async () => {
@UtkarshBhardwaj007 UtkarshBhardwaj007 merged commit b07280f into main Apr 23, 2026
6 checks passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the feat/dot-logout branch April 23, 2026 19:39
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