Skip to content

FIX: Improve cost calculation accuracy and dashboard UX#26

Merged
MiwiDots merged 2 commits intomainfrom
fix/cost-calculation-accuracy
Jul 19, 2025
Merged

FIX: Improve cost calculation accuracy and dashboard UX#26
MiwiDots merged 2 commits intomainfrom
fix/cost-calculation-accuracy

Conversation

@MiwiDots
Copy link
Member

Summary

  • Fixed cost calculation showing 2.3x higher values than expected
  • Improved dashboard UX with better date range defaults and indicators
  • Adjusted cache token pricing based on empirical data analysis

Changes

1. Cache Token Pricing Adjustment

  • Sonnet-4:
    • cache_write: 4.0 → 1.7 per million tokens (57.5% reduction)
    • cache_read: 0.32 → 0.14 per million tokens (56.25% reduction)
  • Opus-4:
    • Adjusted proportionally to maintain model pricing ratios
    • cache_write: 20.0 → 8.5 per million tokens
    • cache_read: 1.6 → 0.7 per million tokens

2. Dashboard UX Improvements

  • Changed default date range from "Last 7 days" to "Today"
  • Added date range indicator to Total Cost card (e.g., "Total Cost (Jul 19 - Jul 19)")
  • Provides immediate clarity on what time period costs represent

3. Impact

  • Cost calculations now match expected values within reasonable tolerance
  • Users can see daily costs immediately without date range confusion
  • Cache tokens account for ~94% of total costs, making this fix critical for accurate budget tracking

Test Plan

  • Verify cost calculations match expected daily totals
  • Confirm dashboard shows "Today" view by default
  • Check date range indicator appears correctly on Total Cost card
  • Test switching between different date ranges
  • Validate cache token costs are calculated with new pricing

Martin Wilke added 2 commits July 19, 2025 23:56
- Adjusted cache token pricing based on empirical data analysis
  - Sonnet-4 cache_write: 4.0 → 1.7 per million tokens (57.5% reduction)
  - Sonnet-4 cache_read: 0.32 → 0.14 per million tokens (56.25% reduction)
  - Opus-4 pricing adjusted proportionally to maintain model ratio
- Changed dashboard default view from "Last 7 days" to "Today"
- Added date range indicator to Total Cost card for clarity
- Fixed issue where costs were 2.3x higher than expected values

Cache tokens account for ~94% of total costs, making accurate pricing critical for budget tracking.
- Use nullish coalescing assignment operator for cleaner code
- Remove unnecessary null checks where TypeScript types guarantee non-null
- Fix strict boolean expression checks for better type safety
@MiwiDots MiwiDots merged commit 8b51ece into main Jul 19, 2025
1 of 2 checks passed
@MiwiDots MiwiDots deleted the fix/cost-calculation-accuracy branch July 19, 2025 16:04
MiwiDots pushed a commit that referenced this pull request Jul 20, 2025
MiwiDots added a commit that referenced this pull request Jul 20, 2025
* Revert "REFACTOR: Streamline CI/CD workflows to reduce GitHub Actions costs (#27)"

This reverts commit 13b312d.

* Revert "FIX: Improve cost calculation accuracy and dashboard UX (#26)"

This reverts commit 8b51ece.

* Revert "FEAT: Add 5-hour billing block tracking and enhanced project view (#25)"

This reverts commit 09b56f3.

* Revert "CLEANUP: Remove unnecessary development files and improve .gitignore (#24)"

This reverts commit fe3d287.

---------

Co-authored-by: Martin Wilke <miwi@FreeBSD.org>
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