Skip to content

feat(web): add /usage command to the web UI - #2359

Open
Song2012 wants to merge 2 commits into
MoonshotAI:mainfrom
Song2012:feat/web-usage-command
Open

feat(web): add /usage command to the web UI#2359
Song2012 wants to merge 2 commits into
MoonshotAI:mainfrom
Song2012:feat/web-usage-command

Conversation

@Song2012

Copy link
Copy Markdown

Related Issue

Resolve #2354

Problem

See linked issue. The web UI (kimi web) is missing the /usage command: 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?

  • Add /usage to the web slash-command menu (apps/kimi-web/src/lib/slashCommands.ts).
  • New UsagePanel.vue component with the same four sections as the TUI usage panel: session usage, context window, plan usage (weekly / 5-hour limits), and extra usage (加油包).
  • New pure-function lib usageFormat.ts (+ 16 unit tests) mirroring the TUI usage-panel.ts semantics.
  • Wire the managed-usage data through the web API layer: GET /oauth/usage DTOs in api/daemon/wire.ts, domain types in api/types.ts, getManagedUsage() in api/daemon/client.ts, exposed via useKimiWebClient.
  • English and Chinese i18n strings (commands.usage.desc + new usage namespace).
  • Add a changeset (minor).

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changeset (pnpm changeset)
  • I have updated relevant documentation

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-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d089004

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/kimi-web/src/App.vue Outdated
usagePanelResult.value = null;
usagePanelError.value = null;
try {
usagePanelResult.value = await client.getManagedUsage();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard stale usage fetches

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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in d089004 👍

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.
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.

Web UI: /usage slash command missing from web command menu (0.30.0)

1 participant