From 5ed6e9087fda367ee2f823e15844cf47a5d8b2fd Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:35:47 -0500 Subject: [PATCH] fix(web): keep usage pace lines on weekly windows and fix Antigravity Windows User-Agent Short 5-hour session usage bars showed pace marks and 'ahead of pace' copy even though burst usage inside a 5-hour window is normal. Separately, Antigravity's Cloud Code quota request sent Node platform and architecture names (win32, x64) instead of the Go client names (windows, amd64). - Limit usage bar pace marks and 'ahead of pace' copy to weekly and longer windows (7 days or more) in providerUsage, and update the app guide to match. - Normalize Antigravity's Cloud Code User-Agent to map win32 -> windows, x64 -> amd64, and ia32 -> 386. --- apps/server/src/guide/topics.ts | 2 +- .../antigravity/AntigravityUsage.test.ts | 20 ++++++ .../provider/antigravity/AntigravityUsage.ts | 7 +- apps/web/src/lib/providerUsage.test.ts | 64 ++++++++++++++----- apps/web/src/lib/providerUsage.ts | 24 +++++-- 5 files changed, 94 insertions(+), 23 deletions(-) diff --git a/apps/server/src/guide/topics.ts b/apps/server/src/guide/topics.ts index b79df273a..6d85120aa 100644 --- a/apps/server/src/guide/topics.ts +++ b/apps/server/src/guide/topics.ts @@ -317,7 +317,7 @@ Antigravity runs Google's Antigravity CLI (agy), which Threadlines downloads and Each Antigravity account brings in your own rules and skills from ~/.gemini at every start (AGENTS.md, GEMINI.md, config/rules, and the config/skills and antigravity-cli/skills folders with skills.json); your sign-in, hooks, plugins and MCP servers stay out. Antigravity runs a skill or one of its own commands (such as /goal or /compact, when it offers them) when a message starts with / and its name, so typing / in the composer lists its skills, and while Antigravity runs in that thread, the commands it offers there. A message whose typed words start with one of those goes to Antigravity alone and as typed, even in plan mode; the context Threadlines would put in front of it waits for the next ordinary message. Editing an earlier message stops anything Antigravity still runs before the files are restored, and starts it over with only the turns before it, since it can't rewind its own conversation. -How much of each plan you've used is on {place:usage}. The ring beside the composer's send button shows the same limits when you hover or tap it; a short upright tick on each bar marks how much of that limit's window has passed (hover the tick for the exact share, "55% of the week has passed"), so a bar filled past its tick is on track to run out before the reset, and its line says "ahead of pace" once it is clearly past. The same ticks show on a provider's Usage tab in Settings › Providers. Clicking a limit there opens {place:usage}. An Antigravity account signed in with Google shows a 5-hour and a weekly limit for each group of models Google meters apart (Gemini, each Gemini 4 model with its own limit, and Claude & GPT together), read from Google every few minutes; each model in the picker shows its own group's limit. Google renews that sign-in only while Antigravity runs, so when it has lapsed the last numbers stay, with their age and a line saying a chat refreshes them. API-key and Vertex AI accounts have no plan limits to show. +How much of each plan you've used is on {place:usage}. The ring beside the composer's send button shows the same limits when you hover or tap it; a short upright tick on weekly and longer bars marks how much of that window has passed (hover the tick for the exact share, "55% of the week has passed"), so a bar filled past its tick is on track to run out before the reset, and its line says "ahead of pace" once it is clearly past. The same ticks show on a provider's Usage tab in Settings › Providers. Clicking a limit there opens {place:usage}. An Antigravity account signed in with Google shows a 5-hour and a weekly limit for each group of models Google meters apart (Gemini, each Gemini 4 model with its own limit, and Claude & GPT together), read from Google every few minutes; each model in the picker shows its own group's limit. Google renews that sign-in only while Antigravity runs, so when it has lapsed the last numbers stay, with their age and a line saying a chat refreshes them. API-key and Vertex AI accounts have no plan limits to show. An agent's row that says Can't start means its program is on this computer but fails to launch, usually because an update stopped partway. It is not a sign-in problem: the sign-in is still saved. The row has Reinstall when Threadlines can put that same copy back: with npm, bun or Homebrew for a copy they installed, or with the agent's own installer for a copy sitting where that installer puts it (Claude, OpenCode, Cursor, fx, Muse Code, and Codex on Windows). For Pi it reinstalls an npm copy, or installs Threadlines' own copy of Pi. There is no Reinstall for a copy from pnpm, Scoop, winget or Nix, for one at a custom path, or for Grok from xAI's installer (it would switch the release channel); reinstall those the way they were installed. An update that leaves an agent unable to start runs that reinstall once on its own before reporting. Community agents are installed by Threadlines itself and have Install again instead. Antigravity is downloaded and checked by Threadlines, so it isn't covered. diff --git a/apps/server/src/provider/antigravity/AntigravityUsage.test.ts b/apps/server/src/provider/antigravity/AntigravityUsage.test.ts index 0aeb7892d..d54593970 100644 --- a/apps/server/src/provider/antigravity/AntigravityUsage.test.ts +++ b/apps/server/src/provider/antigravity/AntigravityUsage.test.ts @@ -16,6 +16,7 @@ import { ANTIGRAVITY_USAGE_EXPIRED_DETAIL, ANTIGRAVITY_USAGE_FAILED_DETAIL, ANTIGRAVITY_USAGE_USER_AGENT, + antigravityUsageUserAgent, makeAntigravityUsageReader, withAntigravityUsage, } from "./AntigravityUsage.ts"; @@ -255,6 +256,25 @@ const windowsOf = (snapshot: ServerProvider) => })); describe("Antigravity plan limits", () => { + it("formats Cloud Code User-Agent with Go OS and architecture names", () => { + assert.equal( + antigravityUsageUserAgent("darwin", "arm64"), + "antigravity/hub/2.24.0 (aidev_client; os_type=darwin; arch=arm64; cl=963137146)", + ); + assert.equal( + antigravityUsageUserAgent("win32", "x64"), + "antigravity/hub/2.24.0 (aidev_client; os_type=windows; arch=amd64; cl=963137146)", + ); + assert.equal( + antigravityUsageUserAgent("win32", "arm64"), + "antigravity/hub/2.24.0 (aidev_client; os_type=windows; arch=arm64; cl=963137146)", + ); + assert.equal( + antigravityUsageUserAgent("linux", "x64"), + "antigravity/hub/2.24.0 (aidev_client; os_type=linux; arch=amd64; cl=963137146)", + ); + }); + it.effect("reads each family's 5-hour and weekly limits, with the email from the sign-in", () => Effect.gen(function* () { const { readOnce, google } = yield* setup({ diff --git a/apps/server/src/provider/antigravity/AntigravityUsage.ts b/apps/server/src/provider/antigravity/AntigravityUsage.ts index 07de75451..2f71cbdcf 100644 --- a/apps/server/src/provider/antigravity/AntigravityUsage.ts +++ b/apps/server/src/provider/antigravity/AntigravityUsage.ts @@ -94,13 +94,16 @@ export const ANTIGRAVITY_USAGE_LABEL = "Antigravity usage"; /** * Google's Cloud Code quota endpoints gate on the client User-Agent and * refuse or drop groups for unrecognized strings. Matches Antigravity's own - * client string on those endpoints; userinfo still sends Threadlines' name. + * Go client string (`runtime.GOOS` / `runtime.GOARCH`) on those endpoints; + * userinfo still sends Threadlines' name. */ export function antigravityUsageUserAgent( platform: NodeJS.Platform = process.platform, architecture: NodeJS.Architecture = process.arch, ): string { - return `antigravity/hub/2.24.0 (aidev_client; os_type=${platform}; arch=${architecture}; cl=963137146)`; + const osType = platform === "win32" ? "windows" : platform; + const arch = architecture === "x64" ? "amd64" : architecture === "ia32" ? "386" : architecture; + return `antigravity/hub/2.24.0 (aidev_client; os_type=${osType}; arch=${arch}; cl=963137146)`; } export const ANTIGRAVITY_USAGE_USER_AGENT = antigravityUsageUserAgent(); diff --git a/apps/web/src/lib/providerUsage.test.ts b/apps/web/src/lib/providerUsage.test.ts index b0f15bcef..86d59b0d2 100644 --- a/apps/web/src/lib/providerUsage.test.ts +++ b/apps/web/src/lib/providerUsage.test.ts @@ -70,8 +70,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 63, reachedLimit: false, warning: false, - elapsedPercent: 80, - paceDetail: "80% of the 5-hour window has passed", }, ], }); @@ -119,8 +117,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 63, reachedLimit: false, warning: false, - elapsedPercent: 80, - paceDetail: "80% of the 5-hour window has passed", }, { key: "secondary", @@ -344,8 +340,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 63, reachedLimit: false, warning: false, - elapsedPercent: 80, - paceDetail: "80% of the 5-hour window has passed", }, ], }); @@ -427,8 +421,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 69, reachedLimit: false, warning: false, - elapsedPercent: 49.3, - paceDetail: "49% of the 5-hour window has passed", }, { key: "secondary", @@ -489,8 +481,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 65, reachedLimit: false, warning: false, - elapsedPercent: 49.3, - paceDetail: "49% of the 5-hour window has passed", }, { key: "secondary", @@ -613,8 +603,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 0, reachedLimit: true, warning: true, - elapsedPercent: 33.3, - paceDetail: "33% of the 5-hour window has passed", }, { key: "secondary", @@ -674,8 +662,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 0, reachedLimit: true, warning: true, - elapsedPercent: 33.3, - paceDetail: "33% of the 5-hour window has passed", }, { key: "secondary", @@ -735,8 +721,6 @@ describe("deriveProviderAccountUsagePresentation", () => { remainingPercent: 58, reachedLimit: false, warning: false, - elapsedPercent: 33.3, - paceDetail: "33% of the 5-hour window has passed", }, { key: "secondary", @@ -834,6 +818,54 @@ describe("usageWindowElapsedPercent", () => { expect(detailAt(30)).toBe("30% used · resets in 5d"); expect(detailAt(34)).toBe("34% used · ahead of pace · resets in 5d"); }); + + it("keeps pace marks and ahead-of-pace copy on weekly windows, not 5h sessions", () => { + const presentation = deriveProviderAccountUsagePresentation( + { + source: "grok-billing", + checkedAt: "2026-04-10T00:00:00.000Z", + primaryLimitId: "antigravity", + limits: [ + { + limitId: "antigravity", + limitName: "Antigravity usage", + scoped: [ + { + scopeLabel: "Gemini", + usedPercent: 40, + remainingPercent: 60, + resetsAt: nowMs + 4 * 3_600_000, + windowDurationMins: 300, + }, + { + scopeLabel: "Gemini", + usedPercent: 40, + remainingPercent: 60, + resetsAt: nowMs + 5 * 86_400_000, + windowDurationMins: 10_080, + }, + ], + }, + ], + }, + nowMs, + ); + + expect(presentation?.windows).toEqual([ + expect.objectContaining({ + label: "Gemini (5h)", + detail: "40% used · resets in 4h", + }), + expect.objectContaining({ + label: "Gemini (weekly)", + detail: "40% used · ahead of pace · resets in 5d", + elapsedPercent: 28.6, + paceDetail: "29% of the week has passed", + }), + ]); + expect(presentation?.windows[0]?.elapsedPercent).toBeUndefined(); + expect(presentation?.windows[0]?.paceDetail).toBeUndefined(); + }); }); describe("deriveProviderAccountUsagePresentationForProvider", () => { diff --git a/apps/web/src/lib/providerUsage.ts b/apps/web/src/lib/providerUsage.ts index a98338aed..a42667a13 100644 --- a/apps/web/src/lib/providerUsage.ts +++ b/apps/web/src/lib/providerUsage.ts @@ -31,8 +31,8 @@ export interface ProviderAccountUsageWindowPresentation { /** * How much of the window has passed (0-100), where a usage bar draws its * pace mark: usage left of the mark is on track to last until the reset. - * Unset when the provider doesn't say how long the window is or when it - * resets. + * Set only for weekly (and longer) windows whose length and reset time are + * known; short session windows such as 5h have no pace mark. */ readonly elapsedPercent?: number; /** @@ -255,6 +255,22 @@ export function usageWindowElapsedPercent( return Math.round((1 - remainingMs / durationMs) * 1000) / 10; } +/** + * Short session windows (such as 5h) are used in bursts, so pace marks and + * "ahead of pace" apply only to weekly (and longer) windows. + */ +const MIN_PACE_WINDOW_MINS = 7 * 24 * 60; + +function usageWindowPaceElapsedPercent( + window: Pick, + nowMs: number, +): number | undefined { + if (window.windowDurationMins === undefined || window.windowDurationMins < MIN_PACE_WINDOW_MINS) { + return undefined; + } + return usageWindowElapsedPercent(window, nowMs); +} + /** "the week", "the day", "the 5-hour window": the span a pace mark measures. */ function formatUsageWindowSpan(minutes: number): string { if (minutes === 10_080) return "the week"; @@ -476,7 +492,7 @@ function formatUsageWindowPresentation( const blockedByLimitDetail = windowReachedLimit ? null : formatBlockedByLimitDetail(blockingLimitLabels); - const elapsedPercent = usageWindowElapsedPercent(window, nowMs); + const elapsedPercent = usageWindowPaceElapsedPercent(window, nowMs); const detailParts = [ windowReachedLimit ? "limit reached" : `${usedPercent}% used`, // Pace stops mattering once this limit or another one is the blocker. @@ -517,7 +533,7 @@ function formatScopedUsageWindowPresentation( const severityWarning = window.severity !== undefined && window.severity !== "normal"; const resetDetail = formatResetDetail(window.resetsAt, nowMs); const durationLabel = formatUsageWindowDurationLabel(window, ""); - const elapsedPercent = usageWindowElapsedPercent(window, nowMs); + const elapsedPercent = usageWindowPaceElapsedPercent(window, nowMs); const detailParts = [ reachedLimit ? "limit reached" : `${usedPercent}% used`, reachedLimit ? null : formatPaceDetail(usedPercent, elapsedPercent),