Skip to content

feat(tui): show CLI version and plan usage in the footer#2044

Open
yichensunjoe wants to merge 1 commit into
MoonshotAI:mainfrom
yichensunjoe:feat/footer-plan-usage
Open

feat(tui): show CLI version and plan usage in the footer#2044
yichensunjoe wants to merge 1 commit into
MoonshotAI:mainfrom
yichensunjoe:feat/footer-plan-usage

Conversation

@yichensunjoe

Copy link
Copy Markdown

Related Issue

Resolve #1171. Refs #1835 (implements the plan-usage portion of that proposal).

Problem

Weekly / rolling-window quota and reset times are only visible by interrupting
the flow to run /usage. Heavy users want them at a glance (see linked issues).

What changed

  • New optional [footer] section in tui.toml (all defaults off, so existing
    users see zero change): show_version, show_plan_usage,
    plan_usage_refresh_seconds (default 60).
  • Footer line 1 shows a dim vX.Y.Z after the model label when show_version
    is on.
  • Footer line 2 shows compact plan-usage rows when show_plan_usage is on
    (e.g. Weekly limit ██████░░ 70% (resets in 6d 2h) · 5h limit …), reusing the
    managed-usage data behind /usage with severity-colored bars. Transient hints
    take precedence; narrow terminals drop rolling-window rows before the weekly
    summary; the segment hides for non-managed providers / signed-out users /
    before the first successful fetch, and keeps last good data on errors.
  • Polling uses a setTimeout chain: after success it waits the configured
    interval, after failure it retries in 5s so the first paint is fast.
    /reload-tui applies changes live.
  • The managed-usage fetch logic is extracted into a shared helper now used by
    both /usage and the footer (no behavior change in /usage).
  • Tests: plan usage (13), config (4). Full suite, typecheck, lint green.
    Docs (en/zh) and changeset (minor) included.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Add an opt-in [footer] section to tui.toml:

- show_version renders the CLI version next to the model name.
- show_plan_usage renders managed-plan quota (weekly summary plus
  rolling windows, with reset hints and severity-colored progress bars)
  left of the context readout, refreshed every
  plan_usage_refresh_seconds (default 60). Polling stays silent when
  signed out or on non-managed providers, retries quickly until the
  first successful fetch, keeps the last good data on errors, and
  yields the slot to the transient exit hint.

The managed-usage fetch logic previously inline in the /usage and
/status commands is extracted to tui/utils/managed-usage.ts and shared
with the footer. /reload-tui picks up config changes.

Refs MoonshotAI#1171 MoonshotAI#1835
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4617ecf

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: 4617ecfb55

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +473 to +474
const key = String(config.planUsageRefreshSeconds);
if (key === this.planUsageTimerKey) 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 Refresh quota when provider state changes

When a user logs out of the managed provider or switches /model to a non-managed provider after a successful footer fetch, setAppState changes model/availableModels but the footer config key is still just the refresh interval, so this early return skips both clearing and refetching planUsageReport. The footer therefore keeps rendering the stale managed quota until the next scheduled poll (60s by default), even though the feature is supposed to hide for signed-out/non-managed providers; include provider/model applicability in the key or clear/refetch on those state changes.

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.

[Feature Request] 底部状态栏显示额度/用量

1 participant