[PR #13329] fix(win32): clean up TUI screen on Ctrl+C exit #14618

Closed
opened 2026-02-16 18:19:23 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13329

State: closed
Merged: No


Summary

Builds on @j-token's exitSignals: [] fix from #13298. After Ctrl+C, the TUI screen content remained visible in the terminal instead of being cleaned up. Fixes #13301, #12939.

Three changes:

  1. exitSignals: [] (app.tsx) — prevent opentui from registering signal handlers that race with the win32 Ctrl+C guard (from #13298).
  2. Terminal restore on graceful exit (exit.tsx) — after renderer.destroy(), wait 50ms for the zig render thread to finish its final frame, then write \x1b[?1049l\x1b[2J\x1b[H\x1b[?25h\x1b[0m via writeSync to exit alternate screen, clear the viewport, and restore cursor.
  3. SIGINT handler (app.tsx) — catch Ctrl+C arriving as signal (win32 guard race condition) and write the same terminal restore sequences before process.exit(0).
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13329 **State:** closed **Merged:** No --- ## Summary Builds on @j-token's `exitSignals: []` fix from #13298. After Ctrl+C, the TUI screen content remained visible in the terminal instead of being cleaned up. Fixes #13301, #12939. Three changes: 1. **`exitSignals: []`** (`app.tsx`) — prevent opentui from registering signal handlers that race with the win32 Ctrl+C guard (from #13298). 2. **Terminal restore on graceful exit** (`exit.tsx`) — after `renderer.destroy()`, wait 50ms for the zig render thread to finish its final frame, then write `\x1b[?1049l\x1b[2J\x1b[H\x1b[?25h\x1b[0m` via `writeSync` to exit alternate screen, clear the viewport, and restore cursor. 3. **SIGINT handler** (`app.tsx`) — catch Ctrl+C arriving as signal (win32 guard race condition) and write the same terminal restore sequences before `process.exit(0)`.
yindo added the pull-request label 2026-02-16 18:19:23 -05:00
yindo closed this issue 2026-02-16 18:19:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14618