Skip to content

refactor(overview): move usage panels to the Usage page - #408

Merged
caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
haocheng23:feat/usage-page-consolidation
Oct 27, 2026
Merged

caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
haocheng23:feat/usage-page-consolidation

Conversation

@haocheng23

Copy link
Copy Markdown
Contributor

Summary

The Overview page had accumulated three read-only insight panels that duplicate what the standalone Usage page is for. This PR keeps Overview focused on gateway health and moves the credit-expiry view to where the other usage numbers already live.

Overview

  • Removes the Usage breakdown and Credit deduction history panels, along with the fetchRequestUsage call, the usage / usageLoading / usageError state, and the usage branch of the 30s background refresh that fed them. The page keeps gateway status, traffic, account pool, resources and the ranking cards.
  • Drops the regional catalog fetch (fetchModels(..., 'regional')) that existed only to resolve model credit rates for the credit history.

Usage

  • Mounts Credit expiry distribution under the Stats tab, following the same time window as the tables above it.
  • Defaults the window to Today, matching Overview.
  • Adds Today to the Quota tab, which previously started at All retained, and defaults it there too — otherwise one page would open on two different windows.

Cleanup

  • Deletes UsagePanels.tsx, the RequestUsage* types and fetchRequestUsage from api/logs.ts.
  • Removes the 36 i18n keys that only those panels used. en and zh stay in parity at 851 keys each.
  • npm run sync regenerated internal/webui/static.

Deliberately not included

GET /api/logs/usage and SummarizeRequestUsage are left in place. They are public console API surface covered by TestRequestUsageEndpointCredits, so deleting them is a separate, breaking change rather than part of a menu reshuffle. Say the word and I will open a follow-up.

Test plan

  • go test ./...
  • go vet ./...
  • cd worker && npm test (87 pass; untouched by this PR)
  • cd frontend && npm run build && npm run lint — build green, 50 warnings / 0 errors (51 before this PR; no new warnings)
  • Added changelog/unreleased/usage-page-consolidation.md (EN + 中文), release-notes.py validate passes
  • No tokens, auth blobs, raw captures, or host details in the diff
  • Manually verified on a scratch port against a copy of a live database (6,872 request logs): Overview renders with no usage panels, Usage opens on Today in both tabs, and the expiry distribution renders 23 days of real credit-expiry data (including a 733-credit day and a 3.5k-credit batch expiring 11/19)
  • Switching Today / 1h / 24h / 7d / 30d / custom keeps the tables and the expiry distribution in lockstep

The Overview page had grown three read-only insight panels that duplicate
what the standalone Usage page is for. Keep Overview about gateway health
and move the credit-expiry view to where the other usage numbers live.

Overview:
- Drop the Usage breakdown and Credit deduction history panels together
  with the usage fetch, its state and the 30s refresh branch that fed
  them; the page keeps status, traffic, account pool, resources and ranks.
- Drop the now-unused regional catalog fetch that only fed Credit history.

Usage:
- Mount the credit expiry distribution under the Stats tab, following the
  same window as the tables above it.
- Default the window to Today, matching Overview.
- Add Today to the Quota tab, which previously started at the full
  retained range, and default it there too.

Cleanup: delete UsagePanels.tsx, the RequestUsage types and fetcher, and
the 36 i18n keys that only those panels used (en/zh stay in parity).

The `/api/logs/usage` endpoint and SummarizeRequestUsage stay in place:
they are public console API surface covered by TestRequestUsageEndpointCredits,
so removing them is a separate breaking change.

Verified against a copy of a live database on a scratch port: Overview has
no usage panels, Usage defaults to Today on both tabs with the expiry
distribution rendering 23 days of real credit expiry data.

@caigee-cmd caigee-cmd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:Overview 去掉重复用量面板,ExpiryDistribution 复用到 Usage,today 默认窗口合理。

Resolve rename conflicts under internal/webui/static after caigee-cmd#407 landed.
@caigee-cmd
caigee-cmd merged commit 2615f25 into caigee-cmd:main Oct 27, 2026
6 checks passed
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