🐛 fix(utils): keep tiny prices visible in formatPrice#14235
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 378fa777d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #14235 +/- ##
==========================================
- Coverage 68.09% 68.09% -0.01%
==========================================
Files 2266 2266
Lines 194349 194343 -6
Branches 20344 19559 -785
==========================================
- Hits 132338 132330 -8
- Misses 61882 61883 +1
- Partials 129 130 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
sxueck
pushed a commit
to sxueck/lobehub
that referenced
this pull request
Apr 28, 2026
mutoe
pushed a commit
to mutoe/lobehub
that referenced
this pull request
May 1, 2026
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.
💻 Change Type
🔗 Related Issue
N/A — surfaced while reviewing DeepSeek V4 Pro's cache-hit input price card.
🔀 Description of Change
formatPricealways rounds tofractionDigits(default2) viatoFixed, so any positive price under$0.005collapses to\"0.00\". The model detail panel hits this for any model whose cache-hit price is less than half a cent — DeepSeek V4 Pro's cache-hit input rate ($0.003625 / M tokens) renders as\$0.00 / M tokens, which reads as "free" and is misleading.Fix: when the price is positive but rounds to zero at the requested precision, expand precision to
Math.ceil(-Math.log10(price))so at least one significant digit is visible:0.003625→\"0.004\"0.0001→\"0.0001\"0→\"0.00\"(unchanged)0.99/1234.56/1,000,000.01(unchanged)Also collapsed
formatSpeedearly-returns to silence a long-standinglet word = ''ESLint warning that lit up while editing the file.🧪 How to Test
```
cd packages/utils && bunx vitest run --silent='passed-only' src/format.test.ts
```
📝 Additional Information
Pure display-layer change. `formatPrice` is not on any server-side billing path (CostService / spend log / Stripe all consume raw `pricing.units[].rate` numbers); the only non-UI caller in cloud (`subscription/selectors.ts`) feeds dollars-scale values that never trip the new branch.