fix - chat not scrolling to the newest messages in long conversations#334
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-only scrolling failure in long chat conversations by replacing ScrolledComposite-based scrolling (which can hit native coordinate limits) with a self-managed, windowed vertical scroller in ChatContentViewer.
Changes:
- Reworked
ChatContentViewertoextends Compositewith a logical scroll model (scrollOffset,totalHeight) and manual child positioning. - Added windowing + measurement caching (
IdentityHashMapheight cache) to avoid remeasuring sealed turns and to keep off-viewport turns hidden. - Implemented explicit mouse wheel scrolling and scrollbar synchronization for the manual layout approach.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #63. In long conversations the chat could no longer be scrolled down
to the latest messages: the scrollbar looked scrolled to the bottom (or kept
moving) but the content stopped, leaving the newest turns unreachable.
Root cause
ChatContentViewerextendedScrolledComposite, which scrolls by moving asingle content child whose height equals the entire conversation. On Windows
a native child window position is a signed 16-bit value, so once the required
offset exceeded that range the OS clamped it — the content could not move
further and the bottom became unreachable. This matches every reported
symptom: only long sessions, Windows only, and "maximize the view" or
"Ctrl+-" (which shrink the total pixel height) working around it.
Fix
Rewrite
ChatContentVieweras a self-managed, windowed vertical scroller(
extends CompositewithSWT.V_SCROLL):cmpContentis pinned to the viewport rectangle and never grown or moved.scrollOffset/totalHeight/ per-turn tops)drives scrolling; each turn is positioned at
y = top - scrollOffset.setVisible(false), so no native child ever receives an out-of-rangecoordinate.
Behavior preserved from the previous implementation:
during streaming; scrolling back to the bottom resumes it.
padding, which also keeps "scroll to bottom" aligned with the real maximum
so auto-scroll stays correct for both short and long rounds.
(mutating) turns; sealed turns keep cached heights.
Scroll step now derives from the OS-provided wheel line count (
event.count)times the font line height, so it follows the user's system scroll settings
and DPI instead of a fixed pixel constant.