SuperMagic's accounts (mycf_711's magicrew plugin) are prepaid wallets of
points with no total. A plugin can now send a usage window as
{name, balance: 6291, unit: "积分"} with no used or limit.
- host.js passes a finite balance on (at least 0), anything else as null.
plugin.UsageWindow.Balance and provider.QuotaWindow.Balance are *float64.
- quotaOfPlugin keeps the figure and does not make the window Text or
Aside, so routing knows the account with no Used invented. allowanceOf
copies it into Limit.Balance; an empty wallet counts as used up.
Allowance.Left(model) is the least balance of the windows that count
the model.
- weighRouted fills routes.Seat.Left and Seat.LeftIn (the account's
provider and unit). Smart, pace and usage (least used) put the seat
with more left first where they would otherwise tie (byLeft), only
when every seat with a balance shares one LeftIn: balances in two
units or two providers are never compared. Tiers still come first.
- The Usage card, the Routing page (Weighed.Balance: the small row's
text, no bar, a why sentence, the account list), magpie accounts and
the status line show the figure, "6,291 积分 left", never a share.
- Docs: provider-plugins (new section), gateway-routing,
providers-accounts, plugin-runtime, host.js typings and the site's
plugins page (en, zh, ja).
Run, at base f13aafa87, on mote:
- go test -tags nogui -timeout 45m ./...: 72 packages ok; red were
TestQuotaSpanCarriesEveryWindowField (this change's: its fixture now
sets Balance, green after), and on the unchanged base too
TestWSLColdPlaceOpensNothing (#3924), TestFetchAsksASharedBaseOnce and
two siblings (#3854), TestTUIFetchesSubscriptionModels (#3919), all
fixed on main since and run again after the rebase; and
TestPluginStreamsPastTheBudgetWait (#3946), green alone on both.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/..., go
build ./..., gofmt -l: clean.
- New tests: TestPluginWalletBalanceIsAReading, TestAllowanceLeftIsTheLeastBalance,
TestPluginHostPassesABalanceOn (through real Bun and host.js),
TestWalletsGoByWhatTheyHaveLeft, TestWalletLeftWithinItsTier,
TestWalletWithMoreLeftGoesFirst, TestQuotaCell's balance cases;
usage-wallet-balance.test.cjs and routing-wallet-balance.test.cjs,
34 of 34 in Chromium and WebKit, en zh zh-TW ja de, 1100/900/420/390px.
- GUI: every quota*, usage*, panel*, routing*, i18n* and tray* file (220
files, 2928 tests), concurrency 4: 130 red, in 21 files. Those 21 files
run again on an unchanged base copy and on this change, concurrency 2:
the same 19 files red on both (126 and 131), the differing subtests
being routing-rule-remove / rules-line / intent-entry flaps that go
both ways. Each is filed (#3679, #2115, #3410, #3404, #3411, #3897,
#1905, #3096, #3593, #3408, #3409, #3799, #3789, #3412, #3947, #3415,
#3414, #1345); routing-story-shrinks had none and is #3954.
After rebasing on origin/main 833f51adc, on mote: Linux and Windows vet,
go build, gofmt clean; go test -tags nogui of internal/routes, provider,
gateway, cli, plugin, gui (the script budgets), agent and tui: all ok;
the two wallet GUI files and i18n-keys: 37 of 38, the red being
i18n-keys' "Runs as" (#3897, not this change).
Broken by hand, each red then restored: quotaReport's Balance copy
removed (TestQuotaSpanCarriesEveryWindowField red); byLeft always nil (routes and
gateway tests red); host.js's balance line removed (host test red);
quotaOfPlugin's balance copy removed (provider tests red); app.js and
client.js at base (both GUI files 34 of 34 red, "0% used" / "已用 0%").
Not tried: a real SuperMagic account or the magicrew plugin (it isn't
in the community repo; it needs to send balance), Windows and Linux
GUI apps, and the WebKitGTK app.