Skip to content

feat(tui): show managed usage quotas in footer status bar#702

Open
grandmaster451 wants to merge 9 commits into
MoonshotAI:mainfrom
grandmaster451:feat/footer-managed-quotas
Open

feat(tui): show managed usage quotas in footer status bar#702
grandmaster451 wants to merge 9 commits into
MoonshotAI:mainfrom
grandmaster451:feat/footer-managed-quotas

Conversation

@grandmaster451

@grandmaster451 grandmaster451 commented Jun 12, 2026

Copy link
Copy Markdown

This PR adds managed OAuth usage quotas to the TUI footer.

What changed

  • Added QuotaInfo to the TUI app state and exposed fetchManagedQuotas() from KimiTUI.
  • SessionEventHandler polls managed usage every 30 s for the default OAuth provider and caches the last server-side values so the footer keeps showing numbers while offline.
  • Footer now renders a unified status block so that context:, week:, and 5h: share aligned columns.

Footer layout

/yolo: toggle yolo | /help: show commands
                 context:  37.0%   (96.9k/262.1k)
                    week:  44.6%   (4d, 17h)
                      5h:  72.0%   (2h, 13m)

Details of the layout:

  • Labels are shortened (weekly limitweek, 5h limit5h) and right-aligned so the words sit next to the colons.
  • Quota percentages use one decimal place.
  • The percentage column is always wide enough for 100.0 %; reaching 100 % does not shift the block.
  • The percentage color uses a smooth green → yellow → red gradient based on the usage ratio.
  • Weekly reset countdown drops minutes while days remain, then switches to hours, minutes when under a day, keeping the suffix column stable.

Why

Users on managed Kimi Code plans previously had to run /info or open the status card to see weekly/hourly limits. Showing them in the always-visible footer makes remaining quota glanceable.

Testing

  • pnpm run typecheck passes.
  • Added/updated unit tests:
    • test/tui/components/chrome/footer.test.ts
    • test/tui/components/panels/footer-context.test.ts
    • test/tui/controllers/session-event-handler-quota.test.ts
  • pnpm run build:native:sea succeeds for darwin-arm64.

Notes

  • Quotas are displayed exactly as returned by the server. The 30 s poll is authoritative; no client-side token delta is added, so transient local usage spikes cannot push a quota to a misleading 100 %.
  • Only the default managed OAuth provider is polled; other providers keep the existing behavior (no quota rows).
  • Lessons from the layout work were captured in .kimi-code/skills/engineering/kimi-code-cli/SKILL.md under TUI Footer / Status Line Alignment Gotchas.

- Poll managed usage every 30s for the default OAuth provider.
- Cache the last server-side quotas so they stay visible when offline.
- Add current-turn token usage as a live delta between refreshes.
- Render aligned quota rows under the context percentage with a
  green-to-red gradient for the percentage value.
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 87202b6

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: 91043b4260

ℹ️ 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 on lines +704 to +707
private scheduleQuotaRefresh(): void {
this.clearQuotaRefreshTimer();
const providerKey = this.host.state.appState.availableModels[this.host.state.appState.model]?.provider;
if (!isManagedUsageProvider(providerKey)) return;

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 Reschedule quota polling after model changes

When the TUI starts on one provider and the user later switches models with /model, this quota refresh is not revisited: performModelSwitch updates appState.model, and agent.status.updated can also patch the model, but neither path calls scheduleQuotaRefresh or clears appState.quotas. As a result, switching from a custom provider to the managed provider never starts quota polling, while switching away from managed keeps the last quota rows visible because subsequent refreshes just return early. Please reschedule/clear the quota state whenever the active model's provider changes, not only when the session subscription starts.

Useful? React with 👍 / 👎.

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.

1 participant