Skip to content

feat: show live vehicle position on departure details map - #772

Merged
gorandalum merged 3 commits into
mainfrom
dalum/follow_bus
Jul 17, 2026
Merged

feat: show live vehicle position on departure details map#772
gorandalum merged 3 commits into
mainfrom
dalum/follow_bus

Conversation

@gorandalum

@gorandalum gorandalum commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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.

Screenshot 2026-07-16 at 14 44 46

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.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
planner-web Ready Ready Preview, Comment Jul 17, 2026 8:54am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_URL through 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.

Comment thread src/utils/use-subscription.ts
Comment thread src/page-modules/departures/details/utils.ts
Comment thread src/components/map/use-live-vehicle.ts
Comment thread src/components/map/use-live-vehicle.ts
@gorandalum
gorandalum marked this pull request as ready for review July 17, 2026 08:52
@gorandalum
gorandalum requested a review from rosvik July 17, 2026 08:52

@rosvik rosvik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@gorandalum

Copy link
Copy Markdown
Contributor Author

I'll look into it. Still merging this as it is not connected to map not showing up on small devices.

@gorandalum
gorandalum merged commit 1a1a2a6 into main Jul 17, 2026
5 checks passed
@gorandalum
gorandalum deleted the dalum/follow_bus branch July 17, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants