fix(cli): clear default_workspace on cloud logout#773
Conversation
`bm cloud logout` previously only invalidated OAuth tokens, leaving config.default_workspace pointing at whatever tenant was selected before the session ended. A subsequent `bm cloud login` (often as a different user, or returning from an org workspace to personal) would silently inherit the stale selection and route every cloud-mode project through the wrong tenant. Clear default_workspace on logout, and only rewrite the config file when there was a value to clear (avoid touching the file when nothing needs to change). Closes #755 Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 11s —— View job PR Review: fix(cli): clear default_workspace on cloud logoutTasks:
SummaryClean, well-scoped fix. The bug is real, the change is minimal, and the tests cover both branches. A few notes below. Code Quality & Standards
Minor inconsistency (non-blocking): Testing & Documentation
Test structure note (non-blocking): Basic Memory Architecture
Security & Performance
Compatibility
UX Nit (optional)When console.print("[dim]Default workspace selection cleared.[/dim]")inside the Overall: LGTM with the optional nit above. The fix is correct, minimal, well-tested, and properly documented. Ready to merge. |
Summary
bm cloud logoutonly invalidated OAuth tokens — it leftconfig.default_workspacepointing at the previously selected tenant.bm cloud login(e.g. switching from an org workspace back to personal) inherited that stale selection and silently routed every cloud-mode project through the wrong tenant. The user had no signal that the active workspace hadn't reset.bm cloud workspace set-default <personal>recovered.Change
cli/commands/cloud/core_commands.py—logout()now clearsconfig.default_workspaceand saves the config when a non-None value was cleared. Skips the write when there's nothing to clear, so we don't touch the file unnecessarily.Out of scope
loginshould prompt to pick a default workspace when multiple are available. That's a UX enhancement (needs to fetch workspaces, render a chooser, validate selection) and worth a separate PR. This change focuses on the smaller invariant: ending a session must invalidate the cached selection.Test plan
TestLogoutCommandclass intests/cli/test_cloud_authentication.py:test_logout_clears_default_workspace— confirms the value goes from set → None and config is saved exactly oncetest_logout_skips_save_when_no_default_workspace— confirms no save call when there was nothing to clearuv run pytest tests/cli/test_cloud_authentication.py --no-cov— greenCloses #755
🤖 Generated with Claude Code