This document describes the implementation of graceful degradation features for the telemetry conversion system, addressing Requirements 9.1, 9.2, and 9.4.
WHEN a telemetry message is missing expected fields, THEN the Message Aggregator SHALL use default values for missing fields
Implementation:
- StateAggregator already initializes all fields with sensible defaults (0 for numbers, '-' for strings)
- The
createInitialState(),createHeartData(), andcreateSensorData()methods ensure all fields have default values - Missing fields in incoming messages don't crash the system; they simply retain their default values
- Unknown message types are logged but don't prevent processing of subsequent messages
WHEN telemetry for one pump side is unavailable, THEN the Dashboard UI SHALL display the available pump side data and indicate the other side as unavailable
WHEN no telemetry has been received for an extended period, THEN the Dashboard UI SHALL display a "No Data" indicator
Implementation:
Added telemetry status tracking to StateAggregator:
lastTelemetryTime: Tracks when any telemetry was last receivedleftHeartLastUpdate: Tracks when left heart data was last receivedrightHeartLastUpdate: Tracks when right heart data was last received
The getState() method now includes a _telemetryStatus object with:
noDataReceived: Boolean indicating if no data received for 30+ secondsleftHeartAvailable: Boolean indicating if left heart data received in last 10 secondsrightHeartAvailable: Boolean indicating if right heart data received in last 10 seconds- Timestamp fields for debugging
Added new Jotai atoms in atoms.js:
noDataReceivedAtom: Tracks overall telemetry timeoutleftHeartAvailableAtom: Tracks left heart data availabilityrightHeartAvailableAtom: Tracks right heart data availability
The updateAtomsFromState() function updates these atoms from the _telemetryStatus object.
Updated Dashboard.jsx to display status:
-
Global "No Data" Alert: When
noDataReceivedis true, displays a prominent warning banner at the top of the dashboard:⚠ No Data Received No telemetry data has been received for an extended period. Check device connection. -
Pump Side Indicators: Each heart card (Left/Right) shows:
- Reduced opacity (50%) when data is unavailable
- "No Data" badge in the card header
- Available data continues to display (last known values)
WHEN telemetry resumes after a gap, THEN the Message Aggregator SHALL resume normal operation without requiring a restart
Implementation:
- The
updateState()method updateslastTelemetryTimeon every message - Pump-side specific timestamps are updated based on the
pumpSidefield - When telemetry resumes, the timestamps are automatically updated
- The
getState()method recalculates availability status on every call - No manual reset or restart is required; the system automatically recovers
Two timeout thresholds are used:
-
TELEMETRY_TIMEOUT: 30 seconds
- Used to detect complete loss of telemetry
- Triggers the global "No Data" warning
-
SIDE_TIMEOUT: 10 seconds
- Used to detect loss of data from individual pump sides
- Triggers per-side "No Data" badges
These values can be adjusted in StateAggregator.js if needed.
Created comprehensive tests in server/GracefulDegradation.test.js:
- ✓ Default values for missing fields (Requirement 9.1)
- ✓ Telemetry status tracking (Requirement 9.2)
- ✓ Initial availability state
- ✓ Left heart availability tracking (Requirement 9.2)
- ✓ Right heart availability tracking (Requirement 9.2)
- ✓ "All" pump side updates both sides (Requirement 9.2)
- ✓ Recovery after telemetry gap (Requirement 9.4)
- ✓ Timestamp tracking
- ✓ Missing message fields handling (Requirement 9.1)
- ✓ Unknown message types handling (Requirement 9.1)
All tests pass successfully.
server/StateAggregator.js: Added telemetry tracking and status reportingserver/GracefulDegradation.test.js: New test file
src/atoms.js: Added telemetry status atoms and update logicsrc/pages/dashboard/Dashboard.jsx: Added UI indicators for data availability
All changes are backward compatible:
- The
_telemetryStatusobject is added to state but doesn't affect existing fields - UI changes are purely additive (new indicators)
- Existing functionality continues to work unchanged
- All existing tests continue to pass
The graceful degradation features work automatically:
- Normal Operation: When telemetry is flowing normally, no special indicators appear
- Partial Loss: If one pump side stops sending data, that side's card shows reduced opacity and a "No Data" badge
- Complete Loss: If no telemetry is received for 30+ seconds, a warning banner appears at the top
- Recovery: When telemetry resumes, all indicators automatically clear
No configuration or manual intervention is required.