plugins: host.js passes a usage window's pool and family on, so Antigravity's card shows its pools (plugins#935)

mk311 (plugins#935): the Antigravity plugin's Usage card listed every
model's own window (13 rows, each Gemini one at 85.1%, Claude and
GPT-OSS at 100%), then a bare "7 days" and "5 hours" twice. The plugin
(0.1.0) already groups them as the built-in did: each model's window
carries its family and its pool ("Gemini", "Claude & GPT"), each pool's
own 5 hours and 7 days carry the pool. f92c0a2bd taught
plugin.UsageWindow and quotaOfPlugin to read the two fields, but
host.js's usageOf builds each window from a fixed list of fields and
left them out, so nothing reached Go: its test hands quotaOfPlugin a
plugin.Usage directly, past the host. Now host.js passes family and
pool on, and the card, menu bar rings, TUI page (PooledWindows), quota
alerts, caps and routing's pool holds treat the plugin's pools as the
built-in's. Only the antigravity plugin sends these fields (grep of the
plugins repo). The plugin docs (en, zh, ja, llms-full.txt) name them.

TestPluginAntigravityPoolsReachTheCard goes through the real plugin host
(bun, the fake plugin's FAKE_WINDOWS) with the windows the antigravity
plugin's own usage() returns for the reporter's literal figures (each
Gemini model 85.1% left resetting 20:31 +08, Claude and GPT-OSS 100%
resetting 11-11 00:24:47 +08, Gemini 7 days 91.8% left; the Claude & GPT
week isn't in the screenshots and is set to 100% left), kept in
testdata/antigravity-plugin-usage-935.json. The card's lines are then
Gemini · 7 days, Gemini · 5 hours, Claude & GPT · 7 days, Claude & GPT ·
5 hours.

A cap a user set on the plugin's bare "7 days" (two pools under one
name) is now keyed "Gemini · 7 days", as the built-in's was.

Run (mote refused SSH, kex reset; wsl-run in magpie-desktop at this
commit on 6886da1ca):
- gofmt -l: clean; go vet linux, windows, darwin: ok
- go test ./internal/provider, targeted -run with the new test: ok
- go test ./internal/plugin: ok (219s)
- site worker.test.mjs: 38 pass, 0 fail
- GUI quota-pools, quota-pool-model, quota-pool-order, window-cap-pool
  (chromium + webkit, every language): 52/52, also 52/52 at 9c39edb92
  and 4a9142ccd. A first run at 9c39edb92 had one red in window-cap-pool
  (chromium 420 de, each pool's caps); it passed 40/40 alone and on every
  rerun, filed as #5949.
- The antigravity plugin's own usage() (plugins repo, unchanged) run on
  the reporter's figures produced the testdata file.

Broken by hand: host.js with pool dropped: the new test is red with the
reporter's card (13 model rows, then "7 days", "5 hours" twice, no pool).

Not tried: a real Antigravity account through the plugin in the GUI;
macOS and Windows runs (mote down).
This commit is contained in:
yetone
2026-11-10 20:32:38 +08:00
parent ad2be8dbb0
commit 016763f237
7 changed files with 70 additions and 1 deletions
+8 -1
View File
@@ -3168,7 +3168,12 @@ async function load({ provider, account, proxy }) {
// "credits"), span? (seconds the window runs), model? (a
// word in the ids of the only models it counts), models? / notModels?
// (the ids it counts, or all but these; a bare id and its id@size
// count as one), aside? (using it up doesn't
// count as one), family? (the model family a model's own window
// belongs to: "Gemini"), pool? (the group of models sharing one
// allowance: "Gemini", "Claude & GPT"; on the group's own windows,
// with no family, and on each of its models' — the GUI shows the
// group's windows in place of its models', as for magpie's built-in
// Antigravity), aside? (using it up doesn't
// stop the account), runsOutAt? (ISO or ms: when the soonest
// credits left in it are lost, apart from its reset, as WorkBuddy's
// packages end) / runsOut? (how many are lost then), balance?
@@ -3235,6 +3240,8 @@ async function usageOf(provider, account, signal) {
model: text(w?.model),
models: ids(w?.models),
notModels: ids(w?.notModels),
family: text(w?.family),
pool: text(w?.pool),
aside: !!w?.aside,
runsOutAt: when(w?.runsOutAt),
runsOut: Math.max(0, num(w?.runsOut)),
@@ -0,0 +1,57 @@
package provider
import (
"os"
"path/filepath"
"slices"
"testing"
)
// plugins#935 (mk311): the Antigravity plugin groups its models' windows
// into the pools they share ("Gemini", "Claude & GPT"), as the built-in
// did, but host.js passed neither a window's family nor its pool on (the
// Go side, quotaOfPlugin, already read them: TestPluginWindowsKeepPoolAndFamily
// hands it a plugin.Usage past the host), so the card showed every
// model's window and two "7 days" with no pool named. testdata/antigravity-plugin-usage-935.json is what the plugin
// (0.1.0) sends for the reporter's figures: each Gemini model 85.1% left
// resetting at 20:31 +08, Claude and GPT-OSS 100% resetting 11-11 00:24:47
// +08, and a 7 days at 91.8% left. Through the host, the card is each
// pool's 5 hours and 7 days in place of its models'.
func TestPluginAntigravityPoolsReachTheCard(t *testing.T) {
ws, err := os.ReadFile("testdata/antigravity-plugin-usage-935.json")
if err != nil {
t.Fatal(err)
}
windows := filepath.Join(t.TempDir(), "windows.json")
if err := os.WriteFile(windows, []byte(`{"a@fake": `+string(ws)+`}`), 0o600); err != nil {
t.Fatal(err)
}
q := fakePluginUsage(t, windows)["a@fake"]
if len(q.Windows) != 17 {
t.Fatalf("windows: %d, want 17: %+v", len(q.Windows), q.Windows)
}
for _, w := range q.Windows {
if w.Pool == "" {
t.Errorf("%q has no pool", w.Name)
}
if (w.Model != "") != (w.Family != "") {
t.Errorf("%q: model %q, family %q", w.Name, w.Model, w.Family)
}
}
var lines []string
for _, w := range PooledWindows(q.Windows) {
lines = append(lines, w.Name)
}
want := []string{"Gemini · 7 days", "Gemini · 5 hours", "Claude & GPT · 7 days", "Claude & GPT · 5 hours"}
if !slices.Equal(lines, want) {
t.Errorf("the card's lines: %q, want %q", lines, want)
}
// the Claude & GPT pool's windows hold its models, and only them
for _, w := range q.Windows {
if w.PoolWindow() && w.Pool == "Claude & GPT" {
if !w.CountsIn(q.Windows, "gpt-oss-120b-medium") || !w.CountsIn(q.Windows, "claude-opus-4-6-thinking") || w.CountsIn(q.Windows, "gemini-3.8-flash") {
t.Errorf("%s counts the wrong models", w.LineName())
}
}
}
}
@@ -0,0 +1 @@
[{"name":"Claude Opus 4.6 (Thinking)","used":0,"model":"claude-opus-4-6-thinking","family":"Claude","models":["claude-opus-4-6-thinking"],"resetsAt":"2026-11-10T16:24:47Z","pool":"Claude & GPT"},{"name":"Claude Sonnet 4.6 (Thinking)","used":0,"model":"claude-sonnet-4-6-thinking","family":"Claude","models":["claude-sonnet-4-6-thinking"],"resetsAt":"2026-11-10T16:24:47Z","pool":"Claude & GPT"},{"name":"gemini-2.5-flash","used":14.900000000000002,"model":"gemini-2.5-flash","family":"Gemini","models":["gemini-2.5-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"gemini-2.5-flash-lite","used":14.900000000000002,"model":"gemini-2.5-flash-lite","family":"Gemini","models":["gemini-2.5-flash-lite"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3 Flash","used":14.900000000000002,"model":"gemini-3-flash","family":"Gemini","models":["gemini-3-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.1 Flash Image","used":14.900000000000002,"model":"gemini-3.1-flash-image","family":"Gemini","models":["gemini-3.1-flash-image"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.1 Flash Lite","used":14.900000000000002,"model":"gemini-3.1-flash-lite","family":"Gemini","models":["gemini-3.1-flash-lite"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.5 Flash Lite","used":14.900000000000002,"model":"gemini-3.5-flash-lite","family":"Gemini","models":["gemini-3.5-flash-lite"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.8 Flash (High)","used":14.900000000000002,"model":"gemini-3.8-flash-high","family":"Gemini","models":["gemini-3.8-flash-high","gemini-3.8-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.8 Flash (Low)","used":14.900000000000002,"model":"gemini-3.8-flash-low","family":"Gemini","models":["gemini-3.8-flash-low","gemini-3.8-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.8 Flash (Medium)","used":14.900000000000002,"model":"gemini-3.8-flash-medium","family":"Gemini","models":["gemini-3.8-flash-medium","gemini-3.8-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"gemini-3.8-flash-tiered","used":14.900000000000002,"model":"gemini-3.8-flash-tiered","family":"Gemini","models":["gemini-3.8-flash-tiered"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"GPT-OSS 120B (Medium)","used":0,"model":"gpt-oss-120b-medium","family":"GPT-OSS","models":["gpt-oss-120b-medium"],"resetsAt":"2026-11-10T16:24:47Z","pool":"Claude & GPT"},{"name":"7 days","pool":"Gemini","used":8.199999999999996,"aside":true,"span":604800,"resetsAt":"2026-11-15T00:00:00Z"},{"name":"5 hours","pool":"Gemini","used":14.900000000000002,"aside":true,"span":18000,"resetsAt":"2026-11-10T12:31:00Z"},{"name":"7 days","pool":"Claude & GPT","used":0,"aside":true,"span":604800,"resetsAt":"2026-11-17T11:30:00Z"},{"name":"5 hours","pool":"Claude & GPT","used":0,"aside":true,"span":18000,"resetsAt":"2026-11-10T16:24:47Z"}]
+1
View File
@@ -554,6 +554,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
amount: 370, limit: 1000, unit: <span class="s">"credits"</span>, <span class="c">// its own count, when it counts amounts</span>
model: <span class="s">"opus"</span>, <span class="c">// counts only models whose ids hold this word</span>
models: [], notModels: [], <span class="c">// or exactly these ids, or all but these</span>
family: <span class="s">"Gemini"</span>, pool: <span class="s">"Gemini"</span>, <span class="c">// a model's family, and the group sharing its allowance: the card shows a pool's own windows (no model, no family) in place of its models'</span>
aside: false, <span class="c">// true: using it up doesn't stop the account</span>
runsOutAt: <span class="s">"2026-10-05T00:00:00Z"</span>, runsOut: 120, <span class="c">// when the soonest credits left are lost, and how many</span>
balance: 6291, <span class="c">// a prepaid wallet: what is left, in unit; no used or limit</span>
+1
View File
@@ -554,6 +554,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
amount: 370, limit: 1000, unit: <span class="s">"credits"</span>, <span class="c">// its own count, when it counts amounts</span>
model: <span class="s">"opus"</span>, <span class="c">// counts only models whose ids hold this word</span>
models: [], notModels: [], <span class="c">// or exactly these ids, or all but these</span>
family: <span class="s">"Gemini"</span>, pool: <span class="s">"Gemini"</span>, <span class="c">// a model's family, and the group sharing its allowance: the card shows a pool's own windows (no model, no family) in place of its models'</span>
aside: false, <span class="c">// true: using it up doesn't stop the account</span>
runsOutAt: <span class="s">"2026-10-05T00:00:00Z"</span>, runsOut: 120, <span class="c">// when the soonest credits left are lost, and how many</span>
balance: 6291, <span class="c">// a prepaid wallet: what is left, in unit; no used or limit</span>
+1
View File
@@ -554,6 +554,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
amount: 370, limit: 1000, unit: <span class="s">"credits"</span>, <span class="c">// 按数量计时,窗口自己的用量</span>
model: <span class="s">"opus"</span>, <span class="c">// 只统计 id 含这个词的模型</span>
models: [], notModels: [], <span class="c">// 或恰好这些 id,或除这些外的全部</span>
family: <span class="s">"Gemini"</span>, pool: <span class="s">"Gemini"</span>, <span class="c">// 模型所属系列,和共用一份额度的分组:卡片显示分组自己的窗口(不带 model 和 family),代替其中各模型的</span>
aside: false, <span class="c">// true:用完也不影响账号使用</span>
runsOutAt: <span class="s">"2026-10-05T00:00:00Z"</span>, runsOut: 120, <span class="c">// 剩余额度中最早作废的一笔何时作废、作废多少</span>
balance: 6291, <span class="c">// 预付钱包:剩余多少(按 unit 计),不写 used 和 limit</span>
+1
View File
@@ -4245,6 +4245,7 @@ throw Object.assign(new Error("Acme refused the sign-in; sign in again"), { sign
amount: 370, limit: 1000, unit: "credits", // its own count, when it counts amounts
model: "opus", // counts only models whose ids hold this word
models: [], notModels: [], // or exactly these ids, or all but these
family: "Gemini", pool: "Gemini", // a model's family, and the group sharing its allowance: the card shows a pool's own windows (no model, no family) in place of its models'
aside: false, // true: using it up doesn't stop the account
runsOutAt: "2026-10-05T00:00:00Z", runsOut: 120, // when the soonest credits left are lost, and how many
balance: 6291, // a prepaid wallet: what is left, in unit; no used or limit