macOS: Terminal becomes unusable after opencode exits ("dead terminal") #4774

Open
opened 2026-02-16 17:45:23 -05:00 by yindo · 4 comments
Owner

Originally created by @RandyMcMillan on GitHub (Jan 11, 2026).

Originally assigned to: @kommander on GitHub.

Description

When running opencode on macOS and exiting (Ctrl+C, closing terminal, or normal exit), the terminal is left in an unusable state with scrambled output, requiring users to manually reset it with reset command or reopen terminal.

Expected Behavior:
Terminal should be restored to a usable state when opencode exits.

Actual Behavior:
Terminal is left in a corrupted state with:

  • Scrambled text output
  • Unresponsive input
  • Cursor positioning issues
  • Requires manual reset command
    Environment
  • OS: macOS (any version)
  • Terminal: Terminal.app, iTerm2, ...
  • opencode version: [current]
    Additional Context
    This appears to be related to terminal escape sequences and alternate screen buffer management not being properly cleaned up on exit.

Plugins

No response

OpenCode version

No response

Steps to reproduce

  1. Run opencode on macOS (Terminal.app, iTerm2, ...)
  2. Use the application normally
  3. Exit opencode using Ctrl+C or normal exit
  4. Terminal becomes corrupted/unresponsive

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @RandyMcMillan on GitHub (Jan 11, 2026). Originally assigned to: @kommander on GitHub. ### Description When running opencode on macOS and exiting (Ctrl+C, closing terminal, or normal exit), the terminal is left in an unusable state with scrambled output, requiring users to manually reset it with `reset` command or reopen terminal. Expected Behavior: Terminal should be restored to a usable state when opencode exits. Actual Behavior: Terminal is left in a corrupted state with: - Scrambled text output - Unresponsive input - Cursor positioning issues - Requires manual `reset` command Environment - OS: macOS (any version) - Terminal: Terminal.app, iTerm2, ... - opencode version: [current] Additional Context This appears to be related to terminal escape sequences and alternate screen buffer management not being properly cleaned up on exit. ### Plugins _No response_ ### OpenCode version _No response_ ### Steps to reproduce 1. Run opencode on macOS (Terminal.app, iTerm2, ...) 2. Use the application normally 3. Exit opencode using Ctrl+C or normal exit 4. Terminal becomes corrupted/unresponsive ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the opentuibug labels 2026-02-16 17:45:23 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

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

  • #5990: Bug: Ctrl+C interruption in opencode causes terminal corruption with ANSI escape sequences (Windows)
  • #6912: Ctrl+C does not disable mouse tracking, causing raw escape sequences to flood terminal (Windows)
  • #7062: Pressing Ctrl+C in input field outputs ANSI escape sequences/garbled text

These issues describe very similar terminal corruption/scrambling when exiting opencode. While those focus on Windows and specific Ctrl+C handling, they may share the same root cause related to terminal escape sequence cleanup on exit.

Feel free to ignore if your case is specifically different from these.

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be a duplicate of existing issues. Please check: - #5990: Bug: Ctrl+C interruption in opencode causes terminal corruption with ANSI escape sequences (Windows) - #6912: Ctrl+C does not disable mouse tracking, causing raw escape sequences to flood terminal (Windows) - #7062: Pressing Ctrl+C in input field outputs ANSI escape sequences/garbled text These issues describe very similar terminal corruption/scrambling when exiting opencode. While those focus on Windows and specific Ctrl+C handling, they may share the same root cause related to terminal escape sequence cleanup on exit. Feel free to ignore if your case is specifically different from these.
Author
Owner
@RandyMcMillan commented on GitHub (Jan 11, 2026): https://github.com/anomalyco/opencode/issues/7861#issuecomment-3735747358 [https://github.com/anomalyco/opencode/pull/7860/files#r2680287550](https://github.com/anomalyco/opencode/pull/7860/files#r2680287550)
Author
Owner

@kommander commented on GitHub (Jan 12, 2026):

Is that happening when exiting with ctrl+c from the error boundary screen or just always? This only has been an issue on windows so far.

@kommander commented on GitHub (Jan 12, 2026): Is that happening when exiting with ctrl+c from the error boundary screen or just always? This only has been an issue on windows so far.
Author
Owner

@RandyMcMillan commented on GitHub (Jan 12, 2026):

I will attempt to do a deeper investigation into open-tui. Maybe the appropriate fix needs to be there.

I am not setup to debug in Windows.

@RandyMcMillan commented on GitHub (Jan 12, 2026): I will attempt to do a deeper investigation into open-tui. Maybe the appropriate fix needs to be there. I am not setup to debug in Windows.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4774