Repository navigation
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 |
Port review: Command Code granted monthly credits (#632, GAP-38)Reviewed the branch diff What I checked:
Result: no findings. The port matches upstream semantics on grant precedence, failed-lookup retention and sizing. File sizes fine (mod.rs +130/−46, tests 235 new). No dependency, locale, bridge or frontend change. |
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.