fix: prevent inflated timed-race fuel estimates - #631
Draft
tariknz wants to merge 2 commits into
Draft
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes inflated fuel recommendations in timed races when transient or invalid lap-time telemetry produced an unrealistic race-distance estimate. The race-distance calculation now rejects implausible lap times, falls back through validated leader and player timing sources, and returns remaining distance directly so the fuel calculator does not reconstruct it from a rounded total.
Also fixes the fuel grid's checkered-flag mask and removes its duplicate race-distance telemetry subscription. This reduces unnecessary renderer work and aligns with the cheap subscription/performance improvements described in Architecture Review Phase 1.
Root cause: the shared timed-race estimator accepted any positive leader lap time, including the approximately one-second values that can appear transiently or in replay data. That could project hundreds of remaining laps, trigger multi-stop logic, and turn a small fuel deficit into a full-tank recommendation.
Validated with
npm run lintandnpm run test -- --no-coverage(86 test files, 1,064 tests). Added regression coverage for a 25-minute timed race, invalid one-second lap times, timing-source fallback, and partial-lap progress.Screenshots
No visual changes.
Before
A transient invalid lap time could produce an excessive timed-race distance and recommend adding more than 50 L when only a small amount was required.
After
Invalid lap times are rejected, validated fallbacks are used, and the grid displays the corrected fuel recommendation without adding a duplicate race-distance subscription.
Type of Change
Checklist
npm testnpm run lintand fixed any issues