From 34c8b4aa8669713cbabb79a9d8ab437250f6191a Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Tue, 7 Jul 2026 11:04:04 +0530 Subject: [PATCH] refactor(onboarding-tour, layout, sidebar): reduce thread fetch limit to 6 for improved performance - Updated thread fetching logic across multiple components to limit the number of threads fetched to 6 instead of 40. - Adjusted related placeholder data and chat display logic in the sidebar to reflect the new limit. --- .../components/layout/providers/LayoutDataProvider.tsx | 6 +++--- .../components/layout/ui/sidebar/AllChatsSidebar.tsx | 2 +- surfsense_web/components/layout/ui/sidebar/Sidebar.tsx | 2 +- surfsense_web/components/onboarding-tour.tsx | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/surfsense_web/components/layout/providers/LayoutDataProvider.tsx b/surfsense_web/components/layout/providers/LayoutDataProvider.tsx index 901e9a8ab..639965d38 100644 --- a/surfsense_web/components/layout/providers/LayoutDataProvider.tsx +++ b/surfsense_web/components/layout/providers/LayoutDataProvider.tsx @@ -118,10 +118,10 @@ export function LayoutDataProvider({ workspaceId, children }: LayoutDataProvider enabled: !!workspaceId, }); - // Fetch threads (40 total to allow up to 20 per section - shared/private) + // Fetch recent threads for the sidebar. const { data: threadsData, isPending: isLoadingThreads } = useQuery({ - queryKey: ["threads", workspaceId, { limit: 40 }], - queryFn: () => fetchThreads(Number(workspaceId), 40), + queryKey: ["threads", workspaceId, { limit: 6 }], + queryFn: () => fetchThreads(Number(workspaceId), 6), enabled: !!workspaceId, }); diff --git a/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx index c02fd31ef..3063a9c50 100644 --- a/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx @@ -99,7 +99,7 @@ function AllChatsContent({ workspaceId, className }: AllChatsContentProps) { queryKey: ["all-threads", workspaceId], queryFn: () => fetchThreads(Number(workspaceId)), enabled: !!workspaceId && !isSearchMode, - placeholderData: () => queryClient.getQueryData(["threads", workspaceId, { limit: 40 }]), + placeholderData: () => queryClient.getQueryData(["threads", workspaceId, { limit: 6 }]), }); const { diff --git a/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx b/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx index 5927b8e45..016085f5a 100644 --- a/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx @@ -311,7 +311,7 @@ export function Sidebar({ ) : chats.length > 0 ? (