State Management
ADOS Mission Control uses Zustand for all client-side state. There are more than 70 stores covering telemetry, drone management, mission planning, video, settings, and more. Each store is a small, focused slice of state with its own actions and selectors.Why Zustand
Zustand is a minimal state manager for React. It has no boilerplate, no context providers, and no reducers. A store is a plain function that returns state and actions. Components subscribe to specific fields and only re-render when those fields change. This matters for a GCS because telemetry arrives at 10-50 Hz. A full React context re-render at 50 Hz would freeze the browser. Zustand’s fine-grained subscriptions keep the frame rate stable even under heavy telemetry load.Store categories
The stores group into six broad categories (representative examples shown, not the full list):Ring buffers for telemetry
High-frequency telemetry stores use ring buffers instead of growing arrays. A ring buffer holds a fixed number of samples (typically 300) and overwrites the oldest when full. This keeps memory bounded regardless of flight duration.The drone manager bridge
DroneManager is the central coordinator between protocol adapters and stores. When a connection is established, bridgeTelemetry() subscribes to all protocol callbacks and routes the data to the correct stores:
protocol.capabilities. For example, onGimbalManagerStatus only subscribes if capabilities.supportsGimbalV2 is true.
Each subscription returns an unsubscribe function. When the connection closes, all subscriptions are cleaned up.
Parameter store
The parameter store holds the flight controller’s full parameter set (1,000+ parameters for ArduPilot). It supports:- Batch loading via
PARAM_REQUEST_LIST(receives all parameters over 5-15 seconds) - Individual reads via
PARAM_REQUEST_READ - Writes via
PARAM_SETwith optimistic UI update and rollback on failure - Search and filtering by parameter name, group, or description
usePanelParams hook is the primary interface for configure panels:
Demo mode and the mock engine
Demo mode runs seven simulated drones with realistic telemetry, including two iNav vehicles (a quad and a fixed-wing). The mock engine generates synthetic MAVLink messages:- Attitude oscillates with configurable rates
- GPS follows circular or waypoint paths
- Battery drains over time
- Mode transitions happen on a timer
DroneProtocol interface, so the rest of the app cannot tell the difference between a real drone and a simulated one. This is useful for development, demos, and testing UI without hardware.
Demo mode activates from the welcome modal or the settings page. It runs entirely in the browser with no backend.
Connection lifecycle
Theconnection-store tracks this state machine. UI components subscribe to the connection state to show appropriate indicators (green dot, yellow reconnecting, red disconnected).
Persist and hydration
Some stores persist across reloads via Zustand’spersist middleware, backed by IndexedDB or browser local storage depending on the store:
Each persisted store has a version number. When the schema changes, a migration function converts the old format to the new one. The version is bumped in the same commit that changes the schema.
Stores that hold ephemeral telemetry (attitude, GPS, battery) never persist. They reset to defaults on page load.
Selectors and performance
Components use Zustand selectors to subscribe to specific fields:useShallow prevents unnecessary re-renders:
Notifications
Thenotifications-store handles transient alerts (arm/disarm, mode changes, failsafe triggers, parameter save confirmations). Notifications auto-dismiss after 5 seconds. Critical notifications (failsafe, low battery) stay until acknowledged.
The store caps at 50 notifications and drops the oldest when full.
What is next
- MAVLink Protocol for the protocol adapter layer
- Agent Services for the server-side state
- Project Structure for where stores live in the codebase