Skip to content

fix: resolve provider data output issues#12

Merged
DimazzzZ merged 2 commits into
mainfrom
fix/provider-data-output-issues
Jun 22, 2026
Merged

fix: resolve provider data output issues#12
DimazzzZ merged 2 commits into
mainfrom
fix/provider-data-output-issues

Conversation

@DimazzzZ

Copy link
Copy Markdown
Owner

What

Fixes several issues with provider data output formatting and edge cases.

Why

Multiple providers had incorrect or inconsistent output formats for different balance display options.

Changes

Bug Fixes

  1. Xiaomi API empty accountId - fetchApiBalance was setting accountId = "" instead of account.id. Fixed by passing account to the method.

  2. PERCENTAGE_REMAINING shows raw dollar amount - When only remaining was available (no total, no used), the format showed $55 instead of --. Fixed to return -- when percentage cannot be calculated.

  3. PERCENTAGE_REMAINING with zero values - When remaining=0, used=0, showed $0 instead of 0% remaining. Fixed to handle zero case properly.

  4. REMAINING_ONLY DESCRIPTIVE for used-only data - DESCRIPTIVE format was identical to COMPACT when only used was available. Fixed to show "$50 used this period" for DESCRIPTIVE.

  5. USED_OF_REMAINING description mismatch - Description said "Used / Remaining" but implementation shows "Remaining / Total". Updated description to match.

Tests Added

  • formats PERCENTAGE_REMAINING with zero remaining and used - Tests zero case
  • formats PERCENTAGE_REMAINING with only remaining falls back to remaining only - Tests fallback behavior
  • formats REMAINING_ONLY DESCRIPTIVE with only used - Tests DESCRIPTIVE format

Files Modified

  • src/main/kotlin/org/zhavoronkov/tokenpulse/provider/xiaomi/XiaomiProviderClient.kt
  • src/main/kotlin/org/zhavoronkov/tokenpulse/ui/BalanceFormatter.kt
  • src/main/kotlin/org/zhavoronkov/tokenpulse/settings/TokenPulseSettings.kt
  • src/test/kotlin/org/zhavoronkov/tokenpulse/ui/BalanceFormatterTest.kt

Verification

  • All tests pass ✓
  • Detekt clean ✓

DimazzzZ added 2 commits June 22, 2026 16:53
The 'Used / Remaining' format was showing 'used / remaining' but users
expected 'remaining / total'. Changed formatUsedOfRemaining to prefer
'remaining / total' when total is available, with fallback to
'used / remaining' when total is not provided.
1. Fix Xiaomi API empty accountId - pass account to fetchApiBalance
2. Fix PERCENTAGE_REMAINING showing raw dollar amount - return -- when percentage cannot be calculated
3. Fix PERCENTAGE_REMAINING with zero values - show '0% remaining' instead of '/bin/zsh'
4. Fix REMAINING_ONLY DESCRIPTIVE for used-only data - show 'used this period' instead of 'used'
5. Update USED_OF_REMAINING description to match implementation - 'Remaining / Total'
6. Add tests for edge cases
@DimazzzZ DimazzzZ merged commit 21a2a03 into main Jun 22, 2026
2 checks passed
@DimazzzZ DimazzzZ deleted the fix/provider-data-output-issues branch June 22, 2026 15:22
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.

1 participant