claude-code - 💡(How to fix) Fix [BUG] Thinking spinner causes terminal content to jump/flicker in tmux (main buffer instead of alternate screen) [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#51868Fetched 2026-04-23 07:42:45
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

When Claude is in thinking/streaming mode, the terminal content visibly jumps. The bottom of the pane gains and loses one blank line repeatedly, causing entire content to scroll.

Error Message

Error Messages/Logs

Root Cause

Claude CLI uses Ink.js which does not use alternate screen (smcup/rmcup) by default. It writes directly to the main buffer:

  1. Spinner appends a new line → triggers scroll region → all content shifts up 1 line
  2. Spinner erased with \033[A\033[2K → blank line at bottom momentarily
  3. Terminal redraws → visible jump

In tmux this is amplified by tmux's own redraw cycle.

Code Example

process.stdout.write('\x1b[?1049h'); // enter alternate screen
// ... TUI lifecycle ...
process.stdout.write('\x1b[?1049l'); // exit alternate screen

---
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?

Environment

  • Claude CLI (latest)
  • tmux inside Emacs vterm (also reproducible in any terminal emulator with tmux)

Description

When Claude is in thinking/streaming mode, the terminal content visibly jumps. The bottom of the pane gains and loses one blank line repeatedly, causing entire content to scroll.

Root Cause

Claude CLI uses Ink.js which does not use alternate screen (smcup/rmcup) by default. It writes directly to the main buffer:

  1. Spinner appends a new line → triggers scroll region → all content shifts up 1 line
  2. Spinner erased with \033[A\033[2K → blank line at bottom momentarily
  3. Terminal redraws → visible jump

In tmux this is amplified by tmux's own redraw cycle.

Why Hard to Work Around

  • vterm (Emacs): process filter hardcoded in C, no raw output hook exposed to Emacs Lisp
  • pty wrapper: causes buffering/latency issues
  • tmux status-position top: reduces severity but doesn't fix root cause

Reference

Google Gemini CLI (also Ink.js-based) has already implemented alternate screen and achieves flicker-free rendering. Fix is feasible.

Suggested Fix

process.stdout.write('\x1b[?1049h'); // enter alternate screen
// ... TUI lifecycle ...
process.stdout.write('\x1b[?1049l'); // exit alternate screen

What Should Happen?

Tmux pane should not jump/flicker when claude is thinking.

Error Messages/Logs

Steps to Reproduce

  1. Open new vterm buffer in Emacs
  2. Create a new claude session in the vterm buffer
  3. Interact with claude

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

2.1.112

Claude Code Version

2.1.112

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

No response

extent analysis

TL;DR

Enable alternate screen mode in Claude CLI to prevent terminal content from jumping when in thinking/streaming mode.

Guidance

  • The issue is caused by Claude CLI writing directly to the main buffer, triggering scroll region and content shifts.
  • To fix this, enter alternate screen mode using the suggested fix code: process.stdout.write('\x1b[?1049h') before TUI lifecycle and exit with process.stdout.write('\x1b[?1049l') afterwards.
  • Verify the fix by checking if the tmux pane no longer jumps or flickers when Claude is thinking.
  • Consider referencing the Google Gemini CLI implementation for a working example of alternate screen mode with Ink.js.

Example

// Enter alternate screen mode
process.stdout.write('\x1b[?1049h');
// ... TUI lifecycle ...
// Exit alternate screen mode
process.stdout.write('\x1b[?1049l');

Notes

This fix may not be applicable if the terminal emulator or tmux version does not support alternate screen mode.

Recommendation

Apply the workaround by enabling alternate screen mode in Claude CLI, as it is a feasible fix that has been implemented in other Ink.js-based projects like Google Gemini CLI.

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