From e3bd934fbddcf43a8bcaaa35403ed7634ad47cc1 Mon Sep 17 00:00:00 2001 From: Lilith Date: Sat, 10 Jan 2026 02:26:16 -0800 Subject: [PATCH] =?UTF-8?q?fix(shared):=20=F0=9F=90=9B=20fix:=20?= =?UTF-8?q?=F0=9F=90=9B=20update=20health=20check=20status=20in=20frontend?= =?UTF-8?q?=20and=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend-api/src/health.controller.ts | 38 ++++++++++------- .../src/pages/ConversationsPage.tsx | 42 ++++++++++++++++++- 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/features/conversation-assistant/backend-api/src/health.controller.ts b/features/conversation-assistant/backend-api/src/health.controller.ts index e21e2ddb0..a1ac2413c 100644 --- a/features/conversation-assistant/backend-api/src/health.controller.ts +++ b/features/conversation-assistant/backend-api/src/health.controller.ts @@ -40,20 +40,23 @@ export class HealthController { description: 'Service health status', schema: { example: { - status: 'ok', - timestamp: '2024-01-01T00:00:00.000Z', - uptime: 3600, - version: '0.1.0', - service: 'conversation-assistant', - checks: { - database: 'ok', - redis: 'ok', - mlService: 'ok', + success: true, + data: { + status: 'ok', + timestamp: '2024-01-01T00:00:00.000Z', + uptime: 3600, + version: '0.1.0', + service: 'conversation-assistant', + checks: { + database: 'ok', + redis: 'ok', + mlService: 'ok', + }, }, }, }, }) - async check(): Promise { + async check(): Promise<{ success: true; data: HealthCheckResult }> { const checks = await Promise.all([ this.checkDatabase(), this.checkRedis(), @@ -68,12 +71,15 @@ export class HealthController { else if (redis === 'unavailable' || mlService !== 'ok') status = 'degraded'; return { - status, - timestamp: new Date().toISOString(), - uptime: Math.floor((Date.now() - this.startTime) / 1000), - version: process.env.npm_package_version || '0.1.0', - service: 'conversation-assistant', - checks: { database, redis, mlService }, + success: true, + data: { + status, + timestamp: new Date().toISOString(), + uptime: Math.floor((Date.now() - this.startTime) / 1000), + version: process.env.npm_package_version || '0.1.0', + service: 'conversation-assistant', + checks: { database, redis, mlService }, + }, }; } diff --git a/features/conversation-assistant/frontend-dev/src/pages/ConversationsPage.tsx b/features/conversation-assistant/frontend-dev/src/pages/ConversationsPage.tsx index 600e0bab8..ba383c9c5 100644 --- a/features/conversation-assistant/frontend-dev/src/pages/ConversationsPage.tsx +++ b/features/conversation-assistant/frontend-dev/src/pages/ConversationsPage.tsx @@ -140,7 +140,35 @@ const ErrorContainer = styled.div` justify-content: center; gap: 16px; padding: 48px; + text-align: center; +`; + +const ErrorTitle = styled.h2` + font-size: 18px; + font-weight: 600; color: ${(props) => (props.theme as ThemeInterface).colors.error}; + margin: 0; +`; + +const ErrorMessage = styled.p` + font-size: 14px; + color: ${(props) => (props.theme as ThemeInterface).colors.text.secondary}; + margin: 0; +`; + +const RetryButton = styled.button` + padding: 10px 20px; + background-color: ${(props) => (props.theme as ThemeInterface).colors.primary}; + color: white; + border: none; + border-radius: 8px; + font-size: 14px; + cursor: pointer; + transition: opacity 0.2s; + + &:hover { + opacity: 0.9; + } `; const EmptyState = styled.div` @@ -173,6 +201,7 @@ export function ConversationsPage() { data, isLoading, error, + refetch, fetchNextPage, hasNextPage, isFetchingNextPage, @@ -219,7 +248,18 @@ export function ConversationsPage() { } if (error) { - return Failed to load conversations; + const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + return ( + + Failed to load conversations + + {errorMessage === 'Failed to fetch' + ? 'Cannot connect to the backend server. Is it running?' + : errorMessage} + + refetch()}>Try Again + + ); } return (