Input sometimes starts to only show ASCII escape codes
Description
Even mousing over will cause the input to fill
OpenCode version
1.0.34
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
MacOS Tahoe 26.1
Terminal
Ghostty 1.2.3
This issue might be a duplicate of existing issues. Please check:
- #457: Scroll down -> get ascii coded into input (same symptom of ASCII codes appearing in input)
- #2593: [bug] opencode produces gabled text when input containing non-ascii characters (related character encoding issues)
- #4320: Characters are encoding gibberish all over the frontend (broader character encoding problem)
Feel free to ignore if none of these address your specific case.
Having same issue on Windows both in git bash and powershell using both the new Windows terminal and built in VS Code terminal
You are mentioning version 1.0.34, which had that issue, is that a typo in the version or can you upgrade to the latest version, which is quite ahead?
It's version 1.0.134
What command are you running to get this?
It happens when the opencode memory grows crazy high. 10s of GBs. There's no specifc command, if I run for 3 - 4 hours of work it'll happen every time
But that doesn't look like opencode?
Edit: Sorry I meant what @vruss posted doesn't look like opencode.
@bcardarella So the actual issue is memory pressure and the process getting killed, which doesn't reset the terminal, stdin staying in raw mode with mouse capturing enabled, ending up in the spilled escaped sequence issue.
Can you run with opencode spawn, which separates the server and TUI in own processes. Then when the high memory usage happens, could you check which of the processes has the high memory usage? On macos you can run ps -axww -o pid,ppid,command | grep opencode which should give you something like this:
Where the second process 19989 is the TUI, so you can lookup which process actually has the high memory usage. That would help diagnosing if it is an agent or TUI issue.
Will do!
But that doesn't look like opencode?
Edit: Sorry I meant what @vruss posted doesn't look like opencode.
Oh I forgot to mention it happens after I exit opencode with ctrl+c. Then that terminal window is bugged and keep spewing characters as I move my mouse aroudn until I close it.
Steps to reproduce for me:
- Start opencode from terminal
- Type any prompt
- Kill process with ctrl+c
- Now mouse will enter stuff in terminal, if not, then repeat step 1-3
I just did that like 50 times with PowerShell 7.5.4 on win11 and it exits cleanly with ctrl+c. It definitely looks like windows is shutting down the process before any cleanup can happen. The signal seems to be fine, just SIGINT for ctrl+c. Maybe windows/bun has a limit in which a process needs to be shut down after the signal and if it is too slow it will not get to the cleanup part. I can try moving the the terminal cleanup up front before other shutdown stuff so it happens as the first thing when a signal is received. I'll try that tomorrow and give you a snapshot to test.
Ok thank you @kommander ! Just some some more context. I tried this in Alacritty and WezTerm too, with powershell and gitbash as shell and they all have the same behavior.