Open History to see the last commit
1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { describe, expect, it } from "@effect/vitest";
3import {
4 ANTIGRAVITY_DEFAULT_MODEL,
5 AntigravitySettings,
6 ProviderDriverKind,
7 ProviderInstanceId,
8 ProviderSetupError,
9 type ServerProviderUsageLimits,
10} from "@t3tools/contracts";
11import * as Deferred from "effect/Deferred";
12import * as Effect from "effect/Effect";
13import * as Fiber from "effect/Fiber";
14import * as Layer from "effect/Layer";
15import * as Ref from "effect/Ref";
16import * as Schema from "effect/Schema";
17import * as Stream from "effect/Stream";
18import * as EffectAcpErrors from "effect-acp/errors";
19import type * as EffectAcpSchema from "effect-acp/compat";
20
21import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
22import * as ServerConfig from "../config.ts";
23import * as ServerSettings from "../serverSettings.ts";
24import * as ProviderHostLive from "./ProviderHostLive.ts";
25import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
26import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
27import {
28 buildAntigravityModelsFromSession,
29 makeAntigravityProvider,
30} from "./AntigravityProvider.ts";
31
32const decodeSettings = Schema.decodeSync(AntigravitySettings);
33const instanceId = ProviderInstanceId.make("antigravity-test");
34const driver = ProviderDriverKind.make("antigravity");
35
36const initializeResult = {
37 protocolVersion: 1,
38 agentCapabilities: {
39 loadSession: true,
40 promptCapabilities: { image: true, audio: true, embeddedContext: true },
41 sessionCapabilities: { list: {}, resume: {} },
42 },
43 authMethods: [{ id: "oauth-personal", name: "Log in with Google" }],
44 agentInfo: {
45 name: "antigravity-acp",
46 title: "Google Antigravity",
47 version: "agy_acp_server_20260818_01_RC01",
48 },
49} satisfies EffectAcpSchema.InitializeResponse;
50
51const modelOptions = [
52 { value: "gemini-3.8-flash-high", name: "Gemini 3.8 Flash (High)" },
53 { value: "gemini-3.8-flash-medium", name: "Gemini 3.8 Flash (Medium)" },
54 { value: "gemini-3.8-flash-low", name: "Gemini 3.8 Flash (Low)" },
55 { value: "gemini-3.7-flash-high", name: "Gemini 3.7 Flash (High)" },
56 { value: "gemini-3.7-flash-medium", name: "Gemini 3.7 Flash (Medium)" },
57 { value: "gemini-3.7-flash-low", name: "Gemini 3.7 Flash (Low)" },
58 { value: "gemini-3.6-flash-high", name: "Gemini 3.6 Flash (High)" },
59 { value: "gemini-3.6-flash-medium", name: "Gemini 3.6 Flash (Medium)" },
60 { value: "gemini-3.6-flash-low", name: "Gemini 3.6 Flash (Low)" },
61 { value: "gemini-pro-agent", name: "Gemini 3.1 Pro (High)" },
62 { value: "gemini-3.1-pro-low", name: "Gemini 3.1 Pro (Low)" },
63];
64
65const modelConfig = {
66 id: "model",
67 name: "Model",
68 category: "model",
69 type: "select",
70 currentValue: "gemini-3.7-flash-high",
71 options: modelOptions,
72} satisfies EffectAcpSchema.SessionConfigOption;
73
74const sessionSetupResult = {
75 sessionId: "session-1",
76 models: {
77 currentModelId: "gemini-3.7-flash-high",
78 availableModels: modelOptions.map((option) => ({ modelId: option.value, name: option.name })),
79 },
80 configOptions: [
81 modelConfig,
82 {
83 id: "mode",
84 name: "Session Mode",
85 category: "mode",
86 type: "select",
87 currentValue: "default",
88 options: [
89 { value: "default", name: "Default" },
90 { value: "yolo", name: "YOLO" },
91 ],
92 },
93 ],
94} satisfies EffectAcpSchema.NewSessionResponse;
95
96const started = {
97 sessionId: "session-1",
98 initializeResult,
99 sessionSetupResult,
100 modelConfigId: "model",
101} satisfies AcpSessionRuntime.AcpSessionRuntimeStartResult;
102
103const commands = [
104 { name: "plan", description: "Create a plan", input: { type: "text", hint: "What to plan" } },
105 { name: "logout", description: "Sign out of Google" },
106] satisfies ReadonlyArray<EffectAcpSchema.AvailableCommand>;
107
108const expectedCommands = [
109 { name: "plan", description: "Create a plan", input: { hint: "What to plan" } },
110 { name: "logout", description: "Sign out of Google" },
111];
112
113const layerTest = ProviderHostLive.layer.pipe(
114 Layer.provideMerge(
115 Layer.mock(BackgroundPolicy.BackgroundPolicy)({
116 shouldRunScopeWork: () => Effect.succeed(false),
117 }),
118 ),
119 Layer.provideMerge(ServerSettings.layerTest()),
120 Layer.provideMerge(ServerSecretStore.layer),
121 Layer.provide(
122 ServerConfig.layerTest(process.cwd(), { prefix: "t3-antigravity-provider-test-" }).pipe(
123 Layer.provideMerge(NodeServices.layer),
124 ),
125 ),
126);
127
128type ProbeError = EffectAcpErrors.AcpError | ProviderSetupError;
129
130const makeHarness = Effect.fn("makeAntigravityProviderHarness")(function* (
131 options: {
132 readonly enabled?: boolean;
133 readonly safe?: boolean;
134 readonly probeUsage?: Effect.Effect<ServerProviderUsageLimits>;
135 } = {},
136) {
137 const initialProbe = yield* Deferred.make<EffectAcpSchema.InitializeResponse, ProbeError>();
138 const probeCalls = yield* Ref.make(0);
139 const safetyCalls = yield* Ref.make(0);
140 const probe = yield* Ref.make<Effect.Effect<EffectAcpSchema.InitializeResponse, ProbeError>>(
141 Deferred.await(initialProbe),
142 );
143 const safety = yield* Ref.make<Effect.Effect<boolean>>(Effect.succeed(options.safe ?? true));
144 const provider = yield* makeAntigravityProvider(
145 decodeSettings({ enabled: options.enabled ?? true, customModels: ["do-not-seed-me"] }),
146 {
147 stampIdentity: (snapshot) => Effect.succeed({ ...snapshot, instanceId, driver }),
148 ...(options.probeUsage ? { probeUsage: options.probeUsage } : {}),
149 probe: Ref.update(probeCalls, (count) => count + 1).pipe(
150 Effect.andThen(Ref.get(probe)),
151 Effect.flatten,
152 ),
153 supportsTextGeneration: Ref.update(safetyCalls, (count) => count + 1).pipe(
154 Effect.andThen(Ref.get(safety)),
155 Effect.flatten,
156 ),
157 },
158 );
159 const initialUpdate = yield* Stream.toPull(
160 provider.snapshot.streamChanges.pipe(
161 Stream.filter((snapshot) => snapshot.installed || snapshot.status === "error"),
162 ),
163 );
164 const initialize = Deferred.succeed(initialProbe, initializeResult).pipe(
165 Effect.andThen(initialUpdate),
166 Effect.asVoid,
167 );
168 return {
169 provider,
170 probe,
171 probeCalls,
172 safety,
173 safetyCalls,
174 initialProbe,
175 initialUpdate,
176 initialize,
177 };
178});
179
180describe("Antigravity model catalog", () => {
181 it("uses legacy session models only when model config is absent", () => {
182 const fromLegacy = buildAntigravityModelsFromSession({
183 models: sessionSetupResult.models,
184 });
185 expect(fromLegacy).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
186 expect(
187 buildAntigravityModelsFromSession({
188 ...sessionSetupResult,
189 configOptions: [{ ...modelConfig, options: [] }],
190 }),
191 ).toEqual([]);
192 });
193
194 it("flattens native option groups without combining distinct model IDs", () => {
195 const models = buildAntigravityModelsFromSession({
196 configOptions: [
197 {
198 ...modelConfig,
199 currentValue: "gemini-pro-agent",
200 options: [
201 { groupId: "Flash", name: "Flash", options: [modelOptions[3]!, modelOptions[4]!] },
202 { groupId: "Pro", name: "Pro", options: [modelOptions[9]!, modelOptions[3]!] },
203 ],
204 },
205 ],
206 });
207 expect(models.map((model) => model.slug)).toEqual([
208 "gemini-3.7-flash-high",
209 "gemini-3.7-flash-medium",
210 "gemini-pro-agent",
211 ]);
212 expect(models.find((model) => model.isDefault)?.slug).toBe("gemini-pro-agent");
213 expect(models.find((model) => model.aliases?.includes(ANTIGRAVITY_DEFAULT_MODEL))?.slug).toBe(
214 "gemini-pro-agent",
215 );
216 });
217});
218
219it.layer(layerTest)("Antigravity provider snapshots", (it) => {
220 it.effect("does not probe or run helper safety checks while disabled", () =>
221 Effect.scoped(
222 Effect.gen(function* () {
223 const harness = yield* makeHarness({ enabled: false });
224 const snapshot = yield* harness.provider.snapshot.refresh;
225 expect(snapshot).toMatchObject({
226 enabled: false,
227 installed: false,
228 status: "disabled",
229 auth: { status: "unknown" },
230 models: [],
231 setup: { canAuthenticate: true, canInstall: true },
232 showInteractionModeToggle: false,
233 supportsConversationRollback: false,
234 supportsTextGeneration: false,
235 });
236 expect(yield* Ref.get(harness.probeCalls)).toBe(0);
237 expect(yield* Ref.get(harness.safetyCalls)).toBe(0);
238 }),
239 ),
240 );
241
242 it.effect("treats initialize as installation proof, not account or model discovery", () =>
243 Effect.scoped(
244 Effect.gen(function* () {
245 const harness = yield* makeHarness();
246 expect(yield* harness.provider.snapshot.getSnapshot).toMatchObject({
247 installed: false,
248 status: "warning",
249 auth: { status: "unknown" },
250 models: [],
251 });
252 yield* harness.initialize;
253 const snapshot = yield* harness.provider.snapshot.getSnapshot;
254 expect(snapshot).toMatchObject({
255 installed: true,
256 status: "warning",
257 version: "agy_acp_server_20260818_01_RC01",
258 auth: { status: "unknown" },
259 models: [],
260 });
261 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
262 }),
263 ),
264 );
265
266 it.effect("publishes session metadata and native commands without another health probe", () =>
267 Effect.scoped(
268 Effect.gen(function* () {
269 const harness = yield* makeHarness();
270 yield* harness.initialize;
271 const nextReady = yield* Stream.toPull(
272 harness.provider.snapshot.streamChanges.pipe(
273 Stream.filter(
274 (snapshot) =>
275 snapshot.auth.status === "authenticated" && snapshot.slashCommands.length > 0,
276 ),
277 ),
278 );
279 yield* harness.provider.onSessionStarted(started, "/workspace");
280 yield* harness.provider.onAvailableCommands(commands, "/workspace");
281 const [snapshot] = yield* nextReady;
282 expect(snapshot).toMatchObject({
283 status: "ready",
284 auth: { status: "authenticated", type: "oauth-personal" },
285 supportsTextGeneration: true,
286 });
287 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
288 expect(snapshot.slashCommands).toEqual(expectedCommands);
289 expect((yield* harness.provider.snapshotForCwd("/workspace")).slashCommands).toEqual(
290 expectedCommands,
291 );
292 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
293 }),
294 ),
295 );
296
297 it.effect("clears all account metadata on sign-out and authentication failure", () =>
298 Effect.scoped(
299 Effect.gen(function* () {
300 const harness = yield* makeHarness();
301 yield* harness.initialize;
302 for (const clear of [harness.provider.onSignedOut, harness.provider.onAuthRequired]) {
303 yield* harness.provider.onSessionStarted(started, "/workspace");
304 yield* harness.provider.onAvailableCommands(commands, "/workspace");
305 yield* clear;
306 expect(yield* harness.provider.snapshot.getSnapshot).toMatchObject({
307 installed: true,
308 status: "warning",
309 auth: { status: "unauthenticated" },
310 models: [],
311 slashCommands: [],
312 skills: [],
313 workspaceSnapshots: [],
314 supportsTextGeneration: false,
315 });
316 yield* harness.provider.onAvailableCommands(commands, "/workspace");
317 yield* harness.provider.onConfigOptionsUpdated([modelConfig]);
318 expect((yield* harness.provider.snapshotForCwd("/workspace")).slashCommands).toEqual([]);
319 expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual([]);
320 }
321 const refreshed = yield* harness.provider.snapshot.refresh;
322 expect(refreshed.auth.status).toBe("unauthenticated");
323 expect(refreshed.supportsTextGeneration).toBe(false);
324 }),
325 ),
326 );
327
328 it.effect("replaces live model choices and accepts an empty catalog", () =>
329 Effect.scoped(
330 Effect.gen(function* () {
331 const harness = yield* makeHarness();
332 yield* harness.initialize;
333 yield* harness.provider.onSessionStarted(started, "/workspace");
334 yield* harness.provider.onAvailableCommands(commands, "/workspace");
335 const before = yield* harness.provider.snapshot.getSnapshot;
336 const configOptions = [
337 {
338 ...modelConfig,
339 currentValue: "gemini-3.8-flash-high",
340 options: modelOptions.slice(0, 3),
341 },
342 ];
343 const nextSnapshot = yield* Stream.toPull(
344 harness.provider.snapshot.streamChanges.pipe(
345 Stream.filter((snapshot) => snapshot.models.length === 3),
346 ),
347 );
348 yield* harness.provider.onConfigOptionsUpdated(configOptions);
349 expect((yield* nextSnapshot)[0]).toMatchObject({
350 models: buildAntigravityModelsFromSession({ configOptions }),
351 auth: before.auth,
352 workspaceSnapshots: before.workspaceSnapshots,
353 slashCommands: expectedCommands,
354 });
355 yield* harness.provider.onConfigOptionsUpdated([]);
356 expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual([]);
357 }),
358 ),
359 );
360
361 it.effect("does not guess a version before a custom launcher's first handshake", () =>
362 Effect.scoped(
363 Effect.gen(function* () {
364 const harness = yield* makeHarness();
365 yield* Deferred.succeed(harness.initialProbe, {
366 ...initializeResult,
367 agentInfo: { ...initializeResult.agentInfo, version: "unknown" },
368 });
369 yield* harness.initialUpdate;
370 expect((yield* harness.provider.snapshot.getSnapshot).version).toBeNull();
371 }),
372 ),
373 );
374
375 it.effect("does not replace a handshake version with an unknown custom-launcher probe", () =>
376 Effect.scoped(
377 Effect.gen(function* () {
378 const harness = yield* makeHarness();
379 yield* harness.initialize;
380 yield* harness.provider.onSessionStarted({
381 ...started,
382 initializeResult: {
383 ...initializeResult,
384 agentInfo: { ...initializeResult.agentInfo, version: "1.4.0" },
385 },
386 });
387 yield* Ref.set(
388 harness.probe,
389 Effect.succeed({
390 ...initializeResult,
391 agentInfo: { ...initializeResult.agentInfo, version: "unknown" },
392 }),
393 );
394 expect((yield* harness.provider.snapshot.refresh).version).toBe("1.4.0");
395 }),
396 ),
397 );
398
399 it.effect("replaces one account's catalog instead of combining accounts", () =>
400 Effect.scoped(
401 Effect.gen(function* () {
402 const harness = yield* makeHarness();
403 yield* harness.initialize;
404 yield* harness.provider.onSessionStarted(started);
405 yield* harness.provider.onSignedOut;
406 yield* harness.provider.onSessionStarted({
407 ...started,
408 sessionSetupResult: {
409 sessionId: "new-account-session",
410 configOptions: [
411 { ...modelConfig, currentValue: "gemini-pro-agent", options: [modelOptions[9]!] },
412 ],
413 },
414 });
415 expect(
416 (yield* harness.provider.snapshot.getSnapshot).models.map((model) => model.slug),
417 ).toEqual(["gemini-pro-agent"]);
418 }),
419 ),
420 );
421
422 it.effect("retains known account metadata when a local health check fails", () =>
423 Effect.scoped(
424 Effect.gen(function* () {
425 const harness = yield* makeHarness();
426 yield* harness.initialize;
427 yield* harness.provider.onSessionStarted(started, "/workspace");
428 yield* harness.provider.onAvailableCommands(commands, "/workspace");
429 yield* Ref.set(
430 harness.probe,
431 Effect.fail(EffectAcpErrors.AcpRequestError.internalError("probe failed")),
432 );
433 const snapshot = yield* harness.provider.snapshot.refresh;
434 expect(snapshot).toMatchObject({
435 installed: true,
436 status: "error",
437 auth: { status: "authenticated" },
438 });
439 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
440 expect(snapshot.slashCommands).toEqual(expectedCommands);
441 expect(snapshot.workspaceSnapshots?.[0]?.cwd).toBe("/workspace");
442 }),
443 ),
444 );
445
446 it.effect("distinguishes missing executables from a failed installed executable", () =>
447 Effect.scoped(
448 Effect.gen(function* () {
449 const harness = yield* makeHarness();
450 yield* harness.initialize;
451 const failures = [
452 {
453 error: new EffectAcpErrors.AcpSpawnError({ cause: { code: "ENOENT" } }),
454 installed: false,
455 },
456 {
457 error: new EffectAcpErrors.AcpSpawnError({ cause: { code: "EACCES" } }),
458 installed: true,
459 },
460 {
461 error: new ProviderSetupError({
462 instanceId,
463 operation: "resolve",
464 detail: "Antigravity is not installed.",
465 }),
466 installed: false,
467 },
468 ];
469 for (const { error, installed } of failures) {
470 yield* harness.provider.onSessionStarted(started, "/workspace");
471 yield* harness.provider.onAvailableCommands(commands, "/workspace");
472 yield* Ref.set(harness.probe, Effect.fail(error));
473 const snapshot = yield* harness.provider.snapshot.refresh;
474 expect(snapshot).toMatchObject({
475 installed,
476 status: "error",
477 auth: { status: "authenticated" },
478 });
479 expect(snapshot.models).toHaveLength(installed ? 11 : 0);
480 expect(snapshot.slashCommands).toHaveLength(installed ? 2 : 0);
481 expect(snapshot.workspaceSnapshots).toHaveLength(installed ? 1 : 0);
482 expect(snapshot.supportsTextGeneration).toBe(installed);
483 }
484 }),
485 ),
486 );
487
488 it.effect("does not let an old health result restore a signed-out account", () =>
489 Effect.scoped(
490 Effect.gen(function* () {
491 const harness = yield* makeHarness();
492 yield* harness.initialize;
493 yield* harness.provider.onSessionStarted(started);
494 const releaseProbe = yield* Deferred.make<EffectAcpSchema.InitializeResponse>();
495 const probeEntered = yield* Deferred.make<void>();
496 yield* Ref.set(
497 harness.probe,
498 Deferred.succeed(probeEntered, undefined).pipe(
499 Effect.andThen(Deferred.await(releaseProbe)),
500 ),
501 );
502 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
503 yield* Deferred.await(probeEntered);
504 yield* harness.provider.onSignedOut;
505 yield* Deferred.succeed(releaseProbe, initializeResult);
506 const snapshot = yield* Fiber.join(refresh);
507 expect(snapshot).toMatchObject({
508 auth: { status: "unauthenticated" },
509 models: [],
510 supportsTextGeneration: false,
511 });
512 }),
513 ),
514 );
515
516 it.effect("exposes helper support only when the supplied safety check allows it", () =>
517 Effect.scoped(
518 Effect.gen(function* () {
519 const harness = yield* makeHarness({ safe: false });
520 yield* harness.initialize;
521 yield* harness.provider.onSessionStarted(started);
522 expect((yield* harness.provider.snapshot.getSnapshot).supportsTextGeneration).toBe(false);
523 yield* Ref.set(harness.safety, Effect.succeed(true));
524 yield* harness.provider.snapshot.refresh;
525 expect((yield* harness.provider.snapshot.getSnapshot).supportsTextGeneration).toBe(true);
526 }),
527 ),
528 );
529
530 it.effect("keeps discovered workspace skills through session and command updates", () =>
531 Effect.scoped(
532 Effect.gen(function* () {
533 const harness = yield* makeHarness();
534 yield* harness.initialize;
535 const skills = [
536 {
537 name: "deploy",
538 description: "Ship it",
539 path: "/workspace/.agent/skills/deploy",
540 enabled: true,
541 },
542 ];
543 const discovered = yield* harness.provider.snapshotForCwd("/workspace", skills);
544 expect(discovered.skills).toEqual(skills);
545 yield* harness.provider.onSessionStarted(started, "/workspace");
546 yield* harness.provider.onAvailableCommands(commands, "/workspace");
547 const after = yield* harness.provider.snapshot.getSnapshot;
548 expect(
549 after.workspaceSnapshots?.find((entry) => entry.cwd === "/workspace")?.skills,
550 ).toEqual(skills);
551 expect((yield* harness.provider.snapshotForCwd("/workspace")).skills).toEqual(skills);
552
553 const rescanned = [
554 ...skills,
555 { name: "review", path: "/workspace/.agent/skills/review", enabled: true },
556 ];
557 yield* harness.provider.snapshotForCwd("/workspace", rescanned);
558 yield* harness.provider.onSessionStarted(started, "/workspace");
559 expect(
560 (yield* harness.provider.snapshot.getSnapshot).workspaceSnapshots?.find(
561 (entry) => entry.cwd === "/workspace",
562 )?.skills,
563 ).toEqual(rescanned);
564 }),
565 ),
566 );
567
568 it.effect("bounds workspace metadata without starting sessions for workspace lookup", () =>
569 Effect.scoped(
570 Effect.gen(function* () {
571 const harness = yield* makeHarness();
572 yield* harness.initialize;
573 yield* harness.provider.onSessionStarted(started);
574 for (let index = 0; index < 35; index++) {
575 yield* harness.provider.onAvailableCommands(commands, `/workspace-${index}`);
576 }
577 const snapshot = yield* harness.provider.snapshotForCwd("/workspace-34");
578 expect(snapshot.workspaceSnapshots).toHaveLength(32);
579 expect(snapshot.workspaceSnapshots?.[0]?.cwd).toBe("/workspace-3");
580 expect(snapshot.slashCommands).toEqual(expectedCommands);
581 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
582 }),
583 ),
584 );
585
586 it.effect(
587 "publishes limits, retains a successful read on failure, and clears them on sign-out",
588 () =>
589 Effect.scoped(
590 Effect.gen(function* () {
591 const limits: ServerProviderUsageLimits = {
592 checkedAt: "2026-10-09T12:00:00.000Z",
593 windows: [
594 {
595 id: "3p-weekly",
596 kind: "weekly",
597 label: "Claude & GPT (shared) · Weekly",
598 usedPercent: 75,
599 },
600 ],
601 };
602 const usage = yield* Ref.make(limits);
603 const harness = yield* makeHarness({ probeUsage: Ref.get(usage) });
604 yield* harness.initialize;
605 expect((yield* harness.provider.snapshot.getSnapshot).usageLimits).toEqual(limits);
606 yield* Ref.set(harness.probe, Effect.succeed(initializeResult));
607 yield* Ref.set(usage, {
608 checkedAt: "2026-10-09T12:01:00.000Z",
609 windows: [],
610 unavailable: { reason: "probeFailed" },
611 });
612 expect((yield* harness.provider.snapshot.refresh).usageLimits).toEqual(limits);
613 yield* harness.provider.onSignedOut;
614 expect((yield* harness.provider.snapshot.getSnapshot).usageLimits).toBeUndefined();
615 yield* Ref.set(usage, {
616 checkedAt: "2026-10-09T12:02:00.000Z",
617 windows: [],
618 unavailable: { reason: "unsupported" },
619 });
620 expect((yield* harness.provider.snapshot.refresh).usageLimits?.windows).toEqual([]);
621 }),
622 ),
623 );
624
625 it.effect("a quota read finishing after sign-out cannot restore account limits", () =>
626 Effect.scoped(
627 Effect.gen(function* () {
628 const readStarted = yield* Deferred.make<void>();
629 const readResult = yield* Deferred.make<ServerProviderUsageLimits>();
630 const usage = yield* Ref.make<Effect.Effect<ServerProviderUsageLimits>>(
631 Effect.succeed({ checkedAt: "2026-10-09T12:00:00.000Z", windows: [] }),
632 );
633 const harness = yield* makeHarness({ probeUsage: Ref.get(usage).pipe(Effect.flatten) });
634 yield* harness.initialize;
635 yield* Ref.set(harness.probe, Effect.succeed(initializeResult));
636 yield* Ref.set(
637 usage,
638 Deferred.succeed(readStarted, undefined).pipe(Effect.andThen(Deferred.await(readResult))),
639 );
640 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
641 yield* Deferred.await(readStarted);
642 yield* harness.provider.onSignedOut;
643 yield* Deferred.succeed(readResult, {
644 checkedAt: "2026-10-09T12:01:00.000Z",
645 windows: [
646 { id: "gemini-5h", kind: "session", label: "Gemini · 5-hour", usedPercent: 10 },
647 ],
648 });
649 yield* Fiber.join(refresh);
650 expect((yield* harness.provider.snapshot.getSnapshot).usageLimits).toBeUndefined();
651 }),
652 ),
653 );
654});