fix(billing): add parentheses around breakdown in billing formula display - #4415
fix(billing): add parentheses around breakdown in billing formula display#4415octo-patch wants to merge 1 commit into
Conversation
…play (fixes QuantumNous#4406) The billing formula template was missing parentheses around the breakdown expression, causing visual ambiguity about operator precedence. Users reading the formula literally would compute a value ~10x off from the actual charge, since the group ratio should apply to the entire (prompt + completion) sum, not just the completion portion. Before: prompt_tokens * $5 + completion_tokens * $25 * groupRatio 0.1 = total After: (prompt_tokens * $5 + completion_tokens * $25) * groupRatio 0.1 = total Updated the i18n key in all locale files (en, zh-CN, zh-TW, fr, ja, ru, vi) to match the corrected template. The backend billing logic is unchanged and was already correct.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
WalkthroughUpdates Claude model billing text rendering by wrapping the breakdown portion in parentheses to clarify that the group ratio applies to the entire sum of components. Synchronizes all i18n locale files with the new parenthesized template key. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
51fdfc5 to
2b6f1df
Compare
Fixes #4406
Problem
The billing formula shown in the log's "计费过程" (billing process) section was missing parentheses around the breakdown expression, creating a visual ambiguity about operator precedence.
Current display:
A user reading this literally (following standard math precedence where
*binds tighter than+) would compute:Root Cause
In
web/src/helpers/render.jsx, the template string used for the final billing formula was:The
breakdownpart is a+-separated sum of prompt and completion costs, but it was not wrapped in parentheses, so when rendered, the group ratio visually appears to apply only to the last term.Solution
Wrap
{{breakdown}}in parentheses in the template:After fix:
This correctly conveys that the group ratio applies to the whole sum. The backend billing logic is unchanged and was already correct — this is a display-only fix.
Files Changed
web/src/helpers/render.jsx— updated template stringweb/src/i18n/locales/{en,zh-CN,zh-TW,fr,ja,ru,vi}.json— updated i18n key to match new templateTesting
The formula renders with parentheses, and the computed total matches the actual deduction. No backend changes required.
Summary by CodeRabbit