| author | |
| committer | |
| log | 4baba3b50359743998502f804801c2473b4123fe |
| tree | 0532fc661eb81a5a8706742d54382a3d89c0875c |
| parent | 0eef5d0c76f1765b7a44fa82e965bf5142d64169 |
| signature | Signed by PGP key B5690EEEBB952194 |
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>5 files changed, 48 insertions(+), 23 deletions(-)
apps/server/src/provider/AntigravityProvider.test.ts+7-15| ... | ... | @@ -257,31 +257,23 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { |
| 257 | 257 | ), |
| 258 | 258 | ); |
| 259 | 259 | |
| 260 | it.effect("records explicit sign-in while disabled without starting a health probe", () => | |
| 260 | it.effect("ignores account updates while disabled", () => | |
| 261 | 261 | Effect.scoped( |
| 262 | 262 | Effect.gen(function* () { |
| 263 | 263 | const harness = yield* makeHarness({ enabled: false }); |
| 264 | const signedIn = yield* Stream.toPull( | |
| 265 | harness.provider.snapshot.streamChanges.pipe( | |
| 266 | Stream.filter( | |
| 267 | (snapshot) => | |
| 268 | snapshot.auth.status === "authenticated" && snapshot.slashCommands.length > 0, | |
| 269 | ), | |
| 270 | ), | |
| 271 | ); | |
| 272 | 264 | yield* harness.provider.onSessionStarted(started); |
| 273 | 265 | yield* harness.provider.onAvailableCommands(commands); |
| 274 | const [snapshot] = yield* signedIn; | |
| 266 | yield* harness.provider.onSignedOut; | |
| 267 | const snapshot = yield* harness.provider.snapshot.refresh; | |
| 275 | 268 | expect(snapshot).toMatchObject({ |
| 276 | 269 | enabled: false, |
| 277 | installed: true, | |
| 270 | installed: false, | |
| 278 | 271 | status: "disabled", |
| 279 | auth: { status: "authenticated", type: "oauth-personal" }, | |
| 272 | auth: { status: "unknown" }, | |
| 273 | models: [], | |
| 274 | slashCommands: [], | |
| 280 | 275 | workspaceSnapshots: [], |
| 281 | 276 | }); |
| 282 | expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult)); | |
| 283 | expect(snapshot.slashCommands).toEqual(expectedCommands); | |
| 284 | expect((yield* harness.provider.snapshot.refresh).models).toEqual(snapshot.models); | |
| 285 | 277 | expect(yield* Ref.get(harness.probeCalls)).toBe(0); |
| 286 | 278 | }), |
| 287 | 279 | ), |
apps/server/src/provider/AntigravityProvider.ts+9-3| ... | ... | @@ -132,7 +132,10 @@ interface AntigravityProviderOptions { |
| 132 | 132 | readonly auth?: { readonly type: string; readonly label: string }; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | /** Health uses initialize only. Session callbacks supply account-specific metadata. */ | |
| 135 | /** | |
| 136 | * Health uses initialize only. Session callbacks supply account-specific | |
| 137 | * metadata, which a disabled instance never shows. | |
| 138 | */ | |
| 136 | 139 | export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(function* ( |
| 137 | 140 | settings: AntigravitySettings, |
| 138 | 141 | options: AntigravityProviderOptions, |
| ... | ... | @@ -271,6 +274,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func |
| 271 | 274 | started: AcpSessionRuntime.AcpSessionRuntimeStartResult, |
| 272 | 275 | cwd?: string, |
| 273 | 276 | ) { |
| 277 | if (!settings.enabled) return; | |
| 274 | 278 | const before = yield* SubscriptionRef.get(metadata); |
| 275 | 279 | const supportsTextGeneration = yield* options.supportsTextGeneration; |
| 276 | 280 | const usageLimits = |
| ... | ... | @@ -293,7 +297,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func |
| 293 | 297 | draft: { |
| 294 | 298 | ...draft, |
| 295 | 299 | installed: true, |
| 296 | status: settings.enabled ? "ready" : "disabled", | |
| 300 | status: "ready", | |
| 297 | 301 | version: started.initializeResult.agentInfo?.version || draft.version, |
| 298 | 302 | auth: { |
| 299 | 303 | status: "authenticated", |
| ... | ... | @@ -339,6 +343,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func |
| 339 | 343 | commands: ReadonlyArray<EffectAcpSchema.AvailableCommand>, |
| 340 | 344 | cwd?: string, |
| 341 | 345 | ) { |
| 346 | if (!settings.enabled) return; | |
| 342 | 347 | const slashCommands = nativeCommands(commands); |
| 343 | 348 | const updatedAt = DateTime.formatIso(yield* DateTime.now); |
| 344 | 349 | yield* SubscriptionRef.update(metadata, (state) => { |
| ... | ... | @@ -371,6 +376,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func |
| 371 | 376 | |
| 372 | 377 | const clearAccountMetadata = Effect.fn("AntigravityProvider.clearAccountMetadata")(function* () { |
| 373 | 378 | if (options.clearUsage) yield* options.clearUsage; |
| 379 | if (!settings.enabled) return; | |
| 374 | 380 | const updatedAt = DateTime.formatIso(yield* DateTime.now); |
| 375 | 381 | yield* SubscriptionRef.update( |
| 376 | 382 | metadata, |
| ... | ... | @@ -380,7 +386,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func |
| 380 | 386 | draft: { |
| 381 | 387 | ...state.draft, |
| 382 | 388 | auth: { status: "unauthenticated" }, |
| 383 | status: settings.enabled ? "warning" : "disabled", | |
| 389 | status: "warning", | |
| 384 | 390 | message: SIGN_IN_MESSAGE, |
| 385 | 391 | checkedAt: updatedAt, |
| 386 | 392 | models: [], |
apps/server/src/provider/Drivers/AntigravityDriver.test.ts+4-4| ... | ... | @@ -187,7 +187,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( |
| 187 | 187 | const instance = yield* AntigravityDriver.create({ |
| 188 | 188 | instanceId, |
| 189 | 189 | displayName: "Google test account", |
| 190 | enabled: options.enabled ?? false, | |
| 190 | enabled: options.enabled ?? true, | |
| 191 | 191 | config: { ...AntigravityDriver.defaultConfig(), ...options.config }, |
| 192 | 192 | environment: [ |
| 193 | 193 | { name: "PATH", value: instancePath }, |
| ... | ... | @@ -292,7 +292,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => { |
| 292 | 292 | |
| 293 | 293 | it.effect.skipIf(windowsHost)("does not launch a process for a disabled instance", () => |
| 294 | 294 | Effect.gen(function* () { |
| 295 | const h = yield* makeHarness(); | |
| 295 | const h = yield* makeHarness({ enabled: false }); | |
| 296 | 296 | const snapshot = yield* h.instance.snapshot.refresh; |
| 297 | 297 | expect(snapshot.status).toBe("disabled"); |
| 298 | 298 | expect(h.acquisitions).toEqual([]); |
| ... | ... | @@ -322,13 +322,13 @@ it.layer(layerTest)("AntigravityDriver", (it) => { |
| 322 | 322 | ); |
| 323 | 323 | |
| 324 | 324 | it.effect.skipIf(windowsHost)( |
| 325 | "refreshes a disabled instance through the selected executable and personal Google ACP", | |
| 325 | "refreshes through the selected executable and personal Google ACP", | |
| 326 | 326 | () => |
| 327 | 327 | Effect.gen(function* () { |
| 328 | 328 | const h = yield* makeHarness(); |
| 329 | 329 | yield* h.refresh(); |
| 330 | 330 | const snapshot = yield* h.instance.snapshot.getSnapshot; |
| 331 | expect(snapshot.status).toBe("disabled"); | |
| 331 | expect(snapshot.status).toBe("ready"); | |
| 332 | 332 | expect(snapshot.auth.status).toBe("authenticated"); |
| 333 | 333 | expect(snapshot.models.map((model) => model.slug)).toEqual([ |
| 334 | 334 | "gemini-test-low", |
packages/provider-core/src/server/managedProvider.test.ts+25| ... | ... | @@ -183,6 +183,31 @@ describe("makeManagedServerProvider", () => { |
| 183 | 183 | ).pipe(Effect.provide(layerAlwaysRunTest)), |
| 184 | 184 | ); |
| 185 | 185 | |
| 186 | it.effect("does not enrich a disabled provider's snapshot", () => | |
| 187 | Effect.scoped( | |
| 188 | Effect.gen(function* () { | |
| 189 | let enrichmentCalls = 0; | |
| 190 | const provider = yield* makeManagedServerProvider<TestSettings>({ | |
| 191 | resolveMaintenance: () => Effect.succeed(maintenanceCapabilities), | |
| 192 | getSettings: Effect.succeed({ enabled: false }), | |
| 193 | streamSettings: Stream.empty, | |
| 194 | haveSettingsChanged: (previous, next) => previous.enabled !== next.enabled, | |
| 195 | refreshOnInterval: false, | |
| 196 | initialSnapshot: () => Effect.succeed({ ...initialSnapshot, enabled: false }), | |
| 197 | checkProvider: Effect.succeed({ ...refreshedSnapshot, enabled: false }), | |
| 198 | enrichSnapshot: () => { | |
| 199 | enrichmentCalls += 1; | |
| 200 | return Effect.void; | |
| 201 | }, | |
| 202 | }); | |
| 203 | ||
| 204 | yield* provider.refresh; | |
| 205 | ||
| 206 | assert.strictEqual(enrichmentCalls, 0); | |
| 207 | }), | |
| 208 | ).pipe(Effect.provide(layerAlwaysRunTest)), | |
| 209 | ); | |
| 210 | ||
| 186 | 211 | it.effect("skips periodic provider refreshes without foreground provider-status demand", () => |
| 187 | 212 | Effect.scoped( |
| 188 | 213 | Effect.gen(function* () { |
packages/provider-core/src/server/managedProvider.ts+3-1| ... | ... | @@ -106,7 +106,9 @@ export const makeManagedServerProvider = Effect.fn("makeManagedServerProvider")( |
| 106 | 106 | yield* Fiber.interrupt(previousFiber).pipe(Effect.ignore); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | if (!input.enrichSnapshot) { | |
| 109 | // Enrichment resolves binaries and package-manager state, which a disabled | |
| 110 | // provider has no use for. | |
| 111 | if (!input.enrichSnapshot || !snapshot.enabled) { | |
| 110 | 112 | return; |
| 111 | 113 | } |
| 112 | 114 |