claude-code - 💡(How to fix) Fix [Bug] TUI re-renders leak into scrollback causing duplicate fragments with large terminal buffers

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

Bug Description Environment

  • Claude Code v2.1.111, Opus 4.7 (1M context), max effort
  • macOS Terminal.app (built-in)
  • Darwin 24.5.0

Issue 1 — Raising Terminal.app scrollback limit causes scrollback pollution

What I did:

  1. macOS Terminal was truncating my session — I couldn't scroll back to see
    the start of my Claude Code conversation. That's bad behavior for a terminal: I should be able to read my full session history.
  2. Went to Terminal → Settings → Profiles → [profile] → Window → "Limit to N
    rows" and raised it to 1,000,000 so the full session would be preserved. This is what the setting is for.
  3. Ran Claude Code normally.
  4. When I scrolled back, the scrollback was full of tens of thousands of
    duplicated fragments of the same turns — same bash output, same file reads, same assistant text, randomly cut and stacked on top of each other. The
    session became unreadable.

The user is trapped:

  • Keep default scrollback (~10K) → terminal truncates, can't read full session
  • Raise scrollback so full session is preserved → scrollback becomes garbage

Either way, the user loses the ability to review their own Claude Code
session. At ~10K rows the problem is hidden because duplicates get evicted
before they pile up — but that's not a fix, it's just concealment.

Root cause (likely): Claude Code's TUI re-renders (input box refreshes, token streaming, spinner updates, resize events) leak into scrollback instead of staying in the live render region. Thousands of re-renders with no eviction = buffer full of duplicate fragments.

Expected: each turn lands in scrollback once, cleanly, regardless of how large the user sets scrollback. Actual: raising scrollback linearly scales the pollution.

Suggested fix: use the alternate screen buffer for the live TUI region so
redraws never touch scrollback. Only finalized transcript lines should be
committed to history. Then users can set scrollback as large as they want and still read their sessions.


Issue 2 — Paste preview truncation hides pasted content from the user

In newer Claude Code versions, pasting a large block into the input shows only the first few lines + … N lines go after that + last few lines. The model
receives the full paste, but… Note: Content was truncated.

RAW_BUFFERClick to expand / collapse

Bug Description Environment

  • Claude Code v2.1.111, Opus 4.7 (1M context), max effort
  • macOS Terminal.app (built-in)
  • Darwin 24.5.0

Issue 1 — Raising Terminal.app scrollback limit causes scrollback pollution

What I did:

  1. macOS Terminal was truncating my session — I couldn't scroll back to see
    the start of my Claude Code conversation. That's bad behavior for a terminal: I should be able to read my full session history.
  2. Went to Terminal → Settings → Profiles → [profile] → Window → "Limit to N
    rows" and raised it to 1,000,000 so the full session would be preserved. This is what the setting is for.
  3. Ran Claude Code normally.
  4. When I scrolled back, the scrollback was full of tens of thousands of
    duplicated fragments of the same turns — same bash output, same file reads, same assistant text, randomly cut and stacked on top of each other. The
    session became unreadable.

The user is trapped:

  • Keep default scrollback (~10K) → terminal truncates, can't read full session
  • Raise scrollback so full session is preserved → scrollback becomes garbage

Either way, the user loses the ability to review their own Claude Code
session. At ~10K rows the problem is hidden because duplicates get evicted
before they pile up — but that's not a fix, it's just concealment.

Root cause (likely): Claude Code's TUI re-renders (input box refreshes, token streaming, spinner updates, resize events) leak into scrollback instead of staying in the live render region. Thousands of re-renders with no eviction = buffer full of duplicate fragments.

Expected: each turn lands in scrollback once, cleanly, regardless of how large the user sets scrollback. Actual: raising scrollback linearly scales the pollution.

Suggested fix: use the alternate screen buffer for the live TUI region so
redraws never touch scrollback. Only finalized transcript lines should be
committed to history. Then users can set scrollback as large as they want and still read their sessions.


Issue 2 — Paste preview truncation hides pasted content from the user

In newer Claude Code versions, pasting a large block into the input shows only the first few lines + … N lines go after that + last few lines. The model
receives the full paste, but… Note: Content was truncated.

extent analysis

TL;DR

Use the alternate screen buffer for the live TUI region to prevent redraws from touching scrollback.

Guidance

  • The issue is likely caused by Claude Code's TUI re-renders leaking into scrollback, resulting in duplicate fragments and pollution.
  • To verify, try setting the scrollback limit to a small value (e.g., 100) and observe if the pollution occurs.
  • Consider using the alternate screen buffer for the live TUI region, as suggested, to prevent redraws from touching scrollback.
  • Only commit finalized transcript lines to history, allowing users to set scrollback as large as they want without pollution.

Example

No code snippet is provided, as the issue does not contain sufficient technical details to generate a concrete example.

Notes

The provided issue content is truncated, which may limit the accuracy of the suggested fix. Additionally, the issue describes two separate problems, but the suggested fix only addresses the first issue.

Recommendation

Apply workaround: use the alternate screen buffer for the live TUI region, as this approach directly addresses the likely cause of the issue and provides a clear solution to prevent scrollback pollution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING