Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧵 fix: Prevent Unnecessary Re-renders when Loading Chats #5189

Merged
merged 11 commits into from
Jan 6, 2025

Conversation

danny-avila
Copy link
Owner

Summary

I optimized to prevent unnecessary re-renders when loading conversations initially

  • Refactored the message selection logic using useCallback to prevent buildTree from unnecessarily invoking more than once on initial conversation load.
  • Improved message scrolling logic to handle empty message trees and reference checks.
  • Optimized icon rendering and chat properties to enhance rendering performance.
  • Integrated queryClient to reset message data when initiating a new conversation.
  • Updated data-testid attributes for consistency and improved code readability.
  • Removed unnecessary console logs in useQueryParams cleanup.

Closes #5185

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

I tested the changes by loading conversations with over 1000 messages and verified that the application does not re-render unnecessarily or crash with recursion error. I ensured that starting new conversations resets message data correctly and that icon rendering works as expected. I also checked that data-testid attributes are consistent and that there are no console errors or warnings.

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • Local unit tests pass with my changes

@danny-avila danny-avila merged commit b01c744 into main Jan 6, 2025
2 checks passed
@danny-avila danny-avila deleted the fix/recursion-error branch January 6, 2025 15:32
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]: In long chats, letting the page load in the background causes no messages to be rendered
1 participant