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
Merge remote-tracking branch 'origin/dev' into feat/trip-route-overview
Konstantinos Thermos3c735c80a4a9
diff --cc client/src/components/Map/MapView.test.tsxindex 0ac36bc0f,5c10577c7..72d69f3f5--- a/client/src/components/Map/MapView.test.tsx+++ b/client/src/components/Map/MapView.test.tsx@@@ -221,17 -227,6 +227,24 @@@ describe('MapView', () =>expect(screen.getAllByTestId('polyline').length).toBeGreaterThan(0)})- it('FE-COMP-MAPVIEW-006b: the whole-trip overview colours each line, on a white casing', () => {- render(<MapView route={[[[48.0, 2.0], [49.0, 3.0]]]} routeColors={['#ea580c']} />)++ it('FE-COMP-MAPVIEW-006b: a caller-coloured route takes its own core and casing', () => {++ render(<MapView route={[[[48.0, 2.0], [49.0, 3.0]]]} routeColors={[{ line: '#ff9f0a', casing: '#c2740a' }]} />)++ const [casing, core] = screen.getAllByTestId('polyline')+ .map(el => JSON.parse(el.getAttribute('data-path-options') as string))- // White under the colour, the same trick the coloured GPX tracks use to stay- // readable on satellite and dark basemaps.- expect(casing.color).toBe('#ffffff')- expect(core.color).toBe('#ea580c')++ expect(casing.color).toBe('#c2740a')++ expect(core.color).toBe('#ff9f0a')++ })++++ it('FE-COMP-MAPVIEW-006c: a line with no colour of its own keeps the route blue', () => {++ render(<MapView route={[[[48.0, 2.0], [49.0, 3.0]]]} routeColors={[undefined]} />)++++ const [casing, core] = screen.getAllByTestId('polyline')++ .map(el => JSON.parse(el.getAttribute('data-path-options') as string))++ expect(casing.color).toBe('#0a5cc2')++ expect(core.color).toBe('#0a84ff')+ })+it('FE-COMP-MAPVIEW-007: does not render polyline when route is null', () => {render(<MapView route={null} />)expect(screen.queryByTestId('polyline')).toBeNull()diff --cc client/src/components/Map/MapViewGL.test.tsxindex e2e07abed,3f8ffe0f7..26e38f607--- a/client/src/components/Map/MapViewGL.test.tsx+++ b/client/src/components/Map/MapViewGL.test.tsx@@@ -1540,19 -1540,6 +1540,21 @@@ describe('MapViewGL', () =>expect(features[0].geometry.coordinates).toEqual([[2, 48], [3, 49]])})- it('FE-COMP-MAPVIEWGL-048b: the whole-trip overview colours each line on the feature', async () => {++ it('FE-COMP-MAPVIEWGL-048b: a caller-coloured route rides its colours on the feature', async () => {+ const routeSource = geoSource()+ glMap.getSource.mockImplementation((id: string) => (id === 'trip-route' ? routeSource : null))+- render(<MapViewGL places={[]} fitKey={1} route={[[[48, 2], [49, 3]], [[50, 4], [51, 5]]]} routeColors={['#1d4ed8', null]} />)++ render(<MapViewGL places={[]} fitKey={1} route={[[[48, 2], [49, 3]], [[50, 4], [51, 5]]]}++ routeColors={[{ line: '#ff9f0a', casing: '#c2740a' }, undefined]} />)+ await act(async () => {})++ const { features } = lastData(routeSource)- expect(features[0].properties.color).toBe('#1d4ed8')++ expect(features[0].properties.color).toBe('#ff9f0a')++ expect(features[0].properties.casing).toBe('#c2740a')+ // No colour means the day route's own blue, which the layer paint falls back to.- expect(features[1].properties.color).toBeUndefined()++ expect(features[1].properties.color).toBeNull()+ })+it('FE-COMP-MAPVIEWGL-049: unusable GPX geometry is skipped instead of breaking the layer', async () => {const gpxSource = geoSource()glMap.getSource.mockImplementation((id: string) => (id === 'trip-gpx' ? gpxSource : null))diff --cc client/src/components/Map/TripRouteOverview.test.tsxindex 1dfbd5fd3,000000000..93a91eca7mode 100644,000000..100644--- a/client/src/components/Map/TripRouteOverview.test.tsx+++ b/client/src/components/Map/TripRouteOverview.test.tsx@@@ -1,90 -1,0 +1,90 @@@+import { render, screen, fireEvent } from '@testing-library/react'+import { describe, it, expect, vi } from 'vitest'+import { TripRouteOverviewPill, TripRouteOverviewPanel } from './TripRouteOverview'+import type { TripRouteOverview } from './useTripRouteOverview'++const overview = (over: Partial<TripRouteOverview> = {}): TripRouteOverview => ({+ days: [- { dayId: 1, dayNumber: 1, date: '2025-06-01', title: null, color: '#1d4ed8', lines: [], segments: [], distance: 82000, duration: 3600, modes: ['driving'] },- { dayId: 2, dayNumber: 2, date: '2025-06-02', title: 'Coast road', color: '#ea580c', lines: [], segments: [], distance: 140500, duration: 7200, modes: ['driving', 'walking'] },++ { dayId: 1, dayNumber: 1, date: '2025-06-01', title: null, color: { line: '#0a84ff', casing: '#0a5cc2' }, lines: [], segments: [], distance: 82000, duration: 3600, modes: ['driving'] },++ { dayId: 2, dayNumber: 2, date: '2025-06-02', title: 'Coast road', color: { line: '#ff9f0a', casing: '#c2740a' }, lines: [], segments: [], distance: 140500, duration: 7200, modes: ['driving', 'walking'] },+ ],+ lines: [], lineColors: [], segments: [], focusPoints: [],+ totalDistance: 222500, totalDuration: 10800, loading: false,+ ...over,+})++describe('TripRouteOverviewPill', () => {+ it('FE-MAP-TROU-001: says which way it will take you, and reports its state', () => {+ const onToggle = vi.fn()+ const { rerender } = render(<TripRouteOverviewPill active={false} onToggle={onToggle} />)++ const button = screen.getByTestId('trip-overview-pill')+ expect(button).toHaveAttribute('aria-pressed', 'false')+ expect(button).toHaveAttribute('aria-label', 'map.overview.show')++ fireEvent.click(button)+ expect(onToggle).toHaveBeenCalledTimes(1)++ rerender(<TripRouteOverviewPill active onToggle={onToggle} />)+ expect(screen.getByTestId('trip-overview-pill')).toHaveAttribute('aria-label', 'map.overview.hide')+ })+})++describe('TripRouteOverviewPanel', () => {+ it('FE-MAP-TROU-002: leads with the trip total in the reader\'s own unit', () => {+ const { rerender } = render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)+ expect(screen.getByText('222.5 km')).toBeInTheDocument()++ rerender(<TripRouteOverviewPanel overview={overview()} unit="imperial" />)+ expect(screen.getByText('138.3 mi')).toBeInTheDocument()+ })++ it('FE-MAP-TROU-003: names every day, its distance and how it is travelled', () => {+ render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)++ expect(screen.getByText('dayplan.dayN')).toBeInTheDocument()+ // A day with a title is named by it rather than by its number.+ expect(screen.getByText('Coast road')).toBeInTheDocument()+ expect(screen.getByText('82 km')).toBeInTheDocument()+ expect(screen.getByText('140.5 km')).toBeInTheDocument()+ })++ it('FE-MAP-TROU-004: marks the total as partial while legs are still coming in', () => {+ const { container, rerender } = render(<TripRouteOverviewPanel overview={overview({ loading: true })} unit="metric" />)+ expect(container.textContent).toContain('…')++ rerender(<TripRouteOverviewPanel overview={overview()} unit="metric" />)+ expect(container.textContent).not.toContain('…')+ })++ it('FE-MAP-TROU-005: a day row picks that day when the shell offers it', () => {+ const onSelectDay = vi.fn()+ render(<TripRouteOverviewPanel overview={overview()} unit="metric" selectedDayId={2} onSelectDay={onSelectDay} />)++ fireEvent.click(screen.getByText('Coast road'))+ expect(onSelectDay).toHaveBeenCalledWith(2)+ })++ it('FE-MAP-TROU-006: read-only shells get rows, not buttons', () => {+ render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)+ expect(screen.queryAllByRole('button')).toHaveLength(0)+ })++ it('FE-MAP-TROU-008: hugs its rows, and takes the cap the shell gives it', () => {+ const { container, rerender } = render(<TripRouteOverviewPanel overview={overview()} unit="metric" />)+ const card = () => screen.getByTestId('trip-overview-panel')++ expect(card().style.width).toBe('fit-content')+ expect(card().style.maxWidth).toBe('320px')++ // The phone shell asks for a narrower card so the map keeps the space.+ rerender(<TripRouteOverviewPanel overview={overview()} unit="metric" maxWidth={240} />)+ expect(card().style.maxWidth).toBe('240px')+ expect(container).not.toBeEmptyDOMElement()+ })++ it('FE-MAP-TROU-007: draws nothing at all for a trip with no routed day', () => {+ const { container } = render(<TripRouteOverviewPanel overview={overview({ days: [], totalDistance: 0 })} unit="metric" />)+ expect(container).toBeEmptyDOMElement()+ })+})diff --cc client/src/components/Map/TripRouteOverview.tsxindex 7392ca1be,000000000..5c0145b89mode 100644,000000..100644--- a/client/src/components/Map/TripRouteOverview.tsx+++ b/client/src/components/Map/TripRouteOverview.tsx@@@ -1,130 -1,0 +1,130 @@@+import { Route } from 'lucide-react'+import { useTranslation } from '../../i18n'+import { profileIcon } from '../Planner/DayPlanSidebarRouteConnector'+import { formatDistance } from '../../utils/units'+import { MAP_CONTROL_SHADOW } from './mapControlShadow'+import type { TripRouteOverview as Overview } from './useTripRouteOverview'+import type { DistanceUnit } from '../../types'++/**+ * Toggle for the whole-trip route overview (#1736). Same frosted shell as the other+ * map controls, so it lines up with the compass and the layer switcher.+ */+export function TripRouteOverviewPill({ active, onToggle }: { active: boolean; onToggle: () => void }) {+ const { t } = useTranslation()+ const label = active ? t('map.overview.hide') : t('map.overview.show')+ return (+ <div style={{+ display: 'inline-flex', alignItems: 'center', padding: 4, borderRadius: 999, pointerEvents: 'auto',+ background: 'var(--sidebar-bg)',+ backdropFilter: 'blur(20px) saturate(180%)',+ WebkitBackdropFilter: 'blur(20px) saturate(180%)',+ boxShadow: MAP_CONTROL_SHADOW,+ }}>+ <button+ type="button"+ onClick={onToggle}+ aria-label={label}+ title={label}+ aria-pressed={active}+ data-testid="trip-overview-pill"+ className={active ? 'text-accent' : 'text-content-muted'}+ style={{+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',+ width: 34, height: 34, borderRadius: 999, border: 'none', cursor: 'pointer',+ background: 'transparent', padding: 0,+ transition: 'background 0.14s, color 0.14s',+ }}+ onMouseEnter={e => { e.currentTarget.style.background = 'var(--bg-hover)' }}+ onMouseLeave={e => { e.currentTarget.style.background = 'transparent' }}+ >+ <Route size={17} strokeWidth={2} />+ </button>+ </div>+ )+}++/**+ * The trip's stages and its total distance, read off the overview the map is drawing.+ *+ * One component for both shells: the phone and the desktop place it differently but the+ * rows are the same rows, and a second copy of them is a second thing to keep in step.+ */+export function TripRouteOverviewPanel({ overview, unit, selectedDayId, onSelectDay, maxWidth = 320 }: {+ overview: Overview+ unit: DistanceUnit+ selectedDayId?: number | null+ onSelectDay?: (dayId: number) => void+ /** How wide the card may grow before day names start to ellipsize. */+ maxWidth?: number+}) {+ const { t } = useTranslation()+ if (!overview.days.length) return null++ return (+ <div+ data-testid="trip-overview-panel"+ style={{+ pointerEvents: 'auto', borderRadius: 14, overflow: 'hidden',+ background: 'var(--sidebar-bg)',+ backdropFilter: 'blur(20px) saturate(180%)',+ WebkitBackdropFilter: 'blur(20px) saturate(180%)',+ boxShadow: 'var(--sidebar-shadow, 0 4px 16px rgba(0,0,0,0.14))',+ // Sized to its rows rather than to the space available: a trip of short day+ // names left a band of empty card over the map, which on a phone is most of+ // what there is to look at.+ width: 'fit-content', maxWidth,+ }}+ >+ <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12, padding: '10px 14px 8px' }}>+ <span className="text-content-muted" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', textTransform: 'uppercase', letterSpacing: 0.4 }}>+ {t('map.overview.total')}+ </span>+ {/* Same tier as the label beside it: the two read as one line rather than as a+ heading with a number stuck under it. */}+ <span className="text-content" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 600 }}>+ {formatDistance(overview.totalDistance / 1000, unit)}+ {/* Still routing: the number is a partial sum, and saying so beats a total+ that silently grows while you read it. */}+ {overview.loading && <span className="text-content-muted" style={{ fontWeight: 400 }}>{' '}…</span>}+ </span>+ </div>+ <div style={{ maxHeight: 220, overflowY: 'auto', borderTop: '1px solid var(--border-primary)' }}>+ {overview.days.map(day => {+ const label = day.title || t('dayplan.dayN', { n: day.dayNumber })+ const row = (+ <>- <span style={{ width: 8, height: 8, borderRadius: 999, background: day.color, flexShrink: 0 }} aria-hidden />++ <span style={{ width: 8, height: 8, borderRadius: 999, background: day.color.line, flexShrink: 0 }} aria-hidden />+ <span className="text-content" style={{ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>+ {label}+ </span>+ <span style={{ display: 'inline-flex', alignItems: 'center', gap: 3, flexShrink: 0 }} className="text-content-muted">+ {day.modes.map(mode => {+ const Icon = profileIcon(mode)+ return <Icon key={mode} size={12} strokeWidth={2} aria-hidden />+ })}+ </span>+ <span className="text-content-muted" style={{ flexShrink: 0, fontVariantNumeric: 'tabular-nums' }}>+ {formatDistance(day.distance / 1000, unit)}+ </span>+ </>+ )+ const style = {+ display: 'flex', alignItems: 'center', gap: 8, width: '100%',+ padding: '7px 14px', textAlign: 'left' as const,+ fontSize: 'calc(12px * var(--fs-scale-body, 1))',+ background: day.dayId === selectedDayId ? 'var(--bg-hover)' : 'transparent',+ border: 'none',+ }+ return onSelectDay ? (+ <button key={day.dayId} type="button" onClick={() => onSelectDay(day.dayId)} style={{ ...style, cursor: 'pointer' }}>+ {row}+ </button>+ ) : (+ <div key={day.dayId} style={style}>{row}</div>+ )+ })}+ </div>+ </div>+ )+}diff --cc client/src/components/Map/useTripRouteOverview.test.tsindex 2d33ca919,000000000..fd7d2e596mode 100644,000000..100644--- a/client/src/components/Map/useTripRouteOverview.test.ts+++ b/client/src/components/Map/useTripRouteOverview.test.ts@@@ -1,137 -1,0 +1,139 @@@+import { renderHook, waitFor } from '@testing-library/react'+import { describe, it, expect, vi, beforeEach } from 'vitest'- import { TRACK_COLORS } from '@trek/shared'++import { dayColor } from '../Roadtrip/dayColors'+import { useTripRouteOverview } from './useTripRouteOverview'+import { buildAssignment, buildDay, buildPlace } from '../../../tests/helpers/factories'+import type { AssignmentsMap, RouteSegment } from '../../types'++vi.mock('./RouteCalculator', async (importActual) => {+ const actual = await importActual<typeof import('./RouteCalculator')>()+ return { ...actual, calculateRouteWithLegs: vi.fn() }+})++const { calculateRouteWithLegs } = await import('./RouteCalculator')++const leg = (distance: number, duration: number): RouteSegment => ({+ mid: [0, 0], from: [0, 0], to: [0, 0],+ distance, duration,+ distanceText: `${Math.round(distance / 1000)} km`,+ durationText: '1 h', walkingText: '5 h', drivingText: '1 h',+})++const at = (lat: number, lng: number, order: number, dayId: number, extra: Record<string, unknown> = {}) =>+ buildAssignment({ day_id: dayId, order_index: order, place: buildPlace({ lat, lng }), ...extra })++const DAYS = [buildDay({ id: 1, day_number: 1 }), buildDay({ id: 2, day_number: 2 })]+const ASSIGNMENTS: AssignmentsMap = {+ '1': [at(48.86, 2.35, 0, 1), at(48.88, 2.36, 1, 1)],+ '2': [at(45.76, 4.83, 0, 2), at(45.78, 4.85, 1, 2)],+}++const render = (enabled = true, assignments: AssignmentsMap = ASSIGNMENTS, days = DAYS) =>+ renderHook(+ ({ assignments: a }: { assignments: AssignmentsMap }) =>+ useTripRouteOverview(7, days, a, [], [], 'driving', enabled),+ { initialProps: { assignments } },+ )++beforeEach(() => {+ vi.mocked(calculateRouteWithLegs).mockReset()+ vi.mocked(calculateRouteWithLegs).mockResolvedValue({+ coordinates: [[48.86, 2.35], [48.87, 2.355], [48.88, 2.36]],+ distance: 12000, duration: 900,+ legs: [leg(12000, 900)],+ })+})++describe('useTripRouteOverview', () => {+ it('FE-MAP-TRO-001: does nothing at all until it is switched on', () => {+ const { result } = render(false)++ expect(result.current.days).toEqual([])+ expect(result.current.totalDistance).toBe(0)+ expect(result.current.loading).toBe(false)+ expect(calculateRouteWithLegs).not.toHaveBeenCalled()+ })++ it('FE-MAP-TRO-002: sums every day into the trip total', async () => {+ const { result } = render()++ await waitFor(() => expect(result.current.loading).toBe(false))+ expect(result.current.days).toHaveLength(2)+ expect(result.current.days.map(d => d.distance)).toEqual([12000, 12000])+ expect(result.current.totalDistance).toBe(24000)+ expect(result.current.totalDuration).toBe(1800)+ })+- it('FE-MAP-TRO-003: gives each day its own colour from the map palette', async () => {++ it('FE-MAP-TRO-003: gives each day the colour the road trip draws it in', async () => {+ const { result } = render()++ await waitFor(() => expect(result.current.loading).toBe(false))+ const colors = result.current.days.map(d => d.color)- expect(colors[0]).toBe(TRACK_COLORS[1])- expect(colors[1]).toBe(TRACK_COLORS[2])++ // The same palette either way, so a day does not change colour when the trip is++ // read as a road trip instead of an overview.++ expect(colors[0]).toEqual(dayColor(1))++ expect(colors[1]).toEqual(dayColor(2))+ // Every drawn line is labelled with the colour of the day it belongs to.+ expect(result.current.lineColors).toHaveLength(result.current.lines.length)- expect(new Set(result.current.lineColors).size).toBe(2)++ expect(new Set(result.current.lineColors.map(c => c.line)).size).toBe(2)+ })++ it('FE-MAP-TRO-004: reports the modes each day is travelled in', async () => {+ const { result } = render(true, {+ '1': [at(48.86, 2.35, 0, 1, { leg_transport_mode: 'walking' }), at(48.88, 2.36, 1, 1)],+ '2': ASSIGNMENTS['2'],+ })++ await waitFor(() => expect(result.current.loading).toBe(false))+ expect(result.current.days[0].modes).toEqual(['walking'])+ expect(result.current.days[1].modes).toEqual(['driving'])+ expect(result.current.days[0].segments[0].mode).toBe('walking')+ })++ it('FE-MAP-TRO-005: draws straight lines first and keeps them when routing refuses', async () => {+ vi.mocked(calculateRouteWithLegs).mockRejectedValue(new Error('429'))+ const { result } = render()++ await waitFor(() => expect(result.current.loading).toBe(false))+ // The shape of the trip is still on the map...+ expect(result.current.lines).toHaveLength(2)+ expect(result.current.lines[0]).toEqual([[48.86, 2.35], [48.88, 2.36]])+ // ...but a leg that never answered contributes no distance.+ expect(result.current.totalDistance).toBe(0)+ })++ it('FE-MAP-TRO-006: a day with nothing to drive is left out', async () => {+ const { result } = render(true, { '1': ASSIGNMENTS['1'], '2': [at(45.76, 4.83, 0, 2)] })++ await waitFor(() => expect(result.current.loading).toBe(false))+ expect(result.current.days.map(d => d.dayId)).toEqual([1])+ })++ it('FE-MAP-TRO-007: frames the whole trip, not one day of it', async () => {+ const { result } = render()++ await waitFor(() => expect(result.current.loading).toBe(false))+ expect(result.current.focusPoints.length).toBe(result.current.lines.flat().length)+ expect(result.current.focusPoints.length).toBeGreaterThan(2)+ })++ it('FE-MAP-TRO-008: renaming a place does not re-route the trip', async () => {+ const { result, rerender } = render()+ await waitFor(() => expect(result.current.loading).toBe(false))+ const calls = vi.mocked(calculateRouteWithLegs).mock.calls.length++ expect(calls).toBeGreaterThan(0)++ // A new object identity with the same geometry: the plan memo re-runs, the+ // routing round must not.+ rerender({+ assignments: {+ ...ASSIGNMENTS,+ '1': ASSIGNMENTS['1'].map(a => ({ ...a, place: { ...a.place, name: 'Renamed' } })),+ },+ })++ await waitFor(() => expect(result.current.loading).toBe(false))+ expect(vi.mocked(calculateRouteWithLegs).mock.calls.length).toBe(calls)+ })+})diff --cc client/src/components/Map/useTripRouteOverview.tsindex 5aa8f34d3,000000000..5487e3bb4mode 100644,000000..100644--- a/client/src/components/Map/useTripRouteOverview.ts+++ b/client/src/components/Map/useTripRouteOverview.ts@@@ -1,225 -1,0 +1,227 @@@+import { useEffect, useMemo, useRef, useState } from 'react'+import { calculateRouteWithLegs, type RouteProfileKey } from './RouteCalculator'+import { buildDayRouteRuns, type DayRoutePoint } from './dayRoutePlan'+import { resolveLegMode } from '../Planner/legMode'+import { useSettingsStore } from '../../store/settingsStore'- import { TRACK_COLORS } from '@trek/shared'++import { dayColor } from '../Roadtrip/dayColors'+import type { Accommodation, AssignmentsMap, Day, Reservation, RouteSegment } from '../../types'++/** One travel day of the overview: the roads it covers, in its own colour. */+export interface TripOverviewDay {+ dayId: number+ dayNumber: number+ date: string | null+ title: string | null- color: string++ /** The core and casing this day is drawn in — the road trip's palette, so a day is++ * the same colour whichever way the trip is being read. */++ color: { line: string; casing: string }+ /** One polyline per run of the day, `[lat, lng]`. */+ lines: [number, number][][]+ segments: RouteSegment[]+ /** Metres and seconds, summed over the day's legs. */+ distance: number+ duration: number+ /** The modes this day is actually travelled in, first use first. */+ modes: string[]+}++export interface TripRouteOverview {+ days: TripOverviewDay[]+ /** Every day's polylines flattened in trip order — what the map draws. */+ lines: [number, number][][]+ /** The colour of each entry of `lines`, same index. */- lineColors: string[]++ lineColors: { line: string; casing: string }[]+ segments: RouteSegment[]+ /** Every drawn coordinate, so the map can frame the whole trip at once. */+ focusPoints: [number, number][]+ totalDistance: number+ totalDuration: number+ /** True until every leg has answered — the totals are a partial sum until then. */+ loading: boolean+}++const EMPTY: TripRouteOverview = {+ days: [], lines: [], lineColors: [], segments: [], focusPoints: [],+ totalDistance: 0, totalDuration: 0, loading: false,+}++/** Neighbouring legs of one run that resolve to the same mode travel as one request,+ * exactly as the single-day route builds them. */+interface Chunk { points: DayRoutePoint[]; mode: string }++function chunkRun(run: DayRoutePoint[], dayDefaultMode: string): Chunk[] {+ const chunks: Chunk[] = []+ let i = 0+ while (i < run.length - 1) {+ const mode = resolveLegMode(run[i], run[i + 1], dayDefaultMode)+ let end = i + 1+ while (end < run.length - 1 && resolveLegMode(run[end], run[end + 1], dayDefaultMode) === mode) end+++ chunks.push({ points: run.slice(i, end + 1), mode })+ i = end+ }+ return chunks+}++const straight = (points: DayRoutePoint[]): [number, number][] => points.map(p => [p.lat, p.lng])++/**+ * Every travel day's route at once, each day in its own colour, with the trip's total+ * distance (#1736).+ *+ * The geometry is the day view's own — `buildDayRouteRuns` is the same builder+ * `useRouteCalculation` draws the selected day from, so a day looks identical whether+ * you are looking at it alone or at the whole trip. Only the aggregation is new.+ *+ * Legs go out a few at a time rather than all at once: a fortnight is dozens of legs and+ * the routing host is usually a shared OSRM. RouteCalculator's cache is shared with the+ * day route and the sidebar connectors, so the day already on screen costs nothing.+ */+export function useTripRouteOverview(+ tripId: number | null,+ days: Day[],+ assignments: AssignmentsMap,+ reservations: Reservation[],+ accommodations: Accommodation[],+ profile: RouteProfileKey,+ enabled: boolean,+): TripRouteOverview {+ const optimizeFromAccommodation = useSettingsStore(s => s.settings.optimize_from_accommodation)+ // Leg text is formatted at compute time, so a km↔mi switch has to re-run (#1300).+ const distanceUnit = useSettingsStore(s => s.settings.distance_unit)+ const [result, setResult] = useState<TripRouteOverview>(EMPTY)+ const abortRef = useRef<AbortController | null>(null)++ const plan = useMemo(() => {+ if (!enabled) return []+ return [...days]+ .sort((a, b) => (a.day_number ?? 0) - (b.day_number ?? 0))+ .map(day => ({+ day,+ runs: buildDayRouteRuns(day.id, { days, assignments, reservations, accommodations, optimizeFromAccommodation }),+ }))+ .filter(entry => entry.runs.length > 0)+ }, [enabled, days, assignments, reservations, accommodations, optimizeFromAccommodation])++ // Only geometry and mode decide whether legs have to be fetched again: renaming a+ // place or editing its notes must not fire a routing round.+ const planKey = useMemo(+ () => plan.map(({ day, runs }) => `${day.id}@${day.default_transport_mode ?? ''}:${runs+ .map(run => run.map(p => `${p.lat.toFixed(5)},${p.lng.toFixed(5)},${p.leg_transport_mode ?? ''},${p.incoming_leg_transport_mode ?? ''}`).join('|'))+ .join('/')}`).join(';'),+ [plan],+ )++ useEffect(() => {+ abortRef.current?.abort()+ if (!plan.length) { setResult(EMPTY); return }++ const controller = new AbortController()+ abortRef.current = controller+- const colorFor = (day: Day) => TRACK_COLORS[Math.abs(day.day_number ?? 0) % TRACK_COLORS.length]++ const colorFor = (day: Day) => dayColor(day.day_number ?? 0)++ // Chunk every day up front, so the routed answers can be filed by position and+ // reassembled in order however they come back.+ const chunked = plan.map(({ day, runs }) => {+ const dayDefaultMode = day.default_transport_mode || profile+ return { day, runs: runs.map(run => chunkRun(run, dayDefaultMode)) }+ })++ const assemble = (+ routed: (({ coordinates: [number, number][]; legs: RouteSegment[] }) | null)[][][],+ ): TripRouteOverview => {+ const overviewDays: TripOverviewDay[] = chunked.map(({ day, runs }, d) => {+ const lines: [number, number][][] = []+ const segments: RouteSegment[] = []+ runs.forEach((chunks, r) => {+ const polyline: [number, number][] = []+ chunks.forEach((chunk, c) => {+ const answer = routed[d][r][c]+ const coords = answer && answer.coordinates.length >= 2 ? answer.coordinates : straight(chunk.points)+ for (const point of coords) {+ // Drop the point shared with the previous chunk so concatenated legs+ // don't leave a duplicate at each junction.+ const last = polyline[polyline.length - 1]+ if (last && last[0] === point[0] && last[1] === point[1]) continue+ polyline.push(point)+ }+ if (answer) for (const leg of answer.legs) segments.push({ ...leg, mode: chunk.mode })+ })+ if (polyline.length >= 2) lines.push(polyline)+ })+ const modes: string[] = []+ for (const chunk of runs.flat()) if (!modes.includes(chunk.mode)) modes.push(chunk.mode)+ return {+ dayId: day.id,+ dayNumber: day.day_number ?? 0,+ date: day.date ?? null,+ title: day.title ?? null,+ color: colorFor(day),+ lines,+ segments,+ distance: segments.reduce((sum, s) => sum + s.distance, 0),+ duration: segments.reduce((sum, s) => sum + s.duration, 0),+ modes,+ }+ })+ const lines = overviewDays.flatMap(d => d.lines)+ return {+ days: overviewDays,+ lines,+ lineColors: overviewDays.flatMap(d => d.lines.map(() => d.color)),+ segments: overviewDays.flatMap(d => d.segments),+ focusPoints: lines.flat(),+ totalDistance: overviewDays.reduce((sum, d) => sum + d.distance, 0),+ totalDuration: overviewDays.reduce((sum, d) => sum + d.duration, 0),+ loading: false,+ }+ }++ const routed = chunked.map(({ runs }) => runs.map(chunks => chunks.map(() => null as+ ({ coordinates: [number, number][]; legs: RouteSegment[] }) | null)))++ // Straight lines first so the shape of the trip is on screen immediately, then the+ // real roads replace them — the same two-step the single-day route draws with.+ setResult({ ...assemble(routed), loading: true })++ ;(async () => {+ const tasks: (() => Promise<void>)[] = []+ chunked.forEach(({ day, runs }, d) => {+ runs.forEach((chunks, r) => {+ chunks.forEach((chunk, c) => {+ tasks.push(async () => {+ try {+ const answer = await calculateRouteWithLegs(+ chunk.points.map(p => ({ lat: p.lat, lng: p.lng })),+ { signal: controller.signal, profile: chunk.mode, tripId, dayId: day.id },+ )+ routed[d][r][c] = { coordinates: answer.coordinates, legs: answer.legs }+ } catch {+ // Routing refused this leg (usually a rate limit) — it keeps its+ // straight line and contributes no distance, exactly as a day route's+ // failed leg does.+ }+ })+ })+ })+ })++ // Small pool on purpose, the same one the sidebar connectors use: a fortnight is+ // dozens of legs and the routing host is often a shared OSRM.+ let next = 0+ const worker = async () => {+ while (next < tasks.length && !controller.signal.aborted) await tasks[next++]()+ }+ await Promise.all(Array.from({ length: Math.min(6, tasks.length) }, worker))++ if (!controller.signal.aborted) setResult(assemble(routed))+ })()++ return () => controller.abort()+ // planKey is derived from the same inputs as plan, so keying on the string is+ // equivalent while staying stable across unrelated renders.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [planKey, profile, tripId, distanceUnit])++ return result+}diff --cc client/src/pages/TripPlannerPage.tsxindex 50e03f72b,44d99e41d..6e3c6dd9f--- a/client/src/pages/TripPlannerPage.tsx+++ b/client/src/pages/TripPlannerPage.tsx@@@ -252,8 -252,7 +253,8 @@@ function TripPlannerPageDesktop(): ReacselectedDayId, isLoading, tripActions, can, canUploadFiles,pushUndo, undo, canUndo, lastActionLabel, handleUndo,enabledAddons, collabFeatures, tripAccommodations, setTripAccommodations,- roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripCorridor,+ roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripLineColors, roadtripMapLines, roadtripMapPlaces, collapsedRoadtripDays, toggleRoadtripDay, roadtripCorridor,+ overviewActive, tripOverview, toggleOverview, overviewShown,followTrack, roadtripViaCounts,allowedFileTypes, tripMembers, setTripMembers, refreshMembers, loadAccommodations,TRANSPORT_TYPES, TRIP_TABS, activeTab, setActiveTab, handleTabChange,@@@ -397,10 -403,10 +406,10 @@@<div style={{ position: 'absolute', inset: 0 }}><MapViewtripId={tripId}- places={mapPlaces}+ places={roadtripActive ? roadtripMapPlaces : mapPlaces}dayPlaces={dayPlaces}- route={roadtripActive ? roadtripRoutes.lines : overviewActive ? tripOverview.lines : route}- routeColors={overviewActive ? tripOverview.lineColors : undefined}- route={roadtripActive ? roadtripMapLines : route}- routeColors={roadtripActive ? roadtripLineColors : undefined}++ route={roadtripActive ? roadtripMapLines : overviewActive ? tripOverview.lines : route}++ routeColors={roadtripActive ? roadtripLineColors : overviewActive ? tripOverview.lineColors : undefined}routeVias={roadtripActive ? roadtripRoutes.vias : routeVias}accessLines={roadtripActive ? roadtripRoutes.accessLines : undefined}showTransitRoutes={transitRoutesShown}@@@ -443,7 -448,7 +451,7 @@@onRouteClick={roadtripActive && can('day_edit', trip) ? addRoadtripVia : undefined}roadtripVias={roadtripActive ? roadtripVias.byDay : undefined}alternativeRoutes={alternativeOverlays}- focusPoints={overviewActive ? tripOverview.focusPoints : alternativeFocusPoints}- focusPoints={mapFocusPoints}++ focusPoints={overviewActive ? tripOverview.focusPoints : mapFocusPoints}clusterLoosely={roadtripActive}activeAlternative={highlightedAlternative}onChooseAlternative={chooseRouteAlternative}diff --cc client/src/pages/tripPlanner/useTripPlanner.tsindex 301cdfc0a,9aa3dcfbb..13d74eb37--- a/client/src/pages/tripPlanner/useTripPlanner.ts+++ b/client/src/pages/tripPlanner/useTripPlanner.ts@@@ -1800,8 -2009,7 +2025,8 @@@ export function useTripPlanner()selectedDayId, isLoading, tripActions, can, canUploadFiles,pushUndo, undo, canUndo, lastActionLabel, handleUndo,enabledAddons, collabFeatures, tripAccommodations, setTripAccommodations,- roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripCorridor,+ roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripLineColors, roadtripMapLines, roadtripMapPlaces, collapsedRoadtripDays, toggleRoadtripDay, roadtripCorridor,+ overviewShown, toggleOverview, overviewActive, tripOverview,followTrack, roadtripViaCounts,allowedFileTypes, tripMembers, setTripMembers, refreshMembers, loadAccommodations,TRANSPORT_TYPES, TRIP_TABS, activeTab, setActiveTab, handleTabChange,