Skip to content

Playable Area layer and toggle layers button - #159

Open
cosminpolifronie wants to merge 16 commits into
simrail:mainfrom
cosminpolifronie:playable-area
Open

cosminpolifronie wants to merge 16 commits into
simrail:mainfrom
cosminpolifronie:playable-area

Conversation

@cosminpolifronie

@cosminpolifronie cosminpolifronie commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

After merging #158, this PR can be merged to add a "Playable area" toggle. When hovering over the tracks you can also see details related to them.

Also added a "Layers" toggle button, as on some devices the layers just don't fit properly.

Summary by CodeRabbit

  • New Features

    • Added map layers for passenger stations and playable railway tracks, with controls to show or hide the layers menu.
    • Playable tracks are color-coded by availability. Hover to inspect nearby lines and click to highlight them.
    • Map popups now reposition to stay within the map view.
  • Bug Fixes

    • Improved train route drawing to better follow rail lines and handle connections between route segments.
    • Updated station locations and details across the map.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5e5d0ecd-a3e3-4c44-9734-b2cb84c57ed9

📥 Commits

Reviewing files that changed from the base of the PR and between 3123309 and e9ac429.

⛔ Files ignored due to path filters (2)
  • packages/map/public/markers/icon-station-passenger.png is excluded by !**/*.png
  • packages/map/public/markers/icon-station-remote.png is excluded by !**/*.png
📒 Files selected for processing (23)
  • packages/map/components/Map.tsx
  • packages/map/components/Markers/HoverPopup.tsx
  • packages/map/components/Markers/NonPlayableStationMarker.tsx
  • packages/map/components/Markers/PassengerStationMarker.tsx
  • packages/map/components/Markers/SignalMarker.tsx
  • packages/map/components/Markers/StationMarker.tsx
  • packages/map/components/Markers/StationRemoteMarker.tsx
  • packages/map/components/Markers/TrainMarker.tsx
  • packages/map/components/PassengerStations.tsx
  • packages/map/components/PlayableArea.tsx
  • packages/map/components/TrainRoute.tsx
  • packages/map/components/playableArea.json
  • packages/map/components/railData.json
  • packages/map/components/stations.json
  • packages/map/components/stationsPassenger.json
  • packages/map/components/stationsRemote.json
  • packages/map/lib/trainRoute.ts
  • packages/map/package.json
  • packages/map/scripts/check-routes.mjs
  • packages/map/scripts/generate-rail-data.mjs
  • packages/map/scripts/generate-stations.mjs
  • packages/map/scripts/rail-helpers.mjs
  • packages/map/styles/globals.css

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The map adds passenger-station and playable-area overlays, persisted layer-menu visibility, and a shared popup component. Railway scripts generate station and track data, assemble route geometry, and check routes for jumps and hairpins.

Changes

Map features and railway data

Layer / File(s) Summary
Station catalogs and source data
packages/map/scripts/generate-stations.mjs, packages/map/components/stations*.json
A new script builds station catalogs from wiki and server data. The station datasets are added or updated.
Rail graph, route data, and validation
packages/map/scripts/rail-helpers.mjs, packages/map/scripts/generate-rail-data.mjs, packages/map/scripts/check-routes.mjs, packages/map/package.json
The scripts build a rail graph from wiki track data, generate route and playable-area data, and check routes for jumps and hairpins. Package scripts expose station generation and route checking.
Route assembly and playable-area rendering
packages/map/lib/trainRoute.ts, packages/map/components/TrainRoute.tsx, packages/map/components/PlayableArea.tsx, packages/map/styles/globals.css
Route assembly uses line and color-run data with configured joins. The map renders playable tracks and highlights nearby lines on hover or click.
Map overlays and popup placement
packages/map/components/Map.tsx, packages/map/components/PassengerStations.tsx, packages/map/components/Markers/*, packages/map/components/Markers/HoverPopup.tsx, packages/map/styles/globals.css
The map adds persisted layer-menu visibility and passenger-station and playable-area overlays. Marker popups use a shared component that adjusts placement within the map.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant generateRailData as generate-rail-data.mjs
  participant railHelpers as rail-helpers.mjs
  participant routeData as Generated route and playable-area data
  participant checkRoutes as check-routes.mjs
  participant trainRoute as trainRoute.ts
  generateRailData->>railHelpers: Build graph and find track paths
  generateRailData->>routeData: Write route and playable-area data
  generateRailData->>checkRoutes: Check generated routes
  checkRoutes->>trainRoute: Load routes from cached timetable data
Loading

Suggested reviewers: julian-louis

Merge Risk: ⚪ Minimal · up to e9ac4

The new map layers and popup behavior have no established merge-blocking defect. Interrupted local catalog generation can be repaired by rerunning the command; merging remains subject to normal build and functional checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e9ac4

Risk appears limited to generated map-data integrity and browser presentation. The inspected tooltip escapes external text, and generation uses fixed output destinations. Generated-data contents and popup lifecycle compatibility remain partially verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — External data influences committed map geometry and metadata consumed by map viewers. The inspected generator operates with its invoking process's filesystem authority over fixed cache and output locations; no runtime consumer supplies generator URLs or filesystem destinations.

Security Findings and Attack Paths

  • observed — The new relevant attack path is wiki metadata through generated playable-area records into Leaflet tooltip HTML. Line names, titles, and line identifiers are escaped before interpolation, and style colors come from a fixed local palette. This counterevidence rejects an injection concern for the inspected sink, without establishing integrity of the excluded generated files.

Trust Boundaries and Controls

  • observed — Inspected wiki route and station cache filenames sanitize external names. Runtime timetable requests encode server and train identifiers beneath a fixed endpoint. The route checker executes a copy of repository route source and reads generated data through JSON.parse rather than interpolating upstream metadata as executable source.

Resilience and Maintainability Implications

  • observed — HoverPopup owns its popup reference, observer, and map listeners per instance and removes listeners and disconnects observation on popup removal and component cleanup. Placement uses private Leaflet members and depends on receiving an add event after handler registration. Immediate-open and remount ordering remain unverified; the established consequence is presentation uncertainty, not a demonstrated security-control bypass.

Hardening Proposals

  • proposed — For stronger generated-data recovery guarantees, stage both outputs and validate them before replacing committed files, retaining previous outputs when generation or validation fails. This is a hardening proposal, not an established production exposure.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 16 files. (5 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the two main changes: the Playable Area layer and the layers-menu toggle button. It is concise and specific enough for the changeset.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 16 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Not every station in the layer is a dispatch station.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cosminpolifronie and others added 7 commits October 1, 2026 02:42
…ations""

The non-dispatch stations in that layer get their own "Passenger stations"
layer instead.

This reverts commit 136693d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CS icon with something more in the already existing style
Joins were stored as geometry only, and the client drew each one in the
colour of the leg before it, so a join crossing track that isn't in the
game was drawn green. Joins now carry their colour runs (same format as
segmentColors), which the client applies, reversed for joins drawn
backwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cosminpolifronie

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cosminpolifronie

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
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.

1 participant