Forced scroll to bottom when window gains focus (Windows Terminal + WSL2)

Status Closed — not planned
Reported on v2.1.74
Maintainer reply None cached
Activity 11 comments · opened Mar 12, 2026 · closed Apr 13, 2026

Summary

When the Claude Code window gains focus, the terminal view forcibly scrolls to the bottom, making it impossible to read past output.

Environment

  • OS: Windows 11 + WSL2 (Ubuntu)
  • Terminal: Windows Terminal 1.23.20211.0
  • Claude Code: 2.1.74
  • Shell: bash

Steps to Reproduce

  1. Start Claude Code in Windows Terminal (WSL2)
  2. Scroll up to read previous output
  3. Click on another window (lose focus)
  4. Click back on the Claude Code window (regain focus)
  5. View immediately jumps back to the bottom

Expected Behavior

Scroll position should be preserved when the window regains focus.

Actual Behavior

Every time the window gains focus, the view is forcibly scrolled to the bottom. This makes it impossible to read past output while multitasking.

Additional Notes

  • scrollToBottomOnInput: false is already set in Windows Terminal settings — no effect
  • The issue does NOT occur when focus remains on the Claude Code window
  • On another PC with the same WSL2 setup but with Claude Code not focused (user working in other windows), the issue is not noticed — consistent with this being a focus-triggered bug
  • Likely related to: focus gain event → scroll-to-bottom triggered in TUI/Ink rendering
  • Possibly related to #32473 (scroll/display issues on Windows)

View original on GitHub ↗

11 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/19030
  2. https://github.com/anthropics/claude-code/issues/18299
  3. https://github.com/anthropics/claude-code/issues/24269

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

cruzlauroiii · 5 months ago

Root cause traced in cli.js v2.1.76 source: Ink's rendering uses \ on every re-render. When output is large, the cursor moves far up in the buffer and Windows Terminal (and iTerm) follows the cursor, snapping the viewport to the top. Full analysis in #34794.

cruzlauroiii · 5 months ago

Updated PR #34798 with v2 fix: stateful stdout.write interceptor that clamps cursor-up across ALL writes (not just sync blocks). Catches Ink renderer, prompt renderer, and all other cursor-up sources. Patch + PowerShell script included.

cruzlauroiii · 5 months ago

Updated PR #34798 with 3 combined patches: (1) stateful stdout.write interceptor clamping cursor-up, (2) render throttle 16ms→200ms, (3) disable synchronized update mode. All three are needed — cursor-up clamping alone does not fix it because Windows Terminal exits scroll mode on ANY stdout write, and sync blocks batch writes into one viewport-resetting update. PowerShell apply/revert script included.

cruzlauroiii · 5 months ago

v3 update: Previous fixes (cursor-up clamping, disabling sync update) did not work and caused flickering.

Root cause identified: Windows Terminal bug microsoft/terminal#14774SetConsoleCursorPosition always scrolls viewport to cursor, even when visible. Every Ink re-render triggers this. Cannot be fixed from within the process.

v3 patch: render throttle SK6=16SK6=1000 (1fps). Gives 1 second of uninterrupted reading between viewport resets. Trade-off: streaming text in ~1s chunks. No flickering.

PR #34798 updated. Real fix needs Microsoft (terminal#14774) or Anthropic (PTY proxy/append-only rendering).

cruzlauroiii · 5 months ago

v5 update: Fundamentally different approach — buffer ALL Ink renders during active work, screen stays frozen (no viewport jumping). Flush only when (a) user types (at prompt/bottom, safe to update) or (b) 5s of no renders (Claude finished). Previous v1-v4 failed because WT bug microsoft/terminal#14774 triggers viewport scroll on ANY cursor positioning. v5 avoids this by not writing to stdout at all during active work. Trade-off: no spinner/progress visible during work. PR #34798 updated.

cruzlauroiii · 5 months ago

v6: Buffer ALL renders, flush ONLY on user input (stdin). No timer. No auto-flush. Zero viewport jumping while not at bottom. Root cause: WT bug microsoft/terminal#14774. PR #34798.

cruzlauroiii · 5 months ago

v7: Replay ALL buffered frames on flush (fixes v6 outdated screens). Keeps entire diff chain so screen content is always correct. Still zero viewport jumping — flush only on user input (stdin). PR #34798.

cruzlauroiii · 5 months ago

Final fix: Ctrl+6 freeze toggle. Press Ctrl+6 to freeze screen (buffer renders, scroll freely). Press again to unfreeze (replay + live output). Tab title shows [FROZEN]. Root cause is WT bug microsoft/terminal#14774 — cannot be detected/fixed automatically. PR #34798.

github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.