Tie GPS tracking to trip status and reconcile it after loading trips
GPS tracking is a side effect of the trip lifecycle, not a prerequisite for displaying trips.
- Start tracking only when a trip enters
inTransit. - Do not start tracking for
boardingor other non-transit states. - Stop tracking when a trip becomes
completedor returns toscheduled, clearing the stored vehicle identifier. - When trips are loaded, inspect the complete trip list for an already-
inTransittrip and start tracking if tracking is not already running. Prefer the selected trip when it is active; otherwise use an active trip from the loaded list. - Guard startup reconciliation so it runs once per page initialization, and make starting idempotent when tracking is already active.
- If the tracking controller is unavailable, continue rendering and updating trips without crashing.
This keeps persisted trip state and process state convergent after app restarts while preserving trip-list availability when tracking services are unavailable.