chore: hoist useDriverLivePositions from TrackCanvas to TrackMap - #567
Conversation
TrackCanvas's Storybook stories were failing with "useRunningState must be used within a RunningStateProvider" after #551 added a disconnect-reset inside useDriverLivePositions. Move the hook call to TrackMap (the data-wiring layer) and pass driverLivePositions to TrackCanvas as a prop, mirroring how driverIdentities is already handled. TrackCanvas becomes more presentational and its stories no longer need provider plumbing. TelemetryDecorator now also mounts RunningStateProvider so TrackMap (and any other widget consuming useDriverLivePositions transitively) works in Storybook. RunningStateProvider's bridge prop widened to IrSdkBridge | Promise<IrSdkBridge> for parity with SessionProvider and TelemetryProvider. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR lifts the ChangesDriver state and provider refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Description
TrackCanvas's Storybook stories were failing withuseRunningState must be used within a RunningStateProviderafter #551 added a disconnect-reset effect insideuseDriverLivePositions(whichTrackCanvascalled transitively).The fix has two parts:
useDriverLivePositionsfromTrackCanvastoTrackMap—TrackMapis the data-wiring layer; it already callsuseDriverProgress,useSectorColors, etc. The result is passed toTrackCanvasas adriverLivePositionsprop (defaults to{}), mirroring howdriverIdentitiesis already handled.TrackCanvasbecomes one step more presentational and its stories no longer requireRunningStateProviderplumbing.RunningStateProviderinsideTelemetryDecorator— soTrackMap(and any other story consuminguseDriverLivePositionstransitively) works in Storybook. The mock bridge fromgenerateMockDataFromPathalready implementsonRunningState. While here, widenedRunningStateProvider'sbridgeprop toIrSdkBridge | Promise<IrSdkBridge>for parity withSessionProvider/TelemetryProvider.No runtime behaviour change in the app —
TrackMapcalls the hook with the sameenabledpredicate (settings?.displayMode === 'livePosition'), anduseDriverLivePositions's subscriptions / memoization are unchanged.Verified locally:
npm test(842 tests, all pass),npm run lintclean, typecheck clean, TrackCanvas + TrackMap stories render in Storybook.Screenshots
Before
http://localhost:6006/?path=/story/widgets-trackmap-components-trackcanvas--primarythrows:After
TrackCanvas and TrackMap stories both render correctly.
Type of Change
Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Tests