-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or requesthooksChanges to React hooksChanges to React hooksperformancePerformance improvements and monitoringPerformance improvements and monitoringpriority-2Medium priority - depends on priority-1Medium priority - depends on priority-1refactoring
Description
Problem
The workspace issues page makes redundant auth checks and data fetches, with the same requests happening 4-5 times in rapid succession.
User Impact:
- Unnecessary network traffic
- Slower perceived performance
- Waterfall of duplicate requests
Evidence from console logs:
[LOG] [Workspace] Checking auth status... (×2)
[DEBUG] [Auth] No authenticated user found (×4)
[DEBUG] Fetched workspace repositories: 1 [Object] (×4)
[DEBUG] Transformed repositories: 1 [Object] (×4)
[LOG] Issue data last synced 38100.0 minutes ago (stale) (×5)
[WARNING] No GitHub token available for syncing issues (×5)
Root Cause
Multiple components fetch the same data independently without coordination:
- No request deduplication layer
- Each component trigger fires its own fetch
- React Query or SWR not implemented for global state management
Proposed Solution
Implement React Query for automatic request deduplication:
// App.tsx or WorkspacePage.tsx
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 60 * 1000, // 1 minute
refetchOnWindowFocus: false,
refetchOnMount: false,
retry: 1,
},
},
});
export function WorkspacePage() {
return (
<QueryClientProvider client={queryClient}>
{/* workspace content */}
</QueryClientProvider>
);
}// hooks/useWorkspaceRepositories.ts
export function useWorkspaceRepositories(workspaceId: string) {
return useQuery({
queryKey: ['workspace-repos', workspaceId],
queryFn: async () => {
const { data } = await supabase
.from('workspace_repositories')
.select('*')
.eq('workspace_id', workspaceId);
return data;
},
staleTime: 5 * 60 * 1000, // 5 minutes
});
}Expected Impact
- Reduces duplicate requests by ~75%
- Single source of truth for fetched data
- Automatic background refetching
- Better loading states across components
- Cleaner data flow
Acceptance Criteria
- Install
@tanstack/react-query - Wrap workspace pages with QueryClientProvider
- Convert auth checks to use React Query
- Convert repository fetching to use React Query
- Verify "Fetched workspace repositories" appears only once in console
- All data still displays correctly
Dependencies
- Should be implemented after Fix triple component initialization causing page flickering on workspace issues #1186 (triple initialization fix)
- Complements Fix 12+ failed RPC calls to calculate_assignee_distribution #1187 (RPC fix)
Related
See full audit: tasks/workspace-issues-performance-audit.md
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthooksChanges to React hooksChanges to React hooksperformancePerformance improvements and monitoringPerformance improvements and monitoringpriority-2Medium priority - depends on priority-1Medium priority - depends on priority-1refactoring