Revert owned userdata leasing and restore synchronous teardown
Reverts https://github.com/manaflow-ai/ghostty/pull/140 while preserving the bounded renderer drain from https://github.com/manaflow-ai/ghostty/pull/135 and https://github.com/manaflow-ai/ghostty/pull/136 that fixes https://github.com/manaflow-ai/cmux/issues/8808.
PR 140 changed the embedder contract by adding atomic userdata leases around every host callback. That broad ownership layer is unnecessary if ghostty_surface_free keeps its established contract: stop renderer and IO callbacks synchronously before returning.
This PR restores borrowed callback userdata, keeps an outer surface allocation alive only for an in-flight app action, and always tears down the live core synchronously. The regression test is a separate commit before the fix.
Validation:
- Zig 0.15.2 formatting passed on a 48 GB fleet Mac
- focused embedded teardown, action lifetime, and redraw tests passed
- full GitHub checks required before merge
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Reverts owned userdata leasing and restores synchronous surface teardown. ghostty_surface_free now stops renderer and IO before returning and serializes teardown with cross-thread actions, while keeping the bounded renderer drain that fixes cmux issue 8808.
-
Bug Fixes
- Teardown is synchronous and waits for actions running on other threads before destroying core state.
- Reentrant free on the action thread skips the wait; only the outer allocation is retained until the callback returns.
- Keeps PTY tee callback fields synchronized with the IO setter.
- Adds tests for retained-action teardown and cross-thread free during redraw.
-
Migration
- Removes
ghostty_userdata_release_cbandghostty_surface_new_with_owned_userdatafrom the C API. - Use
ghostty_surface_newand manage callbackuserdatayourself. - Callbacks now receive the original
userdatadirectly; no internal leases.
- Removes