renderer: harden bounded drains for external rendering

Merged
LA
4mo ago
+202-24

Summary

Austin Wang's https://github.com/manaflow-ai/ghostty/pull/135 bounds normal renderer mailbox turns and fixes the continuous-output latency regression from https://github.com/manaflow-ai/cmux/issues/8808.

This follow-up closes the external-rendering and error-path gaps found during review:

  • drain one finite mailbox snapshot per synchronous render, then render immediately
  • retain remaining work through the existing app-mailbox .render action instead of spinning until empty
  • convert external xev wakeups into unconditional embedder render requests so coalescing cannot drop work
  • preserve failed lifecycle requests without overwriting newer publications
  • recheck work published during normal rendering before deciding whether to notify again
  • make focus application transactional so a retry is not suppressed

The normal mailbox batching implementation from https://github.com/manaflow-ai/ghostty/pull/135 remains unchanged.

Tests

On the exact PR head with Zig 0.15.2:

  • synchronous renderer drains one finite batch and retains continuation
  • synchronous renderer retains continuation after drain error
  • surface lifecycle retry restoration preserves newer publications
  • surface lifecycle state bypasses a full renderer mailbox and keeps latest values
  • visibility regain suite

The focused suite passes on cmuxs-mac-mini-3.1, a 48 GB fleet Mac running macOS 26.5.

Fixes the remaining external-render correctness gap exposed while investigating https://github.com/manaflow-ai/cmux/issues/8808.