fix: unify station clicks, improve detour accuracy and UX#22
Conversation
- Map station clicks now trigger station-leg preview (same as sidebar) - Detour baseline flags large negative diffs as failed (-1) instead of silently clamping to 0, exposing bad baseline matches - Station-leg route errors show as transient amber toast (3s auto-dismiss) instead of being invisible when base routes exist - Route alternatives block uses preview metrics for the selected route during station-leg preview, keeping numbers consistent - Detour streaming depends on station IDs instead of the full converted collection, preventing currency changes from restarting calculations
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChanged detour delta handling to compute a signed raw delta and reject large negative deltas; stabilized primary-stations referencing to avoid redundant detour recomputation; added auto-triggered station-leg logic with transient error toast and adjusted route-row metric selection. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/search/search-panel.tsx (1)
419-433: Auto-trigger logic is sound.The
prevSelectedRefcomparison prevents spurious triggers when other deps change. Ref-based handler/data access avoids stale closures.Minor: Line 430
station.properties.brand ?? station.properties.namecould beundefinedif both are nullish, resulting in "undefined" displayed in the waypoint label. Consider a fallback:- station.properties.brand ?? station.properties.name, + station.properties.brand ?? station.properties.name ?? station.properties.id,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/search/search-panel.tsx` around lines 419 - 433, The label fallback can still produce "undefined" when both brand and name are nullish; update the call in the useEffect where handleStationLegRef.current is invoked (inside the selectedStationId/phase effect) to pass a safe fallback string instead of station.properties.brand ?? station.properties.name — for example use station.properties.brand ?? station.properties.name ?? `Waypoint ${station.properties.id}` or a generic 'Waypoint' so the waypoint label never ends up as "undefined"; adjust the argument passed to handleStationLegRef.current accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/search/search-panel.tsx`:
- Around line 419-433: The label fallback can still produce "undefined" when
both brand and name are nullish; update the call in the useEffect where
handleStationLegRef.current is invoked (inside the selectedStationId/phase
effect) to pass a safe fallback string instead of station.properties.brand ??
station.properties.name — for example use station.properties.brand ??
station.properties.name ?? `Waypoint ${station.properties.id}` or a generic
'Waypoint' so the waypoint label never ends up as "undefined"; adjust the
argument passed to handleStationLegRef.current accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a2ef2a12-e110-4340-9147-d872634d5d2f
📒 Files selected for processing (3)
src/app/api/route-detour/route.tssrc/components/home-client.tsxsrc/components/search/search-panel.tsx
When a station-leg preview fails or its waypoint is removed, selectedStationId is now cleared. This allows re-clicking the same station to trigger a new preview, since the useEffect depends on the value actually changing.
Summary
useEffectpath that watchesselectedStationIdchanges.detourDuration - baselineDuration < -60sas failed (-1) instead of silently clamping to 0. Also includes the intermediate waypoint fix (already on main) that pins the baseline to the actual highway.displayRoutes[0]for the selected route during station-leg preview, matching the header metrics.stationKey(sorted station IDs) instead of the fullprimaryStationscollection, so currency/rate changes no longer blow away in-progress detour calculations.Test plan
Summary by CodeRabbit
Bug Fixes
Improvements
New Features