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 ? (
4 ? "pb-2" : ""}`}> - {chats.slice(0, 20).map((chat) => ( + {chats.slice(0, 6).map((chat) => ( fetchThreads(Number(workspaceId), 40), + queryKey: ["threads", workspaceId, { limit: 6 }], // Same key as layout + queryFn: () => fetchThreads(Number(workspaceId), 6), enabled: !!workspaceId, });