commandcode 0.1.24: a Go, GOAT or Pro Credits window tells its count in credits, so magpie adds accounts up

chen2652 on magpie's Discord (v0.1.3361): three Command Code Go
accounts, folded together on the Routing page, showed no summed
credits. The Credits window of a units plan said only its share and
a display string, so magpie's mergeQuotas could only take the mean of
the shares, and only for cards on one plan. It now carries amount (the
credits used, as the display rounds them), limit (the month's pool)
and unit "credits", so magpie adds them up: "16.40 / 30 credits".

Bought and free credits (dollars at model cost) left the display's
"+ $X extra" for the account's balance, a row of its own under the
windows on magpie's Usage card. With a limit set, magpie's GUI and TUI
say the count from amount and limit, not the display, so the extra
would have been lost from the card otherwise.

Not changed: Max, Ultra and Teams Pro, whose Credits pool is dollars,
keep display and share only (magpie would print "$" as a unit after
the numbers).

Run: bun test in packages/commandcode on mote (100 pass, 1 skip, as
before), bun scripts/check.mjs (all ok). The test expectations for
the units plans' Credits window now include amount, limit and unit,
and GOAT's bought credits are the balance.
This commit is contained in:
yetone
2026-11-09 12:26:36 +08:00
parent d54df279c0
commit c8125b92b5
6 changed files with 32 additions and 14 deletions
+10 -4
View File
@@ -616,8 +616,12 @@ function limits(c) {
// never there (01huadalang on Discord). On a plan whose credits are
// usage-value units (Go, GOAT, Pro) the bar is the month's credits alone,
// said as credits, and the bought and free ones, dollars at model cost
// (the docs: "Buy extra credits at model cost"), are said beside it, not
// added to a pool of another unit (plugins #556). A reply with neither
// (the docs: "Buy extra credits at model cost"), are the account's
// balance beside it, not added to a pool of another unit (plugins #556).
// Its count goes as amount of limit in credits, so magpie adds several
// accounts' credits up ("16.40 / 30 credits") where it puts them together,
// as it does the Usage page's strip and a Routing fold (chen2652 on
// magpie's Discord), rather than a mean of their shares. A reply with neither
// windows nor a plan tells a balance: a key's money, not an allowance. The
// month's credits come back at until, the end of the plan's period
// (billing/subscriptions' currentPeriodEnd), when it is known
@@ -641,8 +645,10 @@ function allowanceOf(c, until) {
if (known && planMonthly > 0 && unit === "units") {
const pool = Math.max(planMonthly, monthly)
const extra = left - monthly
const display = credits(pool - monthly) + " / " + credits(pool) + " credits" + (extra > 0 ? " + " + money(extra) + " extra" : "")
out.windows.splice(1, 0, { name: "Credits", used: Math.min(100, (100 * (pool - monthly)) / pool), display, ...reset })
const spent = credits(pool - monthly)
const display = spent + " / " + credits(pool) + " credits"
out.windows.splice(1, 0, { name: "Credits", used: Math.min(100, (100 * (pool - monthly)) / pool), display, amount: Number(spent), limit: pool, unit: "credits", ...reset })
if (extra > 0) out.balance = money(extra)
} else if (known && planMonthly > 0) {
const pool = Math.max(planMonthly, monthly) + left - monthly
out.windows.splice(1, 0, { name: "Credits", used: Math.min(100, (100 * (pool - left)) / pool), display: money(pool - left) + " / " + money(pool), ...reset })