Add quota-run efficiency metrics on Charts (SOU-299) - #144
Conversation
Capture best-effort local tokens during open runs, derive tokens per 1% used, cache-read share, projection to 100%, and run-over-run delta. Surface one card per window on Charts with honest local-observation labeling. Unblocks comparing how far an allowance actually went across resets.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ceiling | 3e6c3de | Commit Preview URL Branch Preview URL |
Jul 24 2026, 11:52 PM |
📝 WalkthroughWalkthroughQuota-run history now captures local token samples, computes efficiency metrics, exposes them through a new Tauri command and TypeScript bridge, and renders quota-efficiency cards in provider charts with supporting tests and styles. ChangesQuota run efficiency
Sequence Diagram(s)sequenceDiagram
participant ProviderCharts
participant TauriBridge
participant NativeCommand
participant QuotaRunHistory
ProviderCharts->>TauriBridge: request provider efficiency
TauriBridge->>NativeCommand: invoke get_quota_run_efficiency
NativeCommand->>QuotaRunHistory: call efficiency_for_provider
QuotaRunHistory-->>NativeCommand: return efficiency rows
NativeCommand-->>TauriBridge: return typed rows
TauriBridge-->>ProviderCharts: render quota efficiency card
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/desktop-tauri/src/surfaces/settings/providers/sections/charts/ChartsSection.tsx (2)
487-505: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winEfficiency card doesn't refresh while the user stays on the same provider.
The fetch effect only re-runs on
[providerId, accountEmail]. If a quota run closes (reset/drop) while the Charts tab remains open for the same provider/account, the new efficiency row won't appear until the user navigates away and back. Consider also refetching whenusageWindowsKey/datachanges (mirroring the existing chart-data refresh trigger).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop-tauri/src/surfaces/settings/providers/sections/charts/ChartsSection.tsx` around lines 487 - 505, The efficiency-fetching useEffect in ChartsSection must also rerun when chart usage data refreshes, not only when providerId or accountEmail changes. Add the existing usageWindowsKey/data refresh trigger to its dependency array, matching the chart-data effect, while preserving the cancellation and provider-support checks.
147-152: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPossible duplicate of the existing token formatter.
formatCompactTokensabbreviates tokens into K/M/B, the same style already used elsewhere in this component for token counts (e.g. the period cards). If an equivalent formatter already exists in this file/module, prefer reusing it instead of introducing a near-duplicate.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop-tauri/src/surfaces/settings/providers/sections/charts/ChartsSection.tsx` around lines 147 - 152, Check the existing token-count formatter used by the period cards in ChartsSection and reuse it for the new display instead of maintaining formatCompactTokens. Remove the duplicate formatCompactTokens helper and update its callers to use the existing formatter, preserving the current K/M/B formatting behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@apps/desktop-tauri/src/surfaces/settings/providers/sections/charts/ChartsSection.tsx`:
- Around line 487-505: The efficiency-fetching useEffect in ChartsSection must
also rerun when chart usage data refreshes, not only when providerId or
accountEmail changes. Add the existing usageWindowsKey/data refresh trigger to
its dependency array, matching the chart-data effect, while preserving the
cancellation and provider-support checks.
- Around line 147-152: Check the existing token-count formatter used by the
period cards in ChartsSection and reuse it for the new display instead of
maintaining formatCompactTokens. Remove the duplicate formatCompactTokens helper
and update its callers to use the existing formatter, preserving the current
K/M/B formatting behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5e838276-de65-4ee5-81bc-8a13878826be
📒 Files selected for processing (9)
apps/desktop-tauri/src-tauri/permissions/commands.tomlapps/desktop-tauri/src-tauri/src/commands/chart.rsapps/desktop-tauri/src-tauri/src/main.rsapps/desktop-tauri/src-tauri/src/quota_run_history.rsapps/desktop-tauri/src/lib/tauri.tsapps/desktop-tauri/src/styles.cssapps/desktop-tauri/src/surfaces/settings/providers/sections/charts/ChartsSection.test.tsxapps/desktop-tauri/src/surfaces/settings/providers/sections/charts/ChartsSection.tsxapps/desktop-tauri/src/types/bridge.ts
Summary
get_quota_run_efficiency(+ ACL).Honesty
Provider % stays authoritative. Token totals may still be machine-wide for some providers; the card copy says so. Projection is suppressed early in a run.
Test plan
quota_runtests (6)Closes SOU-299. No release.
Summary by CodeRabbit