[BUG] Scrollback buffer cleared when streaming output arrives while user is scrolled up

Status Open
Reported on v2.1.234
Maintainer reply None cached
Activity 0 comments · opened Aug 17, 2026

[BUG] Scrollback buffer cleared when streaming output arrives while user is scrolled up

Description

When Claude Code is streaming a long response and the user scrolls up in the terminal to inspect earlier output, the scrollback buffer above the viewport is cleared or overwritten. The user loses access to all prior output that was above the current viewport.

This is distinct from the corruption/truncation bugs in #85508, #76692, and #84247. The scrollback isn't corrupted or duplicated; it's destroyed. Content that should be preserved in the scrollback region is wiped by the TUI's repaint or cursor-repositioning logic while streaming continues below the viewport.

Steps to reproduce

  1. Start a Claude Code session
  2. Have a conversation that produces enough output to fill several screens of scrollback
  3. Ask a question that produces a long streaming response
  4. While the response is streaming, scroll up in the terminal to read earlier output
  5. The scrollback buffer is cleared. All content above the viewport is gone

Expected behavior

Scrollback buffer is preserved. Output streaming below the viewport should not affect content that has already been emitted above the viewport. The terminal's scrollback region should be read-only from the TUI's perspective once content has scrolled past the viewport.

Actual behavior

The scrollback buffer is cleared while the user is scrolled up. All prior conversation output is permanently destroyed. This is unrecoverable data loss. The terminal scrollback is the only human-readable record of the conversation's output as rendered; it cannot be reconstructed from session state.

Environment

  • Claude Code version: 2.1.234
  • OS: Linux 5.15.0-181-generic (Ubuntu)
  • Terminal: xterm-256color
  • Shell: zsh
  • Running in: native terminal (not VS Code, not IDE extension)

Impact

This is unrecoverable data loss during normal use. Scrolling up to review earlier output during a long response is a standard workflow when the response references or builds on prior conversation content. The TUI destroys the content the user is actively trying to read, with no warning and no recovery path.

Notes

The likely cause is the TUI using ANSI escape sequences (cursor repositioning, screen clearing, or alternate screen buffer manipulation) that reach into the scrollback region during streaming repaints. The streaming output renderer should confine its repaint operations to the visible viewport and not emit sequences that affect the scrollback buffer.

View original on GitHub ↗