diff --git a/client/src/components/Roadtrip/RoadtripSidebar.tsx b/client/src/components/Roadtrip/RoadtripSidebar.tsx index 3448450ec..39b58484e 100644 --- a/client/src/components/Roadtrip/RoadtripSidebar.tsx +++ b/client/src/components/Roadtrip/RoadtripSidebar.tsx @@ -17,7 +17,7 @@ import { formatDistance } from '../../utils/units' import { formatDate, formatClockTime } from '../../utils/formatters' import { formatDurationShort, isServiceStopType, serviceColor, type ScheduleEntry, type ScheduleWarning, refuelsRange } from './roadtripModel' import { STOP_KIND_BY_KEY } from './stopKinds' -import { destinationCount, legReroutable } from './roadtripRowModel' +import { destinationCount, isHop, legReroutable } from './roadtripRowModel' import { spurWorthLabelling } from './accessSpur' import StopKindPicker from './StopKindPicker' import StopFillPicker from './StopFillPicker' @@ -693,6 +693,18 @@ function DriveBand({ leg, onAskAlternatives, alternativesOpen }: { const distanceUnit = useSettingsStore(s => s.settings.distance_unit) const mode = leg?.mode ?? 'driving' const Icon = mode.startsWith('plugin:') ? Zap : MODE_ICON[mode] ?? CarFront + // A hop (the hire desk beside the terminal) keeps the line and drops the pill: there is + // nothing to say about it and no other way to drive it. + if (isHop(leg)) { + return ( +
+ + + + +
+ ) + } // The band's contents, shared by the clickable and the read-only shape so the two can // never drift apart in what they say. const band = ( diff --git a/client/src/components/Roadtrip/roadtripRowModel.test.ts b/client/src/components/Roadtrip/roadtripRowModel.test.ts index 26c3f3555..da8460176 100644 --- a/client/src/components/Roadtrip/roadtripRowModel.test.ts +++ b/client/src/components/Roadtrip/roadtripRowModel.test.ts @@ -567,6 +567,17 @@ describe('roadtripRows with a ride (#2428)', () => { expect(stopRows(landing).map(r => [r.stop.name, r.number])).toEqual([['Hamburg Airport', null], ['Hotel', 1]]) }) + it('FE-RTROW-051: a hop, the desk beside the terminal, is no leg row and is offered no other ways', () => { + const hop: RouteSegment = { ...seg(0), distance: 120, duration: 45, distanceText: '0 km', durationText: '0 min' } + const d = day([stop('Sixt Airport'), stop('Hamburg Airport'), stop('Hotel')], { legs: [hop, seg(1)] }) + expect(roadtripRows(d).map(r => r.kind)).toEqual(['stop', 'stop', 'leg', 'stop']) + expect(legReroutable(d, 0)).toBe(false) + expect(legReroutable(d, 1)).toBe(true) + // A note a plugin attached keeps the row, however short the hop. + const noted = day([stop('A'), stop('B')], { legs: [{ ...hop, noteText: '10 min charge' }] }) + expect(roadtripRows(noted).map(r => r.kind)).toEqual(['stop', 'leg', 'stop']) + }) + it('FE-RTROW-050: a hire car\'s desks are unnumbered stop rows the road runs through', () => { const desk = (name: string, role: 'pickup' | 'return') => stop(name, { diff --git a/client/src/components/Roadtrip/roadtripRowModel.ts b/client/src/components/Roadtrip/roadtripRowModel.ts index 5f55f0684..ce744f7f0 100644 --- a/client/src/components/Roadtrip/roadtripRowModel.ts +++ b/client/src/components/Roadtrip/roadtripRowModel.ts @@ -138,6 +138,20 @@ function isStationary(seg: RouteSegment | undefined): boolean { && seg.from[1] === seg.to[1] } +/** + * A leg too short to be a drive: the hire desk beside the terminal, the car park beside + * the gate. Under 150 m and two minutes it is a hop, and a pill reading "0 km in 0 min" + * under it is noise where the eye wants the next stop. The line still joins the two, + * and a note a plugin attached is still worth the row. + */ +export function isHop(seg: RouteSegment | undefined): boolean { + return !!seg + && Number.isFinite(seg.distance) + && seg.distance < 150 + && seg.duration < 120 + && !seg.noteText +} + export function roadtripRows(day: RoadtripDay): RoadtripRow[] { const rows: RoadtripRow[] = [] const spills = day.spills ?? [] @@ -198,7 +212,7 @@ export function roadtripRows(day: RoadtripDay): RoadtripRow[] { function pushLeg(i: number): void { const stop = day.stops[i]! const seg = day.legs[i] - if (i < day.stops.length - 1 && !isStationary(seg)) { + if (i < day.stops.length - 1 && !isStationary(seg) && !isHop(seg)) { rows.push({ kind: 'leg', index: i, seg, mode: day.stops[i + 1]?.incomingLegMode ?? stop.legMode ?? null }) const dry = (day.dryPoints ?? []).find(p => p.legIndex === i) if (dry) { @@ -226,6 +240,7 @@ export function legReroutable(day: RoadtripDay, index: number): boolean { return index >= 0 && index < day.stops.length - 1 && !!day.legs[index] + && !isHop(day.legs[index]) && !day.stops[index].automaticNight && !day.stops[index + 1].automaticNight // A leg leaving a terminal is either the ride, which has no other way, or the road