Persist Cloud display membership across clients

Merged
AU
2mo ago
+1046-140

A VNC display opened from a Cloud machine’s display pool was associated with the originating Mac’s bound workspace only through a local SurfaceProjection. A second authorized client rebuilt the daemon snapshot without that local pane and therefore omitted the workspace display row.

This change persists display membership in the daemon’s revisioned frontend_projection resource. The payload carries the owning VM, remote workspace, display resource, and per-client view token. Snapshot and event reconciliation validates that provenance against the VM’s workspace and display inventory, projects workspace rows from that accepted state, and keeps the machine-level Displays pool separate. Attach, move, close, restore, reconnect, and revision-conflict paths use the same placement coordinator and CAS retry path.

It also fixes Cloud terminal startup replay when the attach stream delivers the initial VT snapshot before the native pane has bound its TerminalSurface. The replay is retained and applied exactly once when the surface binds, including a prompt with no trailing newline. This is the Cloud startup boundary related to #3079’s partial-line report; the focused regression covers the Cloud replay race and does not claim the #3079 screenshot was reproduced.

Impact map

  • Source of truth / owner: the Cloud daemon’s frontend_projection record is authoritative for VNC workspace membership. CloudVMState parses and cursor-orders it; SurfaceCatalogSnapshot and the Cloud tree consume only accepted, VM-validated memberships. Local panes remain projections and never become authority. Cloud terminal bytes remain owned by the manual mirror attach stream and are buffered by the terminal surface until its runtime is ready.
  • Direct callers and sibling lifecycle paths inspected: machine-pool open, bound-workspace projection, drag/move, restore/pending restore, close, reconnect, full snapshot, event delta, stale/out-of-order cursor handling, CloudWorkspaceLayoutTranslator, workspace group lookup/open, machine-level display inventory, manual mirror handshake, VT snapshot/output delivery, runtime binding, and remote-output buffering.
  • Persistence / API / platform: adds a typed macOS model and the existing cmux.protocol/2 frontend_projection.put request. No database migration, web API, provider image change, billing change, or new platform target. The Xcode source/test wiring is updated.
  • Localization / docs / release: no new user-facing strings; the existing localized unavailable-display message is reused. No docs or release metadata need changes.
  • Focused tests: CloudDisplayMembershipProjectionTests covers two-client snapshot projection, machine-pool separation, unknown/foreign display rejection, revision ordering, and reconnect identity. CloudManualMirrorStartupRenderingTests covers a newline-free Cloud prompt received before surface binding. Existing Cloud membership, layout, restore, ownership, display catalog, and manual mirror transport suites remain in scope.
  • Residual risk: I could not run a real two-computer Cloud GUI session from this Mac, so the visual noVNC repro, live two-client screen rendering, and Austin’s exact blank-pane screenshot are not claimed. The state/projection and Cloud replay boundaries are covered; fleet compilation and hosted tests provide the remaining execution evidence.

Validation

  • Scoped Swift syntax, test wiring, PBX wiring, project normalization, localization parity, package policy, workspace package grouping, diff checks, and Swift file-length budget pass locally.
  • No local app compilation or app test execution was performed, per the issue’s controller-fleet requirement.
  • Regression history is split across c2c6f8f876 (display behavior test), 971f372e8c (display membership fix), and a75f0e1c22 (Cloud startup replay fix).

Changelog

Fixed: Persist Cloud display membership across authorized clients and retain newline-free Cloud terminal replay until the native pane is ready.

Fixes #12226.

Summary by CodeRabbit

  • New Features
    • Shared cloud workspace displays retain their workspace and display associations across views and reconnections.
    • Cloud workspace views can be opened without requiring a specific remote tab.
    • Shared displays appear in the cloud workspace they belong to.
  • Bug Fixes
    • Display membership changes persist reliably when moving a display between workspaces, without removing it from the display pool.
    • Terminal replay data received before the terminal is ready is applied once the display becomes available.
    • Existing local display previews correctly satisfy matching cloud workspace placements.