Long responses corrupt terminal scrollback — earlier output overwritten mid-stream (iTerm2)
Title: Long responses corrupt terminal scrollback — earlier output overwritten mid-stream (iTerm2)
Environment
- Claude Code version: 2.1.226 (latest on npm at time of report)
- Terminal: iTerm.app
- TERM: xterm-256color
- OS: macOS (Darwin 25.5.0)
Description
During a long streamed response, the terminal display gets corrupted: earlier lines of the response are overwritten/obscured, and only a later fragment of the output remains visible on screen. The beginning of the response has to be re-requested from Claude to be seen again — it isn't just scrolled out of view, it appears to be actually overwritten in place.
Suspected cause
Likely related to how the CLI redraws its status/spinner line using ANSI cursor-positioning escape codes. If a repaint happens while new output is still streaming in and lines have scrolled, the cursor-position math may target the wrong row and overwrite prior scrollback content instead of just the live status line.
Steps to reproduce
- Open Claude Code in iTerm.app (TERM=xterm-256color).
- Ask a question that produces a long response (long enough to scroll the visible window).
- Watch the output stream in.
- Observe that partway through, earlier lines are overwritten and no longer visible/readable, while the status/spinner area and later content continue to render.
Expected behavior
Streamed output should append to scrollback normally; only the transient status/spinner line should be redrawn in place, and it should never overwrite previously printed response text.
Additional notes
Not yet confirmed whether this is iTerm2-specific — planning to A/B test against Terminal.app to narrow it down and will update this issue with results. Happy to provide a screen recording if useful.