Team picker: switch/create teams and scope Cloud

Merged
AU
2mo ago
+4138-344

Closes #13019

The existing compact account menu now shows the current team with a hover submenu for switching and creating teams. Team rows have neutral checkmarks and even spacing. Selecting or creating a team keeps the menu open; clicking outside either menu, pressing Escape, or switching apps dismisses the whole menu. Settings opens the Account section with its configured shortcut hint. The footer retains cmux's existing avatar button.

Stack Auth persists the selected team. AuthCoordinator supplies the confirmed account/team scope to the app, CLI and web dashboard. HostAccountFlow owns a single pending selection for immediate UI feedback and clears it on failure; Cloud requests wait for the server-confirmed selection. The customizable shortcut, command palette, Settings and cmux auth team list|use|create use the shared actions.

Cloud switches clear prior-team workspaces and credentials, cancel stale list/usage requests, restart visible Machines panels immediately, and reconcile provider teardown without blocking later team changes. Existing VM ownership and backend membership checks supply team sharing; this change adds no new ownership migration. The authenticated teams route supports create and select mutations with membership and browser-origin checks.

Hovering away from both the team row and its submenu now closes only the submenu. A narrow geometric bridge across their gap keeps it open while moving between them. The account menu stays open until click-away, Escape, or app deactivation. Mouse tracking is restored when the group closes.

The nested menus share a dismissal owner and use AppKit's application-defined popover behavior: AppKit explicitly disallows nesting semitransient popovers. Children close before the parent, and independent close animations are disabled so no empty window is left behind.

Validation:

  • Prior focused web suites: 27 tests, zero failures; web typecheck and complexity checks passed.
  • CLI pipe regressions pass on 0d0a49c267: 13 closed-pipe/socket cases and 2 cloud-hostname cases. Merging main restored the missing hostname test file and resolved branch conflicts.
  • Popover behavior tests pass: 7 tests executed, zero failures (confirmed in the Swift Testing log and workflow execution guard). Coverage includes hover from row to submenu, returning to another account row, child-only close, click-away, teardown, reopening, left/right geometry, and restoring mouse tracking. The test-only commit ran 6 tests and failed both the missing child close and mouse-tracking subscription before the fix.
  • Tagged local build and signed-in UI verification are in progress, using the GCP development backend. Local builds use reload.sh at Austin's explicit request; Swift tests run in hosted CI.
  • Swift parse, file-length, project normalization and test-wiring checks pass. The localization audit found no new strings and all six catalogs pass parity checks across nine locales.
  • Same-tag reloads now serialize cleanup, build and launch to prevent competing reloads from deleting each other's generated app. Both lifecycle tests pass.

The current team label updates optimistically; Cloud access waits for confirmation so failed switches preserve the confirmed authority. Existing resources are not transferred between teams. Final build and screenshot evidence will be added after UI verification.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Closes #13019. Adds team switching and creation to the compact account menu so the active team can be changed without leaving the app. The menu shows the active team with a hover submenu, and the same actions are available from Settings, mobile settings, the command palette, ⌥⇧⌘T, and cmux auth team list|use|create.

  • Stack Auth stores the selected team across devices, with a local fallback for launch.
  • The UI can show a pending selection, but Cloud and VM access switch only after the server confirms it; failed switches leave the current team and Cloud scope untouched.
  • Cloud requests and registrations re-scope on team change; old-team VM sessions are disconnected and stale work is fenced.
  • Existing VMs and resources stay with their team; no ownership migration is added.
  • The web dashboard and Iroh now prefer Stack Auth's selected team over the legacy cookie, and the teams route supports create/select mutations with membership and browser-origin checks.
  • The nested menus share a dismissal owner because AppKit doesn't allow nested popovers. Hovering between the account menu and team submenu keeps both open; clicking outside, Escape, app deactivation, or leaving the hover region closes them.
  • Same-tag dev reloads are serialized so a losing concurrent reload can't delete the active build.
  • Adds tests for team actions, popover dismissal and hover lifecycle, dashboard team scope, hosted team routes, and reload concurrency.

Summary by CodeRabbit

  • New Features

    • Added team listing, selection, and creation across the CLI, desktop app, mobile settings, and web dashboard.
    • Added a sidebar team picker with team status, Pro indicators, team creation, and account actions.
    • Added persisted team selection and team-management APIs.
    • Added Cloud VM and connection handling when switching teams.
    • Added an “Open Team Picker” command and keyboard shortcut (⌘⇧⌥T).
  • Bug Fixes

    • Team-scoped cloud requests and registrations now refresh correctly after switching teams.
    • Dashboard team selection now honors the persisted selected team.
  • Tests

    • Added coverage for team creation, selection, validation, and scope updates.