Terminal scrollback wiped during session (alternate screen buffer cleared on redraw)

Resolved 💬 8 comments Opened Apr 2, 2026 by civillizard Closed Apr 17, 2026

Description

Terminal scrollback gets completely wiped mid-session, losing all previous output. The screen clears and only shows the Claude Code banner + greeting as if the session just started. This happens multiple times within a single session, sometimes close together.

Environment

  • Claude Code version: v2.1.90
  • Model: Opus 4.6 (1M context) with Claude Max
  • Terminal: macOS Terminal.app, 130x37+
  • OS: macOS 26.x (Darwin 25.4.0)
  • Shell: zsh

Reproduction

  1. Start a Claude Code session
  2. Run several tool-heavy operations (SSH commands, parallel Agent calls, long markdown table output)
  3. After some time (varies — sometimes 10-12 minutes), the entire terminal output is cleared
  4. Only the Claude Code banner, the greeting line, and the latest prompt remain visible
  5. All previous output (tool results, tables, analysis) is gone from scrollback

Observed behavior

  • Screen wipes happen at unpredictable intervals, sometimes twice in quick succession
  • Context usage at time of wipe is low (~12% of usable context, ~20K tokens) — not near autocompact threshold
  • The session continues working normally after the wipe — only the terminal display is affected
  • The conversation context is preserved (Claude remembers prior exchanges), but the user can't scroll back to see previous output

Expected behavior

Terminal scrollback should be preserved throughout the session. If Claude Code needs to redraw its UI (autocompact, context management), it should not clear the alternate screen buffer's scrollback.

Investigation done

Checked all custom hooks — none write terminal-clearing escape sequences:

  • set-terminal-title.sh (SessionStart) — writes OSC title sequence to TTY, no screen clear
  • gsd-context-monitor.js (PostToolUse) — JSON stdout only
  • gsd-statusline.js — JSON stdout only
  • format-on-edit.sh (PostToolUse) — runs formatters silently
  • Custom statusline.sh — ANSI color codes via stdout only

The issue appears to be Claude Code's internal rendering/redraw logic clearing the alternate screen buffer.

Screenshots

Two consecutive screen wipes during a single session — first showing 8K tokens consumed, second showing 20.2K tokens. Both times the screen was wiped clean to just the banner + greeting.

Workaround

Running inside tmux preserves scrollback independent of Claude Code's buffer management.

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