Conversation
…as props Move logic: - move useSidebarSessions call from CloudChatContainer to CloudChatPage for both packages - CloudChatContainer now accepts sessions: StoredSession[] and refetchSessions: () => void; remove internal fetch - CloudChatPage now uses useSidebarSessions and passes sessions and refetchSessions to container - update type imports to include StoredSession BREAKING CHANGE: CloudChatContainer API changed to require sessions and refetchSessions props; CloudChatPage wires loading to avoid re-renders
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewClean refactor that lifts the Key observations:
Files Reviewed (4 files)
|
alex-alecu
approved these changes
Mar 3, 2026
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.
Problem
useSidebarSessions(which callsuseQueryforunifiedSessions.list) was called insideCloudChatContainer. That component re-renders ~6 times during its session-loading lifecycle due to cascading state updates fromuseState/useAtomValue, and React Strict Mode doubles that to ~12.tRPC's batching layer collects all
useQuerycalls within a React tick and sends them as one HTTP request. React Query deduplicates concurrent requests with the same key, but here it sees a single in-flight batched request with 12 sub-operations — so deduplication never fires. The server processes the same query 12 times per page load (6 in production without Strict Mode).Fix
Lifted
useSidebarSessionsone level up intoCloudChatPage, which is a stateless pass-through component that never re-renders during the session-loading lifecycle.sessionsandrefetchSessionsare passed down as props toCloudChatContainer.cloud-agent/CloudChatPage.tsx— calluseSidebarSessionshere, pass results as propscloud-agent/CloudChatContainer.tsx— acceptsessions/refetchSessionsas props, remove hook callcloud-agent-next/CloudChatPage.tsx— samecloud-agent-next/CloudChatContainer.tsx— sameAll downstream consumers (
handleStreamComplete,useSessionDeletion,CloudChatPresentation) are unchanged — they consume the same values, now via props instead of a local hook call.Expected outcome