Skip to content

Fix Kimi window ordering: prioritize rate limit over weekly quota#550

Open
ajaxjiang96 wants to merge 1 commit intosteipete:mainfrom
ajaxjiang96:fix-kimi-window-ordering
Open

Fix Kimi window ordering: prioritize rate limit over weekly quota#550
ajaxjiang96 wants to merge 1 commit intosteipete:mainfrom
ajaxjiang96:fix-kimi-window-ordering

Conversation

@ajaxjiang96
Copy link
Contributor

Summary

This PR restores the original intent from PR #310 (by @ajaxjiang96), which was partially reverted in PR #390 (commit ad6c751).

Problem

PR #390 took a "view-layer fix" approach that required special-case logic in StatusItemController and UsageStore to pick the secondary window for Kimi in automatic mode. This created architectural inconsistency:

  • Claude: primary = 5h session, secondary = weekly
  • Kimi: primary = weekly, secondary = 5h rate limit (but automatic mode picked secondary)

The menu displayed "Weekly" first, then "Rate Limit", which is the opposite of what users expect when comparing to Claude's display order.

Solution

This fix takes a "model-layer" approach that aligns Kimi with Claude's data model:

  1. Swaps the primary/secondary mapping in KimiUsageSnapshot to put rateLimitWindow as primary and weeklyWindow as secondary
  2. Updates menu labels to match the data: sessionLabel="Rate Limit", weeklyLabel="Weekly"
  3. Removes the now-unnecessary .kimi special-case from automatic mode selection in both StatusItemController and UsageStore+HighestUsage

Result

  • Kimi now displays the 5-hour rate limit first in the menu (matching Claude's display order)
  • The menubar icon shows the rate limit percentage in automatic mode
  • No special-case logic needed - both providers now have consistent semantics for primary and secondary

Why PR #390 Didn't Fully Work

PR #390 (the merge of #310) included commit ad6c751 which scoped the Kimi short-window priority to automatic metric selection only. This:

The current fix restores the original #310 approach but does it cleanly by also removing the now-unnecessary special-casing.

Files Changed

  • Sources/CodexBarCore/Providers/Kimi/KimiUsageSnapshot.swift - Swap primary/secondary windows
  • Sources/CodexBarCore/Providers/Kimi/KimiProviderDescriptor.swift - Update labels to match data model
  • Sources/CodexBar/StatusItemController.swift - Remove .kimi from automatic mode special-case
  • Sources/CodexBar/UsageStore+HighestUsage.swift - Remove .kimi from automatic mode special-case

Testing

  • Built and tested locally with ./Scripts/compile_and_run.sh
  • Kimi menu now shows "Rate Limit" progress bar first, then "Weekly"
  • Menubar icon displays rate limit percentage

Copy link

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

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: e07d6f9eba

ℹ️ 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 +76 to +77
primary: rateLimitWindow,
secondary: weeklyWindow,

Choose a reason for hiding this comment

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

P2 Badge Preserve Kimi metric preference semantics across remap

Swapping Kimi to primary=rateLimit/secondary=weekly changes the meaning of persisted .primary/.secondary menu-bar metric preferences for existing users, because preferences are stored as raw enum values and loaded verbatim (no Kimi-specific migration). After upgrading, anyone who had explicitly chosen Primary or Secondary for Kimi will silently see the opposite window than before until they reconfigure it, which is a user-visible regression in settings behavior.

Useful? React with 👍 / 👎.

This change restores the original intent from PR steipete#310 by @ajaxjiang96,
which was partially reverted in PR steipete#390 (commit ad6c751).

PR steipete#390 took a view-layer approach that required special-case logic in
StatusItemController and UsageStore to pick the secondary window for Kimi
in automatic mode. This created architectural inconsistency:
- Claude: primary=5h session, secondary=weekly
- Kimi: primary=weekly, secondary=5h rate limit (but automatic mode picked secondary)

This fix takes a model-layer approach that aligns Kimi with Claude:

1. Swaps the primary/secondary mapping in KimiUsageSnapshot:
   - When rate limit exists: primary=rate limit (5h), secondary=weekly
   - When no rate limit: primary=weekly, secondary=nil

2. Updates menu labels to match: sessionLabel="Rate Limit", weeklyLabel="Weekly"

3. Removes the now-unnecessary .kimi special-case from automatic mode selection
   in both StatusItemController and UsageStore+HighestUsage

4. Updates tests to reflect new window ordering:
   - KimiProviderTests.swift: Updated window assertions
   - StatusItemAnimationTests.swift: Swapped test data values
   - UsageStoreHighestUsageTests.swift: Swapped test data values
   - UsageStoreCoverageTests.swift: Swapped test data values

Result: Kimi now displays the 5-hour rate limit first in the menu (matching
Claude's display order), and the menubar icon shows the rate limit percentage.
@ajaxjiang96 ajaxjiang96 force-pushed the fix-kimi-window-ordering branch from e07d6f9 to 6893b11 Compare March 17, 2026 02:46
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