Skip to content

Conversation

@JustHereToHelp
Copy link

Summary

Fixes #2384, fixes #2790

Two related scroll-to-top bugs that have been driving me crazy:

Tab switch scroll jump: Switching between tabs would reset the terminal scroll position to the top. The issue was that intermediate tab repositioning during the switch triggered resize events that reset the viewport. Fix: skip intermediate tab repositioning for already-initialized tabs in emain-window.ts, and guard handleResize to only restore scroll if dimensions actually changed.

Alt buffer exit scroll jump: Exiting a full-screen program (htop, vim, less, etc.) would scroll the terminal to the top. Fix: save the baseY scroll position via xterm.js onBufferChange, then restore it with requestAnimationFrame after the buffer switch completes. Also added an auto-scroll guard so it doesn't interfere if the user was already at the bottom.

Heads up — this fixes it in most cases but I've still seen occasional jumps in edge cases. Probably needs a couple more trigger points caught, but it's way better than before.

Test plan

  • Open two terminal tabs with scrollback history
  • Scroll up in one tab, switch to the other and back — position should be preserved
  • Run htop or less /etc/hosts, scroll around, quit — terminal should not jump to top
  • Run vim, edit something, quit — scroll should hold
  • Verify normal scrolling and auto-scroll-to-bottom on new output still works

Two related scroll-to-top bugs:

Tab switch: switching tabs triggered intermediate repositioning that
caused xterm.js buffer reflow and scroll loss. Fix: skip intermediate
positioning for already-initialized tabs via skipIntermediate flag.

Alt buffer exit: exiting htop/vim/less reset scroll to top. Fix: save
baseY before alt buffer exit in OSC 16162 "R" handler, restore via
onBufferChange + requestAnimationFrame. Also guards handleResize to
only restore scroll when dimensions actually changed.

Fixes wavetermdev#2384, fixes wavetermdev#2790
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Terminal still scrolls to top after Claude output [Bug]: Terminal scrolls to top after Claude output

1 participant