Skip to content

refactor(tui): use Latch for renderer shutdown gate - #43572

Merged
kitlangton merged 1 commit into
v2from
latch-tui-shutdown
Aug 20, 2026
Merged

refactor(tui): use Latch for renderer shutdown gate#43572
kitlangton merged 1 commit into
v2from
latch-tui-shutdown

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

The TUI's renderer shutdown signal is a Deferred<unknown> completed once with Effect.void when the renderer emits destroy — the value is never consumed, and the <unknown> type parameter obscures that. It is a pure "renderer destroyed" gate, which is exactly what Latch expresses.

How

packages/tui/src/app.tsx:

  • shutdown is now yield* Latch.make() (starts closed).
  • renderer.once("destroy", ...) calls shutdown.openUnsafe() instead of Deferred.doneUnsafe(shutdown, Effect.void).
  • The single waiter uses yield* shutdown.await.

No behavior change. Found by a repo-wide audit of Deferred<void>-as-gate patterns; sibling PRs convert the other pure-gate sites.

Testing

  • packages/tui: bun typecheck; bun test test/app-lifecycle.test.tsx (5 pass, exercising the destroy → shutdown path); full bun run test (738 tests, 0 fail).

@kitlangton
kitlangton enabled auto-merge (squash) August 20, 2026 15:37
@kitlangton
kitlangton merged commit ad7ebe8 into v2 Aug 20, 2026
10 checks passed
@kitlangton
kitlangton deleted the latch-tui-shutdown branch August 20, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant