fix(cloud): stop reconciling panes a Cloud workspace already shows
Cloud reconciliation no longer spins forever or fails on a workspace that already shows its terminal tabs or local Desktop and port previews. #15748 changed CloudWorkspaceProjectionPlan so that only display memberships count as already present. Every daemon tab a workspace showed was reported missing on every reconcile. That froze the main actor, and it is why the Cloud app-host suites started hitting their 300 s and 60 s limits (#15488).
Cause
CloudWorkspaceProjectionPlan.init collects the desired placements that existing panes already show in seen. #15748 added a second set, satisfied, filled only for local display previews, and computed missing from it:
missing = desired.filter { !satisfied.contains($0) && missingSeen.insert($0).inserted }
A terminal tab the workspace already shows is in seen but not in satisfied, so it is always missing. That starts a loop:
CloudWorkspaceProjectionCoordinatorrunswhile requested.remove(machine) != nil { reconcile }.- For each missing tab,
reconcilecallsSurfaceCatalog.project(reuseExisting: true), which reuses the existing pane throughattachRemoteView. attachRemoteViewcallsreconcileCloudWorkspaceBinding, which requests the next reconcile of the same machine.
The reuse path never suspends, so the main actor never yields. waitForIdle() and waitForPendingOperations() never return, and the test hits its time limit.
Evidence
- Spindumps: every hang in the validation full suite (run 36713362165) shows the main thread at about 100% CPU in
SurfaceCatalog.projectโCloudWorkspaceProjectionCoordinator.reconcile. That covers shards 2, 4 and 7 on fleet minis and shard 6 on a Blacksmith runner. - Suites that hung:
CloudWorkspaceRowOpenTests,CloudMachineWorkspaceAdoptionTests,CloudWorkspaceCreationSidebarTests,CloudWorkspaceRenameSurfaceParityTests,CloudDesktopGraphOpenTestsandCloudInitialWorkspaceNamingTests. - #15748's own CI: run 36680498375 hung the same way before it merged.
- Baseline: main's full suite at 478e3232b, before #15748, passed every one of these suites.
A second path: the preview's own workspace row
#15748 also removed seen.insert(placement) from the local-preview branch, and put only the matching membership views in its place. The workspace group emits a row for every local preview, (resource, workspace, no tab), and that row was never seen, so it was reported missing on every reconcile.
- One accepted membership: the row resolves to the membership view.
project()reuses the preview through the membership branch ofattachRemoteView, which requests the next reconcile: the same spin. - Otherwise: the row can't be resolved, so every reconcile fails the workspace. Validation run 36726041181 showed this on the first fix alone:
CloudWorkspaceLiveProjectionTests"Cloud refresh and reconnect preserve local Desktop and port splits" failed at:98(closed.isEmpty) and:100(appliedLayouts) for all four arguments.
Change
missingis computed fromseenagain, andsatisfiedis removed. Everythingsatisfiedheld was also inserted intoseen.- A local preview marks its own workspace row as seen again, next to the membership views #15748 added. The branch comment already said so: "It satisfies its desired workspace row".
- The existing plan tests are unchanged.
Two plan tests cover the regressions, and each was committed before its fix:
- Red, test commit a8a0094c3e2: this PR's
swift-package-testsjob failed withCloudWorkspaceProjectionPlanTests.swift:118:9: Expectation failed: (plan.missing โ [...]), and the other 221 tests passed. - Green, fix commit 8816493d733: this PR's package tests passed.
- Red,
localDisplayPreviewSatisfiesItsWorkspaceRowalone (6131848bd3c): this job failed at:88for both variants, a preview with and without a membership row. - Green, fix commit 1b8d62a7ae3: this PR's package tests on the head commit. The Cloud app-host suites that hung or failed run in the #15488 full-suite validation.
Changelog
- Fixed: Cloud workspaces no longer freeze the app or fail to refresh when they already show terminal tabs, Desktop previews or port previews.
๐ค Generated with Claude Code