opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Screen flickering/vibrating on diff views in v1.0.120, causes PTY host crash

Open wthrbtn opened this issue 1 month ago β€’ 14 comments

Description

Screen flickering/vibrating when viewing file diffs in v1.0.120. The display constantly repaints causing a "vibrating" visual effect on diff views (Edit tool output).

This occurs after prolonged use of a session, not immediately. After the flickering starts, it leads to:

  • All OpenCode terminal windows in VSCode becoming unresponsive
  • Yellow PTY host error: "Restarting the terminal because the connection to the shell process was lost"

Regression: Issue does not occur in v1.0.119. Rolling back to v1.0.119 resolves the problem.

Likely cause: Commit 52deb7f35 ("opentui diffs") which:

  1. Upgrades @opentui/core from 0.1.50 to 0.1.51
  2. Replaces custom diff rendering with new native <diff> component

v1.0.120 (broken) v1.0.119 (works)

OpenCode version

1.0.120

Steps to reproduce

  1. Run OpenCode v1.0.120 in VSCode terminal
  2. Use for an extended session with multiple edits/diffs
  3. Eventually screen starts flickering/vibrating on diff output
  4. Terminal hangs and PTY host error appears

Screenshot and/or share link

I have tried to reproduce this on demand but cannot - will add a screen recording if possible when it occurs again.

Operating System

macOS 26.1 (Tahoe)

Terminal

VSCode integrated terminal zsh

wthrbtn avatar Nov 29 '25 18:11 wthrbtn

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

  • #4818: Heavy CPU Usage and making my M1 mac laggy after updating (v1.0.119 - timing suggests related to the same upgrade cycle)
  • #4804: High CPU usage (general performance degradation on macOS)
  • #3822: Output starts to slow to a crawl (rendering performance issue in v1.0.15, similar symptoms of display lag)

While these issues may have different root causes, they all involve rendering performance degradation and CPU spikes after recent version updates. The flickering/vibrating behavior you're experiencing might be a visual manifestation of the same underlying rendering performance problem.

Feel free to ignore if your specific case with diff views and PTY crashes is distinctly different from these general performance issues.

github-actions[bot] avatar Nov 29 '25 18:11 github-actions[bot]

I have a vague idea where that could come from, but a screen recording of the kind of flickering would be really helpful.

Can you reproduce it when loading a large session and continuing maybe?

If you get it reproduced it would be really helpful if you could run it with OTUI_DEBUG_FFI=true, which creates a log in the cwd.

kommander avatar Nov 29 '25 19:11 kommander

https://github.com/user-attachments/assets/a5266f61-81d2-445b-9008-28609dc97079 @kommander I have a screen recording of a few seconds now on 1.0.121 The sessions is locked up flicker and after about 10 minutes it stopped and the Pty Host error came Sorry, forgot the OTUI_DEBUG_FFI on this. Will try again.

wthrbtn avatar Nov 30 '25 00:11 wthrbtn

Haha, I was also recording this now, and after the record it looked even worse. 🀣 (Fresh session; no -c here...)

Image

redtux avatar Nov 30 '25 00:11 redtux

started and resumed the session with OTUI_DEBUG_FFI=true and then scrolled up and it triggered on a side by side diff and got stuck - 218 MB - 3,355,681 lines - in a few seconds. Wow πŸ˜…

ffi_otui_debug_2025-11-30_00-31-20-773.log.gz

wthrbtn avatar Nov 30 '25 00:11 wthrbtn

I converted the captured video (1.0.121) to a gif also.

  • Note: the real flickering is much faster
  • It also occurs on 1.0.122

Image

wthrbtn avatar Nov 30 '25 00:11 wthrbtn

Hi, I also noticed this issue. In my case, it occurs when the terminal window is wide enough for the chat to display a side-by-side β€œ+ / –” comparison between two files. If the window isn’t wide enough, the two columns don’t appear β€” only a single modification view is shown β€” and in that situation, the flickering does not happen.

