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.
This commit is contained in:
Anish Sarkar 2026-07-07 11:04:04 +05:30
parent 1c9ab207ef
commit 34c8b4aa86
4 changed files with 7 additions and 7 deletions

View file

@ -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,
});

View file

@ -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 {

View file

@ -311,7 +311,7 @@ export function Sidebar({
) : chats.length > 0 ? (
<div className="relative">
<div className={`flex flex-col gap-0.5 ${chats.length > 4 ? "pb-2" : ""}`}>
{chats.slice(0, 20).map((chat) => (
{chats.slice(0, 6).map((chat) => (
<ChatListItem
key={chat.id}
name={chat.name}

View file

@ -395,8 +395,8 @@ export function OnboardingTour() {
// Fetch threads data
const { data: threadsData } = useQuery({
queryKey: ["threads", workspaceId, { limit: 40 }], // Same key as layout
queryFn: () => fetchThreads(Number(workspaceId), 40),
queryKey: ["threads", workspaceId, { limit: 6 }], // Same key as layout
queryFn: () => fetchThreads(Number(workspaceId), 6),
enabled: !!workspaceId,
});