Skip to content

Improve login/logout CLI UX#4367

Merged
clockwork-labs-bot merged 20 commits intomasterfrom
bot/login-logout-ux
Mar 6, 2026
Merged

Improve login/logout CLI UX#4367
clockwork-labs-bot merged 20 commits intomasterfrom
bot/login-logout-ux

Conversation

@clockwork-labs-bot
Copy link
Collaborator

Summary

Improves the spacetime login and spacetime logout UX to behave more like standard CLI tools.

spacetime login

Before: If already logged in, prints "You are already logged in" and exits. User must manually run logout first.

After: If already logged in, automatically logs out the previous session and proceeds with a fresh login. Prints the old identity being logged out and the new identity on success.

$ spacetime login
Logged out of previous session (identity 0xabc...).
Opening https://spacetimedb.com/login/cli?token=... in your browser.
Waiting to hear response from the server...
Logged in with identity 0xdef...

spacetime logout

Before: No output on success. Hard failure if offline.

After:

  • Prints confirmation: Logged out (identity 0xabc...).
  • Prints You are not logged in. if already logged out
  • Best-effort server-side session invalidation with 5s timeout (prints warning if offline instead of failing)

Changes

  • login.rs: Remove spacetimedb_token_cached early-return; instead log out previous session and proceed. Show identity on login success.
  • logout.rs: Add identity display, not-logged-in check, 5s timeout for server call with warning on failure.

Note: This subsumes the offline fix from #4361.

login:
- If already logged in, automatically log out of the previous session
  and proceed with a fresh login (instead of refusing with 'already
  logged in')
- Print the identity on successful login
- Show which identity was logged out when re-logging in

logout:
- Print confirmation message with identity on logout
- Print 'You are not logged in.' if already logged out (instead of
  silently doing nothing)
- Best-effort server-side session invalidation with 5s timeout (does
  not fail if offline, but prints a warning)
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
@bfops bfops added Do not merge Do not merge PRs with this label without coordinating further and removed Do not merge Do not merge PRs with this label without coordinating further labels Mar 3, 2026
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke with Zeke on a call

@bfops bfops enabled auto-merge March 5, 2026 21:52
@bfops bfops disabled auto-merge March 5, 2026 22:07
@clockwork-labs-bot clockwork-labs-bot added this pull request to the merge queue Mar 6, 2026
Merged via the queue into master with commit 78c8acd Mar 6, 2026
32 of 33 checks passed
clockwork-labs-bot added a commit that referenced this pull request Mar 6, 2026
PR #4367 (login/logout UX overhaul) accidentally removed the early
return after saving a token via `spacetime login --token`. This caused
the command to fall through into the web login flow, which fails when
no browser/server is available.

This breaks all Private repo smoketests that use `spacetime login --token`
(replication tests, teams tests — 9 failures total).
github-merge-queue bot pushed a commit that referenced this pull request Mar 7, 2026
## Bug

PR #4367 (login/logout UX overhaul) accidentally removed the early
`return Ok(())` after saving a token via `spacetime login --token`. This
caused the command to fall through into the web login flow
(`spacetimedb_login_and_save`), which fails when no browser or server is
available.

## Impact

All tests that use `spacetime login --token` are broken:
- 4 replication tests (`test_enable_disable_replication`,
`test_enable_replication_on_suspended_database`,
`test_enable_replication_fails_if_not_suspended`, `test_prefer_leader`)
- 5 teams tests (`test_permissions_clear_org`,
`test_permissions_delete_org`,
`test_org_permissions_mut_sql_org_members`,
`test_org_permissions_private_tables`,
`test_permissions_publish_org_members`)

## Fix

One line: restore `return Ok(())` after the `--token` branch.

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
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.

3 participants