Context compaction clears terminal scrollback history
Problem
When Claude Code compacts context during a long session, it clears the terminal screen. This destroys the terminal scrollback buffer, making it impossible to scroll back and review earlier output (command results, test output, build logs, etc.).
Expected Behavior
Context compaction should preserve terminal scrollback history. The compaction is an internal operation — it shouldn't affect the user's ability to review their terminal history.
Current Behavior
During compaction, the terminal is cleared (likely via ANSI clear-screen escape sequences). After compaction completes, scrolling up shows nothing before the compaction point. All prior command output, test results, and conversation history is gone from the terminal buffer.
Impact
This is particularly painful during long development sessions where you need to:
- Reference earlier test output or build errors
- Compare before/after results across multiple runs
- Review a sequence of changes that were made earlier in the session
Suggested Fix
Either:
- Don't emit terminal-clearing escape sequences during compaction
- Use an approach that preserves scrollback (e.g., just continue output below without clearing)
- Add a configuration option to disable screen clearing during compaction
Environment
- macOS (iTerm2 terminal)
- Claude Code CLI
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