Skip to content

bm cloud login/logout don't reset default_workspace; no workspace picker on login #755

Closed

Description

@groksrc

Summary

bm cloud logout followed by bm cloud login leaves config.default_workspace pointing at whatever tenant was previously selected. If a user had run bm cloud workspace set-default <some-org-tenant>, re-authentication keeps them stuck on that organization — even if they intended the re-login to return to their personal workspace. Additionally, bm cloud login performs no workspace selection step, so users with multiple workspaces can't change their default without a second explicit command.

Reproduction

  1. bm cloud workspace set-default <org-tenant-id> (switch default to a Teams/org workspace)
  2. bm cloud logout
  3. bm cloud login
  4. Inspect ~/.basic-memory/config.json → default_workspace is still the org tenant
  5. bm project list → all cloud projects route to the org workspace, not the user's personal workspace

Expected

Either (or both):

  • bm cloud logout should clear default_workspace in config (since the session is being ended)
  • bm cloud login should detect multiple available workspaces and prompt the user to pick the default — similar to the existing workspace set-default interactive flow

The login-side prompt is the better UX: users with a single workspace shouldn't be prompted, but users with a personal + one-or-more org workspaces should get a chooser after the WorkOS OAuth handshake succeeds. This also gives first-time Teams members a clean on-ramp without needing to discover the workspace set-default subcommand.

Relevant code

  • src/basic_memory/cli/commands/cloud/core_commands.py — login() (no workspace selection), logout() (only clears tokens via auth.logout(), doesn't touch config.default_workspace)
  • src/basic_memory/cli/commands/cloud/workspace.py:108 — where config.default_workspace gets written via set_default_workspace. The existing interactive chooser there could be reused.

Context

Hit this while migrating a private project out of a Teams workspace back to a personal subscription. After re-auth, every bm command (and the MCP server wiring downstream) kept pointing at the org tenant, which was confusing — bm cloud status said "Cloud connected" with no hint that the active workspace was still the org. Manually running bm cloud workspace set-default <personal-tenant> fixed it.

Activity

  1. claude commented on Apr 18, 2026

    @claude
    Contributor

    Claude finished @groksrc's task in 5m 18s —— View job • claude/issue-755-20260418-0142 • Create PR ➔


    Triage & Implementation

    Classification: Bug + Enhancement | Component: Cloud/CLI | Complexity: Medium

    • Analyze issue
    • Read relevant source files (core_commands.py, workspace.py, auth.py, project_context.py)
    • Check for duplicates (none found)
    • Add labels (bug, cloud, enhancement)
    • Implement fix: logout clears default_workspace
    • Implement fix: login prompts workspace selection when multiple workspaces exist
    • Write tests for both new behaviors (7 new test cases)
    • Commit and push

    Changes Made

    src/basic_memory/cli/commands/cloud/core_commands.py

    • logout() — now clears config.default_workspace = None and persists config after removing tokens. This prevents the stale workspace from silently routing to the wrong tenant on re-login.

    • login() — calls new _select_default_workspace_on_login() after successful authentication:

      • Single workspace: auto-set as default (no prompt needed)
      • Multiple workspaces: displays numbered list, prompts user to pick one (Enter = skip)
      • Discovery failure: non-fatal, prints guidance to use bm cloud workspace set-default

    tests/cli/test_cloud_authentication.py

    Added TestLogoutCommand and TestLoginWorkspaceSelection test classes covering:

    • Logout clears default_workspace when set
    • Logout is safe when default_workspace is already None
    • Login auto-sets single workspace
    • Login prompts and saves selection for multiple workspaces
    • Login skips without setting when user presses Enter
    • Login succeeds even if workspace discovery fails

    |

  2. added
    bug
    cloud
    on Apr 18, 2026
  3. added a commit that references this issue on Apr 18, 2026
    ffdd9af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcloud

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions