@@ -54,6 +54,8 @@ const fixture = Effect.fn("AntigravityUsageTest.fixture")(function* (
5454 summaryStatus ?: number ;
5555 tokenStatus ?: number ;
5656 refreshToken ?: string ;
57+ projectId ?: string ;
58+ companionProject ?: string ;
5759 userId ?: string ;
5860 missingToken ?: boolean ;
5961 authMethod ?: "oauth-personal" | "gemini-api-key" ;
@@ -64,14 +66,16 @@ const fixture = Effect.fn("AntigravityUsageTest.fixture")(function* (
6466 const profileDirectory = yield * fs . makeTempDirectoryScoped ( ) ;
6567 yield * fs . makeDirectory ( path . join ( profileDirectory , "antigravity-acp" ) ) ;
6668 const tokenPath = path . join ( profileDirectory , "antigravity-acp" , "acp_token.json" ) ;
69+ const configuredProjectId = options . projectId ?? "project-id" ;
70+ const expectedProjectId = options . companionProject ?? configuredProjectId ;
6771 const writeToken = ( refreshToken : string ) =>
6872 fs . writeFileString (
6973 tokenPath ,
7074 JSON . stringify ( {
7175 client_id : "client-id" ,
7276 client_secret : "client-secret" ,
7377 refresh_token : refreshToken ,
74- project_id : "project-id" ,
78+ project_id : configuredProjectId ,
7579 } ) ,
7680 ) ;
7781 if ( ! options . missingToken ) yield * writeToken ( options . refreshToken ?? "refresh-a" ) ;
@@ -102,7 +106,18 @@ const fixture = Effect.fn("AntigravityUsageTest.fixture")(function* (
102106 : Response . json ( { } , { status : 403 } ) ,
103107 ) ;
104108 }
105- expect ( JSON . parse ( body ) ) . toEqual ( { project : "project-id" } ) ;
109+ if ( request . url . endsWith ( ":loadCodeAssist" ) ) {
110+ expect ( JSON . parse ( body ) ) . toEqual ( { metadata : { ideType : "ANTIGRAVITY" } } ) ;
111+ return HttpClientResponse . fromWeb (
112+ request ,
113+ Response . json (
114+ options . companionProject
115+ ? { cloudaicompanionProject : options . companionProject }
116+ : { } ,
117+ ) ,
118+ ) ;
119+ }
120+ expect ( JSON . parse ( body ) ) . toEqual ( { project : expectedProjectId } ) ;
106121 return HttpClientResponse . fromWeb (
107122 request ,
108123 request . url . endsWith ( ":retrieveUserQuotaSummary" )
@@ -265,4 +280,81 @@ describe("Antigravity subscription limits", () => {
265280 }
266281 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
267282 ) ;
283+
284+ it . effect ( "resolves companion project for consumer accounts and merges weekly groups with model 5h quotas" , ( ) =>
285+ Effect . gen ( function * ( ) {
286+ const { probe } = yield * fixture ( {
287+ projectId : "aicode-consumers" ,
288+ companionProject : "companion-project-123" ,
289+ summary : {
290+ groups : [
291+ {
292+ displayName : "Gemini Models" ,
293+ buckets : [
294+ {
295+ displayName : "Weekly" ,
296+ remainingFraction : 1 ,
297+ resetTime : "2026-10-23T01:41:56Z" ,
298+ } ,
299+ ] ,
300+ } ,
301+ {
302+ displayName : "Claude and GPT Models" ,
303+ buckets : [
304+ {
305+ displayName : "Weekly" ,
306+ description :
307+ "You have hit your weekly limit for Claude and GPT models. Limit refreshes in 2h 30m." ,
308+ } ,
309+ ] ,
310+ } ,
311+ ] ,
312+ } ,
313+ models : {
314+ models : {
315+ "gemini-3-flash" : {
316+ modelProvider : "MODEL_PROVIDER_GOOGLE" ,
317+ quotaInfo : { remainingFraction : 1 , resetTime : "2026-10-17T22:55:26Z" } ,
318+ } ,
319+ "claude-sonnet-4-6" : {
320+ modelProvider : "MODEL_PROVIDER_ANTHROPIC" ,
321+ quotaInfo : { remainingFraction : 1 , resetTime : "2026-10-17T22:57:08Z" } ,
322+ } ,
323+ } ,
324+ } ,
325+ } ) ;
326+ const limits = yield * probe ;
327+ expect ( limits . windows . map ( ( window ) => window . id ) ) . toEqual ( [
328+ "gemini-5h" ,
329+ "gemini-weekly" ,
330+ "3p-5h" ,
331+ "3p-weekly" ,
332+ ] ) ;
333+ const byId = new Map ( limits . windows . map ( ( window ) => [ window . id , window ] ) ) ;
334+ expect ( byId . get ( "gemini-5h" ) ) . toMatchObject ( {
335+ label : "Gemini · 5-hour" ,
336+ kind : "session" ,
337+ usedPercent : 0 ,
338+ windowDurationMins : 300 ,
339+ } ) ;
340+ expect ( byId . get ( "gemini-weekly" ) ) . toMatchObject ( {
341+ label : "Gemini · Weekly" ,
342+ kind : "weekly" ,
343+ usedPercent : 0 ,
344+ windowDurationMins : 10080 ,
345+ } ) ;
346+ expect ( byId . get ( "3p-5h" ) ) . toMatchObject ( {
347+ label : "Claude & GPT (shared) · 5-hour" ,
348+ kind : "session" ,
349+ usedPercent : 0 ,
350+ windowDurationMins : 300 ,
351+ } ) ;
352+ expect ( byId . get ( "3p-weekly" ) ) . toMatchObject ( {
353+ label : "Claude & GPT (shared) · Weekly" ,
354+ kind : "weekly" ,
355+ usedPercent : 100 ,
356+ windowDurationMins : 10080 ,
357+ } ) ;
358+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
359+ ) ;
268360} ) ;
0 commit comments