claude-code - 💡(How to fix) Fix [BUG] Claude Code: Streamed-output rendering corruption on Ghostty + SSH [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#55089Fetched 2026-05-01 05:46:31
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Error Message

Error Messages/Logs

Root Cause


A more detailed write-up is in the attached markdown file (or pasted below). It covers:

  • Five hypothesized root causes ordered by likelihood
  • Six investigation steps for maintainers (cheapest-first), starting with capturing the raw byte stream via script(1) and replaying against a clean xterm
  • Workarounds I'm using until the fix lands

Fix Action

Fix / Workaround


A more detailed write-up is in the attached markdown file (or pasted below). It covers:

  • Five hypothesized root causes ordered by likelihood
  • Six investigation steps for maintainers (cheapest-first), starting with capturing the raw byte stream via script(1) and replaying against a clean xterm
  • Workarounds I'm using until the fix lands
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When Claude Code streams a long markdown response (multiple code blocks, headings, tables — roughly 2+ screenfuls), the rendered output becomes visually corrupted partway through. Text from later in the response is overdrawn on top of text from earlier in the same response, leaving duplicated section headers and overlapping fragments visible on screen.

The actual textual content of the response is correct (copying from the terminal yields clean text); only the on-screen rendering is wrong. The corruption persists until the user resizes the window or otherwise forces a full repaint.

This appears to be cursor-position bookkeeping inside the streaming renderer drifting from the terminal's actual cursor state, so subsequent draws land in already-occupied rows.

What Should Happen?

Streamed output should render incrementally with no overdraw of previously rendered lines. As new content is appended at the bottom, older content should scroll up cleanly, and the visible region of the terminal should remain a consistent, sequential rendering of the message so far.

Error Messages/Logs

Steps to Reproduce

Reproduction is sporadic; I haven't found a fixed input that triggers it 100% of the time. Conditions that correlate with reproduction:

  1. SSH from a local Mac (running Ghostty terminal) into a remote Linux host running Claude Code.
  2. Ask Claude a question whose response will be long — multiple sections, 2+ code blocks, a markdown table, and roughly 2+ screenfuls of output.
  3. Let the response stream to the terminal (do NOT scroll during streaming).
  4. Observe: somewhere mid-response, a section header that already scrolled past the top of the visible area is redrawn on top of the current bottom-of-screen content. The original section's content remains visible below the duplicate header, so the screen now shows the same heading and intro twice with different content following each.

Things present in the responses where I've reproduced this:

  • Fenced code blocks with syntax highlighting
  • Markdown tables
  • Mixed heading levels (## and ###)
  • Some non-ASCII characters: emoji (✅, ❌, ⚠️), box-drawing horizontal rules (─ U+2500), en-dashes/em-dashes
  • Bullet lists nested inside other formatting

The bug does not appear consistently for short responses (single screen), nor for purely-text responses without code blocks.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.123 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

Operating System

Linux (CBL-Mariner 2.0, kernel 5.15) on the remote host where Claude Code runs. Local terminal host: macOS (Ghostty terminal). SSH connection between the two.


Terminal/Shell

Terminal: Ghostty (on macOS, locally) Shell on remote: bash 5.1.8 TERM environment variable on remote: xterm-256color


A more detailed write-up is in the attached markdown file (or pasted below). It covers:

  • Five hypothesized root causes ordered by likelihood
  • Six investigation steps for maintainers (cheapest-first), starting with capturing the raw byte stream via script(1) and replaying against a clean xterm
  • Workarounds I'm using until the fix lands

One specific data point worth flagging: the remote $TERM is "xterm-256color" even though the local terminal is Ghostty. If Claude Code's renderer infers terminal capabilities (e.g., wide-char width tables, supported escape sequences) from terminfo, it may be using a generic xterm profile that doesn't match Ghostty's actual rendering — which would explain why line-wrap and cursor-position math drift over the course of a long stream.

Setting TERM=xterm-ghostty on the remote (if Ghostty's terminfo is available there) and re-testing is the first thing I'd try to confirm or rule out this hypothesis.

claude_code_rendering_bug.md

extent analysis

TL;DR

The most likely fix for the rendering corruption issue in Claude Code is to ensure that the terminal capabilities are correctly inferred, potentially by setting the correct TERM environment variable.

Guidance

  • Investigate the terminal capabilities inferred by Claude Code and verify if they match the actual capabilities of the Ghostty terminal.
  • Try setting TERM=xterm-ghostty on the remote host, if available, to see if it resolves the issue.
  • Capture the raw byte stream of the response using script(1) and replay it against a clean xterm to isolate the problem.
  • Review the hypothesized root causes and investigation steps provided in the attached markdown file for further guidance.
  • Consider testing with a different terminal or shell to determine if the issue is specific to the Ghostty terminal or bash shell.

Example

No code snippet is provided as the issue is related to terminal rendering and not a specific code block.

Notes

The issue may be related to the mismatch between the terminal capabilities inferred by Claude Code and the actual capabilities of the Ghostty terminal. Further investigation is needed to confirm the root cause.

Recommendation

Apply the workaround by setting TERM=xterm-ghostty on the remote host, if available, to potentially resolve the issue. This change may help ensure that Claude Code uses the correct terminal capabilities, preventing the rendering corruption.

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