Modern Apps git

← Modern-Apps.git

taxi: an expired or canceled ride no longer claims 'Ride complete'

Commit
3dc6ef77b608ae25f9184c713f73666b91ab1a27
Author
Vayun Mathur <[email protected]>
When
2026-12-01 15:39 UTC (4 days ago)
Parents
3f38178
Consumers conflated isTerminal (a polling stop condition)
with trip-completed: a server 'lapsed' ride (request
expired, no driver ever assigned) rendered 'Ride complete'
in the tracking card, and the live-update notification
mapped every terminal status — lapsed and canceled alike —
to the COMPLETE milestone.

Both display surfaces now special-case CANCELED/LAPSED to
'This ride has ended' before the terminal branch;
DROPPED_OFF/COMPLETED/PROCESSED keep 'Ride complete', and
polling/progress semantics are untouched. Six regression
tests pin both surfaces plus the live labels. Fare, ETA and
quote paths were audited and cleared (taxi has no trip
history feature). Verified: :taxi:testDevUnitTest 274 tests
pass; lint errors are pre-existing on untouched files.

Diff

taxi/src/main/java/com/vayunmathur/taxi/notifications/RideLiveUpdate.kt
diff --git a/taxi/src/main/java/com/vayunmathur/taxi/notifications/RideLiveUpdate.kt b/taxi/src/main/java/com/vayunmathur/taxi/notifications/RideLiveUpdate.ktindex 23f26f9eb7..dc8dff74d7 100644--- a/taxi/src/main/java/com/vayunmathur/taxi/notifications/RideLiveUpdate.kt+++ b/taxi/src/main/java/com/vayunmathur/taxi/notifications/RideLiveUpdate.kt@@ -78,7 +78,7 @@ object RideLiveUpdate {                 )                 .setProgress(index)             builder.setStyle(progressStyle)-            builder.setShortCriticalText(context.getString(milestones[index].labelRes))+            builder.setShortCriticalText(context.getString(statusLabelRes(ride.status, index)))             builder.setRequestPromotedOngoing(true)         } else {             val max = (Milestone.entries.size - 1).coerceAtLeast(1)@@ -106,11 +106,24 @@ object RideLiveUpdate {     }      private fun statusText(context: Context, ride: ActiveRide, index: Int): String {-        val label = context.getString(Milestone.entries[index].labelRes)+        val label = context.getString(statusLabelRes(ride.status, index))         val minutes = pickupEtaMinutes(ride) ?: return label         return context.getString(R.string.notif_status_eta, label, minutes)     } +    /**+     * The label for the ride's current milestone. The terminal milestone only+     * means "no further progress" for polling/progress purposes: a ride that+     * was cancelled, or whose request lapsed with no driver, ended without a+     * trip, so it reads "This ride has ended", not "Ride complete". A ride+     * that reached its destination (dropped-off/completed/processed) keeps+     * the completion label.+     */+    internal fun statusLabelRes(status: RideStatus, index: Int): Int = when (status) {+        RideStatus.CANCELED, RideStatus.LAPSED -> R.string.ride_ended+        else -> Milestone.entries[index].labelRes+    }+     /** Ceiled pickup ETA in minutes, or null when no ETA should be shown yet. */     private fun pickupEtaMinutes(ride: ActiveRide): Int? {         if (!isPrePickupTrackable(ride)) return null
taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingCards.kt
diff --git a/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingCards.kt b/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingCards.ktindex 57bd2d5eed..3db15a11a0 100644--- a/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingCards.kt+++ b/taxi/src/main/java/com/vayunmathur/taxi/ui/RideTrackingCards.kt@@ -166,7 +166,10 @@ internal fun DriverCard(ride: ActiveRide, onCall: (String) -> Unit) {  internal fun statusLabel(status: RideStatus, ended: Boolean): Int = when {     ended && status != RideStatus.CANCELED && !status.isTerminal -> R.string.ride_ended-    status == RideStatus.CANCELED -> R.string.ride_ended+    // Terminal is a polling-stop condition, not a completion claim: a ride that+    // was cancelled, or whose request lapsed with no driver, ended without a+    // trip ever happening, so it must not read "Ride complete".+    status == RideStatus.CANCELED || status == RideStatus.LAPSED -> R.string.ride_ended     status.isTerminal -> R.string.ride_complete     status == RideStatus.ARRIVED -> R.string.status_arrived     status == RideStatus.PICKED_UP -> R.string.status_on_trip
taxi/src/test/java/com/vayunmathur/taxi/ui/TerminalRideLabelTest.kt
diff --git a/taxi/src/test/java/com/vayunmathur/taxi/ui/TerminalRideLabelTest.kt b/taxi/src/test/java/com/vayunmathur/taxi/ui/TerminalRideLabelTest.ktnew file mode 100644index 0000000000..30449562af--- /dev/null+++ b/taxi/src/test/java/com/vayunmathur/taxi/ui/TerminalRideLabelTest.kt@@ -0,0 +1,61 @@+package com.vayunmathur.taxi.ui++import com.vayunmathur.taxi.R+import com.vayunmathur.taxi.data.RideStatus+import com.vayunmathur.taxi.notifications.RideLiveUpdate+import kotlin.test.Test+import kotlin.test.assertEquals++/**+ * Regression: terminal is a polling-stop condition, not a completion claim.+ * A ride the server reports as `lapsed` (request expired, no driver was ever+ * assigned) or `canceled` ended without a trip, so neither the tracking+ * header nor the Live Update notification may call it "Ride complete".+ * Rides that actually reached the destination keep the completion label.+ */+class TerminalRideLabelTest {++    @Test+    fun lapsedRideIsEndedNotCompleteOnTrackingHeader() {+        assertEquals(R.string.ride_ended, statusLabel(RideStatus.LAPSED, ended = false))+        assertEquals(R.string.ride_ended, statusLabel(RideStatus.LAPSED, ended = true))+    }++    @Test+    fun canceledRideIsEndedNotCompleteOnTrackingHeader() {+        assertEquals(R.string.ride_ended, statusLabel(RideStatus.CANCELED, ended = false))+    }++    @Test+    fun finishedRidesKeepCompleteOnTrackingHeader() {+        assertEquals(R.string.ride_complete, statusLabel(RideStatus.DROPPED_OFF, ended = false))+        assertEquals(R.string.ride_complete, statusLabel(RideStatus.COMPLETED, ended = false))+        assertEquals(R.string.ride_complete, statusLabel(RideStatus.PROCESSED, ended = false))+    }++    @Test+    fun lapsedAndCanceledRidesAreEndedNotCompleteInLiveUpdate() {+        // Milestone index 4 is the terminal (COMPLETE) progress milestone.+        assertEquals(R.string.ride_ended, RideLiveUpdate.statusLabelRes(RideStatus.LAPSED, 4))+        assertEquals(R.string.ride_ended, RideLiveUpdate.statusLabelRes(RideStatus.CANCELED, 4))+    }++    @Test+    fun finishedRidesKeepCompleteInLiveUpdate() {+        assertEquals(R.string.ride_complete, RideLiveUpdate.statusLabelRes(RideStatus.COMPLETED, 4))+        assertEquals(R.string.ride_complete, RideLiveUpdate.statusLabelRes(RideStatus.DROPPED_OFF, 4))+        assertEquals(R.string.ride_complete, RideLiveUpdate.statusLabelRes(RideStatus.PROCESSED, 4))+    }++    @Test+    fun liveRideLabelsAreUnchangedInLiveUpdate() {+        assertEquals(+            R.string.status_finding_driver,+            RideLiveUpdate.statusLabelRes(RideStatus.PENDING, 0),+        )+        assertEquals(+            R.string.status_on_trip,+            RideLiveUpdate.statusLabelRes(RideStatus.PICKED_UP, 3),+        )+    }+}