Skip to content

feat: Configurable decimals places for delta times - #532

Merged
tariknz merged 1 commit into
tariknz:mainfrom
toba-k:feat/decimal-places-delta-lap-times-pr
Jun 3, 2026
Merged

feat: Configurable decimals places for delta times#532
tariknz merged 1 commit into
tariknz:mainfrom
toba-k:feat/decimal-places-delta-lap-times-pr

Conversation

@toba-k

@toba-k toba-k commented May 1, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the possibility to chose the decimal places for the delta times in the Standings and Relative widget. User can choose up to 3 decimals, with 1 being the default.

Screenshots

Menu
スクリーンショット 2026-06-01 131456

In-game (example with 2 decimals)
2decim_places

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)

Summary by CodeRabbit

New Features

  • Added a "Decimal Places" configuration option for lap time delta values in Standings and Relative widgets. Users can now customize the display precision of lap timing data, selecting from 1 to 3 decimal places.

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces user-configurable decimal places for lap time delta display in standings and relative widgets. The feature adds a type field, default values, rendering logic, and UI controls across the settings and component layers, allowing users to select 1–3 decimal places for formatting.

Changes

Decimal Places Configuration for Lap Time Deltas

Layer / File(s) Summary
Type contract and default values
src/types/widgetConfigs.ts, src/types/defaultDashboard.ts
StandingsConfig and RelativeConfig now include decimalPlaces: number in the lapTimeDeltas shape. Default values set decimalPlaces: 1 for both standings and relative widgets.
Cell rendering with decimal places prop
src/frontend/components/Standings/components/DriverInfoRow/cells/LapTimeDeltasCell.tsx
LapTimeDeltasCellProps adds an optional decimalPlaces?: number prop, which is destructured and used in formatting lap delta values via toFixed(decimalPlaces) instead of the previous hardcoded toFixed(1).
Component wiring and settings UI
src/frontend/components/Standings/components/DriverInfoRow/DriverInfoRow.tsx, src/frontend/components/Settings/sections/RelativeSettings.tsx, src/frontend/components/Settings/sections/StandingsSettings.tsx, src/frontend/components/Standings/components/DriverInfoRow/DriverInfoRow.ReorderableConfig.stories.tsx
DriverInfoRow wires the decimalPlaces config value to LapTimeDeltasCell. Both settings components render select dropdowns (options 1–3, default 1) to configure lapTimeDeltas.decimalPlaces. Story mock is updated to include the new config field.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • tariknz

Poem

🐰 Hop, hop! Precision takes a hop,
From one fixed digit to a choice,
Lap deltas now can sing and dance,
In decimal places one through three,
A small configuration brings great glee! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description includes a clear feature explanation with screenshots, correctly identifies it as a new feature, and confirms testing in iRacing, lint checks, and defaultDashboard updates. However, Storybook stories were not added/updated and unit tests were not added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title "feat: Configurable decimals places for delta times" directly and clearly summarizes the main change—adding configurable decimal places for delta time display in the Standings and Relative widgets.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@tariknz

tariknz commented May 31, 2026

Copy link
Copy Markdown
Owner

@toba-k do you still want this in? PR still in draft

@toba-k

toba-k commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

@toba-k do you still want this in? PR still in draft

Yes ! I was waiting for the performance PR's to be merged first since we discussed about not having new features until then. This one is pretty small and should not cause any issues. I will rebase, re-test, then put it as ready

@toba-k
toba-k force-pushed the feat/decimal-places-delta-lap-times-pr branch from 6ba7c80 to 1a44466 Compare June 1, 2026 02:41
@toba-k
toba-k marked this pull request as ready for review June 2, 2026 03:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/types/widgetConfigs.ts (1)

154-154: ⚡ Quick win

Encode the 1–3 range in lapTimeDeltas.decimalPlaces

