Skip to content

feat(unit-converter): add optional per-time denominator for rate conversion - #149

Merged
DropSnorz merged 2 commits into
mainfrom
claude/project-thread-yzkk9y
Nov 20, 2026
Merged

DropSnorz merged 2 commits into
mainfrom
claude/project-thread-yzkk9y

Conversation

@DropSnorz

@DropSnorz DropSnorz commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Requested by Dropsnorz · project thread

Summary

Adds a "Per time" checkbox to the Unit Converter. When checked, a per <time unit> select appears under both From and To, so rates convert: MB/s to GB/day, km/h to m/s, L/min to gal/h, kg/h to lb/min.

  • The denominator reuses the existing TIME_UNITS list.
  • Off by default, so plain conversions are unchanged. The checkbox only shows for Length, Mass, Volume and Data (Time per time and Temperature rates don't make sense).
  • Swap also swaps the two time units.
  • New pure helpers in unitConversions.ts: convertRate and supportsRate, with unit tests for the three examples above.
  • State uses useWidgetState (perTime, fromPer, toPer); turning on per time counts as dirty.
  • Definition description and search keywords mention rates.

Result display

  • The result now shows two copyable rows: the raw value (2160) and the value with its unit (2160 GB/d, 212 °F). Each unit got a short symbol field for this.
  • The result sits right under the inputs instead of being pushed to the bottom, so tall widgets no longer leave a gap between inputs and result.
  • Default size for newly added widgets is now 3x4 so per time mode fits without scrolling. The 3x3 minimum is unchanged; at 3x3 plain conversions fit, and per time mode scrolls a little.

Testing

  • npx tsc -b --noEmit, npm run lint (no new warnings), prettier --check
  • npm test: 182 files, 2189 tests passed
  • Checked in the dev server in light and dark themes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Eru75CPpoxvC9CfpdFNKTh

Summary by CodeRabbit

  • New Features
    • Convert rates such as speed, data transfer, and flow across supported unit categories, with independent time-unit selection.
    • Swap both the measured units and their associated time units.
    • See results with destination units or rate units, and copy either the numeric result or the result with its unit.
    • Conversion results now show unit symbols, including for temperature.

@DropSnorz DropSnorz self-assigned this Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The unit converter now supports per-time conversions for length, mass, volume, and data. It adds unit symbols, time-unit selectors, rate results, and separate copy actions for numeric results and results with units.

Changes: Rate conversion

Layer / File(s) Summary
Rate unit data and calculations
src/widgets/unit-converter/unitConversions.ts, src/widgets/unit-converter/unitConversions.test.ts
Unit definitions now include display symbols. Rate conversion uses amount and time base factors. Tests cover rate calculations and supported categories.
Per-time widget integration
src/widgets/unit-converter/UnitConverterWidget.tsx, src/widgets/unit-converter/UnitConverterWidget.test.tsx, src/widgets/unit-converter/definition.ts
The widget adds per-time controls and time-unit selections for supported categories. It displays the destination unit or rate unit and provides separate copy actions. The definition adds rate-related terms and increases the default height.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UnitConverterWidget
  participant unitConversions
  User->>UnitConverterWidget: Enable per-time mode and select units
  UnitConverterWidget->>unitConversions: Check rate support and convert rate
  unitConversions-->>UnitConverterWidget: Return converted value
  UnitConverterWidget-->>User: Display value and destination rate unit
Loading
Merge Risk: Minimal · up to b74c2

This adds an optional per-time mode to the unit converter. The mode is off by default and leaves existing conversions unchanged. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(unit-converter): add optional per-time denominator for rate conversion" names the main change. The PR adds an optional Per time mode to the Unit Converter, with a time denominator for …
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.
Full details: Title check

Explanation

The title "feat(unit-converter): add optional per-time denominator for rate conversion" names the main change. The PR adds an optional Per time mode to the Unit Converter, with a time denominator for source and target units, and adds the convertRate and supportsRate helpers. The title is specific, short, and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a6cdaf1-93e2-4d6e-a3cf-f1a07d7cc010
Commits

Reviewing files that changed from the base of the PR and between 70dc10b and b74c209.

Files selected for processing: 5

  • src/widgets/unit-converter/UnitConverterWidget.test.tsx
  • src/widgets/unit-converter/UnitConverterWidget.tsx
  • src/widgets/unit-converter/definition.ts
  • src/widgets/unit-converter/unitConversions.test.ts
  • src/widgets/unit-converter/unitConversions.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://claude-project-thread-yzkk9y-localgrid-dev.astrelite.workers.dev (commit b74c209)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://08ac3a3c-localgrid-dev.astrelite.workers.dev b74c209 2026-11-19T08:30:45.660Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://22de8421-localgrid-dev.astrelite.workers.dev 8197d88 2026-11-19T07:56:10.857Z Visit the dashboard ↗

@DropSnorz
DropSnorz merged commit 9e6556a into main Nov 20, 2026
7 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