Skip to content

[BUG] Screen flickering in iTerm2 during streaming output — clearScreenDown redraws #1348

@rameshreddy-adutla

Description

@rameshreddy-adutla

Describe the bug

Screen flickers aggressively while Copilot CLI is processing/streaming responses in iTerm2. The flickering occurs across multiple tabs running Copilot CLI and on multiple occasions. It stabilizes after a few minutes but is disruptive and an accessibility concern.

The flickering happens only in Copilot CLI tabs — regular shell tabs in the same iTerm window are unaffected. This rules out an iTerm rendering issue and points to how Copilot CLI handles terminal output.

Affected version

GitHub Copilot CLI 0.0.406

Steps to reproduce the behavior

  1. Open iTerm2 with multiple tabs
  2. Run copilot in one or more tabs
  3. Interact normally — submit prompts and wait for streaming responses
  4. After a few minutes of use (or with longer session history), the screen starts flickering
  5. Flickering persists for several minutes before stabilizing

Expected behavior

Terminal output should update smoothly without full-screen flickering. Status indicators and streaming text should use incremental line updates rather than redrawing the entire visible buffer.

Root cause analysis

Binary analysis of the Copilot CLI SEA bundle (Node.js Single Executable Application) shows heavy use of:

  • clearScreenDown (CSI 0J — erase from cursor to end of display)
  • cursorTo / moveCursor / clearLine from Node.js readline

The clearScreenDown approach clears the entire visible region below the cursor and redraws it on every update. During streaming responses, this means the terminal buffer is cleared and repainted potentially hundreds of times per second, causing visible flicker.

Suggested fix: Replace clearScreenDown (CSI 0J) with line-specific erase sequences (CSI 2K per line) to update only the lines that actually changed. This is a well-known terminal rendering issue in CLI tools that use full-region clears instead of incremental updates.

Additional context

  • OS: macOS 26.2 (Build 25C56)
  • CPU: Apple Silicon (arm64)
  • Terminal: iTerm2 3.6.6
  • TERM: xterm-256color (configured), xterm-color (in session)
  • COLORTERM: truecolor
  • Shell: zsh
  • Flickering scope: Only Copilot CLI tabs; regular shell tabs unaffected

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions