GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): prefer current Antigravity sign-in for usage limits · pingdotgg/t3code@b1e13a7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/provider
    • antigravityUsageLimits.test.ts
    • antigravityUsageLimits.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/provider/antigravityUsageLimits.test.ts
+38-25Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const fixture = Effect.fn("AntigravityUsageTest.fixture")(function* (
7070
userId?: string;
7171
userInfoAt?: number;
7272
missingToken?: boolean;
73+
cliToken?: string;
7374
authMethod?: "oauth-personal" | "oauth-business" | "gemini-api-key";
7475
keyringSecret?: string;
7576
/** Reads the OS keyring instead of `keyringSecret`. */
@@ -92,6 +93,12 @@ const fixture = Effect.fn("AntigravityUsageTest.fixture")(function* (
9293
}),
9394
);
9495
if (!options.missingToken) yield* writeToken(options.refreshToken ?? "refresh-a");
96+
if (options.cliToken !== undefined) {
97+
yield* fs.writeFileString(
98+
path.join(profileDirectory, "antigravity-acp", "antigravity-oauth-token"),
99+
options.cliToken,
100+
);
101+
}
95102
const requests: Array<{ url: string; body: string }> = [];
96103
const http = HttpClient.make((request, url, _signal, fiber) =>
97104
Effect.sync(() => {
@@ -119,7 +126,9 @@ const fixture = Effect.fn("AntigravityUsageTest.fixture")(function* (
119126
: Response.json({}, { status: 403 }),
120127
);
121128
}
122-
expect(JSON.parse(body)).toEqual(options.missingToken ? {} : { project: "project-id" });
129+
expect(JSON.parse(body)).toEqual(
130+
options.missingToken || options.cliToken !== undefined ? {} : { project: "project-id" },
131+
);
123132
expect(request.headers["user-agent"]).toMatch(/^antigravity\/hub\/2\.24\.0 /);
124133
return HttpClientResponse.fromWeb(
125134
request,
@@ -663,31 +672,29 @@ describe("Antigravity subscription limits", () => {
663672
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
664673
);
665674

666-
it.effect("reads the native CLI's stored sign-in when acp_token.json is absent", () =>
675+
it.effect("prefers the native CLI's stored sign-in over a leftover legacy token", () =>
667676
Effect.gen(function* () {
668-
const fs = yield* FileSystem.FileSystem;
669-
const path = yield* Path.Path;
670-
const { probe, tokenPath } = yield* fixture({ missingToken: true });
671-
// The 1.5.x CLI never writes acp_token.json; without a keyring it stores this file instead.
672-
yield* fs.writeFileString(
673-
path.join(path.dirname(tokenPath), "antigravity-oauth-token"),
674-
JSON.stringify({
675-
token: {
676-
access_token: "access-token",
677-
token_type: "Bearer",
678-
refresh_token: "refresh-a",
679-
expiry: "2099-01-01T00:00:00Z",
680-
expires_in: 3600,
681-
},
682-
auth_method: "consumer",
683-
id_token_email: "[email protected]",
684-
}),
685-
);
686-
const limits = yield* probe;
687-
expect(limits.unavailable?.message).not.toBe(
688-
"Sign in with Google to see Antigravity limits.",
689-
);
690-
expect(limits.unavailable?.reason).not.toBe("unsupported");
677+
for (const missingToken of [true, false]) {
678+
const { probe, requests } = yield* fixture({
679+
missingToken,
680+
tokenStatus: 401,
681+
cliToken: JSON.stringify({
682+
token: {
683+
access_token: "access-token",
684+
token_type: "Bearer",
685+
refresh_token: "refresh-a",
686+
expiry: "2099-01-01T00:00:00Z",
687+
expires_in: 3600,
688+
},
689+
auth_method: "consumer",
690+
id_token_email: "[email protected]",
691+
}),
692+
});
693+
const limits = yield* probe;
694+
expect(limits.unavailable).toBeUndefined();
695+
expect(limits.windows).toHaveLength(4);
696+
expect(requests.some((request) => request.url.endsWith("/token"))).toBe(false);
697+
}
691698
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
692699
);
693700

@@ -724,6 +731,12 @@ describe("Antigravity subscription limits", () => {
724731
});
725732
expect((yield* expired.probe).unavailable?.reason).toBe("probeFailed");
726733
expect(expired.requests).toEqual([]);
734+
735+
const expiredFile = yield* fixture({
736+
cliToken: keyringSecret("2026-10-09T12:00:30Z"),
737+
});
738+
expect((yield* expiredFile.probe).unavailable?.reason).toBe("probeFailed");
739+
expect(expiredFile.requests).toEqual([]);
727740
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
728741
);
729742

Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/provider/antigravityUsageLimits.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,11 @@ export const makeAntigravityUsageProbe = Effect.fn("makeAntigravityUsageProbe")(
357357
let accessToken: string;
358358
let account: string;
359359
let projectId: string | undefined;
360-
if (!(yield* fs.exists(tokenPath))) {
360+
const hasCliToken = yield* fs.exists(cliTokenPath);
361+
if (hasCliToken || !(yield* fs.exists(tokenPath))) {
361362
cached = undefined;
362363
// Google account instances bypass the keyring, whose one entry every profile shares.
363-
const stored = (yield* fs.exists(cliTokenPath))
364+
const stored = hasCliToken
364365
? yield* fs.readFileString(cliTokenPath)
365366
: input.authMethod === "oauth-business"
366367
? yield* readKeyringSecret

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.