opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(tui): normalize animated terminal output in bash tool

Open R44VC0RP opened this issue 1 month ago • 0 comments

Collapse spinner frames, progress bars, and status indicator lines that share the same base text to show only the latest frame. This prevents the TUI from displaying hundreds of redundant spinner animation frames when running CLI tools like ora or clack.

  • Add normalizeTerminalOutput utility to process terminal output
  • Strip ANSI codes before normalization for reliable detection
  • Handle carriage returns, spinner prefixes, progress bars, and dots
  • Track base text across lines with animated prefixes to collapse them

Before:

https://github.com/user-attachments/assets/7b8c4e11-f16d-4728-85f5-2a750fdd64c6

After:

https://github.com/user-attachments/assets/7b47d3ec-5f27-4b20-be7a-dfe27a756773

Reasoning:

For some CLI commands that show loading animations and such, it can lead to excess token consumption and it just breaks flow when looking at all of the animation styles streaming down.

Still a WIP, since we have a small graphical bug that causes a weird layout shift, almost an optimistic newline.

OC Session:

https://opncd.ai/share/9NfGjrUS

R44VC0RP avatar Dec 13 '25 15:12 R44VC0RP