Skip to content

fix: prevent inflated timed-race fuel estimates - #631

Draft
tariknz wants to merge 2 commits into
mainfrom
fix/fuel-timed-race-estimates
Draft

fix: prevent inflated timed-race fuel estimates#631
tariknz wants to merge 2 commits into
mainfrom
fix/fuel-timed-race-estimates

Conversation

@tariknz

@tariknz tariknz commented Jul 23, 2026

Copy link
Copy Markdown
Owner

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 lint and npm 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

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Performance improvement
  • Refactoring (no functional changes)
  • Documentation update
  • Dependency update

Checklist

  • I have discussed this change in the discord server
  • I have tested this in iRacing (either in an online session or with AI)
  • All tests pass locally via npm test
  • I have added tests that prove my fix is effective or that my feature works
  • I have run npm run lint and fixed any issues
  • I have performed a self-review of my own code
  • I have added/updated Storybook stories for visual changes
  • I have updated the README.md (if applicable)
  • I have updated defaultDashboard.ts if introducing new widgets or configurations (if applicable)

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c4e661e-b744-4f47-99c5-25e01eacaef0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fuel-timed-race-estimates

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.

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