opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Input sometimes starts to only show ASCII escape codes

Open bcardarella opened this issue 1 month ago • 12 comments

Description

Image

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

bcardarella avatar Dec 06 '25 23:12 bcardarella

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.

github-actions[bot] avatar Dec 06 '25 23:12 github-actions[bot]

Having same issue on Windows both in git bash and powershell using both the new Windows terminal and built in VS Code terminal

Image

vruss avatar Dec 08 '25 06:12 vruss

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?

kommander avatar Dec 08 '25 13:12 kommander

It's version 1.0.134

bcardarella avatar Dec 08 '25 14:12 bcardarella

What command are you running to get this?

kommander avatar Dec 08 '25 14:12 kommander

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

bcardarella avatar Dec 08 '25 14:12 bcardarella

But that doesn't look like opencode?

Edit: Sorry I meant what @vruss posted doesn't look like opencode.

kommander avatar Dec 08 '25 14:12 kommander

@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:

Image

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.

kommander avatar Dec 08 '25 15:12 kommander

Will do!

bcardarella avatar Dec 08 '25 15:12 bcardarella

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:

  1. Start opencode from terminal
  2. Type any prompt
  3. Kill process with ctrl+c
  4. Now mouse will enter stuff in terminal, if not, then repeat step 1-3 Image

vruss avatar Dec 09 '25 00:12 vruss

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.

kommander avatar Dec 09 '25 01:12 kommander

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.

vruss avatar Dec 09 '25 05:12 vruss