I was able to reproduce the problem every time a before/after file comparison was displayed.

tancou avatar Nov 30 '25 14:11 tancou

Hi, I also noticed this issue. In my case, it occurs when the terminal window is wide enough for the chat to display a side-by-side β€œ+ / –” comparison between two files. If the window isn’t wide enough, the two columns don’t appear β€” only a single modification view is shown β€” and in that situation, the flickering does not happen.

I was able to reproduce the problem every time a before/after file comparison was displayed.

In my case it doesn't happen with every diff. It seems to happen to me with every markdown diff (side-by-side), but the same agent called a subagent using many Typescript diffs, and there I didn't experience the issue. I also use zsh, in case this helps. I had the issue on two different machines (with Ubuntu and Debian Sid)...

redtux avatar Nov 30 '25 14:11 redtux

Can it be the sidebar messing with the width calculation, causing wrapping when the rendering is done, it's starting to flip/flop.

Screen Recording 2025-11-30 at 20.01.11.zip

rwese avatar Nov 30 '25 19:11 rwese

Can it be the sidebar messing with the width calculation, causing wrapping when the rendering is done, it's starting to flip/flop.

Screen Recording 2025-11-30 at 20.01.11.zip

I also have it with subagents where there is no sidebar on the right side. But I don't see this all the time, only with certain text. 🀷

redtux avatar Dec 01 '25 01:12 redtux

Should be better in 1.0.123

kommander avatar Dec 01 '25 01:12 kommander

Should be better in 1.0.123

Cool! Was the bug introduced by this change? https://github.com/sst/opentui/pull/358 Can you explain what this does? (The PR contains no information and I found no issue.) What is Claude Code's flicker feature? And why does this only affect markdown files? (And why only sometimes, and why does it not always crash when this happens?) Thanks!

redtux avatar Dec 01 '25 01:12 redtux

can you explain...

Well, yes the bug was introduced with the diffs, the diff view just didn't exist before that. That PR introduces the diff view.

The "cc flicker feature" is just a pun on the Claude Code flickering memes.

It did not only affect markdown files, it would affect all code with conceal highlights, where it removes for example markdown like **/__ etc. which changes the line width and therefor the wrapping, which in turn changes the height of the element, which triggers a layout pass, which makes the diff view rebuild, which sets the text again and causes another highlight pass... repeat indefinitely.

It only happened sometimes, because the width of the diff + text + highlights have to meet the conditions causing the concealed text to change height and trigger the layout pass + highlighting has to be slow enough to trigger another layout pass just after the last one.

The loop caused thousands of frame redraws per second, which overwhelmed the CPU and caused memory pressure - crash.

It did not always crash, because when the renderer is in live mode, running at a target frame rate, which opencode does when the loading indicator in the bottom left is running for example, frame requests that would be triggered by the endless loop would just be deferred to the next scheduled frame, mitigating the crash. Then when the diff goes out of view it is not rendered anymore, breaking the endless loop.

kommander avatar Dec 01 '25 02:12 kommander

Thanks for the explanation! Regarding "infinite loop", I have sessions where it could proceed without issues. When I scroll up, it flickers. When I stay there, it crashes. I liked the diff, and from time to time I also liked the party flickering mode. πŸͺ©πŸ•ΊπŸ“€

Edit: While I can confirm that this has been fixed (at least for me), I never experienced the exact same behavior as @wthrbtn.

Yellow PTY host error: "Restarting the terminal because the connection to the shell process was lost"

In my case the agent just froze or became unresponsive, but I always had to manually kill it then - which resulted in a bunch of numbers in the terminal at every hover or mouse-over (so I had to close the terminal window to totally kill the PTY process...).

redtux avatar Dec 01 '25 23:12 redtux

Hi, shouldn't this be closed as solved?

redtux avatar Dec 04 '25 22:12 redtux

closing

rekram1-node avatar Dec 04 '25 22:12 rekram1-node