Terminal scrollback buffer not cleared on /clear, causing chat history to reappear on window resize

Status Closed — not planned
Maintainer reply None cached
Activity 8 comments · opened Nov 8, 2025 · closed Feb 7, 2026

Description:

When using /clear command in Claude Code within terminal multiplexers (dtach, tmux, screen), the chat history appears to be cleared initially, but old conversations reappear when the terminal window is resized. This causes accumulated chat content and scroll jumping issues.

Steps to Reproduce:

  1. Connect to remote server via SSH
  2. Start Claude Code in a terminal multiplexer:

```bash
# With dtach:
dtach -A /tmp/claude-session -r winch claude

# OR with tmux:
tmux new -s claude
claude

# OR with screen:
screen -S claude
claude
```

  1. Have a conversation with Claude (multiple messages)
  2. Execute /clear command in Claude Code
  3. Observe: chat appears cleared, only 1 message visible
  4. Resize the terminal window (make it larger/smaller)
  5. Observe: old chat history reappears in the visible area

Expected Behavior:

After /clear command, the chat should remain cleared even when terminal window is resized. The terminal scrollback buffer should be completely cleared.

Actual Behavior:

  • /clear clears the internal chat state but doesn't clear the terminal scrollback buffer
  • On window resize (SIGWINCH), Claude Code redraws the UI and old content from terminal buffer becomes visible again
  • With repeated /clear operations, content accumulates causing:
  • Scroll jumping
  • Performance degradation
  • UI rendering issues

Environment:

  • Claude Code version: 2.0.36
  • OS: Linux 6.8.0-85-generic
  • Connection: SSH
  • Terminal multiplexers tested: dtach, tmux, screen (issue occurs with all)
  • Platform: linux

Reproducibility:

  • ✅ Occurs with dtach
  • ✅ Occurs with tmux
  • ✅ Occurs with screen
  • ✅ Occurs over SSH connection
  • ❓ Unknown if occurs without multiplexer/SSH (likely terminal emulator dependent)

Possible Root Cause:

The /clear command likely:

  1. Clears internal conversation state
  2. Redraws the UI
  3. But doesn't emit proper terminal escape sequences to clear scrollback buffer (\\033[3J\)

On resize, the terminal multiplexer and/or SSH session causes terminal state restoration, making old content reappear. The combination of:

  • Alternate screen buffer handling
  • Terminal multiplexer session persistence
  • SIGWINCH signal handling

creates conditions where old buffer content becomes visible again.

Suggested Fix:

When /clear is executed, Claude Code should emit:
\\\
\033[3J\033[H\033[2J
\
\\

  • \\033[3J\ - Clear scrollback buffer
  • \\033[H\ - Move cursor to home
  • \\033[2J\ - Clear entire screen

Additionally, consider:

  • Proper alternate screen buffer reset
  • Clearing internal render cache on /clear
  • Testing with common multiplexers (tmux, screen, dtach)

Workaround:

Currently users need to:

  • Exit and restart multiplexer session instead of using /clear
  • Manually clear terminal before reconnecting to session

View original on GitHub ↗

8 Comments

samuelpatro · 11 months ago

Same issue on windows.

github-actions[bot] · 10 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

apdavydenkov · 10 months ago

Actual. Claude Code 2.0.64. Also in native Claude Code without dtach. It seems to me that the problem is related to the long answers. It feels like when you get long answers (maybe ones that don't fit on one screen), the problem gets worse. Again, with this problem, it feels like the screen is trying to scroll from the beginning of the dialog (top) to the end (bottom), but due to interface updates (animations, answers, reflections), there is a constant redrawing and attempts to scroll from top to bottom again.

Josemboa · 9 months ago
PaulRBerg · 9 months ago

I've reported this as a separate issue: https://github.com/anthropics/claude-code/issues/16457

I've since closed that issue as a duplicate of this issue here.

The bug doesn't apply just to terminal multiplexers - it also applies to normal terminals (e.g. Warp) on macOS.

https://github.com/user-attachments/assets/619138e7-1f2a-485d-95ab-9b9f760b990f

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 8 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 8 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.