@@ -270,47 +270,51 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
270270 const before = yield * SubscriptionRef . get ( metadata ) ;
271271 const supportsTextGeneration = yield * options . supportsTextGeneration ;
272272 const updatedAt = DateTime . formatIso ( yield * DateTime . now ) ;
273- yield * SubscriptionRef . update ( metadata , ( state ) => {
273+ const updatedRevision = yield * SubscriptionRef . modify ( metadata , ( state ) => {
274274 if ( state . authRevision !== before . authRevision ) {
275- return state ;
275+ return [ Option . none < number > ( ) , state ] as const ;
276276 }
277+ const newRevision = state . authRevision + 1 ;
277278 const { message : _previousMessage , ...draft } = state . draft ;
278279 const workspaces = draft . workspaceSnapshots ?? [ ] ;
279280 const workspace = cwd ? workspaces . find ( ( entry ) => entry . cwd === cwd ) : undefined ;
280- return {
281- authRevision : state . authRevision + 1 ,
282- draft : {
283- ...draft ,
284- installed : true ,
285- status : settings . enabled ? "ready" : "disabled" ,
286- version : started . initializeResult . agentInfo ?. version || draft . version ,
287- auth : {
288- status : "authenticated" ,
289- type : options . auth ?. type ?? "oauth-personal" ,
290- label : options . auth ?. label ?? "Google account" ,
281+ return [
282+ Option . some ( newRevision ) ,
283+ {
284+ authRevision : newRevision ,
285+ draft : {
286+ ...draft ,
287+ installed : true ,
288+ status : settings . enabled ? "ready" : "disabled" ,
289+ version : started . initializeResult . agentInfo ?. version || draft . version ,
290+ auth : {
291+ status : "authenticated" ,
292+ type : options . auth ?. type ?? "oauth-personal" ,
293+ label : options . auth ?. label ?? "Google account" ,
294+ } ,
295+ checkedAt : updatedAt ,
296+ models : buildAntigravityModelsFromSession ( started . sessionSetupResult ) ,
297+ supportsTextGeneration,
298+ ...( cwd
299+ ? {
300+ workspaceSnapshots : [
301+ ...workspaces . filter ( ( entry ) => entry . cwd !== cwd ) ,
302+ {
303+ cwd,
304+ checkedAt : updatedAt ,
305+ slashCommands : workspace ?. slashCommands ?? draft . slashCommands ,
306+ skills : workspace ?. skills ?? discoveredSkills . get ( cwd ) ?? [ ] ,
307+ } ,
308+ ] . slice ( - MAX_WORKSPACE_SNAPSHOTS ) ,
309+ }
310+ : { } ) ,
291311 } ,
292- checkedAt : updatedAt ,
293- models : buildAntigravityModelsFromSession ( started . sessionSetupResult ) ,
294- supportsTextGeneration,
295- ...( cwd
296- ? {
297- workspaceSnapshots : [
298- ...workspaces . filter ( ( entry ) => entry . cwd !== cwd ) ,
299- {
300- cwd,
301- checkedAt : updatedAt ,
302- slashCommands : workspace ?. slashCommands ?? draft . slashCommands ,
303- skills : workspace ?. skills ?? discoveredSkills . get ( cwd ) ?? [ ] ,
304- } ,
305- ] . slice ( - MAX_WORKSPACE_SNAPSHOTS ) ,
306- }
307- : { } ) ,
308- } ,
309- } satisfies AntigravityProviderState ;
312+ } satisfies AntigravityProviderState ,
313+ ] as const ;
310314 } ) ;
311315
312- const revision = ( yield * SubscriptionRef . get ( metadata ) ) . authRevision ;
313- if ( options . usageLimits ) {
316+ if ( Option . isSome ( updatedRevision ) && options . usageLimits ) {
317+ const revision = updatedRevision . value ;
314318 yield * options . usageLimits . pipe (
315319 Effect . catchCause ( ( ) => Effect . succeed ( undefined ) ) ,
316320 Effect . flatMap ( ( usageLimits ) =>
0 commit comments