cmux NEXT Cloud: terminals and VM-port browser tabs come back working

AU
3d ago
+1065-129

Fixes #25595

Cloud terminals and VM-port browser tabs recover after a link drop or a relaunch. Terminal input uses a separate link lane from bulk output and browser traffic, and terminal reattachment no longer waits for an echo that the daemon does not send.

What changed

  • Use --lanes auto for the Cloud link, retaining the transport's single-link fallback.
  • Count the replay grid as announced when reattaching a terminal, so a claim of that size needs no further echo.
  • Retry failed machine-list reads with the existing capped retry policy; reset the budget when the account changes. Preserve the base's connection/read ordering fences.
  • Reload remote-localhost pages that received “not connected” when their machine reconnects. Restore Cloud proxy tabs lazily and refresh stale routes with backoff.
  • Require a connected daemon before automatic route refetch. Cached running/paused records can lag, so background page traffic must not resume a disconnected VM.
  • Keep a blocked proxied tab blank when its proxy cannot start, preventing fallback to this Mac's localhost.
  • Move shared browser-route validation into CmuxNextRemoteLocalhostService, preserving limits, refusal codes, hashing and page-origin authorization while reducing app-layer code.

App-link proxy routing remains opt-in with CMUX_NEXT_CLOUD_LINK=app.

No capture: no visible UI change. This changes link arguments, attachment bookkeeping, retries and routing; a still image does not demonstrate recovery.

Defaults chosen

  • Lanes auto: the transport binds lanes to one link when parallel links are unavailable.
  • List retry: 10 timed tries, starting at 1 s and capped at 30 s. After exhaustion, activation, wake or a mutation can trigger another read.
  • Automatic browser-route refetch requires the app link and connected daemon; it does not rely on the cached machine status to authorize a resume.

Tests

The focused regression command is scripts/ci/package-test-lane.sh suite Packages/macOS/CmuxNext CloudBrowserRefetchGateTests, run through cmux-ci run --class light with Xcode 26.6. Test-only commit 51bccc95bf368559b264dff9b985587bee9bff63 failed for a stale running record with a disconnected daemon (fleet step 662a03f5779f567f9b32b362: four parameter cases, one behavioral failure). Repair c1803e2cb76d93c87a68fd226f02c44456203f37 requires the connection; the same regression and ten related Cloud/terminal suites passed at b69a7dddee72f01c0d7452c2ce31a44dc79b4788 (step fb7653d89227a00b41cd66b6). Both connected-daemon cases remain allowed even when the cached record says paused.

Observed / Not run

  • Current head: adaeb284f15c9e39805ec168fa3dea53cd415e1b, including merged base 9b6c218145c02320c5edb61a8b92cbb0911a2d66. The PR's own 21-file diff is unchanged, and git show --remerge-diff is empty.
  • Passed on this head: the static prepush gate, fleet Debug app compile 96b3afb97acc7f9efe2faf52 (58 s), Release recipe-v2 app compile ffbac7dfb75b5e01be698f3f (120 s; unrelated Rust check omitted), and fresh independent correctness-first review.
  • The release-notary guard failure is inherited. The repository base-red classifier confirms the same two signing-runner fallback failures on feat-cmux-next run 41168976072 at 0b855de498. The workflow and those tests are outside this PR's diff.
  • Passed on this head: all 13 focused test filters in fleet step 2b1a5e4f9f3b046cf51278bf (exit 0, completed 2026-10-31 05:47 UTC). Each filter actually executed Swift Testing cases, covering terminal reattachment, Cloud link lanes/reconnection, machine-list retry, browser route/refetch/restore, idle pause, session start and browser-open security.
  • Earlier terminal regression: test-only e5019c1a7991d failed TerminalReattachEchoTests.theReplaysGridCountsSoAClaimOfThatSizeWaitsForNoEcho with echoesDue == [120x40] and announcedSize == nil; affected suites passed at 8a1e4ee0b7392588656dfbfa13c0c1b8ce99b41d (step 102c386d9a1caef97d42dc43).
  • Not run: live Cloud VM dogfood for resize, idle pause, link loss or relaunch with a VM-port tab open. AppServices.configureBrowser and the StrandedPageReload observation loop have not been exercised end to end. No current-head tagged dogfood build has been produced; this pass used fleet compile and focused test jobs.

Changelog

  • Fixed: Cloud terminals stay responsive while browser tabs load machine ports, resize promptly after reconnecting, and Cloud workspaces and machine-port tabs recover after a relaunch or a dropped link.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.