Skip to content

feat: unify transfer risk rule and fix tight-transfer display - #784

Open
reidzeibel wants to merge 4 commits into
mainfrom
ridwan/unify-transfer-risk-rule
Open

feat: unify transfer risk rule and fix tight-transfer display#784
reidzeibel wants to merge 4 commits into
mainfrom
ridwan/unify-transfer-risk-rule

Conversation

@reidzeibel

@reidzeibel reidzeibel commented Sep 4, 2026

Copy link
Copy Markdown
Member

Part of https://github.com/AtB-AS/kundevendt/issues/24416

Background

The same transfer situation was classified by two different rules — one here, one in the app — so planner web and app could disagree about the same trip.

The rule now lives in @atb-as/utils (7.1.0), imported by planner-web (this PR), atb-bff (soon) and mittatb-app (soon).

What changes

  • Deletes the local hasTemporalOverlap / hasGuaranteedInterchangeInto and uses getLegTransferRisk from the package instead. The guaranteed-interchange handling from fix: respect guaranteed interchanges when determining trip status #781 is preserved — same maximumWaitTime semantics, just no longer a local copy.
  • Transfer risk becomes its own axis. TripPatternStatus narrows to 'valid' | 'stale' (data freshness only) and risk is reported per leg as transferRisk, plus the worst value at trip level.
  • Two state instead of one: unlikely below −120 s (error, "Ikke mulig") and the new uncertain at 0…−120 s (info, "Usikker overgang"). The card now shows the same verdict as the details screen. This will be refined further, but for this step, we are just aligning how it is between planner-web and app.

How will it look like

Situation Before After
Transfer with time to spare
Transfer that is exactly flush (0 s) Usikker overgang (info)
Transfer short by 30 s Ikke mulig (error) Usikker overgang (info)
Transfer short by 5 min Ikke mulig (error) Ikke mulig (error)
Guaranteed interchange, within maximumWaitTime
Guaranteed interchange, past maximumWaitTime Ikke mulig (error) Ikke mulig (error)
Transfer still broken, that leg's refresh failed Ikke mulig (error) Ikke mulig (error)
Transfer now fine, that leg's refresh failed Ikke mulig (error) Resultatene kan være utdaterte (info)

started and ended outranks stale, so a started trip will not show "Resultatene kan være utdaterte" message.

Tight transfers

The trip details had no transfer-risk UI at all — only the card chip. It now shows "Usikker overgang" on the leg, styled like the app.

Two display fixes came out of testing a real 23-second transfer, which showed as 15:18 → 15:17 with no message at all:

  • The wait section required more than 30 seconds, so short transfers were silently skipped. Any wait now shows, matching the app.
  • Arrival times round up and departures round down, so a same-minute transfer read as if the connection left before the arrival. The arrival now rounds down in that case — and only then. A genuinely missed connection still rounds up, so it still looks missed.

Rounding

Real times (arrival → departure) On main On this branch
15:17:11 → 15:17:34 15:18 → 15:17 15:17 → 15:17
15:17:10 → 15:17:55 15:18 → 15:17 15:17 → 15:17
15:17:10 → 15:18:40 15:18 → 15:18 unchanged
15:17:10 → 15:20:10 15:18 → 15:20 unchanged
15:18:40 → 15:17:30 (missed) 15:19 → 15:17 unchanged

Kort byttetid message

Wait On main On this branch
23 s no message Kort byttetid
45 s Kort byttetid unchanged
3 min Kort byttetid unchanged

Screenshots

image image

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
planner-web Ready Ready Preview Sep 4, 2026 8:54pm UTC

Request Review

@reidzeibel reidzeibel changed the title refactor: use transfer-risk rules from utils package feat: unify transfer risk rule and fix tight-transfer display Sep 4, 2026
@reidzeibel
reidzeibel marked this pull request as ready for review September 4, 2026 21:14
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