fix: eliminate Ghostty terminal typing lag
Summary
- keep the new Ghostty renderer scheduler, lifecycle publication, redraw delivery, and owned-userdata lifetime work
- restore round-robin selection inside the exact-slot frame-lease pool so low-rate terminal frames present distinct IOSurfaces
- bypass cmux global shortcut/focus resolution for ordinary modifier-free text already owned by Ghostty
- preserve the text-box double-Escape state machine on that typing fast path
Regression result
The bad nightly was built from https://github.com/manaflow-ai/cmux/commit/8f1a959695ec32dd641f7a55c3fb39d13d3f1815 via https://github.com/manaflow-ai/cmux/actions/runs/30065496498.
The remaining macOS culprit is https://github.com/manaflow-ai/ghostty/commit/8c645641a1dd1cbff9aa73189629682c01b1a233 (embedded: add leased external Metal frames). That commit correctly replaced a counting semaphore with exact-slot ownership, but its first-free scan always began at slot zero. At human typing rates, each Metal frame can finish before the next key; every redraw then reacquires slot zero and assigns the same IOSurface object. The IOSurface content seed advances, but Core Animation can deduplicate the same-object contents assignment, so text waits for unrelated layer activity and appears in a burst.
The earlier bounded-mailbox and lifecycle work remains valid hardening, but it was not the complete explanation for this macOS symptom.
Fix
https://github.com/manaflow-ai/ghostty/pull/145 rotates the free-slot scan cursor after every successful acquisition. This changes only the choice among currently free slots: exact-slot ownership, generation tokens, out-of-order release safety, FIFO scheduling, and semaphore backpressure remain intact. A serial producer now cycles 0,1,2,0 instead of reusing 0,0,0,0, forcing Core Animation to observe distinct presentation identities.
The cmux shortcut fast path still avoids browser, palette, workspace, and keyboard-layout work for plain Ghostty text. It now returns the already-resolved window TabManager, so typing can clear the focused terminal text-box Escape arm without re-entering global shortcut-context resolution.
Final Ghostty pin: 50ad1963d9c73ee957932ccb4d26bf6d15575ee7
Verification
- frame-lease red: https://github.com/manaflow-ai/ghostty/commit/3a43d5edc fails the serial-frame assertion on frame two with
expected 1, found 0 - frame-lease green: https://github.com/manaflow-ai/ghostty/commit/fcafac572 passes the assertion and the filtered Ghostty run (73/73 tests)
- Ghostty integration and review: https://github.com/manaflow-ai/ghostty/pull/145 is merged, checks are green, and structured review reported no findings
- exact bad-build observation: successive terminal frames reused one IOSurface pointer while only its seed advanced
- terminal shortcut-routing red: https://github.com/manaflow-ai/cmux/actions/runs/30124996534
- terminal shortcut-routing green: https://github.com/manaflow-ai/cmux/actions/runs/30127199427
- text-box Escape-arm red: https://github.com/manaflow-ai/cmux/actions/runs/30128961587
- text-box Escape-arm green and exact-head terminal fast-path suite: https://github.com/manaflow-ai/cmux/actions/runs/30131336401
- exact-head tagged dev build: https://github.com/manaflow-ai/cmux/actions/runs/30131425653
No user-facing strings changed. Localization audit: no user-facing surfaces were added or modified. No Swift budget TSV was changed; this checkout and current main do not contain the requested Swift file-length budget script/TSV.
Closes #8808