Skip to content

Update styles#40

Merged
Mr-Technician merged 1 commit into
api-and-pmtiles-integrationfrom
update-map-styles
May 10, 2026
Merged

Update styles#40
Mr-Technician merged 1 commit into
api-and-pmtiles-integrationfrom
update-map-styles

Conversation

@Mootbing
Copy link
Copy Markdown
Collaborator

@Mootbing Mootbing commented May 10, 2026

Summary

  • Replace OpenFreeMap liberty styles with custom Apple Maps-inspired color palettes
  • Add light mode style (apple-light-style.json) with warm off-white background, soft blue water, sage greens, and gold motorways
  • Add dark mode style (apple-dark-style.json) with deep charcoal background, navy water, muted greens, and dark gold roads

Test plan

  • Verify light mode map renders correctly on device
  • Verify dark mode map renders correctly on device
  • Confirm colors match Apple Maps aesthetic

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Real-time train position tracking with live WebSocket updates
    • Apple Light and Dark map styles
    • Provider-specific transit routes and stations as interactive map layers
  • Chores

    • Added environment-based configuration support for API endpoints
    • Updated TypeScript type definitions and dependencies

Review Change Stack

Replace OpenFreeMap liberty styles with custom Apple Maps-inspired color palettes for both light and dark modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Mootbing Mootbing requested a review from Mr-Technician May 10, 2026 17:40
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

Review Change Stack

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This PR migrates the mobile app from GTFS parser-based train data to a REST API-backed architecture with WebSocket realtime streaming. It adds API type contracts, HTTP and WebSocket clients, refactors services and hooks to use API data instead of local GTFS parsing, introduces a new map tile component, and updates MapScreen to render provider-specific features without GTFS dependency.

Changes

Mobile App: GTFS → API-Backed Realtime Architecture

Layer / File(s) Summary
API Data Types
apps/mobile/types/api.ts
New TypeScript interfaces mirror backend API spec: ApiAgency, ApiRoute, ApiStop, ApiTrip, ApiTrainPosition, RealtimeUpdate, and related DTOs with camelCase field names.
Provider & Configuration
apps/mobile/constants/providers.ts, apps/mobile/constants/config.ts, apps/mobile/constants/map-styles.ts, apps/mobile/app.config.ts
ProviderId union and Provider interface with zoom thresholds; config module reads from expo-constants with URL fallbacks; MAP_STYLE migrates from URLs to local StyleSpecification objects; app config declares process.env types and adds apiUrl/wsUrl/tilesUrl extras.
Map Style Assets
apps/mobile/assets/apple-light-style.json, apps/mobile/assets/apple-dark-style.json
New Mapbox/MapLibre-compatible JSON style files define rendering layers for background, roads, buildings, labels, and symbols.
REST API Client
apps/mobile/services/api-client.ts
Typed HTTP client with timeout, error handling, in-memory TTL caching; exports endpoint functions for provider/stop/route/trip/search; includes stub functions for unimplemented endpoints; prefetch and cache query helpers.
WebSocket Realtime Client
apps/mobile/services/ws-client.ts
Singleton WebSocket client with per-provider ref-counted subscriptions, exponential backoff reconnect, position caching, and listener dispatch with error isolation.
Train API Adapter
apps/mobile/services/api.ts
Refactored TrainAPIService adapts REST API and WebSocket snapshots into Train/Stop shapes; removed GTFS parser and realtime polling; route names resolved via cache; realtime attached from WebSocket snapshot only for today's trains.
Location Suggestions
apps/mobile/services/location-suggestions.ts
API-backed implementation replaces GTFS parser; requests location permission, fetches nearby stops, and best-effort departures for suggestions.
Realtime Context
apps/mobile/context/RealtimeContext.tsx
React context holds live positions per provider; RealtimeProvider subscribes to WebSocket, merges updates, prefetches routes, and exposes positions via useRealtimePositions hook.
Map Component
apps/mobile/components/map/ProviderTiles.tsx
New component renders PMTiles-backed vector source with route lines, station circles, and labels; detects station/route taps and invokes optional callbacks with normalized payloads.
Hooks Refactoring
apps/mobile/hooks/useFrequentlyUsed.ts, apps/mobile/hooks/useLiveTrains.ts, apps/mobile/hooks/useRealtime.ts
useFrequentlyUsed uses static defaults; useLiveTrains derives from useRealtimePositions; useRealtime replaces polling with 300ms debounced WebSocket-driven refresh with stale-write guard.
MapScreen Integration
apps/mobile/screens/MapScreen.tsx
Renders ProviderTiles per provider instead of clustered GTFS stations; removes GTFS gating on saved train load; adds camera initialization; wraps with RealtimeProvider; adapts tile taps to station/route handlers.
Decoupling
apps/mobile/context/GTFSRefreshContext.tsx, apps/mobile/package.json
Removes gtfsParser import; LocationSuggestionsService.initialize called without parser; adds @types/react-native-vector-icons dev dependency.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • Mr-Technician

🐰 Hops through realms of data, from GTFS groves to API shores,
WebSockets whisper positions, while tiles paint provider lore,
Hooks now dance with realtime grace, no polling chains hold fast,
The migration's done—rejoice, dear dev, the future's here at last!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 51.06% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'Update styles' is too vague and generic. While the PR does update map styles, the title does not convey the specific, substantive nature of the changes: it mentions only styles, but the changeset includes major architectural refactors (API client, WebSocket integration, RealtimeContext, provider-driven tile rendering, removal of polling-based data flows). Consider a more descriptive title that captures the primary architectural changes, such as: 'Migrate to API-driven realtime with PMTiles rendering' or 'Add WebSocket-based realtime tracking and provider tile map rendering'. If the PR is indeed focused on styles alone, clarify the commit scope.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-map-styles

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mootbing Mootbing changed the base branch from main to api-and-pmtiles-integration May 10, 2026 17:44
@Mr-Technician Mr-Technician merged commit 92aa5b0 into api-and-pmtiles-integration May 10, 2026
1 check passed
@Mr-Technician Mr-Technician deleted the update-map-styles branch May 10, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants