[codex] Add Kimi monthly subscription usage#1839
Conversation
|
ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed July 4, 2026, 3:33 AM ET / 07:33 UTC. Summary Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against cec3d6dc2cc3. Label changesLabel changes:
Evidence reviewedWhat I checked:
Likely related people:
How this review workflow works
Review history (1 earlier review cycle)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7dc512ce6
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This PR extends the Kimi provider’s browser/cookie-based usage fetch to also pull monthly subscription usage from Kimi’s membership endpoint and surface it as an additional “Monthly” window in the unified UsageSnapshot.
Changes:
- Add models for Kimi’s subscription stat response (
KimiSubscriptionStatResponse/KimiSubscriptionBalance). - Fetch subscription stats from
GetSubscriptionStatduringfetchUsage(authToken:)and carrysubscriptionBalanceintoKimiUsageSnapshot. - Convert
subscriptionBalance.amountUsedRatiointo an extra “Monthly”NamedRateWindow, with new parsing/conversion tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/CodexBarTests/KimiProviderTests.swift | Adds decoding + conversion tests for the new subscription stat response and monthly extra window. |
| Sources/CodexBarCore/Providers/Kimi/KimiUsageSnapshot.swift | Stores subscription balance and maps it into a “Monthly” extra rate window. |
| Sources/CodexBarCore/Providers/Kimi/KimiUsageFetcher.swift | Adds a second web endpoint call to fetch subscription stats alongside existing usage fetching. |
| Sources/CodexBarCore/Providers/Kimi/KimiModels.swift | Introduces Codable models for the subscription stat payload subset that CodexBar uses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Live verification + review fixesPushed ✅ Live proof (addresses "needs real behavior proof")Fetched through the exact code path the app uses ( {
"provider": "kimi",
"source": "web",
"usage": {
"primary": { "usedPercent": 20, "resetDescription": "20/100 requests", "resetsAt": "2026-07-09T06:56:37Z" },
"secondary": { "usedPercent": 1, "resetDescription": "Rate: 1/100 per 5 hours", "resetsAt": "2026-07-02T16:56:37Z", "windowMinutes": 300 },
"extraRateWindows": [
{ "id": "kimi-monthly", "title": "Monthly", "window": { "usedPercent": 77.22, "resetsAt": "2026-07-23T00:00:00Z" } }
]
}
}
✅ Review fixes (
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
e533fdd to
1522d4d
Compare
- Clamp weekly and rate-limit percentages via clampedPercent so they can't exceed 100% when used > limit, matching the monthly window and other providers. - Document that Monthly tracks the shared subscription amountUsedRatio (the credit pool is shared across features) rather than the Code-only kimiCodeUsedRatio. - Add a partially-used (0.7716 -> 77.16%) monthly-window test so the fully-exhausted 1.0 fixture doesn't imply amountUsedRatio is a constant. Claude-Session: https://claude.ai/code/session_01YW7G46VVTos9nDkx7hRcwn
# Conflicts: # CHANGELOG.md
1522d4d to
ecc71d4
Compare
Summary
Why
Kimi exposes monthly subscription consumption separately from its coding usage response. This keeps the useful Monthly window while preserving the availability of the existing Weekly and Rate Limit data when membership enrichment is slow or unavailable.
Validation
swift test --filter KimiProviderTests— 46 tests across 6 suites passed on exact head.make check— repository checks, SwiftFormat, and strict SwiftLint passed.make test— all 46 sharded groups passed; one unrelated Claude deadline flake passed its automatic retry.cec3d6dc2.Live proof
Log invisible); both production POST routes responded with JSON401, confirming endpoint reachability but blocking a second authenticated exact-head capture.