From 153eb3b96892bf42c01a4d1e142ac5b54b3cf8f2 Mon Sep 17 00:00:00 2001 From: agent-company Date: Thu, 26 Mar 2026 10:11:47 +0000 Subject: [PATCH] feat: improve loading and error states on Batch and Analytics pages Analytics page now shows skeleton loaders (cards and chart placeholders) while data loads, and displays a retry button when the API call fails. Batch page error state now shows the actual error message and suggests user action. Closes leeworks-agents/SPARC#16 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/pages/Analytics.tsx | 44 +++++++++++++++++++++++++------- frontend/src/pages/Batch.tsx | 18 ++++++++++--- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/frontend/src/pages/Analytics.tsx b/frontend/src/pages/Analytics.tsx index 19f4aff..0072a19 100644 --- a/frontend/src/pages/Analytics.tsx +++ b/frontend/src/pages/Analytics.tsx @@ -9,15 +9,38 @@ const COLORS = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6' export function AnalyticsPage() { const [days, setDays] = useState(30); - const { data, isLoading, isError } = useQuery({ + const { data, isLoading, isError, refetch } = useQuery({ queryKey: ['analytics', days], queryFn: () => analyticsApi.getAnalytics(days), }); if (isLoading) { return ( -
-
+
+
+

+ Analytics Dashboard +

+

Loading analytics data...

+
+ {/* Skeleton cards */} +
+ {[1, 2, 3].map((i) => ( +
+
+
+
+ ))} +
+ {/* Skeleton charts */} +
+ {[1, 2].map((i) => ( +
+
+
+
+ ))} +
); } @@ -33,15 +56,18 @@ export function AnalyticsPage() {
- Database Not Connected + Unable to Load Analytics

- Set USE_DATABASE=true in your .env file to enable analytics tracking. + Could not connect to the analytics database. Ensure PostgreSQL is running and + DATABASE_URL is configured correctly.

-
-
- - Analytics features require storing analysis results in PostgreSQL for historical tracking. +
); diff --git a/frontend/src/pages/Batch.tsx b/frontend/src/pages/Batch.tsx index 9b9b351..6620597 100644 --- a/frontend/src/pages/Batch.tsx +++ b/frontend/src/pages/Batch.tsx @@ -114,9 +114,21 @@ export function Batch() { {/* Error */} {mutation.isError && ( -
- - Batch analysis failed. Please try again. +
+
+ + Batch analysis failed +
+

+ {mutation.error instanceof Error ? mutation.error.message : 'An unexpected error occurred.'} + {' '}Check your connection and try again. +

+
)}