Skip to content

feat: show managed quota in footer - #2782

Closed
Coiggahou2002 wants to merge 1 commit into
MoonshotAI:mainfrom
Coiggahou2002:feat/quota-footer
Closed

feat: show managed quota in footer#2782
Coiggahou2002 wants to merge 1 commit into
MoonshotAI:mainfrom
Coiggahou2002:feat/quota-footer

Conversation

@Coiggahou2002

@Coiggahou2002 Coiggahou2002 commented Aug 10, 2026

Copy link
Copy Markdown

Related Issue

Resolves #872

Problem

The interactive footer only shows context-window usage. Managed-plan users must open /usage to see their 5-hour and weekly quota windows, and the existing managed-usage lookup only reads OAuth storage even when the provider is configured with an API key.

What Changed

  • added a provider-scoped managed-usage controller outside the render path
    • refreshes at startup, after completed activity, after login/logout, and every five minutes
    • caches attempts for 60 seconds, coalesces concurrent reads, and ignores stale responses after provider switches
    • falls back to the existing context-only footer when quota data or authentication is unavailable
  • added compact 5-hour and weekly remaining-quota segments with local reset times
    • preserves the context segment
    • drops lower-priority quota segments on narrow terminals instead of clipping the full footer line
  • exposed managedUsage to custom status_line.command JSON payloads
  • allowed managed-usage calls to authenticate with either a configured API key or OAuth tokens
  • reused the shared managed-usage types in the existing /usage and /status panels
  • documented the behavior in English and Chinese and added a patch changeset

Verification

  • 156 focused tests across OAuth, SDK, auth service, controller, footer, usage, and status panels
  • focused footer suite: 18 tests
  • typecheck: OAuth, agent-core-v2, node-sdk, and kimi-code app
  • package build and kimi-code production build
  • English and Chinese documentation build
  • full repository lint (0 errors; existing warnings only)
  • agent-core-v2 import-boundary check
  • git diff --check

Checklist

  • Related issue linked
  • Tests added or updated
  • English and Chinese documentation updated
  • Changeset added for user-visible package changes
  • No network request occurs in the synchronous footer render path

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 88e4759

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

This PR includes changesets to release 3 packages
Name Type
@moonshot-ai/kimi-code Patch
@moonshot-ai/kimi-code-oauth Patch
@moonshot-ai/kimi-code-sdk Patch

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: 88e4759b11

ℹ️ 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".

return this.cachedUsage === undefined ? undefined : { usage: this.cachedUsage };
}

if (this.inFlight?.provider === provider) return this.inFlight.promise;

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 Let forced quota refresh bypass stale in-flight loads

When a /login or same-provider config refresh happens while a background managed-usage request is already in flight, the forced refresh issued by the auth path still returns that old request here. Because syncProvider() only invalidates when the provider id changes, the stale response can repopulate the footer with pre-login quota data (or leave it empty after an old failure) and skip fetching with the new credentials until a later poll/activity refresh. Treat force as a superseding read or invalidate the controller on same-provider auth changes.

Useful? React with 👍 / 👎.

return this.toolkit.getManagedUsage(providerName, {
oauthRef: auth.oauthRef,
baseUrl: auth.baseUrl,
...(apiKey === undefined ? {} : { accessToken: apiKey }),

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 Pass the optional accessToken directly

When passing an optional property, the repository rule says to pass undefined directly rather than using conditional spread; this new options object omits accessToken via spread even though the callee option is optional. Please pass accessToken: apiKey directly (and mirror that in the v2 auth service call) so the new managed-usage auth path follows the repo-wide object construction convention.

AGENTS.md reference: AGENTS.md:L51-L53

Useful? React with 👍 / 👎.

@liruifengv liruifengv closed this Aug 11, 2026
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.

Feature request: display 5-hour and weekly quota remainders alongside context usage in status line

2 participants