TUI rendering leaves stale characters at row edges during partial screen updates

Resolved 💬 4 comments Opened Apr 12, 2026 by gowerlin Closed Apr 12, 2026

Description

When Claude Code's TUI redraws the screen (e.g., during scrolling or navigation), it uses cursor positioning to skip columns at the beginning/end of rows without clearing them first. This leaves "ghost" characters from the previous frame visible at row edges.

Reproduction

  1. Open Claude Code in any xterm.js-based terminal
  2. Wait for the TUI to render (e.g., memory context display, menu screens)
  3. Scroll or navigate to trigger a partial screen redraw
  4. Observe stale characters at the left and right edges of rows

Evidence

Buffer dump via terminal.buffer.active.getLine(n).translateToString() confirms the ghost text is in the xterm.js buffer itself — not a renderer artifact:

bufferType: "alternate", cols: 138, rows: 28
Line 1: "Ge- 既有專案(有 project-context.md)"   ← "Ge" is stale from previous frame
Line 6: "Ap我需要了解你的需求"                     ← "Ap" is stale from previous frame

The TUI positions the cursor to column ~2-3 and starts writing, leaving columns 0-1 with content from the prior render pass.

Cross-version verification

Tested with both xterm.js v5.5.0 and v6.0.0 — identical behavior on both versions. Also tested with both DOM renderer and @xterm/addon-canvas — same result. This confirms the issue is in the TUI's escape sequence output, not the terminal renderer.

Expected behavior

TUI should clear full rows before writing partial content, using either:

  • ESC[2K (erase entire line) before each row update
  • Write spaces to pad unused columns
  • ESC[2J (erase display) before full redraws

Workaround

Triggering a terminal resize (SIGWINCH) forces Claude Code to do a complete screen repaint, which clears all ghost characters. CLAUDE_CODE_NO_FLICKER=1 did not resolve this issue.

Environment

  • OS: Windows 11 Pro
  • Terminal: xterm.js 5.5.0 and 6.0.0 (Electron app)
  • Claude Code: 2.1.100
  • Renderers tested: DOM renderer, @xterm/addon-canvas 0.7.0

View original on GitHub ↗

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