Modern Apps git

← Modern-Apps.git

taxi: keep tracking alive on transient by-id lookup failures

Commit
3504f00375ee3d482f8ef4a16191f2d0800a4280
Author
Vayun Mathur <[email protected]>
When
2026-11-08 02:44 UTC (28 days ago)
Parents
7afa03c
When the active-ride endpoint did not surface a ride, RideTrackingScreen\nfell back to reading it by id — but any RideStatusResult.Failed from\nthat fallback (LyftRidesClient.rideById reports Failed for every\nnon-2xx, including rate limits and transient 5xx) ended tracking\noutright. The equivalent transient failure on the primary active-ride\npath only surfaces an error and keeps polling, so a single blip on\nthe fallback path killed live tracking for a ride that was still\nrunning, with no error shown and no recovery.\n\nA failed by-id read now surfaces its message and keeps polling like\nthe active-ride path; only None (ride genuinely gone) and\nUnsupported still end tracking.\n\nAdds trackingScreenByIdFailureRecovers (404 on active-ride, one 500\nthen success on by-id: the ride renders and cancel stays offered)\nand corrects the trackingScreenErrorState comment, which described\nthe old end-on-failure behavior. Verified with\n:taxi:testDevUnitTest (TaxiPass3TrackingScreenTest: 7/7 pass).

Diff

taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingScreen.kt
diff --git a/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingScreen.kt b/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingScreen.ktindex 91ee2c11c8..74eaf7284e 100644--- a/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingScreen.kt+++ b/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingScreen.kt@@ -90,6 +90,10 @@ fun RideTrackingScreen(rideId: String) {                             ride = byId.ride                             error = null                         }+                        // A transient lookup failure must not end tracking for a+                        // live ride: surface it and keep polling, mirroring the+                        // active-ride Failed branch above.+                        is RideStatusResult.Failed -> error = byId.message                         else -> ended = true                     }                 }
taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3TrackingScreenTest.kt
diff --git a/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3TrackingScreenTest.kt b/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3TrackingScreenTest.ktindex 6e220603cb..8b5677d2cb 100644--- a/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3TrackingScreenTest.kt+++ b/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3TrackingScreenTest.kt@@ -15,6 +15,7 @@ import com.vayunmathur.taxi.network.lyft.LyftToken import kotlinx.coroutines.runBlocking import org.junit.Rule import org.junit.runner.RunWith+import java.util.concurrent.atomic.AtomicInteger import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config import kotlin.test.AfterTest@@ -140,15 +141,38 @@ class TaxiPass3TrackingScreenTest {         assertTrue(http.callsTo("/cancel").isEmpty())     } +    @Test+    fun trackingScreenByIdFailureRecovers() {+        // The active-ride endpoint does not surface this ride, so tracking+        // falls back to the by-id read; the first read fails transiently.+        http.on("/v1/activeride") { http.raw(404, "none", "text/plain", it.url) }+        http.on("/driver-location") {+            http.raw(200, """{"location":{"lat":37.71,"lng":-122.41}}""", url = it.url)+        }+        val attempts = AtomicInteger()+        http.on("/v1/rides/") {+            if (attempts.incrementAndGet() <= 1) {+                http.raw(500, "kaput", "text/plain", it.url)+            } else {+                http.raw(200, rideJson("approaching"), url = it.url)+            }+        }+        rule.setContent { RideTrackingScreen(rideId = "r1") }+        // The transient failure must not end tracking: the next poll recovers+        // and the ride renders with cancel still offered.+        waitForText("Jo Smith")+        rule.onNodeWithText(str(R.string.cancel_ride)).assertIsDisplayed()+    }+     @Test     fun trackingScreenErrorState() {         http.on("/v1/activeride") { http.raw(500, "kaput", "text/plain", it.url) }         http.on("/v1/rides/") { http.raw(500, "kaput", "text/plain", it.url) }         http.on("/driver-location") { http.raw(500, "x", "text/plain", it.url) }         rule.setContent { RideTrackingScreen(rideId = "r1") }-        // Active fails with an error; the by-id read also fails, which ends-        // tracking - the screen settles out of its initial state without-        // crashing (loading or error, never a stuck spinner assertion here).+        // Active fails with an error, so the screen keeps polling and shows+        // the error - it settles out of its initial state without crashing+        // (loading or error, never a stuck spinner assertion here).         rule.waitUntil(20_000) {             rule.onAllNodesWithText(str(R.string.tracking_loading)).fetchSemanticsNodes().isNotEmpty() ||                 rule.onAllNodesWithText(str(R.string.tracking_error, "Lyft returned HTTP 500: kaput"))