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 1/2] 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 ? (
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, }); From 04ea39f4833ad26da67351066e4e237f46417bbf Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Tue, 7 Jul 2026 11:05:35 +0530 Subject: [PATCH 2/2] refactor(sidebar): remove isShared prop from ChatListItem and Sidebar components - Removed the isShared prop from ChatListItemProps interface and its usage in the Sidebar component to simplify the code and improve clarity. --- surfsense_web/components/layout/ui/sidebar/ChatListItem.tsx | 1 - surfsense_web/components/layout/ui/sidebar/Sidebar.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/surfsense_web/components/layout/ui/sidebar/ChatListItem.tsx b/surfsense_web/components/layout/ui/sidebar/ChatListItem.tsx index a027cfb9c..e39075443 100644 --- a/surfsense_web/components/layout/ui/sidebar/ChatListItem.tsx +++ b/surfsense_web/components/layout/ui/sidebar/ChatListItem.tsx @@ -19,7 +19,6 @@ import { sidebarListItemClassName } from "./SidebarListItem"; interface ChatListItemProps { name: string; isActive?: boolean; - isShared?: boolean; archived?: boolean; dropdownOpen?: boolean; onDropdownOpenChange?: (open: boolean) => void; diff --git a/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx b/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx index 016085f5a..35746acf1 100644 --- a/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/Sidebar.tsx @@ -316,7 +316,6 @@ export function Sidebar({ key={chat.id} name={chat.name} isActive={chat.id === activeChatId} - isShared={chat.visibility === "SEARCH_SPACE"} archived={chat.archived} dropdownOpen={openDropdownChatId === chat.id} onDropdownOpenChange={(open) =>