Skip to content

refactor: improve usage tracking and rate limit management#10

Merged
hmenzagh merged 26 commits into
mainfrom
feat/usage/tracking-v2
Apr 12, 2026
Merged

refactor: improve usage tracking and rate limit management#10
hmenzagh merged 26 commits into
mainfrom
feat/usage/tracking-v2

Conversation

@hmenzagh
Copy link
Copy Markdown
Owner

Summary

Comprehensive refactoring of the usage tracking v2 feature with improvements to rate limit management, async discovery handling, and UI component modularization.

Changes

  • refactor(ui): modularize rate tracking into separate components - Decomposed monolithic rate_tracking.rs into 13 focused component modules for better maintainability
  • refactor(data): restructure data models and handlers - Updated data models, OAuth handling, indexing, and rate limit tracking
  • refactor(app): add async discovery refresh state management - Added async discovery refresh capability with proper state management
  • refactor(config): improve discovery configuration and handling - Enhanced discovery configuration logic and error handling
  • style(ui): update dashboard styling for new components - Updated dashboard styling to work with new rate tracking components

Testing

  • All clippy checks pass with no warnings
  • Code formatting verified with cargo fmt
  • Integration with existing rate limit tracking features maintained

🤖 Generated with Claude Code

hmenzagh and others added 26 commits April 7, 2026 01:23
…zation

- Trigger JSONL re-parse when usage data is updated to keep token counts
  and utilization percentages consistent
- Fix UsageWindow.resets_at deserialization failure when API returns null
  (was breaking the entire UsageReport for max subscriptions)
- Align gradient bars with fixed-width label padding

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve conflicts by combining both usage tracking (UsagePoller,
rate tracking) and update notification (version check, banner) features.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ting

Add detailed token tracking that separates input and output tokens in the rate
limiting display. This includes:

- New `tokens_in_window_split()` method to return separate input/output totals
- New `daily_input_output_for_root()` method for per-day token breakdown
- Split `DayBar` to track input and output tokens separately
- Updated rendering to show stacked bars with input (lighter) on top and
  output (darker) on bottom, with distinct colors for each bar type
- Smart token splitting that uses actual ratios when available, falling back
  to 50/50 split

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Automatic formatting changes from cargo fmt including consistent
indentation, line wrapping, and alphabetical import organization.
- Use #[derive(Default)] for UsageStats instead of manual impl
- Change &PathBuf to &Path in function signatures (idiomatic style)
- Collapse nested if-let chains using && operator
- Replace .min(30).max(1) with .clamp(1, 30)
- Use .is_multiple_of(2) instead of % 2 == 0
- Use .div_ceil() for ceiling division
- Use range.contains() instead of manual bounds check
- Add #[allow(dead_code)] for fields used in future functionality
- Add #[allow(too_many_arguments)] on render function
- Shift the last time label left when it would be cut off by the chart boundary
- Skip date labels when bars are too narrow to avoid overlapping text
- Use div_ceil for more idiomatic ceiling division

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: add rate limit tracking view with usage monitoring
Replace cloning references before passing to slice constructors with
std::slice::from_ref, which is more idiomatic and avoids unnecessary
allocations in test code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Do not carry over cached usage when a credential has expired, since the
poller stops fetching expired tokens and stale data would incorrectly
render an invalid session as 'live'.
Change merge_fresh_hits to use asymmetric merging: when a fresh hit
collides with an existing entry, keep the richer value on each field.
This prevents data loss when a fresh scan can no longer compute
per_model or session_duration_min (e.g. source JSONL rotated out).

Also removes unused HashSet import.
Add a new blinking_dot_span helper function that creates animated visual
indicators for status elements. The dot blinks at regular intervals based on
the tick counter, providing visual feedback for active monitoring.

- Add blinking_dot_span function in helpers.rs
- Use blinking dot in live_summary status display
- Use blinking dot in session_forecast status display
- Pass tick parameter through render function chain

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hmenzagh hmenzagh merged commit d478483 into main Apr 12, 2026
11 checks passed
@hmenzagh hmenzagh deleted the feat/usage/tracking-v2 branch April 13, 2026 00:11
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