#2451 drew a plan key's month of credits as a Credits meter beside the
5-hour and weekly windows. Those two say when they start again; the
Credits one said nothing, though cmdKeyPlanID already asks
billing/subscriptions for the plan id and threw its currentPeriodEnd
away. cmdKeyPlanID now keeps the period end beside the plan id (cached
the same ten minutes, and the pair read before kept while the endpoint
can't be read), and cmdQuotaOf puts it on the Credits window's
ResetsAt. No new request. The signed-in subscription's card is the
plugin's since be62bcf79; the plugin sets the same reset from
commandcode-auth 0.1.13.
Patch by ggbdpq (Discord gua2100), as rebased in #2454. Added in
review: a period end already past is dropped, so a pair kept while the
endpoint fails, or a renewal its reply doesn't show yet, never puts a
reset in the past on the card; the test has a case for it.
Run (sandbox HOME, at origin/main 85b45b4d7 plus this):
- go test -tags nogui -run 'CommandCode|KeyQuotas' ./internal/provider/: ok
- Broken by hand: ResetsAt: until taken out -> "the key card's credits
have no reset" (ResetsAt nil); the past-end guard taken out -> "the
key card's credits reset in the past". Each restored: ok.
- go test -tags nogui ./internal/provider/: two known reds on main,
both filed and both red at 85b45b4d7 without this change:
TestUnreadLoginsWriteErrorsKeepCredentials crashes the binary (#3632),
and with it skipped the rest pass except TestFetchAsksASharedBaseOnce
and two siblings (#3854).
- gofmt -l internal/provider: clean. go vet ./internal/provider/ on
darwin, GOOS=windows, GOOS=linux: ok.
Not tried: a real Command Code plan key (none here), the GUI card, a
period that renews while the card is open; go test ./... (one suite per
machine). The key card only learns the period end when billing/credits
leaves the plan id out, which is what it does today; if it starts
sending the plan id, the reset is not read.
tianxia3111 runs Command Code on the keyed preset with a plan's key. Its
card showed the 5-hour and weekly windows as meters, but the month's
credits only as dollars left ($5.27), with no share of the month. The
cause: billing/credits leaves out the planId, so the key's card couldn't
know the plan's monthly pool. The signed-in subscription's card gets
that pool from billing/subscriptions.
The key's card (planKeyWindows -> cmdKeyWindows) now asks
billing/subscriptions with the same key for the plan. It then makes the
month a "Credits" window beside the other two, through the same
cmdQuotaOf the subscription's card uses ("$4.78 / $10.00" on a Go plan).
- The plan id is kept per key for ten minutes, since
billing/subscriptions takes 15-20 s at times.
- The id read before still counts while the plan can't be read.
- A key whose plan was never read keeps its two windows alone.
- A pay-as-you-go key, with no windows, still gets no card.
planWindows' request and status handling move into planBody, so that
cmdKeyWindows can decode the reply itself; other vendors are unchanged.
Run:
- New TestCommandCodeKeyCardHasCredits uses the reporter's own
billing/credits reply. Its billing/subscriptions reply has the shape
the other Command Code tests use (individual-go-monthly), because the
reporter's plan id isn't known.
- With the new branch disabled by hand, the test went red: two windows,
no plan. With it, green.
- TestKeyQuotasKeepLast now answers billing/subscriptions with 503 and
still sees its two windows.
- gofmt; go vet -tags nogui for darwin, linux and windows.
- Not tried against Command Code's real API: there is no plan key here.
- Full suite (go test -timeout 45m ./..., at f1c91a99c plus this change):
every package ok except internal/gui, red only on
TestPanelJoinsFullScreenSpaces, which is #2450 (macOS 26.2, red on
main before this change).