Skip to content

Map: #1899 fix keys selected-trip styling off a palette-lookup null-check — extract a pure, tested selectedTripStyle() #1902

Description

@bmander

From the 2026-07-16 debt review (finding 2). Severity: high.

RouteMapController.kt:600-629 decides "am I in stop focus with this route emphasized?" by whether routeColors[selected.routeDirection] happens to return non-null — a proxy, not a predicate; the controller has the real mode state (stopFocusSession, emphasizedRoute) one line up. The lookup key is built in selectedTripPresentation() (line 680) as activeTrip?.directionId ?: currentDirectionId, while the emphasized route uses presentationDirectionId (lines 156-160, 595) — two independently derived direction values. If a selected vehicle's direction isn't among the focused stop's trip set (e.g. opposite-direction vehicle inside stop focus), the presentation silently degrades to GTFS color + generic underlay — the exact visual #1899 fixed.

Commit 0f9bfa63 shipped no test changes; the decision lives inside the private, stateful publishMapPresentation().

Bonus: in the selected branch, badges (lines 597-599) is provably always empty, so setRouteBadges(badges) at line 627 is an obfuscated emptyList().

Fix (small–medium): extract a pure selectedTripStyle(stopFocusActive, emphasizedRoute, selectedRouteDirection, routeColors, gtfsColor) -> (color, includeUnderlay) into RouteViewGeometry.kt (sibling presentation logic already lives and is tested there) and table-test the four mode combinations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions