Skip to content

Commit 8c53aa7

Browse files
fix(server): Antigravity usage shows the Gemini quota when the summary omits it
Both quota-summary endpoints can answer with only the Claude/GPT group while the account's Gemini models still carry a quota in fetchAvailableModels. The model list was read only when the summary was empty, so the Gemini quota never appeared. Read it whenever no summary window reports Gemini and add only its Gemini windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4fef307 commit 8c53aa7

2 files changed

Lines changed: 56 additions & 3 deletions

File tree

‎apps/server/src/provider/antigravityUsageLimits.test.ts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,52 @@ describe("Antigravity subscription limits", () => {
188188
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
189189
);
190190

191+
it.effect("adds Gemini model quotas when no endpoint's summary reports Gemini", () =>
192+
Effect.gen(function* () {
193+
const { probe, requests } = yield* fixture({
194+
// Both endpoints have answered with only the Claude/GPT group while
195+
// the account's Gemini models still carried a quota.
196+
summary: {
197+
groups: [
198+
{
199+
displayName: "Claude and GPT models",
200+
buckets: [
201+
{ bucketId: "3p-weekly", window: "weekly", remainingFraction: 1 },
202+
{ bucketId: "3p-5h", window: "5h", remainingFraction: 1 },
203+
],
204+
},
205+
],
206+
},
207+
models: {
208+
models: {
209+
"gemini-a": {
210+
modelProvider: "MODEL_PROVIDER_GOOGLE",
211+
quotaInfo: { remainingFraction: 0.99, resetTime: "2026-10-24T04:29:07Z" },
212+
},
213+
"claude-a": {
214+
modelProvider: "MODEL_PROVIDER_ANTHROPIC",
215+
quotaInfo: { remainingFraction: 1, resetTime: "2026-10-24T06:50:54Z" },
216+
},
217+
},
218+
},
219+
});
220+
const limits = yield* probe;
221+
expect(limits.windows.map((window) => window.id).toSorted()).toEqual([
222+
"3p-5h",
223+
"3p-weekly",
224+
"gemini-quota",
225+
]);
226+
expect(limits.windows.find((window) => window.id === "gemini-quota")).toMatchObject({
227+
label: "Gemini · Reported quota",
228+
kind: "other",
229+
resetsAt: "2026-10-24T04:29:07.000Z",
230+
});
231+
expect(
232+
requests.filter((request) => request.url.endsWith(":fetchAvailableModels")),
233+
).toHaveLength(2);
234+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
235+
);
236+
191237
it.effect("keeps one endpoint's quotas when the other fails", () =>
192238
Effect.gen(function* () {
193239
const { probe } = yield* fixture({

‎apps/server/src/provider/antigravityUsageLimits.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function summaryWindows(summary: typeof Summary.Type) {
124124
return [...windows.values()];
125125
}
126126

127-
/** Older accounts expose model quotas without a window length. Do not invent a reset cadence. */
127+
/** Model quotas carry no window length. Do not invent a reset cadence. */
128128
function modelWindows(models: typeof Models.Type) {
129129
const windows = new Map<string, ServerProviderUsageWindow>();
130130
for (const [modelId, model] of Object.entries(models.models)) {
@@ -282,11 +282,18 @@ export const makeAntigravityUsageProbe = Effect.fn("makeAntigravityUsageProbe")(
282282
const summary = yield* fetchWindows("retrieveUserQuotaSummary", (response) =>
283283
decodeSummary(response).pipe(Effect.map(summaryWindows)),
284284
);
285-
const windows = summary.length
286-
? summary
285+
// Every endpoint's summary has also answered with only the Claude/GPT
286+
// group while the Gemini models still carried a quota, so read Gemini from
287+
// the model list whenever no summary reports it.
288+
const reportsGemini = summary.some((window) => window.id.startsWith("gemini-"));
289+
const models = reportsGemini
290+
? []
287291
: yield* fetchWindows("fetchAvailableModels", (response) =>
288292
decodeModels(response).pipe(Effect.map(modelWindows)),
289293
);
294+
const windows = summary.length
295+
? [...summary, ...models.filter((window) => window.id.startsWith("gemini-"))]
296+
: models;
290297
if (windows.length === 0) {
291298
return makeUnavailableUsageLimits({
292299
checkedAt,

0 commit comments

Comments
 (0)