The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(flight-live): keep a past flight's times in its booking view
Maurice856d1e5ea50c
diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.jsonindex 2e21e202a..9503b0f61 100644--- a/client/scripts/feature-pairs.json+++ b/client/scripts/feature-pairs.json@@ -963,6 +963,12 @@"desktop": ["src/components/Planner/DayPlanSidebarTransportDetailModal.tsx"],"mobile": ["src/mobile/screens/trip/sheets/MTransportSheet.tsx"]},+ {+ "feature": "Live flight cards in the booking detail: useFlightLiveCard",+ "hooks": ["src/components/Planner/flightLive/useFlightLiveCard.ts"],+ "desktop": ["src/components/Planner/bookings/BookingDetailDialog.tsx"],+ "mobile": ["src/mobile/screens/trip/sheets/MTransportSheet.tsx"]+ },{"feature": "Transport booking form: bookingFormModel","hooks": ["src/components/Planner/bookingFormModel.ts"],diff --git a/client/src/components/Planner/bookings/BookingDetailDialog.test.tsx b/client/src/components/Planner/bookings/BookingDetailDialog.test.tsxindex 4ddbeb8c7..18ca4ef33 100644--- a/client/src/components/Planner/bookings/BookingDetailDialog.test.tsx+++ b/client/src/components/Planner/bookings/BookingDetailDialog.test.tsx@@ -1,4 +1,4 @@-// FE-PLANNER-BKDETAIL-001 to FE-PLANNER-BKDETAIL-013+// FE-PLANNER-BKDETAIL-001 to FE-PLANNER-BKDETAIL-014import { render, screen, waitFor, within } from '../../../../tests/helpers/render';import userEvent from '@testing-library/user-event';import { http, HttpResponse } from 'msw';@@ -10,6 +10,8 @@ import { useAuthStore } from '../../../store/authStore';import { useTripStore } from '../../../store/tripStore';import { usePluginStore } from '../../../store/pluginStore';import { useSettingsStore } from '../../../store/settingsStore';+import { legKey, useFlightLiveStore } from '../../../store/flightLiveStore';+import type { FlightLiveLeg } from '@trek/shared';import type { Reservation, ReservationEndpoint } from '../../../types';import BookingDetailHost, { type BookingDetailHostProps } from './BookingDetailHost';@@ -224,4 +226,25 @@ describe('BookingDetailDialog', () => {expect(screen.getByText('3:00 PM')).toBeInTheDocument();expect(screen.queryByText('15:00')).not.toBeInTheDocument();});++ it('FE-PLANNER-BKDETAIL-014: a followed flight long over has no live card and keeps its time tiles', () => {+ const r = buildReservation({+ id: 960, title: 'LH 716', type: 'flight', day_id: 1301, reservation_time: '2025-06-01T08:00', reservation_end_time: '2025-06-01T12:30',+ endpoints: [ep({ role: 'from', name: 'Frankfurt', code: 'FRA' }), ep({ role: 'to', sequence: 1, name: 'Haneda', code: 'HND' })],+ });+ const past: FlightLiveLeg = {+ reservation_id: 960, leg_index: 0, callsign: 'DLH716', flight_number: 'LH 716', service_date: '2025-06-01',+ origin: { code: 'FRA', name: 'Frankfurt', lat: 50.03, lng: 8.57, timezone: 'Europe/Berlin' },+ destination: { code: 'HND', name: 'Haneda', lat: 35.55, lng: 139.78, timezone: 'Asia/Tokyo' },+ phase: 'scheduled', scheduled_departure: '2025-06-01T06:00:00Z', scheduled_arrival: '2025-06-01T17:30:00Z',+ departed_at: null, landed_at: null, estimated_arrival: null, departure_delay_min: null, arrival_delay_min: null,+ progress: null, distance_total_km: null, distance_remaining_km: null, position: null, aircraft: null,+ last_seen_at: null, fetched_at: '2025-06-01T05:00:00Z', stale: false, source: 'adsb.lol',+ };+ useFlightLiveStore.setState({ trips: { 1: { enabled: true, attribution: null, legs: { [legKey(960, 0)]: past } } } });+ renderDetail(r);+ const dialog = screen.getByRole('dialog', { name: 'LH 716' });+ expect(within(dialog).getByText('08:00')).toBeInTheDocument();+ expect(within(dialog).getByText('12:30')).toBeInTheDocument();+ });});diff --git a/client/src/components/Planner/bookings/BookingDetailDialog.tsx b/client/src/components/Planner/bookings/BookingDetailDialog.tsxindex 3595dc148..18554f976 100644--- a/client/src/components/Planner/bookings/BookingDetailDialog.tsx+++ b/client/src/components/Planner/bookings/BookingDetailDialog.tsx@@ -25,8 +25,8 @@ import { AirTrailPill, MailPill, BOX, Eyebrow, Field, FileRows, ReviewPill, Travimport { TransitLegs, transitSummary } from './transitParts'import { BookingDialogHeader, StatusPill, TypePill } from './BookingDialogShell'import { DeleteButton, DialogButton, DialogFooter, DialogSection as Section, DialogShell, FooterSpacer, PILL } from '../../shared/DialogShell'-import { useFlightLiveLegs } from '../../../store/flightLiveStore'import FlightLiveCard from '../flightLive/FlightLiveCard'+import { useFlightLiveCardLegs } from '../flightLive/useFlightLiveCard'import { getFlightLegs } from '../../../utils/flightLegs'export interface BookingDetailDialogProps {@@ -69,8 +69,9 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {const tripCurrency = useTripStore(s => s.trip?.currency)const timeFormat = useSettingsStore(s => s.settings.time_format) || '24h'const [renaming, setRenaming] = useState(false)- // A flight TREK follows live shows its live card instead of the plain time tiles.- const liveLegs = useFlightLiveLegs(p.tripId, r.id)+ // A flight TREK follows live shows its live card instead of the plain time tiles;+ // one long over or never seen by the feed has no card and keeps its tiles.+ const liveLegs = useFlightLiveCardLegs(p.tripId, r.id)const legTotal = liveLegs.length > 0 ? getFlightLegs(r).length : 0const [name, setName] = useState('')const meta = parseMeta(r)diff --git a/client/src/components/Planner/flightLive/FlightLiveCard.test.tsx b/client/src/components/Planner/flightLive/FlightLiveCard.test.tsxindex 2aa8df1ae..1a7851e45 100644--- a/client/src/components/Planner/flightLive/FlightLiveCard.test.tsx+++ b/client/src/components/Planner/flightLive/FlightLiveCard.test.tsx@@ -1,4 +1,4 @@-// FE-PLANNER-FLIGHTLIVE-001 to FE-PLANNER-FLIGHTLIVE-007+// FE-PLANNER-FLIGHTLIVE-001 to FE-PLANNER-FLIGHTLIVE-008import type { FlightLiveLeg } from '@trek/shared';import { beforeEach, describe, expect, it, vi } from 'vitest';@@ -9,6 +9,7 @@ import { legKey, useFlightLiveStore } from '../../../store/flightLiveStore';import type { Reservation } from '../../../types';import FlightLiveCard from './FlightLiveCard';import FlightLiveStrip, { PlanFlightLiveLine } from './FlightLiveStrip';+import { useFlightLiveCardLegs } from './useFlightLiveCard';// The map is Leaflet and WebGL, neither of which jsdom draws; the card around it is what is under test here.vi.mock('./FlightMiniMap', () => ({ default: () => null, FLIGHT_MAP_CREDIT: 'map credit' }));@@ -186,3 +187,27 @@ describe('strips and plan lines', () => {expect(container).toBeEmptyDOMElement();});});++describe('useFlightLiveCardLegs', () => {+ function CardLegs() {+ const legs = useFlightLiveCardLegs(1, 6);+ return <span data-testid="card-legs">{legs.map((l) => l.leg_index).join(',')}</span>;+ }++ it('FE-PLANNER-FLIGHTLIVE-008: lists only the legs a card is drawn for, not one long over', () => {+ const now = Date.now();+ seed(+ leg({+ leg_index: 0,+ phase: 'landed',+ scheduled_departure: new Date(now - 30 * H).toISOString(),+ scheduled_arrival: new Date(now - 22 * H).toISOString(),+ landed_at: new Date(now - 22 * H).toISOString(),+ position: null,+ }),+ leg({ leg_index: 1 })+ );+ render(<CardLegs />);+ expect(screen.getByTestId('card-legs')).toHaveTextContent(/^1$/);+ });+});diff --git a/client/src/components/Planner/flightLive/useFlightLiveCard.ts b/client/src/components/Planner/flightLive/useFlightLiveCard.tsindex 3331bd375..a387db640 100644--- a/client/src/components/Planner/flightLive/useFlightLiveCard.ts+++ b/client/src/components/Planner/flightLive/useFlightLiveCard.ts@@ -83,6 +83,8 @@ function delayText(minutes: number | null, t: T): { text: string; tone: DelayTon/** The stages a card speaks for; without live data (past, unknown) there is no card. */type ShownStage = Exclude<FlightStage, 'past' | 'unknown'>;+const isShown = (stage: FlightStage): stage is ShownStage => stage !== 'past' && stage !== 'unknown';+function headlineOf(stage: ShownStage,view: FlightLiveView,@@ -193,7 +195,7 @@ export function useFlightLiveCard(tripId: number, reservationId: number, legIndeconst view = flightLiveView(leg, now);// No live data to show: the flight is long over, or the feed never heard it. Nothing at all then.- if (view.stage === 'past' || view.stage === 'unknown') return null;+ if (!isShown(view.stage)) return null;const time = (ms: number, tz: string | null) => airportTime(ms, tz, locale, timeFormat);const { headline, detail } = headlineOf(view.stage, view, leg, t, time);return {@@ -214,6 +216,19 @@ export function useFlightLiveCard(tripId: number, reservationId: number, legInde};}+/**+ * The legs of one booking a live card is drawn for, in leg order. The server+ * hands over every followed leg at any date, but a flight long over or never+ * heard by the feed gets no card (see useFlightLiveCard). The booking views+ * hide their own time tiles only for these, so such a flight keeps its times.+ */+export function useFlightLiveCardLegs(tripId: number, reservationId: number): FlightLiveLeg[] {+ const legs = useFlightLiveLegs(tripId, reservationId);+ // The card's own pace, so a leg drops out here about when its card goes.+ const now = useNow(30_000, legs.length > 0);+ return legs.filter((leg) => isShown(flightLiveView(leg, now).stage));+}+/*** The leg a one-line summary of a booking speaks for (see currentLeg), as a* leg index, or null while TREK follows none of its legs.diff --git a/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx b/client/src/mobile/screens/trip/sheets/MTransportSheet.tsxindex af6273ced..e24237f2c 100644--- a/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx+++ b/client/src/mobile/screens/trip/sheets/MTransportSheet.tsx@@ -21,7 +21,7 @@ import { ActionCircle, Eyebrow, INNER_CLS, StatBox, TileHeader, displayTime } frimport { CardFiles } from '../tabs/MReservationCardParts'import { downloadAttachment, openAttachment } from '../../../../components/Planner/bookings/openAttachment'import { flowText } from '../../../../utils/flowText'-import { useFlightLiveLegs } from '../../../../store/flightLiveStore'+import { useFlightLiveCardLegs } from '../../../../components/Planner/flightLive/useFlightLiveCard'import MFlightLiveCard from './MFlightLiveCard'import MReviewNotice from './MReviewNotice'@@ -111,7 +111,8 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {const timeFormat = useSettingsStore(s => s.settings.time_format) || '24h'const blurCodes = useSettingsStore(s => s.settings.blur_booking_codes)const [codeRevealed, setCodeRevealed] = useState(false)- const liveLegs = useFlightLiveLegs(planner.tripId, payload.reservationId ?? -1)+ // Only legs with a card: a flight long over keeps its time boxes below.+ const liveLegs = useFlightLiveCardLegs(planner.tripId, payload.reservationId ?? -1)useEffect(() => { if (!open) setCodeRevealed(false) }, [open])// Hold the last reservation so the card content survives the exit animation.@@ -257,7 +258,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {tripId={planner.tripId}reservationId={res.id}legIndex={l.leg_index}- legLabel={shownLive.length > 1 ? t('flightLive.legOf', { n: l.leg_index + 1, total: routeLegs.length }) : undefined}+ legLabel={!leg && routeLegs.length > 1 ? t('flightLive.legOf', { n: l.leg_index + 1, total: routeLegs.length }) : undefined}/>))}diff --git a/client/tests/unit/mobile/trip/MTransportSheet.test.tsx b/client/tests/unit/mobile/trip/MTransportSheet.test.tsxindex 6d98e44b3..a57a9452f 100644--- a/client/tests/unit/mobile/trip/MTransportSheet.test.tsx+++ b/client/tests/unit/mobile/trip/MTransportSheet.test.tsx@@ -2,12 +2,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import MTransportSheet from '../../../../src/mobile/screens/trip/sheets/MTransportSheet'import { downloadFile, openFile } from '../../../../src/utils/fileDownload'import { useSettingsStore } from '../../../../src/store/settingsStore'+import { legKey, useFlightLiveStore } from '../../../../src/store/flightLiveStore'+import type { FlightLiveLeg } from '@trek/shared'import type { Reservation, TripFile } from '../../../../src/types'import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'import { resetAllStores, seedStore } from '../../../helpers/store'import { fireEvent, render, screen } from '../../../helpers/render'-// FE-MOB-TRSH-001 to FE-MOB-TRSH-035+// FE-MOB-TRSH-001 to FE-MOB-TRSH-036vi.mock('../../../../src/utils/fileDownload', () => ({openFile: vi.fn(() => Promise.resolve()),@@ -486,4 +488,20 @@ describe('MTransportSheet', () => {expect(screen.queryByText('4-5A')).not.toBeInTheDocument()})})++ it('FE-MOB-TRSH-036: a followed flight long over has no live card and keeps its time boxes', () => {+ const past: FlightLiveLeg = {+ reservation_id: 7, leg_index: 0, callsign: 'DLH716', flight_number: 'LH 716', service_date: '2026-05-01',+ origin: { code: 'FRA', name: 'Frankfurt', lat: 50.03, lng: 8.57, timezone: 'Europe/Berlin' },+ destination: { code: 'HND', name: 'Tokyo Haneda', lat: 35.55, lng: 139.78, timezone: 'Asia/Tokyo' },+ phase: 'scheduled', scheduled_departure: '2026-05-01T06:00:00Z', scheduled_arrival: '2026-05-01T17:30:00Z',+ departed_at: null, landed_at: null, estimated_arrival: null, departure_delay_min: null, arrival_delay_min: null,+ progress: null, distance_total_km: null, distance_remaining_km: null, position: null, aircraft: null,+ last_seen_at: null, fetched_at: '2026-05-01T05:00:00Z', stale: false, source: 'adsb.lol',+ }+ useFlightLiveStore.setState({ trips: { 1: { enabled: true, attribution: null, legs: { [legKey(7, 0)]: past } } } })+ render(<MTransportSheet planner={makePlanner()} shell={makeShell()} />)+ expect(screen.getByText('10:20')).toBeInTheDocument()+ expect(screen.getByText('06:45')).toBeInTheDocument()+ })})