Terminal randomly scrolls to top and auto-scrolls to bottom during output, breaking scrollback navigation
Problem
Two related scrolling issues in the Claude Code terminal:
1. Viewport jumps to the TOP randomly, even when idle
The terminal spontaneously scrolls to the very top of the scrollback history, even when Claude is not generating output. This happens unpredictably and forces the user to scroll all the way back down to where they were reading.
2. Auto-scroll during output generation overrides manual scrolling
When Claude is actively generating output (streaming tokens or running tools), the terminal automatically scrolls to follow the latest output. This overrides any manual scrolling the user is doing.
Steps to Reproduce
Random scroll-to-top (Issue 1):
- Have a conversation with substantial history
- Scroll up to read previous output (while Claude is idle / not generating)
- The viewport randomly jumps to the very top of the history
Auto-scroll override (Issue 2):
- Start a conversation that produces long output
- While output is still streaming, try to scroll up to read earlier content
- The viewport snaps back to the bottom as new content renders
Expected Behavior
- The viewport should never jump to the top on its own
- Users should be able to scroll freely through history without the position being reset
- Auto-scroll should pause when the user manually scrolls away from the bottom, and resume only when the user scrolls back to the bottom
Impact
This is a significant usability pain point. The random scroll-to-top is especially disruptive — it makes reading through conversation history unreliable and frustrating. Users lose their place constantly.
Environment
- Platform: Linux (Manjaro)
- Terminal: standard terminal emulator
- Claude Code: latest version
Suggested Solution
Implement scroll position preservation:
- Never programmatically scroll to the top
- If the user scrolls up, lock the viewport at that position
- Resume auto-scroll only when the user scrolls back to the bottom
18 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Both issues are related to how Claude Code manages the terminal viewport via ANSI escape sequences (specifically CSI sequences for cursor positioning).
Issue 1 (random scroll-to-top): This typically happens when Claude Code emits a "save cursor position" (
\e[s) without a matching restore, or when the status line refresh triggers a full-screen redraw via\e[H(cursor home). The idle-state UI refresh cycle can cause this even when no output is being generated.Issue 2 (auto-scroll override): Claude Code uses
\e[?25l(hide cursor) + write +\e[?25h(show cursor) patterns during streaming. Each write cycle implicitly moves the viewport to the cursor position, which is always at the bottom.Workaround for tmux users:
Workaround for terminal multiplexer users (screen/tmux):
The most reliable fix is to run Claude Code inside
tmuxorscreen, which gives you a separate scrollback buffer that Claude Code's escape sequences cannot touch. You scroll the outer buffer, not the inner one.For native terminal users:
Some terminals support "scroll lock" when you manually scroll up:
scrollback_pager_history_size+scrollback_fill_enlarged_window noCheck your terminal's documentation for an equivalent "don't chase new output while scrolled up" setting.
These settings prevent the terminal from chasing new output when you are reading history.
This doesn't seem to exist. Is this a claude generated answer or what?
Apologies — my iTerm2 setting suggestions were wrong in both attempts. I don't use iTerm2 and was guessing incorrectly. The tmux workaround in my first comment should still work though.
In my iTerm2(version: 3.6.9), I can't find the 'Scroll to bottom on key press' option under Preferences → Profiles → Terminal. Is it removed or moved somewhere else?
Please stop trying to give advice if you have no idea and just use Claude Code to generate answers. We can all do that ourselves if we think that helps - hint: it does not
Still broken as of v2.1.81:
https://github.com/anthropics/claude-code/issues/36582
https://github.com/anthropics/claude-code/issues/35403
https://github.com/anthropics/claude-code/issues/36816
https://github.com/anthropics/claude-code/pull/35683
https://github.com/anthropics/claude-code/issues/33814
https://github.com/anthropics/claude-code/issues/34845
https://github.com/anthropics/claude-code/issues/33367
https://github.com/anthropics/claude-code/issues/34400
https://github.com/anthropics/claude-code/issues/826
https://github.com/anthropics/claude-code/issues/36621
https://github.com/anthropics/claude-code/issues/36128
https://github.com/anthropics/claude-code/issues/35766
https://github.com/anthropics/claude-code/issues/34242
https://github.com/anthropics/claude-code/issues/18299
+1 — experiencing this on GNOME Terminal (same behavior as IntelliJ terminal). Cursor randomly scrolls up during streaming output.
It was fine when I used iterm + claude code. but when I used tmux with claude code the scroll jump goes crazy.. can't find a way to fix it yet.
I can reproduce this consistently. One additional observation:
When staying at the bottom of the output, it works fine — the view correctly follows new output. The issue only occurs when you scroll up to read previous output. As soon as Claude writes a new line, the view jumps to the top of the conversation instead of staying at the scrolled position.
This happens in VS Code's integrated terminal on macOS. I confirmed it's Claude Code-specific — running a regular command with continuous output in the same VS Code terminal lets you scroll up and stay in place while output continues below.
So the bug seems to be in Claude Code's terminal renderer: when new content is appended and the viewport is not at the bottom, it re-anchors to the top instead of maintaining the current scroll position.
Am also getting this frustrating bug.
--version: 2.1.81 (Claude Code)Running in iTerm 2 on Mac 26.3.1
👍 We're experiencing the same issue embedding xterm.js 6.0.0 in a Tauri app. The scroll position jumps when Claude Code redraws its TUI while the user is scrolled up. Confirmed root cause: cursor-up sequences exceeding viewport height + ESC[2J/ESC[3J.
Have the same issue with Gnome terrminal 3.44.0. Extremely annoying and prevent you to reading anything while claude still work.
Any updates or workarounds?
PLEASE 😢
Dude that's frustrating, feel like "read previous output FAST GOGO YOU HAVE 3 SECONDS"
hey. it's fixed at the terminal level here
https://github.com/Dcouple-Inc/Pane/pull/120
open source, using xtermjs which is the same terminal as VS Code. feel free to copy this fix or download the latest release to run claude code on any operating system with the fix in place. i was so mad and frustrated at this that I had to fix it myself.
yeah i had to switch off cursor/vscode and build myself an ide that managed xtermjs (the library they both use) well enough for the complex TUIs to not break.
works great and i have a fix for the scroll jump i just implemented rn here
https://github.com/Dcouple-Inc/Pane/pull/120