History of decisions/trip-tracking-lifecycle.md
1 version, newest first. Superseded versions stay in the record; nothing here can change them.
Content of f5778488 (no earlier version at this path)
Tie GPS tracking to trip status and reconcile it after loading trips
@@ -0,0 +1,12 @@+# 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 `boarding` or other non-transit states.+- Stop tracking when a trip becomes `completed` or returns to `scheduled`, clearing the stored vehicle identifier.+- When trips are loaded, inspect the complete trip list for an already-`inTransit` trip 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.