Comment by dizhn

6 days ago

Opencode had the same flickering issue not too long ago and they fixed it by switching from ink to opentui if I am not mistaken. So a solution is possible and known. Antropic just doesn't seem to care.

OpenCode, and all these other AI consoles, all do terminal I/O in the dumbest way possible.

A good terminal program, like Emacs, uses escape sequences to create viewports, scroll text, etc. These sequences tell the terminal to do these things internally.

All the modern AI tools ignore these escape sequences (which they wouldn't even have to know if they used ncurses) and just do frame-by-frame animation. So when OpenCode wants to scroll text, first it sends the text to the screen, then it sends ^[[1;1H and sends the whole text again, minus the first line or so, adding a new line to the bottom. Then it sends ^[[1;1H again, and sends the whole text AGAIN, cutting another line from the top, and adding another new one to the bottom. As if the terminal was a graphics device and you had to draw each frame.

The flickering was probably due to sending ^[[2J to clear the screen before "drawing" each "frame."

I oversimplified, though. OpenCode sends hundreds and hundreds of cursor-positioning escape sequences per "frame" of "animation".

Even though it doesn't flicker anymore, "drawing frames" makes the scrolling noticeably slow and choppy if you run OpenCode (or any other terminal-based AI agent) on a different machine than the one your monitor is plugged into, even on a wired LAN.

No AI model can give a believable explanation of why these apps (or their TUI libraries) are written this way.

Docker also does this, and it drives me mad.