cmux-next: signing out of Cloud keeps Cloud workspaces in their windows

LA
7d ago
+98-4

Summary

Signing out of cmux Cloud (or turning the Cloud off) removed every Cloud workspace from the saved window state, so a later sign-in had nothing to restore (P-AUSTIN B7b).

WindowManager.isDead counted a saved workspace as gone when its machine had no daemon in this run and the Cloud counted as "settled", and a signed-out or turned-off Cloud counts as settled. Sign-out removes every Cloud machine from the machine registry, so the next window-state save pruned every Cloud workspace from its window record (WindowRecordSaver keeps only live workspaces).

Now a workspace whose Cloud machine has no daemon is gone only when its machine left the account: the signed-in account's machine list has loaded and does not list it (WindowManager.remoteMachineLeft). Signed out, Cloud off, the list not loaded, or the machine listed with its feature turned off, the workspace stays in its window record and waits for its machine, as a paused machine's workspaces already did. When the Cloud connects and the machine loads, the workspace shows again. The rule is for Cloud machines only (MachineRegistry.isCloudMachineID: ids other than local, ssh-… and server-…): a workspace whose SSH machine or server has no session this run keeps its earlier result (gone once the Cloud is settled), so a forgotten SSH machine or server never keeps its workspaces while signed out of Cloud.

Known limit until the display PR lands: while signed out, a kept Cloud workspace has no sidebar row (the sidebar builds one section per machine in the registry, and signed out there is none). It is kept, not shown. The display PR (stacked on this one) shows those workspaces as Offline: link follows when it opens.

Owner of the area: PL-switch (window membership, plans/cmux-next/OWNERS.md "Workspace, tab and space switch").

Testing

Three commits, in this order:

  1. 81bbdfa817a red: new tests only (a Cloud workspace saved while signed out stays in the record and waits for its machine when the Cloud connects; remoteMachineLeft says a machine left only when the signed-in account's loaded list does not have it), with remoteMachineLeft as a stub.
  2. 9c66b31a3e3 correction of one existing assertion, on its own: aWorkspaceOnAPausedCloudMachineStaysInItsWindowAfterARelaunch expected a machine removed while signed out to prune its workspace, which is the bug this PR fixes. The case it meant (a machine that left the account) is asserted in aMachineLeftOnlyWhenTheAccountListSaysSo with a loaded account list (the tests cannot sign in).
  3. 64589eac9b0 the fix.
  4. 8039fb2e1de red, found before review: a forgotten ssh-… and server-… machine's workspace must still be gone while signed out of Cloud; isCloudMachineID (a stub) must classify only Cloud ids as Cloud.
  5. c63ead94875 the fix: the account-list rule applies to Cloud ids only.

Focused suite: CloudWorkspaceRestoreTests. Compile-check cdc4c698dc579a47e42d070c (running; 3e62e7f036a04e93409eb800 at 64589eac9b0 was cancelled as superseded), Mac red at 81bbdfa817a and green at the head: job ids follow in a comment.

Observed / Not run

  • Observed: prepush-gate.py passes.
  • Not run: the fleet jobs (pending). Not checked live in a signed-in app (a sign-out and sign-in in a running build). Austin's-day numbers: pending harness; the scenario has no sign-out or restore step.

Known limits (from the independent review at c63ead94875f; follow-ups, not in this PR)

  • Switching to another account or team still removes the other account's Cloud workspaces (as before this PR). The fix saves the account with each workspace's machine.
  • The loaded-list check uses hasLoadedMachines; it must be hasLoadedCurrentMachines, because during a team switch the store still holds the old team's list (WindowManager+Membership.swift:452).
  • No test drives the "machine deleted from the account" path through isDead; only the helper is tested.
  • After sign-out, a window that holds only Cloud workspaces stays open with its old content (before, it closed). The stacked display PR covers it.
  • isCloudMachineID reads the id prefix; the ssh- and server- prefixes are literal copies (a drift keeps data, never deletes it).

Changelog

Fixed: Signing out of cmux Cloud no longer removes your Cloud workspaces from your windows; they come back when you sign in again.

Proof

No capture: this changes which workspaces the saved window state keeps; nothing draws differently until the display PR.