Skip to content

feat: optional req/hr burn-rate badge on provider cards#347

Merged
rygel merged 1 commit intodevelopfrom
feat/usage-per-hour
Mar 19, 2026
Merged

feat: optional req/hr burn-rate badge on provider cards#347
rygel merged 1 commit intodevelopfrom
feat/usage-per-hour

Conversation

@rygel
Copy link
Copy Markdown
Owner

@rygel rygel commented Mar 19, 2026

Summary

  • Adds an optional Usage Rate (req/hr) badge to each provider card, derived from DB history without any extra API calls
  • Toggled via Settings → Display Options → Show Usage Rate (req/hr) (off by default)
  • Rate is null (badge hidden) when the counter was reset or fewer than 30 minutes of history exist

How it works

UsageDatabase.GetLatestHistoryAsync now calls a new StampUsageRatesAsync helper after reading the latest rows. A SQL CTE picks the row closest to 1 hour ago (within a 30–120 min window) per provider, computes delta / hoursElapsed, and stamps the result onto ProviderUsage.UsagePerHour (in-memory only — [JsonIgnore], never persisted).

Test plan

  • Enable "Show Usage Rate (req/hr)" in Settings, confirm badge appears on cards that have ≥30 min of history
  • Confirm badge is absent on cards with no/recent-only history
  • Disable setting, confirm all badges disappear immediately
  • Verify setting persists after restart

🤖 Generated with Claude Code

Derives a live usage rate from the database history (delta between latest
row and the row closest to 1 hour ago). Null when counter was reset or
history is insufficient (<30 min). Toggled via Settings → Display Options
→ "Show Usage Rate (req/hr)".

- AppPreferences: add ShowUsagePerHour bool (default false)
- ProviderUsage: add UsagePerHour nullable double (JsonIgnore, computed on read)
- UsageDatabase.GetLatestHistoryAsync: call StampUsageRatesAsync after hydration
- UsageDatabase.StampUsageRatesAsync: SQL CTE picks baseline row in 30–120 min window
- ProviderCardViewModel: ShowUsagePerHour observable + UsageRateBadgeText computed property
- ProviderCardResources.xaml: rate badge TextBlock (NullToVisibilityConverter)
- MainWindow.xaml.cs AddProviderCard: programmatic rate badge element
- SettingsWindow.xaml + .cs: ShowUsagePerHourCheck checkbox wired to preference

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@rygel rygel merged commit 940d046 into develop Mar 19, 2026
16 checks passed
@rygel rygel deleted the feat/usage-per-hour branch March 19, 2026 16:59
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.

2 participants