Implement WebSocket integration with Get Health endpoint#8
Conversation
merge develop to main
…ce dashboard with robot health status ( mock env )
Review Summary by QodoReplace REST client with WebSocket for live robot telemetry WalkthroughsDescription• Replace REST client with WebSocket for real-time robot telemetry • Add discriminated union types for type-safe WebSocket messaging • Create RobotGateway singleton for centralized WebSocket management • Implement useRobotHealth hook for live dashboard metrics • Display dynamic battery, ping, and connection status in header Diagramflowchart LR
A["Robot Backend<br/>ws://localhost:8765"] -->|WebSocket| B["WebSocketClient"]
B -->|Singleton| C["RobotGateway"]
C -->|useEffect| D["useRobotHealth Hook"]
D -->|Props| E["Dashboard Header"]
E -->|Display| F["Battery, Ping,<br/>Connection Status"]
File Changes1. src/architecture/api/types.ts
|
Code Review by Qodo
1. SetState after unmount
|
Summary
Implement WebSocket integration with Get Health endpoint to replace static dashboard data with live robot telemetry (battery, ping, connection status).
Description
The dashboard was currently displaying hardcoded static data. This PR establishes a complete, cohesive WebSocket workflow that:
ws://localhost:8765get_healthrequest automatically on connectionThe implementation follows the protocol defined in
docs/Frontend-comportement.mdand integrates seamlessly with the existing architecture.What's Changed
Affected areas:
Key files:
src/architecture/api/types.ts— Added WebSocket message types (HealthData, RobotState, WsIncomingMessage, WsOutgoingMessage)src/architecture/gateways/robot.gateway.ts(new) — Singleton gateway wrapping WebSocketClientsrc/hooks/use-robot-health.ts(new) — Custom React hook for WebSocket lifecycle managementsrc/components/dashboard/dashboard.tsx— Integrated useRobotHealth hooksrc/components/dashboard/header.tsx— Replaced static text with live data bindingDetails:
How to Test
Screen