feat(web): add /usage command to the web UI - #2359
Conversation
Open a usage panel from the slash menu showing session token usage, the context window, managed plan quotas (per-limit progress bars and reset hints), and the Extra Usage wallet, mirroring the TUI /usage report. Plan data is fetched fresh from GET /api/v1/oauth/usage on each open; session data renders from existing client state. Pure formatting helpers live in lib/usageFormat.ts with unit tests. Includes en/zh strings. Closes MoonshotAI#2354
🦋 Changeset detectedLatest commit: d089004 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec8c066637
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| usagePanelResult.value = null; | ||
| usagePanelError.value = null; | ||
| try { | ||
| usagePanelResult.value = await client.getManagedUsage(); |
There was a problem hiding this comment.
If the user closes and reopens /usage while the first GET /oauth/usage is still pending, the earlier request can settle after the newer one and overwrite usagePanelResult/usagePanelError or clear the loading state for the active refresh. In that slow-network/retry scenario the panel can show an old error over a successful newer result, or stale quota data despite the command intending to fetch fresh data on each open; track a request id or abort the previous request before committing these refs.
Useful? React with 👍 / 👎.
A slow earlier GET /oauth/usage could settle after a newer panel open and overwrite the fresh result, error, or loading state. Each open now supersedes the previous fetch via a monotonically increasing id.
Related Issue
Resolve #2354
Problem
See linked issue. The web UI (
kimi web) is missing the/usagecommand: it is not listed in the slash-command menu and typing it does nothing, while the docs and the TUI both support it.What changed?
/usageto the web slash-command menu (apps/kimi-web/src/lib/slashCommands.ts).UsagePanel.vuecomponent with the same four sections as the TUI usage panel: session usage, context window, plan usage (weekly / 5-hour limits), and extra usage (加油包).usageFormat.ts(+ 16 unit tests) mirroring the TUIusage-panel.tssemantics.GET /oauth/usageDTOs inapi/daemon/wire.ts, domain types inapi/types.ts,getManagedUsage()inapi/daemon/client.ts, exposed viauseKimiWebClient.commands.usage.desc+ newusagenamespace).Checklist
pnpm changeset)