Repository navigation
feat(overview): add usage breakdown, credit-expiry and credit-history panels - #370
Merged
caigee-cmd merged 2 commits intoOct 23, 2026
Merged
Conversation
… panels - New `/api/logs/usage` endpoint + `SummarizeRequestUsage` store aggregation: token split (prompt/completion/total), cache hit/miss, requests, errors, latency, and upstream `usage.credit` sums, grouped by account/model/realm. 10s TTL cache mirrors the existing stats cache. - Overview: credit-expiry distribution (one colour per account, soonest-expiry FEFO table), usage breakdown table (account/model/realm switch, sortable) and credit deduction history with KPI tiles. All follow the page time window. - Add a fixed chart identity palette (--chart-1..8, light/dark) so charts can distinguish 4+ accounts without abusing semantic status colours. - Rebuild embedded console assets (internal/webui/static).
- Overview 30s / visibility refresh also quiet-loads usage panels - Converge creditExprNullable + creditExprOrZero (keep caigee-cmd#361 semantics) - Add SummarizeRequestUsage store/API coverage (native/fallback/NULL/realm/1M) - Drop unused usage.Series scan; mark expired-with-remain packs;口径 footnote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three read-only insight panels to the Overview page, all driven by the same time window as the traffic chart:
usage.creditper account and per model, with KPI tiles for credits deducted, matched tokens, average credits per 1M tokens, valid samples and cache-hit rate. Requests without a credit reading are excluded; nothing is back-filled; model rates come from the regional price catalog.Backend:
GET /api/logs/usageendpoint (internal/console/logs.go).SummarizeRequestUsageaggregation ininternal/store/request_logs.go(single grouped query + credit sums), exposed throughRequestRecorder.Usagewith a 10s TTL cache that mirrors the existing stats cache.RequestUsagetypes ininternal/accounts/request_logs.go.Frontend:
fetchRequestUsage+RequestUsagetypes infrontend/src/api/logs.ts.ExpiryDistribution.tsxandUsagePanels.tsxcomponents; wired intoOverviewPage.tsxreusingstatsQueryso the panels follow the page time window (including the new Today window).--chart-1..8, light/dark) so charts can distinguish 4+ accounts without abusing the semantic status colours (--success/--warning/--danger).Relationship to #336
This is complementary to #336 (
feat(console): add token usage and quota page). #336 adds a standalone usage/quota page; this PR embeds breakdown panels directly in the Overview page and adds the shared/api/logs/usageaggregation. Both touchinternal/store/request_logs.go,internal/logs/recorder.goandfrontend/src/i18n/messages.ts, so whichever lands second will need a small rebase, but the features are additive and independent.Test plan
go test ./...go vet ./...cd worker && npm test(untouched by this PR)cd frontend && npm run build && npm run lint(build green, lint 0 errors)changelog/unreleased/credit-expiry-distribution.md(EN + 中文)