The settings UI only allows selecting decimalPlaces values 1, 2, or 3, but src/types/widgetConfigs.ts currently types both StandingsConfig.lapTimeDeltas.decimalPlaces and RelativeConfig.lapTimeDeltas.decimalPlaces as a plain number. Constraining this to a numeric-literal union keeps the config contract consistent across layers.

♻️ Proposed refactor
+export type LapTimeDeltaDecimalPlaces = 1 | 2 | 3;
+
 export interface StandingsConfig {
   ...
-  lapTimeDeltas: { enabled: boolean; numLaps: number; decimalPlaces: number };
+  lapTimeDeltas: {
+    enabled: boolean;
+    numLaps: number;
+    decimalPlaces: LapTimeDeltaDecimalPlaces;
+  };
   ...
 }
 
 export interface RelativeConfig {
   ...
-  lapTimeDeltas: { enabled: boolean; numLaps: number; decimalPlaces: number };
+  lapTimeDeltas: {
+    enabled: boolean;
+    numLaps: number;
+    decimalPlaces: LapTimeDeltaDecimalPlaces;
+  };
   ...
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/types/widgetConfigs.ts` at line 154, The lapTimeDeltas.decimalPlaces
field is currently typed as a plain number but the UI only permits 1, 2, or 3;
update the type to the numeric-literal union 1 | 2 | 3 to enforce that
constraint. Locate the lapTimeDeltas property in the widget config types (the
lapTimeDeltas declaration and both StandingsConfig.lapTimeDeltas.decimalPlaces
and RelativeConfig.lapTimeDeltas.decimalPlaces) and replace the number type with
1 | 2 | 3; keep all other fields (enabled, numLaps) unchanged and run type
checks to ensure no callers violate the narrower type.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/components/Standings/components/DriverInfoRow/cells/LapTimeDeltasCell.tsx`:
- Line 8: LapTimeDeltasCell currently calls
Math.abs(deltaValue).toFixed(decimalPlaces) without validating the optional
decimalPlaces; fix by validating and normalizing decimalPlaces in
LapTimeDeltasCell (the variable passed into the toFixed call) so it’s a safe
integer in the 0–100 range (e.g., fallback to 1 when undefined/NaN and clamp
using Math.min/Math.max), then use the normalized value in the toFixed call;
reference symbols: LapTimeDeltasCell, decimalPlaces, deltaValue, and the
Math.abs(...).toFixed(...) expression.

---

Nitpick comments:
In `@src/types/widgetConfigs.ts`:
- Line 154: The lapTimeDeltas.decimalPlaces field is currently typed as a plain
number but the UI only permits 1, 2, or 3; update the type to the
numeric-literal union 1 | 2 | 3 to enforce that constraint. Locate the
lapTimeDeltas property in the widget config types (the lapTimeDeltas declaration
and both StandingsConfig.lapTimeDeltas.decimalPlaces and
RelativeConfig.lapTimeDeltas.decimalPlaces) and replace the number type with 1 |
2 | 3; keep all other fields (enabled, numLaps) unchanged and run type checks to
ensure no callers violate the narrower type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c5ef3fb1-0c1f-4731-81a0-6441b89ba819

📥 Commits

Reviewing files that changed from the base of the PR and between 2a86d60 and 1a44466.

📒 Files selected for processing (7)
  • src/frontend/components/Settings/sections/RelativeSettings.tsx
  • src/frontend/components/Settings/sections/StandingsSettings.tsx
  • src/frontend/components/Standings/components/DriverInfoRow/DriverInfoRow.ReorderableConfig.stories.tsx
  • src/frontend/components/Standings/components/DriverInfoRow/DriverInfoRow.tsx
  • src/frontend/components/Standings/components/DriverInfoRow/cells/LapTimeDeltasCell.tsx
  • src/types/defaultDashboard.ts
  • src/types/widgetConfigs.ts

@tariknz tariknz changed the title Feat: Configurable decimals places for delta times feat: Configurable decimals places for delta times Jun 3, 2026
@tariknz
tariknz merged commit 8738b0c into tariknz:main Jun 3, 2026
2 checks passed
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.

2 participants