fix(cloud): make Cloud workspace reconciliation always settle

Merged
AU
2mo ago
+165-17

Nightly b36a9b3 (0.64.25-nightly.3672807119701) ran one core at 98% and grew its memory footprint from 396 MB to 3.3 GB in 92 s, reaching about 64 GB before it was quit. It relaunched straight into the same state and could not run its updater, because Sparkle runs on the pinned main thread. Symbolicated with the Sentry dSYM, the CPU report and a live sample show one main-actor cycle: CloudWorkspaceProjectionCoordinator.reconcile → SurfaceCatalog.project (reuse branch) → attachRemoteView → reconcileCloudWorkspaceBinding → requestCloudWorkspaceProjection → reconcile.

https://github.com/manaflow-ai/cmux/pull/16025 fixed the trigger: the plan reported a pane the workspace already showed as missing. This PR makes the loop impossible regardless of trigger, in two layers.

attachRemoteView and setRemotePlacement return early when the remote workspace and tab are unchanged. Before, they removed and reinserted the projection (clearing and restoring the panel directory, rerunning sidebar git probes, bumping the guest routing revision twice), and attachRemoteView requested another reconcile. A real change is now one projections assignment, so observers never see the pane briefly unprojected.

CloudWorkspaceProjectionCoordinator bounds the passes it runs over one accepted CloudVMState. A converging graph needs two or three. After maxPassesPerState (8) it stops, sends a Sentry warning (cloud.projection, "Cloud workspace projection did not converge"), and waits for the next graph or request, which starts a new count. A future bug of this class becomes one reported warning instead of a hung app.

Regression tests, each committed before its fix:

Results for the last two runs are pending; this description will be updated with them.

Changelog

Fixed: cmux no longer freezes and grows its memory without bound while syncing a Cloud workspace.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Reusing a projection in its current workspace no longer changes its placement or triggers unnecessary projection updates.
    • Remote views now apply consistent tab-compatibility checks, while display-membership views remain tabless.
    • Workspace projection reconciliation now stops after repeated passes without progress or when it reaches its limit, helping prevent unbounded update cycles.
    • Starting reconciliation for a new workspace graph allows a fresh set of update attempts.