Commit Graph
3 Commits
Author SHA1 Message Date
ggbdpqandyetone ca1fc43fc9 provider: quota history draws no line for a plugin's aside window that says no share (#4825)
ggbdpq's patch (gua2100 on Discord), reviewed and landed with an
end-to-end test and a doc line.

What changed
- quotaOfPlugin marks an aside window that leaves `used` out, with no
  count to reckon one from, as noShare. pointOf refuses such a window,
  so the history no longer draws a flat 100%-left line for it. The card
  still shows the row as before.
- noShare is unexported and so lost on JSON. Cards restored from the
  cache have AsOf set, and noteQuotaHistory skips them, so this never
  matters.
- Review changes: TestAsideWindowWithoutUsedDrawsNoLine now also runs
  the windows through noteQuotaHistory and QuotaHistories in a sandbox
  HOME, and wants lines [Bonus Weekly] only.
  docs/subsystems/providers-accounts.md says such a window isn't kept.

Run at the pushed head (on mote, base 4d55a0a02)
- go test -race ./internal/provider passes for the touched tests, and
  the provider package passes.
- The full suite, gofmt and the cross-OS vet are as recorded in the
  #4824 netproxy commit. The only reds are #4826 and #4807, neither in
  provider.

Broken by hand: with noShare removed from pointOf, the test is red:
"On-demand/Points: history point true, want false" and "history lines
[Bonus On-demand Points Weekly], want [Bonus Weekly]".

Not tried: a real plugin reporting such a row, or the chart in a
browser. A wallet Balance window draws the same flat line; that is
#4831, not this commit.

Co-authored-by: yetone <yetoneful@gmail.com>
2026-11-02 09:11:30 +08:00
yetone 1390aa458f provider: a usage window's count is its share when used is left out (plugins#468)
A plugin window that sent amount and limit but no used was text alone
(Text, Aside), and an account whose windows all did so was unknown to
routing, weighed behind accounts it should beat. quotaOfPlugin now fills
Used from amount/limit when both are above 0 and used is absent: 370 of
1000 is 37. An amount of 0 is what a left-out amount reads as, so a limit
alone still says nothing (#3650 unchanged). aside still keeps a window
out of routing whatever its count.

amount is the amount used: the guide ("amount of limit used") and
host.js's usageOf say so, and every community plugin that sends it
(magpie-community/plugins 95fa761) sends the used count, never what is
left: codearts (limit - remain), joycode (item.used), kiro, minimax
(total - left), raccoon (granted - avail), cloudflare-workers-ai, cline
(used, or total - remaining), zcode (used, total - remaining, or
currentValue), gcp-ai (credits.used), copilot (limit - remaining),
trae, workbuddy. None reaches the new path: each of these windows sends
a finite used beside amount/limit. The one that can leave used out,
cloudflare-workers-ai with no Analytics reading, sends amount null,
which reads as 0, so its window stays text as before. The path is for
plugins outside the community repo (GitHub-tagged or local) that send a
count and no share.

Run (mote, at this tree): gofmt -l clean; vet on three OSes; go test
-tags nogui -timeout 45m ./...
(go test -tags nogui -timeout 45m ./... at base 5bfd76cd8: 77 packages ok, none failed (log kept whole). Rebased onto 602ad84ad and run again there: vet on three OSes ok; go test -tags nogui -count=1 ./internal/provider (195s) ./internal/plugin (268s) ./internal/gateway (677s) ok. Rebased onto b5d2858f4 and run again: usage, provider, plugin, gateway ok. Rebased onto 87a983423, the pushed base, and run again at this tree: gofmt -l clean; go vet ./internal/... ok, GOOS=linux and windows go vet of provider, plugin, gateway ok; go test -tags nogui -count=1 ./internal/provider (126s) ./internal/plugin (180s) ./internal/gateway (588s) ./internal/codexcat (1s) ok. Then rebased onto 3ec9babe7 to push; its three commits (WorkBuddy mover min, redact, sessions) share no file with this one, and the same packages are run again at the pushed head after the push).
Broken by hand: on the old plugin_usage.go TestAWindowsCountIsItsShare is
red: "a counted window: Text true, Aside true, Used 0" and "routing:
known false, used 0; want the count's 37".
Not tried: a real plugin sending counts without used (the reporter's
instance isn't named).
2026-10-29 00:52:19 +08:00
yetoneandskygunner 9733ed1b4a usage: a plugin window that doesn't say used is no reading (#3650)
A plugin usage window that leaves out `used` was read as 0 in host.js
usageOf. The card then showed "100% left" (or NaN% once the GUI saw a
missing value), and allowanceOf ranked the account as the one with all
of its allowance left, so smart routing put spent accounts first.

Now a left-out used is null from the host, plugin.UsageWindow.Used is a
*float64, and quotaOfPlugin makes such a window Text and Aside: the card
shows its display (else "No allowance reported"), with no percentage and
no meter, and routing leaves it out. An account whose windows all tell no
share has no allowance and is not known to routing (routedAllowance), as
one never read: not preferred and not rested. A window that says used:0
is a reading at 0, as before.

Ported from skygunner's fix/usage-absent-used (6791aa99). Changed from
the branch:
- lastAllowances (the reading kept on disk) built an empty allowance for
  such an account, which routing read as known with all of it left. Both
  it and Allowances now go through routedAllowance.
- quotaText shows "No allowance reported" for a no-share window with no
  display, rather than a blank.
- A host-level test (the bun host with the fake plugin) and the GUI test
  widened to both engines, every language, 900 and 390px, used and left.
- The branch's check-in wording change is its own commit.
Note: an account whose windows are all aside or text was known with 0%
used before; it is now not known, so loginRoom won't pick it as the
next account with room.

Run at this tree (base 9298d2a7c):
- go test ./internal/provider -run 'Absent|NoShare|PluginUsage|PluginText|
  AllowancePooled|PluginPool|GLMPlan|WorkBuddyCredits|QuotasDedupe'  ok
- go test ./internal/plugin ok; gofmt -l empty; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok
- GUI: usage-no-reading.test.cjs chromium+webkit ok; i18n-keys ok;
  TestCoreScriptBudget ok (budget not raised)
Broken by hand, each red, then restored:
- quotaOfPlugin without the Text/Aside branch: 3 absent tests red
- routedAllowance always ok and allowanceOf not skipping Text:
  TestRoutingKnowsNoAccountThatSaidNoShare red
- host.js's old used line: TestPluginHostPassesAnAbsentUsedOn red
- usage-no-reading on origin/main's assets: red in both engines
  ("12 / 300 · NaN% used")
Not tried: a real Loomy account, a live routed request.

Co-authored-by: skygunner <skygunner@users.noreply.github.com>
2026-10-26 22:42:59 +08:00