Skip to content

fix(SF2.0/UpcomingDepartures): Don't remove Boarding train until vehicle actually leaves the station#2944

Open
joshlarson wants to merge 3 commits intomainfrom
jdl/sf2.0/ud/fix-boarding-before-train-leaves-station
Open

fix(SF2.0/UpcomingDepartures): Don't remove Boarding train until vehicle actually leaves the station#2944
joshlarson wants to merge 3 commits intomainfrom
jdl/sf2.0/ud/fix-boarding-before-train-leaves-station

Conversation

@joshlarson
Copy link
Contributor

@joshlarson joshlarson commented Feb 13, 2026

Scope

Asana Ticket: [SF/UD] 🐞 Don't remove "boarding" train until vehicle actually leaves the station
Other Asana Ticket: [SF/UD] 🐞Show "Stopped at station"

Implementation

Turns out, the bug here wasn't in upcoming_departures/1 at all! It was in Predictions.Repo, which was discarding past subway predictions!

The fix is as follows:

  • Give Predictions.Repo.all/1 the option to set discard_past_subway_predictions to false (defaults to true to avoid changing anything else unintentionally).
  • Some test cleanup and coverage.

Because this PR does a decent amount of refactor-y work on the UpcomingDepartures tests, it may be easiest to review commit-by-commit.

Screenshots

Screenshot 2026-02-13 at 7 21 32 AM
  • Left: SF at Back Bay showing that a train is at Haymarket
  • Center: Before shot, showing that there is no Boarding prediction at Haymarket
  • Right: After shot, showing that there is a Boarding prediction at Haymarket
Screenshot 2026-02-13 at 7 24 07 AM

This screenshot shows the same as the above, except that the train is now Stopped at station instead of Boarding.

How to test

This is kind of a tricky one, because it relies on a prediction for a particular route/stop/trip drifting into the past while the vehicle serving that trip is still at the station. This doesn't happen all the time, so you may have to click around. The way I tested it was to load three windows (as you can see in the screenshots above), one in prod, and one local for the same stop (e.g. Haymarket), and one in prod or local, your call, at a stop downstream (e.g. Back Bay).

You can see this feature working when the downstream page shows a train at a station, the local version of that page shows the train Boarding at that station (or Stopped at station), and the prod version of that page omits that trip. You may have to wait a bit, and/or shift around which stops you're looking at.

Notes

This actually introduces a new bug, where once the train departs from the station, it shows as Arriving until the prediction is dropped from the API. I didn't want to fix that in this PR, because there's an existing PR that introduces some changes that will make that fix a lot easier (and will also conflict with a fix if I tried to introduce said fix right now).

I'll file a follow-up ticket, whose link I'll include in a comment below (if I include it here, Github will think that this PR should be assigned to that ticket, which isn't the case 🙃)


@joshlarson joshlarson requested a review from a team as a code owner February 13, 2026 17:14
@joshlarson joshlarson requested a review from lvachon1 February 13, 2026 17:14
@joshlarson
Copy link
Contributor Author

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.

1 participant