quota: an Antigravity pool with only its week keeps its models' 5-hour windows (#745, werldl517-cyber: PooledWindows drops per-model 5h windows tagged with a pool when the pool's summary has only the 7-day aggregate) — pools() took each of retrieveUserQuotaSummary's buckets on its own, a disabled or unreadable one skipped, and then gave every model of a group that had any bucket left its Pool; PooledWindows put a pool's own windows in place of every model window tagged with that pool once the pool had any window of its own. So a summary with a group's weekly bucket and not its 5-hour one (disabled, or not sent) left the group's "7 days" and dropped the models' 5-hour readings from fetchAvailableModels, the only 5 hours to be had, from the CLI's and TUI's quota lists, /v1/magpie/quotas and quota alerts (dueAlerts reads PooledWindows too). pools() now puts a group's models in its pool only when the group has a 5-hour window, the one that stands in for theirs (the GUI's poolWindows, which keys on the models' pool, then shows them as families beside the pool's week); and PooledWindows drops a model's window only for a pool window of its span (modelSpan, 5 hours, for a model window without one, as fetchAvailableModels' are), so a window tagged by other means isn't lost either. A full summary (5 hours and week) reads as before. TestPooledWindowsPartialAggregateKeepsModelFallback is the reporter's repro plus the cases they listed (both windows, week alone, 5 hours alone, none), and TestAntigravityQuotaPools gains a summary with Gemini's week and its 5 hours disabled, read end to end through quota(): the models' four windows and Gemini · 7 days; both fail on the old code. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried with a real Antigravity account answering a partial summary.

This commit is contained in:
yetone
2026-10-04 12:15:40 +08:00
parent 1594544041
commit c7f693b506
2 changed files with 81 additions and 4 deletions
+24 -4
View File
@@ -1190,7 +1190,7 @@ func (g googleAccount) pools(ctx context.Context, ws []QuotaWindow) []QuotaWindo
if pool == "" {
continue
}
n := 0
n, fiveHour := 0, false
for _, b := range gr.Buckets {
if b.Disabled {
continue
@@ -1220,9 +1220,10 @@ func (g googleAccount) pools(ctx context.Context, ws []QuotaWindow) []QuotaWindo
}
out = append(out, w)
n++
fiveHour = fiveHour || w.Span == modelSpan
}
if n == 0 {
continue
if n == 0 || !fiveHour {
continue // without the group's 5 hours its models' own stand (#745)
}
// a model is in the group its name or description names its
// family in ("Models within this group: Claude Opus, Claude
@@ -1237,13 +1238,30 @@ func (g googleAccount) pools(ctx context.Context, ws []QuotaWindow) []QuotaWindo
return out
}
// modelSpan is the window fetchAvailableModels gives a model of
// Antigravity's, its 5 hours, which its window leaves without a Span.
const modelSpan = 5 * time.Hour
// PooledWindows are ws as a page of text shows them: a pool's own windows,
// named with their pool ("Gemini · 7 days"), in place of the per-model
// windows drawing on it; ws as it is when it has no pool.
// windows drawing on it; ws as it is when it has no pool. A model's window
// goes only for a pool window of its span: one whose pool has only its
// 7 days stays, the 5 hours it reads being the only ones to be had (#745).
func PooledWindows(ws []QuotaWindow) []QuotaWindow {
if !slices.ContainsFunc(ws, func(w QuotaWindow) bool { return w.Pool != "" && w.Model == "" }) {
return ws
}
span := func(w QuotaWindow) time.Duration {
if w.Span == 0 && w.Model != "" {
return modelSpan
}
return w.Span
}
pooled := func(m QuotaWindow) bool {
return slices.ContainsFunc(ws, func(w QuotaWindow) bool {
return w.Pool == m.Pool && w.Model == "" && w.Span == span(m)
})
}
var out []QuotaWindow
for _, w := range ws {
switch {
@@ -1252,6 +1270,8 @@ func PooledWindows(ws []QuotaWindow) []QuotaWindow {
case w.Model == "":
w.Name = w.Pool + " · " + w.Name
out = append(out, w)
case !pooled(w):
out = append(out, w)
}
}
return out
+57
View File
@@ -540,6 +540,63 @@ func TestAntigravityQuotaPools(t *testing.T) {
if len(q.Windows) != 4 || q.Windows[0].Pool != "" || len(PooledWindows(q.Windows)) != 4 {
t.Errorf("without a summary: %+v", q.Windows)
}
// a summary with a group's week and not its 5 hours (#745): the
// group's models aren't put in it, so their 5 hours stay beside its week
f.mu.Lock()
f.summary = `{"groups":[
{"displayName":"Gemini Models","description":"Models within this group: Gemini Flash, Gemini Pro","buckets":[
{"bucketId":"gemini-weekly","window":"weekly","remainingFraction":0.75,"resetTime":"2099-01-07T00:00:00Z"},
{"bucketId":"gemini-5h","window":"5h","remainingFraction":1,"disabled":true}]}]}`
f.mu.Unlock()
q = googleLogins("antigravity")[0].acct.quota(context.Background(), "")
got = nil
for _, w := range PooledWindows(q.Windows) {
got = append(got, w.Name+"|"+w.Pool)
}
if strings.Join(got, ",") != "Claude Opus 4.6 (Thinking)|,Gemini 3 Flash|,Gemini 3.1 Pro (High)|,GPT-OSS 120B (Medium)|,Gemini · 7 days|Gemini" {
t.Errorf("week alone: pooled = %v", got)
}
}
// #745 (werldl517-cyber): a pool's windows stand in for its models' only
// for the spans the pool has; with only its week, a model's 5 hours stay.
func TestPooledWindowsPartialAggregateKeepsModelFallback(t *testing.T) {
ws := []QuotaWindow{
{Name: "Gemini 3 Flash", Model: "gemini-3-flash", Pool: "Gemini", Span: 5 * time.Hour, Used: 40},
{Name: "7 days", Pool: "Gemini", Span: 7 * 24 * time.Hour, Aside: true, Used: 80},
}
got := PooledWindows(ws)
for _, w := range got {
t.Logf("name=%q model=%q pool=%q span=%s used=%.0f aside=%v", w.Name, w.Model, w.Pool, w.Span, w.Used, w.Aside)
}
if len(got) != 2 {
t.Fatalf("got %d windows, want the 5h model fallback plus the 7d pool aggregate", len(got))
}
model := func(id string, span time.Duration) QuotaWindow {
return QuotaWindow{Name: id, Model: id, Pool: "Gemini", Span: span}
}
five := QuotaWindow{Name: "5 hours", Pool: "Gemini", Span: 5 * time.Hour, Aside: true}
week := QuotaWindow{Name: "7 days", Pool: "Gemini", Span: 7 * 24 * time.Hour, Aside: true}
for _, c := range []struct {
name string
ws []QuotaWindow
want string
}{
{"5 hours and week", []QuotaWindow{model("a", 0), model("b", 0), week, five}, "Gemini · 7 days,Gemini · 5 hours"},
{"week alone", []QuotaWindow{model("a", 0), model("b", 5*time.Hour), week}, "a,b,Gemini · 7 days"},
{"5 hours alone", []QuotaWindow{model("a", 0), model("b", 0), five}, "Gemini · 5 hours"},
{"no pool windows", []QuotaWindow{model("a", 0), model("b", 0)}, "a,b"},
} {
var names []string
for _, w := range PooledWindows(c.ws) {
names = append(names, w.Name)
}
if strings.Join(names, ",") != c.want {
t.Errorf("%s: %v, want %s", c.name, names, c.want)
}
}
}
// Antigravity's list is taken as Antigravity gives it (0000FF on Discord: