Skip to content

[Windows] Raw ANSI escape codes printed after Ctrl+C exit #13301

Closed

Description

@j-token

Description

On Windows, pressing Ctrl+C to exit the application causes raw ANSI escape sequences (color codes) to be printed to the terminal after the process terminates. Exiting via the exit command works cleanly without this issue.

Root Cause

The @opentui/core renderer registers SIGINT (and other signal) handlers by default via addExitListeners(). On Windows, the app disables ENABLE_PROCESSED_INPUT so that Ctrl+C is delivered as a keyboard event instead of a signal. However, a race condition exists in the 100ms polling guard — Bun's runtime can momentarily re-enable the flag between polls. When Ctrl+C is pressed during this window, it generates SIGINT instead of a keyboard event, and opentui's handler calls renderer.destroy() directly, bypassing the app's graceful exit flow (process.exit, unguard, worker shutdown).

Steps to reproduce

  1. Run opencode on Windows (PowerShell or Windows Terminal)
  2. Press Ctrl+C to exit
  3. Observe raw ANSI escape codes printed in the terminal after exit

Expected behavior

The application should exit cleanly without printing any ANSI escape codes, the same as when using the exit command.

OpenCode version

v1.1.60

Operating System

Windows 11

Terminal

Windows Terminal / PowerShell

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Feb 12, 2026
  2. github-actions commented on Feb 12, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These issues all describe similar symptoms of raw ANSI escape codes being printed to the terminal after Ctrl+C on Windows, which may be the same underlying bug with different manifestations.

  3. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentuiwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions