feat: show live vehicle position on departure details map - #772
Conversation
Shows the vehicle's live position on the map in departure details, mirroring the mobile app's implementation and using the same BFF vehicles WebSocket endpoint as backend. Unlike the app, where the live view is opened through the follow bus button, the live vehicle is shown and followed by default when viewing departure details. Requires new env var NEXT_PUBLIC_WS_API_BASE_URL.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a live-vehicle overlay to the departures details map by subscribing to the BFF vehicles WebSocket endpoint and updating the map with a vehicle marker that can be auto-followed.
Changes:
- Introduces a reusable WebSocket subscription hook with reconnect/backoff, and a live-vehicle subscription hook for service journeys.
- Adds map-layer rendering + follow behavior for a live vehicle marker (including disconnected/stale visuals).
- Wires up the new
NEXT_PUBLIC_WS_API_BASE_URLthrough env/example, test setup, Dockerfile, and CI docker workflow.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/use-subscription.ts | New WebSocket subscription hook with reconnect/backoff. |
| src/tests/setup.ts | Stubs new env var and a test WebSocket implementation. |
| src/page-modules/departures/details/utils.ts | Adds “should show live vehicle” time-window logic. |
| src/page-modules/departures/details/index.tsx | Enables live vehicle on departure details map and passes props into Map. |
| src/page-modules/departures/client/vehicles/use-live-vehicle-subscription.ts | New hook subscribing to live vehicle updates via WebSocket. |
| src/page-modules/departures/client/vehicles/types.ts | Adds vehicle/location types for live updates. |
| src/page-modules/departures/client/vehicles/index.ts | Re-exports vehicles client modules. |
| src/page-modules/departures/client/index.ts | Re-exports vehicles from departures client package. |
| src/page-modules/departures/tests/get-should-show-live-vehicle.test.ts | Adds unit tests for the live-vehicle visibility window. |
| src/components/map/use-map-follow.ts | New hook for auto-following the vehicle on the map. |
| src/components/map/use-live-vehicle.ts | New hook adding/updating Mapbox source/layers for the live vehicle marker. |
| src/components/map/map.tsx | Extends Map props to accept live vehicle data and hooks it into the map. |
| Dockerfile | Adds per-tenant build args + ENV wiring for WebSocket base URL. |
| .github/workflows/docker.yml | Provides per-tenant WebSocket base URLs for staging/release builds. |
| .env.example | Documents required NEXT_PUBLIC_WS_API_BASE_URL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rosvik
left a comment
There was a problem hiding this comment.
Sweet 🙌 Don't see any issues with this, but noticed that the map on departure details doesn't work on mobile. Same problem in staging, but it works in prod. Could you have a look?
|
I'll look into it. Still merging this as it is not connected to map not showing up on small devices. |
Shows the vehicle's live position on the map in departure details,
mirroring the mobile app's implementation and using the same BFF
vehicles WebSocket endpoint as backend.
Unlike the app, where the live view is opened through the follow bus
button, the live vehicle is shown and followed by default when viewing
departure details.
Requires new env var NEXT_PUBLIC_WS_API_BASE_URL.