claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Bug] Excessive blank lines causing continuous terminal scrolling

Open rgucsb opened this issue 2 months ago • 8 comments

Bug Description I'll draft a comprehensive bug report for you to send to Anthropic.


Subject: Claude Code CLI - Continuous Scrolling/Excessive Blank Lines Bug

Description: Claude Code CLI exhibits continuous scrolling behavior caused by excessive blank lines being added to the terminal output. This makes the tool unusable as the screen constantly scrolls during both user input (every keystroke) and while Claude is thinking/executing.

Environment:

  • Claude Code Version: 2.0.28
  • Operating System: macOS 26.0.1 (Build 25A362) - also occurred on macOS 15.x (Sequoia)
  • Node.js Version: v22.16.0
  • npm Version: 10.9.2
  • Terminals Tested: iTerm2 (v3.6.5), Terminal.app, VS Code integrated terminal
  • Shell: zsh (default macOS configuration)

Timeline:

  • Claude Code worked correctly until approximately 2 months ago (around August 2024)
  • Issue has persisted across multiple Claude Code versions
  • Issue persisted through macOS upgrade from 15.x to 26.0.1

Reproduction Steps:

  1. Run claude auth login or any Claude Code command
  2. Type any input or wait for Claude to respond
  3. Observe continuous scrolling as blank lines are added to the terminal

Expected Behavior: Claude Code should render its UI without adding excessive blank lines, maintaining a stable viewport.

Actual Behavior:

  • Every keystroke triggers scrolling
  • During Claude's thinking/execution, continuous scrolling occurs
  • Multiple blank separator lines with just > character are added after responses
  • Makes the tool completely unusable

Evidence: Script recording of terminal session shows Claude Code adding numerous blank lines with separator characters:

────────────────────────────────────────────────────────────────────────────────
                                                                               >
────────────────────────────────────────────────────────────────────────────────
                                                                               >
────────────────────────────────────────────────────────────────────────────────

Troubleshooting Already Attempted:

  • Complete uninstall/reinstall of Claude Code (removed npm package + all config files)
  • Tested across multiple terminals (iTerm2, Terminal.app, VS Code)
  • Tested with different TERM values (xterm-256color, xterm, dumb)
  • Tested with different terminal dimensions (80x24, 114x80, 244x80)
  • Tested with/without external monitor
  • Verified no shell customizations or conflicts
  • Checked for interfering software (none found)
  • Modified iTerm2 scrollback and mouse reporting settings
  • None of these resolved the issue

Analysis: The issue appears to be a bug in Claude Code's terminal UI rendering library where it incorrectly calculates vertical space requirements and adds excessive blank lines to maintain a viewport, particularly when using status bars or after rendering responses.

Impact: Claude Code CLI is completely unusable. User had to cancel subscription and is unable to use the tool despite multiple reinstallation attempts.

Request: Please investigate this rendering issue in Claude Code's terminal UI. This appears to affect the terminal library's handling of viewport height and blank line insertion.


Where to send this:

You can submit this bug report:

  1. Anthropic Support: https://support.claude.com
  2. Claude Code GitHub Issues (if there's a public repo)
  3. Via the feedback option in Claude Code (if available)

Would you like me to adjust anything in this bug report before you send it?

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.0.28
  • Feedback ID: fa51164b-1c50-44c0-b018-ddd98b8b0f3c

Errors


Note: Error logs were truncated.

rgucsb avatar Oct 28 '25 02:10 rgucsb

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/10465
  2. https://github.com/anthropics/claude-code/issues/8618
  3. https://github.com/anthropics/claude-code/issues/3648

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Oct 28 '25 02:10 github-actions[bot]

I am having this issue not intermittently, as mentioned in the other issues that are similar, but all the time. Making it impossible for me to use claude code. I do not have this issue with Codex. so whatever is causing this is not related to my system settings but something in claude code/its settings. Please resolve ASAP as my productivity is down to zero....

rgucsb avatar Oct 28 '25 15:10 rgucsb

Well I have theory behind the cause for any unexpected behaviour. So here is the deal:

The CLI will emit raw ANSI escapes when previewing files, so a binary payload can accidentally trigger a scroll-to-top:

  • The Read tool treats any non-image file as text. E40 (cli.mjs:399) reads it with fs.readFileSync(..., 'utf8') and passes the string to _f (cli.mjs:403) with no sanitisation.
  • renderResultForAssistant (same file, ~line 519) sends that raw string straight to ink, so bytes like \x1B[3J (or other CSI sequences) are written to the terminal unchanged.
  • If a PDF/zip/etc. happens to contain such a sequence, the terminal responds exactly as if the user had typed it: the cursor jumps to the top, scrollback rewinds, etc. The screen isn’t cleared; you can scroll back down—but it looks like an unexpected rewind.

I confirmed there’s no filtering between the file read and the terminal write, so this can happen whenever a binary is previewed.

Suggested fix: detect binary content (or just the presence of \x1B) before rendering and either block the preview or escape the sequence.

aleksadvaisly avatar Oct 30 '25 10:10 aleksadvaisly

Well I have theory behind the cause for any unexpected behaviour. So here is the deal:

The CLI will emit raw ANSI escapes when previewing files, so a binary payload can accidentally trigger a scroll-to-top:

  • The Read tool treats any non-image file as text. E40 (cli.mjs:399) reads it with fs.readFileSync(..., 'utf8') and passes the string to _f (cli.mjs:403) with no sanitisation.
  • renderResultForAssistant (same file, ~line 519) sends that raw string straight to ink, so bytes like \x1B[3J (or other CSI sequences) are written to the terminal unchanged.
  • If a PDF/zip/etc. happens to contain such a sequence, the terminal responds exactly as if the user had typed it: the cursor jumps to the top, scrollback rewinds, etc. The screen isn’t cleared; you can scroll back down—but it looks like an unexpected rewind.

I confirmed there’s no filtering between the file read and the terminal write, so this can happen whenever a binary is previewed.

Suggested fix: detect binary content (or just the presence of \x1B) before rendering and either block the preview or escape the sequence.

Excellent analysis. The community is willing but unable to fix this since Claude Code is closed-source; despite our best efforts to get the team to communicate we are still greeted with silence so we can't tell if they have picked this up.

@catherinewu @bcherny @anthropics ... any plans to solidify interaction with the community? Please ... no more silence...

dimension-zero avatar Oct 30 '25 10:10 dimension-zero

This issue is a blight upon my work as a developer. I hope the team at Anthropic will take this seriously and at least provide us with some kind of an acknowledgment.

joelmlee avatar Nov 05 '25 17:11 joelmlee

I was able to overcome the solution by creating a whole new user on my macbook pro and reinstalling claude code and all other apps. When i did this, the scrolling goes way. Not ideal, but atleast i can get claude code to work.

rgucsb avatar Nov 05 '25 18:11 rgucsb

When fonts become unreadable, you can copy and paste into another application and see that the text is fine, just messed-up formatting. A strategy I use multiple times a day to get the last output before resetting the VSCode/Claude application and losing the context.

My environment is Ubuntu. The issue persists regardless of regular launching VS Code, launching with a dedicated graphics card, or launching without a graphics card.

johngrabner avatar Nov 07 '25 16:11 johngrabner

Yo lo que hago: creo en la carpeta un archivo, por ejemplo, "leer.md" y le pego ahí texto o consola o instrucciones relativamente largas y le digo que lo lea.... que es lo que hace en mi caso bastante loop.... no es la solución definitiva, pero me ahorra de ir al oculista... porque es hipnótico jeje.

FOREVERARGENTINA avatar Nov 19 '25 02:11 FOREVERARGENTINA