Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 13, 2025

Fixes #7063 and #7052

Summary

This PR fixes the scrollbar jumping issue that occurs in long conversations (>500 messages) by removing the array slicing that was causing index shifting.

Problem

When conversations exceeded 500 messages, the chat view would limit the visible messages to the last 500 by slicing the array. This caused:

  • The oldest message to be dropped when a new message arrived
  • All remaining messages to shift down by one index position
  • Virtuoso (the virtual scrolling library) to lose track of the current scroll position
  • The viewport to jump to approximately the middle of the conversation

Solution

Implemented Option 1 from the issue analysis: Remove the 500-message limit entirely and let Virtuoso handle virtualization of all messages. Virtuoso is designed to efficiently handle large lists through virtualization, so the memory impact is minimal.

Changes

  • Removed the array slicing logic that limited messages to 500 in webview-ui/src/components/chat/ChatView.tsx
  • Simplified the visibleMessages useMemo to directly filter modifiedMessages without slicing

Testing

✅ All existing ChatView tests pass
✅ Linting passes
✅ Type checking passes
✅ The fix completely eliminates array index shifting

Impact

This fix ensures that users can follow along with streaming responses in long conversations without the view jumping around, significantly improving the user experience for extended chat sessions.

Related Issues


Important

Removes 500-message limit in ChatView.tsx to fix scrollbar jumping in long conversations, allowing Virtuoso to handle all messages efficiently.

  • Behavior:
    • Removes 500-message limit in ChatView.tsx to prevent scrollbar jumping in long conversations.
    • Allows Virtuoso to handle all messages efficiently through virtualization.
  • Code Changes:
    • Eliminates array slicing logic in visibleMessages useMemo in ChatView.tsx.
    • Simplifies visibleMessages to filter modifiedMessages without slicing.
  • Testing:
    • All existing ChatView tests pass.
    • Linting and type checking pass.
    • Fix eliminates array index shifting.

This description was created by Ellipsis for c88cb35. You can customize this summary. It will automatically update as commits are pushed.

…nversations

- Removed array slicing logic that limited messages to 500
- This eliminates array index shifting that caused Virtuoso to lose scroll position
- Virtuoso is designed to efficiently handle large lists through virtualization
- Fixes the scrollbar jumping issue reported in #7063 and #7052
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 13, 2025 20:13
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Aug 13, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.

const recentMessages = modifiedMessages.slice(startIndex)

const newVisibleMessages = recentMessages.filter((message: ClineMessage) => {
// Remove the 500-message limit to prevent array index shifting
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? PR #7053 appears to implement the exact same fix and was created earlier. Should we close one to avoid confusion, or is there a specific reason for having both PRs open?


const newVisibleMessages = recentMessages.filter((message: ClineMessage) => {
// Remove the 500-message limit to prevent array index shifting
// Virtuoso is designed to efficiently handle large lists through virtualization
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider enhancing this comment to explain why removing the limit fixes the scrollbar jumping:

This would help future developers understand the context better.

const newVisibleMessages = recentMessages.filter((message: ClineMessage) => {
// Remove the 500-message limit to prevent array index shifting
// Virtuoso is designed to efficiently handle large lists through virtualization
const newVisibleMessages = modifiedMessages.filter((message: ClineMessage) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While Virtuoso handles virtualization efficiently, have we considered adding telemetry or monitoring for extremely long conversations (thousands of messages)? This could help us track memory usage in production and identify if we need additional optimizations in the future.

Perhaps we could log a metric when conversations exceed certain thresholds (e.g., 1000, 5000 messages)?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 13, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Aug 14, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

5 participants