Open dropped Cloud terminals optimistically
Summary
Dragging a Cloud terminal row into a local workspace stalled until the machine answered: Workspace.handleSurfaceResourceDrop projected the group without an optimistic host, so the pane was created only after the provider's link and surface-resolution round trips. The explicit "open here" action already reserved panes; the drop did not.
Drops now use the same reservation owner (Workspace.reserveCloudTerminalPane). Each Cloud terminal gets its pane at the drop spot at once, showing the connecting state, with its projection recorded under the stable terminal and tab ids. The provider then adopts that same pane (materialize(…, adopting:)), so reconciliation never adds a tab or pane. Displays and browsers keep their immediate connecting pane, and a whole-workspace drop no longer waits on its first terminal before the rest appear.
- Rollback: a failed or stale attach, a delete in flight, sign-out, a team switch or a replaced provider removes only the dropped pane and restores the layout, tab selection and focus captured at drop time. A sibling from the same drop that attached keeps its place. Late replies are fenced by reservation identity and provider identity, so they never bring a pane back.
- Idempotency: a Cloud placement already open in the target workspace, pending or attached, is focused instead of opened again. Resources on this Mac are exempt, because dropping them moves their one pane.
- Unchanged: explicit open-here/split, terminal-row navigation and display actions keep their destinations. Open-here now shares the per-member reservation loop, so a mixed group's terminals appear immediately there too.
Trade-offs:
- A dropped terminal attaches once. Any failure rolls it back, including a transient link error. It doesn't retry or show Reconnect the way restored panes do. As before, the drop path reports failures only in the debug log.
- Dropping a Desktop the workspace already shows now focuses that view instead of creating a second one.
CloudDesktopOpenActionTestsasserted the old behavior and is updated. - In a Cloud-bound workspace, dropping a terminal from another remote workspace starts the remote tab move when the pane is admitted, concurrently with the attach. This matches explicit open-here today.
Closes #15910
CI repairs
Merged origin/main at 90e1689ffc9d and imported the existing test-target repairs from #16306 with their original authorship. These fix the VM poll-policy test's target, the mutating Swift Testing assertion, and the CLI hook recovery test harness. The merge also keeps a single pane-resize controller binding.
At baaf96e27c, CI run 36811287794 passed macOS compile admission and Swift package tests. App-host shards and CLI tests are still running; this is not yet an all-green result. Local python3 scripts/verify-local.py passed all 16 selected checks. No native tests ran locally.
Independent correctness review of f53be4c80bf..baaf96e27c found no actionable issues. The optional canonical autoreview helper timed out twice with a process-cleanup permission error and did not produce a passing receipt. All eight GitHub review threads were resolved at this push.
Testing
Focused regression suite cmuxTests/CloudSurfaceDropOptimisticTests (new), using a provider whose attachment the test releases. It covers:
- The pending pane and its stable-id projection existing before the machine answers, for both split and tab drops.
- In-place adoption.
- Rollback with layout and selection restore on failure, on a stale reply and on sign-out, including a late answer arriving after the rollback.
- Repeated drops while the pane is pending and after it attaches.
- A whole-workspace drop reserving every terminal.
- A partial failure keeping its attached sibling.
- Local resources never being reused.
CloudDesktopOpenActionTests covers the idempotent Desktop drop.
- Red:
451ba79990772b9c83041ec87d805c2e85ed8b01on15910-red-proofis current main plus only the test changes. Run 36715153727 executed 13 tests in 2 suites and failed with 29 issues, all on the expected symptoms. No pending reservation exists before the machine answers. A failed or stale attach is not rolled back (the stale reply left 3 panes, against 1 expected). Sign-out leaves the pane. A whole-workspace drop reserves 0 terminals. Dropping an already-open Desktop opens a second view. - Green: head
950fc92b03e693b36b143c41644526ccddd98836, run 36734714091.CloudSurfaceDropOptimisticTestspassed all 13 cases in 4.5 s, including every split and tab variant.CloudDesktopOpenActionTests,CloudNativeLayoutProjectionTestsandCloudSurfaceOwnershipTestspassed. TwoCloudWorkspaceRowOpenTestscases (row click, not drop) hit their 120 s limit while awaitingSurfaceCatalog.project(...), and the suite's other cases passed after the host relaunched. That matches the pre-existing wedge in #16020, which is seen on unrelated PRs. This PR callsprojectGroupwithout an optimistic host on that path, and there the loop is behavior-identical to main. - Local:
python3 scripts/verify-local.py(wire-app-sources, test-wiring, feature-flags) and--only swift-syntax --swift-changedpass.scripts/swift_file_length_budget.pypasses. No local native build was run. - Not dogfooded in a tagged build yet.
Localization: no user-facing strings added.
Changelog
Fixed: Dragging a Cloud terminal or display into a workspace shows it immediately while it connects, removes it cleanly if the connection fails, and focuses it instead of duplicating it when it's already open there.
🤖 Generated with Claude Code