[GH-ISSUE #709] ScrollBox: content size changes reset _hasManualScroll, causing auto-scroll during streaming #961

Closed
opened 2026-03-14 09:09:14 +03:00 by kerem · 1 comment
Owner

Originally created by @mocksoul on GitHub (Feb 19, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/709

When a user scrolls up while content is being streamed (e.g. in opencode TUI), the viewport jumps back toward the bottom. This happens because recalculateBarProps (triggered by content.onSizeChange) updates scrollBar.scrollSize, which can trigger updateStickyState → reset _hasManualScroll = false — even though the user never scrolled back to the sticky edge.

Root cause: PR #531 added _hasManualScroll resets in updateStickyState, but didn't guard them with _isApplyingStickyScroll. So programmatic size recalculations can falsely reset the flag.

Related opencode issues: https://github.com/anomalyco/opencode/issues/7648, https://github.com/anomalyco/opencode/issues/7659

Originally created by @mocksoul on GitHub (Feb 19, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/709 When a user scrolls up while content is being streamed (e.g. in opencode TUI), the viewport jumps back toward the bottom. This happens because `recalculateBarProps` (triggered by `content.onSizeChange`) updates `scrollBar.scrollSize`, which can trigger `updateStickyState` → reset `_hasManualScroll = false` — even though the user never scrolled back to the sticky edge. Root cause: PR #531 added `_hasManualScroll` resets in `updateStickyState`, but didn't guard them with `_isApplyingStickyScroll`. So programmatic size recalculations can falsely reset the flag. Related opencode issues: https://github.com/anomalyco/opencode/issues/7648, https://github.com/anomalyco/opencode/issues/7659
kerem closed this issue 2026-03-14 09:09:20 +03:00
Author
Owner

@mocksoul commented on GitHub (Feb 22, 2026):

Verified — #722 fixes this correctly. The !this._isApplyingStickyScroll guard in updateStickyState plus try/finally in applyStickyStart and recalculateBarProps is exactly the right approach. Tested in opencode with streaming, manual scroll is preserved as expected. Thanks @simonklee for the clean fix!

<!-- gh-comment-id:3940535963 --> @mocksoul commented on GitHub (Feb 22, 2026): Verified — #722 fixes this correctly. The `!this._isApplyingStickyScroll` guard in `updateStickyState` plus try/finally in `applyStickyStart` and `recalculateBarProps` is exactly the right approach. Tested in opencode with streaming, manual scroll is preserved as expected. Thanks @simonklee for the clean fix!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#961
No description provided.