You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Formatter prints "80.0%" and "$10000" when rounding crosses a precision boundary #417
TokenFormatter.percent and TokenFormatter.costCompact pick their output precision from the raw value and only then round. When rounding crosses a boundary, the result contradicts the branch:
Call
Current
Expected
percent(79.96)
80.0%
80%
percent(99.97)
100.0%
100%
costCompact(99.96)
$100.0
$100
costCompact(9_999.6)
$10000
$10.0K
percent checks value == value.rounded(), so any non-integer goes through %.1f, even when it rounds to .0. costCompact checks usd < 100 / usd < 10_000 on the raw value, so values just below a cutoff print in the format of the next bucket.
Reachability
The inputs are arbitrary fractions in production:
Cursor usedPercent is fractional, and remaining mode shows 100 − x (menu bar UsageStore limit parts, popover quota rows, floating pet, notifications).
The usage recap delta is abs(delta) * 100.
Costs come from per-token prices (UsageCost.text(compact:), menu bar cost).
So the menu bar can show 5h 80.0% next to 7d 88%, or $10000 where every other value above $10K is $10.0K.
Why the tests missed it
LocalUsageCacheTests.testFormatterEdges only uses values in the middle of each bucket (88, 88.35, 9.54, 311.4). None of them rounds across a boundary.
Fix
Format with the bucket's precision first, then decide the bucket from the formatted string.
Activity