feat: prewarm selected Cloud machines while typing

Merged
TE
2d ago
+571-24

Closes #34828.

Cloud composer typing now sends a passive prewarm hint for the existing chat machine. A fresh Cloud composer draft also prewarms an explicitly selected existing account machine on its first non-empty edit, before a session exists. This covers both the chat composer and New Tab. Choosing a local project, machine, saved environment, or run mode clears the old target. A separate reconnect gate suppresses typing hints while preserving wake-and-send recovery and pending destination selection.

This follows Leo's Ramp Inspect direction: “Warm on typing: when the user starts typing in a Cloud composer in cmux-next, send a wake/prewarm hint so the machine resumes before send.”

The hint is best effort: it creates no machine or chat and never delays typing or Send. Pending hints deduplicate; accepted hints refresh after two seconds; refused hints retry on the next edit. There is no timer or background observer. A brand-new Run as Cloud draft still allocates on Send. This PR carries the native route from #34522 and its repair: a passive start does not install an optimistic transition, and an explicit user connect survives an authoritative starting record and reports provider failures. Reverting this PR removes the passive typing prewarm integration.

Performance:

metricbeforeafterdeltaharness or run link
synthetic first-keystroke to daemon-ready p506,469 ms5,134 ms−1,335 ms (−20.6%)HQ protected Cloud readiness probe; 3 paired samples, fixed 2 s typing baseline
synthetic first-keystroke to daemon-ready p9511,882 ms5,877 ms−6,005 ms (−50.5%)Same paired probe and sample set
first non-empty edit emits a prewarm hint for a fresh or missing-session selected Cloud machine01+1cloudTypingPrewarm.test.ts deterministic bridge-port harness

Prior art: merged #35170 (8308dd572c48c2bf9ced61aa22a252af8b837329) added the user-gesture optimistic wake callback. The merge preserves that callback beside the passive prewarm hint, and retains its tests.

The p50/p95 values cover the complete Ramp Inspect change set in a synthetic daemon-readiness probe with a fixed 2 s typing baseline and three paired samples. They are not native-composer or full-chat latency measurements.

Validation at a6dd6fba3fa4a2d1cd74e8a2644ca6e8542605ae: Claude Opus 5.5 medium review returned SHIP. Fleet run 41820403960 passed bun run check and all 51 focused Cloud/New Tab tests (0 failures); its source tree 4e33f02bc9c227b94d4d1245d0d516363358ac77 matches the reviewed head. Fleet compile job f9b3f806a5b72faa42b01ad4 completed successfully with app and bundled Rust compile receipts at the same head. git diff --check passes. The normal PR webview shards and base replay are running in CI 41820415416, restored with one owner close/reopen after the head initially received no pull-request CI event. No code or reviewed-head change was needed. The selector probe red is unchanged from base (the affected source, rule and selector table are identical); the advisory gallery metadata update failed on an installation API quota error.

🤖 Generated with Codex

Agent session: agent session