Skip to content

Don't reframe the route on ordinary arrivals polls (#1895)#1896

Merged
bmander merged 1 commit into
mainfrom
fix/no-reframe-on-arrivals-poll
Jul 16, 2026
Merged

Don't reframe the route on ordinary arrivals polls (#1895)#1896
bmander merged 1 commit into
mainfrom
fix/no-reframe-on-arrivals-poll

Conversation

@bmander

@bmander bmander commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1895. In stop + route focus, an ordinary background arrivals poll
reframed the camera to the whole route's extent, throwing away the pan/zoom the
rider had set.

Root cause

HomeViewModel.onArrivalsLoaded runs on every arrivals load. When a route
is selected within a focused stop, it re-emits MapDirective.ShowRoute(..., stopScoped = true, frameRoute = !preserveViewport). On an ordinary poll
preserveViewport is false, so frameRoute was true. That routes through
MapViewModel.toRouteRouteMapController.reframe(frameRoute = true)
host.frameRoute(), re-fitting the camera to the whole route on every poll.

(The retained-FramingIntent.Route theory in the issue was a red herring — the
real trigger is the per-poll ShowRoute re-emission.)

Fix

Frame the selected route only when the load is the initial (restore /
deep-link) focus establishment:

val frameSelectedRoute = pendingMapFocus && !preserveViewportForPendingMapFocus
  • Ordinary poll → pendingMapFocus == falseframeSelectedRoute == false.
    The ShowRoute re-emission still refreshes presentation, but reframe() is a
    no-op (direction unchanged, no focusTripId), so the camera stays put.
  • Initial pending-focus establishment without a saved viewport → frames (unchanged).
  • Pending focus that carries a saved viewport → still declines to frame (unchanged).

The initial route selection continues to frame via selectStopRoute's default
frameRoute = true; the back/undo restore paths already pass their own explicit
frameRoute, so they're unaffected.

Tests

Added an ordinary arrivals poll refreshes the selected route without reframing
to HomeViewModelTest: selects a route in stop focus (asserts the initial
ShowRoute frames), then a subsequent onArrivalsLoaded with no pending focus
re-shows the route with frameRoute = false.

  • ./gradlew :onebusaway-android:testObaGoogleDebugUnitTest --tests 'org.onebusaway.android.ui.home.*' --tests 'org.onebusaway.android.map.*' -PwarningsAsErrors=true

Note

Root cause was found by reading the code, not reproduced on-device — worth a
manual confirmation on the shared phone before merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved map behavior when refreshing arrivals for a selected route.
    • Prevented the map from unnecessarily reframing to the full route during routine arrivals updates.
    • Preserved the initial map focus when selecting a route or restoring a focused stop.

In stop + route focus, onArrivalsLoaded re-emits the selected route's
ShowRoute directive on every arrivals load with frameRoute derived only from
preserveViewport. On an ordinary poll preserveViewport is false, so frameRoute
was true — routing through RouteMapController.reframe -> host.frameRoute() and
snapping the camera back to the whole route's extent, discarding whatever the
rider had panned/zoomed to.

Frame the selected route only when the load is the initial (restore/deep-link)
focus establishment. On an ordinary poll refresh the ShowRoute re-emission now
carries frameRoute=false, so reframe() is a no-op (direction unchanged, no
focusTripId) and the camera stays put. The initial route selection still frames
via selectStopRoute's default frameRoute=true.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3750e193-2090-4b85-a80b-f00750e83008

📥 Commits

Reviewing files that changed from the base of the PR and between 2049fdb and 8981164.

📒 Files selected for processing (2)
  • onebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeViewModel.kt
  • onebusaway-android/src/test/java/org/onebusaway/android/ui/home/HomeViewModelTest.kt

📝 Walkthrough

Walkthrough

The home view model now reframes a selected route only during initial map focus. Subsequent arrivals polls refresh the route without reframing the camera, with a unit test covering both behaviors.

Changes

Route framing refresh control

Layer / File(s) Summary
Focus framing and poll validation
onebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeViewModel.kt, onebusaway-android/src/test/java/org/onebusaway/android/ui/home/HomeViewModelTest.kt
onArrivalsLoaded uses initial focus state to control route framing, and the test verifies that later arrivals polls re-show the selected route without reframing it.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: preventing route reframing on ordinary arrivals polls.
Linked Issues check ✅ Passed The code and test match #1895 by suppressing route framing on ordinary arrivals refreshes while preserving initial focus framing.
Out of Scope Changes check ✅ Passed The changes stay focused on the route-framing fix and its test, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/no-reframe-on-arrivals-poll

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bmander
bmander merged commit f5c7df1 into main Jul 16, 2026
3 checks passed
@bmander
bmander deleted the fix/no-reframe-on-arrivals-poll branch July 16, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop+route focus: data poll reframes the camera to the whole route

1 participant