You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Windows] Terminal left with raw ANSI escape codes after crash (PowerShell) #21277
When OpenCode crashes or exits unexpectedly on Windows (PowerShell), the terminal is left in a broken state showing raw ANSI escape sequences as literal text at the bottom of the screen, e.g.:
555;59;86m
The terminal cursor may also be hidden, requiring the user to close and reopen PowerShell to recover.
Environment
OS: Windows 10
Terminal: PowerShell 5.1
OpenCode version: 1.3.17
Install method: npm (npm install -g opencode-ai)
Expected behavior
On crash or unexpected exit, OpenCode should reset the terminal state (\x1b[0m, \x1b[?25h) before exiting, similar to how other TUI apps (e.g., vim, btop) handle SIGINT/panic cleanup.
Workaround
Wrapping the npm launcher (opencode.ps1) in a PowerShell try/finally block that runs [Console]::ResetColor() and Write-Host -NoNewline "$([char]27)[0m$([char]27)[?25h" mitigates the visible symptom but does not fix the root cause.
Suggested fix
In the crash/exit handler of the binary, add terminal reset before process exit:
Send \x1b[0m (reset all attributes)
Send \x1b[?25h (show cursor)
Call the platform terminal restore function if using a TUI library
If these existing issues cover your problem, please consider referencing them rather than opening a new one. If your issue is distinct (e.g., a regression or different scenario), please clarify the difference.
This problem hasn't occurred now, but I guess it's caused by insufficient memory. Because there are often many temporary files in the /tmp directory in my virtual machine, which takes up a lot of memory. Later, I paid more attention to the usage in the /tmp directory and cleared the cache, so it didn't appear again. @adminxxt
Activity
github-actions commentedon Apr 7, 2026
This issue might be a duplicate of existing issues. Please check:
If these existing issues cover your problem, please consider referencing them rather than opening a new one. If your issue is distinct (e.g., a regression or different scenario), please clarify the difference.
fix(tui): reset terminal state on crash/exit (Windows)
joket1999 commentedon Apr 8, 2026
The same with me. After upgrading to 1.4.0, the probability of crashing increased. It's practically unusable now. (I've posted this several times.)
OS: Ubuntu Server 24.04 LTS
OpenCode version: 1.4.0
Install method: npm (npm install -g opencode-ai@latest)
adminxxt commentedon Jun 18, 2026
Has it been resolved? How to solve @joket1999
joket1999 commentedon Jul 23, 2026
This problem hasn't occurred now, but I guess it's caused by insufficient memory. Because there are often many temporary files in the /tmp directory in my virtual machine, which takes up a lot of memory. Later, I paid more attention to the usage in the /tmp directory and cleared the cache, so it didn't appear again. @adminxxt
github-actions commentedon Sep 23, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.