Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Command Code now sizes the monthly credits row from the grant the credits response reports (
credits.monthlyCreditsis the remaining balance,credits.monthlyCreditsGrantedthe size of the grant).monthlyCreditsGrantedwhen finite and > 0, else the plan catalog value.0, negative andInfinity(andNaN) fall back to the plan/free-tier logic.monthlyCredits.individual-gowith granted 12 and 9 remaining givesGo · $3.00 of $12.00; a grant with no plan gives$6.00 of $10.00.used/limit) uses the same total, so the fixture (4 remaining of 10) reports 6 / 10 instead of 0 / 4.8.78 monthly credits remaining) rather than a 0% quota bar, matching upstream where every lane is nil in that case. This also applies to a fully empty account.Change stays inside
rust/src/providers/commandcode/;plan_cache.rsis untouched (the lookup outcome is derived infetch_webfrom the subscription result, independent of the remembered plan, like upstreamsubscriptionEnrichmentUnavailable).Upstream reference
49e7ff3e).v0.66.0):Sources/CodexBarCore/Providers/CommandCode/CommandCodeUsageFetcher.swift(parseCredits),CommandCodeUsageSnapshot.swift(monthlyCreditsTotal,monthlyCreditsUsed,makeMonthlyWindow,makeLoginMethod),Tests/CodexBarTests/CommandCodeUsageFetcherTests.swift,docs/command-code.md.Ported / Deferred
Ported: every rule above, plus upstream test cases:
parses granted monthly creditsfixture,subscription failure in a fresh process sizes the monthly window from granted credits((4, 60%), (0, 100%) withwindowLimitsfiveHour used 2.5 / cap 10 and weekly used 30 / cap 100, reset nil),granted credits size the monthly window over the plan catalog,unusable granted credits keep the free tier reading(0, -5, Infinity),subscription failure leaves the projected monthly window unavailable.Deferred (pre-existing gaps, not part of steipete#3939, left out to keep this PR one behavior):
parseSubscriptiontreats a 200 response withsuccess != true, a missingdata, or a missingplanIdas a failed lookup. Localfetch_webtreats any 200 JSON body as an answered lookup (a{"success":false}envelope reads as free tier and clears the remembered plan). Worth a separate micro PR.unknownPlanfor an active subscription with an unrecognized plan id; local silently continues.commandCodeMonthlyGrantDepletedstate); no local counterpart in this provider.Validation
Toolchain
cargo +1.98.0, process-localCARGO_TARGET_DIR(pwsh was refused in the worktree, so the target dir was set manually outside every worktree).cargo +1.98.0 fmt --all: clean.cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: pass, no warnings.cargo +1.98.0 test -p codexbar commandcode: 39 passed, 0 failed (11 new ingranted_credits_tests.rs, 28 existing; the six existing call sites ofresult_from_payloadsonly gained theSubscriptionLookup::Answeredargument and still assert the same values).Affected areas
UI proof
Not applicable. No UI code changed; the existing monthly lane and login-method line receive different values.