Skip to content

fix(shell): correct /usage remaining quota colors#2039

Open
binichallein wants to merge 6 commits intoMoonshotAI:mainfrom
binichallein:fix/usage-color-2019
Open

fix(shell): correct /usage remaining quota colors#2039
binichallein wants to merge 6 commits intoMoonshotAI:mainfrom
binichallein:fix/usage-color-2019

Conversation

@binichallein
Copy link
Copy Markdown

@binichallein binichallein commented Apr 23, 2026

Related Issue

Resolve #2019

Description

This fixes the inverted quota colors in /usage.

Root cause:

  • _ratio_color() receives the remaining-quota ratio ((limit - used) / limit), not the used ratio
  • the thresholds were previously mapped as if larger values were more dangerous, so high remaining quota rendered red and low remaining quota rendered green

Changes:

  • map <= 10% left to red
  • map <= 30% left to yellow
  • map > 30% left to green
  • add a regression test covering remaining-quota thresholds and over-limit behavior

This is equivalent to the common used-quota thresholds:

  • < 70% used => green
  • 70%-89% used => yellow
  • >= 90% used => red

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +7 to +8
- Shell: Fix usage remaining quota colors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 English changelog manually edited instead of auto-synced from root CHANGELOG.md

docs/en/release-notes/changelog.md is directly edited in this PR, but docs/AGENTS.md:185 explicitly states: "The English changelog (docs/en/release-notes/changelog.md) is auto-generated from the root CHANGELOG.md. Do not edit it manually." The authoring workflow at docs/AGENTS.md:27 also says: "For changelog: edit the root CHANGELOG.md, then run npm run sync to update the English docs." The correct workflow is to only edit the root CHANGELOG.md and let the sync script (docs/scripts/sync-changelog.mjs) generate the English docs version.

Prompt for agents
The file docs/en/release-notes/changelog.md should not be manually edited. According to docs/AGENTS.md (line 185 and line 27), the correct workflow is to edit only the root CHANGELOG.md and then run 'npm run sync' from the docs/ directory to auto-generate the English changelog. Remove the manual edits from docs/en/release-notes/changelog.md and rely on the sync script to propagate the changes from CHANGELOG.md.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

I initially resolved the changelog conflict manually, but I corrected the workflow afterward.

The current state follows the repo rules:

  • CHANGELOG.md is the source of truth
  • docs/en/release-notes/changelog.md was regenerated via node docs/scripts/sync-changelog.mjs
  • docs/zh/release-notes/changelog.md was merged accordingly as the translated page

Signed-off-by: binichallein <132759743+binichallein@users.noreply.github.com>
@sunmy2019
Copy link
Copy Markdown

You misunderstood the problem and gave a wrong fix.

@sunmy2019
Copy link
Copy Markdown

Usually people gave

0 < used < 70%, green
70% < used < 90%, yellow
90% < used < 100%, red

This is common practice and claude code also obeys.

green under 70%, yellow 70-89%, red 90%+

https://code.claude.com/docs/en/statusline#display-multiple-lines

@binichallein
Copy link
Copy Markdown
Author

@sunmy2019 Thanks for catching this. You were right that my initial fix misunderstood the metric.

I've updated the PR so _ratio_color() now uses the remaining quota ratio correctly:

  • <= 10% left => red
  • <= 30% left => yellow
  • > 30% left => green

That matches the usual used-quota thresholds after converting from remaining quota. I also added regression tests and resolved the changelog/docs conflicts following the repo workflow (CHANGELOG.md -> sync English changelog -> update Chinese changelog).

Latest update is in 4137323a. Please take another look when convenient.

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.

Wrong usage color

2 participants