[Terminal] Scrollbar Abnormal Jumping: Page Shaking and Scrollbar Locked at Top When Using AI CLI Tools with Long Outputs
Description
When using AI command-line tools like CodeBuddy or Claude in terminals such as orcaterm, the scrollbar behaves abnormally—jumping uncontrollably to the top—during long outputs. In severe cases, the page shakes continuously and content flickers, making it impossible to read normally.
Steps to Reproduce
Launch CodeBuddy or Claude in a terminal (e.g., orcaterm). Enter a command that triggers a long response. Observe the scrollbar behavior and whether the page shakes during output. Expected Behavior
The scrollbar should remain stable, allowing normal scrolling through all output content without page shaking.
Actual Behavior
The scrollbar automatically jumps back to the top and cannot be controlled manually. The page shakes noticeably with content flickering, severely affecting the experience.
Possible Root Cause
AI tools use a "clear screen before full rewrite" output mechanism, frequently triggering scroll events. The underlying framework handles scroll events through three asynchronous tasks. Due to async timing issues, scroll events triggered by screen clearing are misinterpreted as user actions, causing incorrect scroll position calculations.
@longshuaige I think this is fixed by supporting sync output https://github.com/xtermjs/xterm.js/pull/5453. Try out with the latest beta if you're able.
I dont know - the fact that the scrollbar jumps around sounds to me like those tools use the terminal wrong. In normal scrollbuffer progression there is no mechanism to to get the scrollbar up again, it would only move downwards.
With one exception - ED 3.
Could it be, that those AI tools use ED 3 to clear the scrollbuffer over and over? Then this is not a misbehavior of the terminal, but a misusage by the app. ED 3 is not meant to be called like crazy. A terminal is meant to write successively on normal buffer - so either append all new content, or erase/refresh only within one terminal page (or stick to alternate buffer to begin with).
Sync output would lower tearing and the scrollbar events, but not change bar jumping, if ED3 + new screen content comes in different sync frames.
@jerch I think claude code (+copilot) clears the entire scroll back and re-renders every time (maybe it's more minimal in some cases). This is what the flickering problems they had were about and why we got the contribution from Anthropic for sync output as obviously it wouldn't work without that feature.
Yes it's not done the way you would expect in the alt buffer, but they do it so they can avoid dealing with mouse events, manage scrollback themselves and get to leverage our fancy scroll bar, smooth scrolling, fancy native-like mouse events, etc. Some CLIs like amp do it in the alt buffer.