From 93ab0884b375f8e66fd1b435d245c7acebac2a53 Mon Sep 17 00:00:00 2001 From: humbertogontijo <96875138+humbertogontijo@users.noreply.github.com> Date: Tue, 3 Nov 2026 22:46:29 -0300 Subject: [PATCH 1/3] fix(usage): show why Cursor and Grok limits are missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unsupported subscription limits with an actionable message were dropped from Usage → Limits, so Cursor Keychain/token gaps and Grok API-key sign-ins looked like limits were never implemented. Surface those messages, and give Grok a console link the same way ChatGPT does. --- .../provider-core/src/server/usageLimits.ts | 2 ++ .../provider-cursor/src/server/usageLimits.ts | 8 +++++- .../src/server/usageLimits.test.ts | 27 +++++++++++++++++++ .../provider-grok/src/server/usageLimits.ts | 11 +++++++- packages/shared/src/usageLimits.test.ts | 26 ++++++++++++++++++ packages/shared/src/usageLimits.ts | 8 +++++- 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 packages/provider-grok/src/server/usageLimits.test.ts diff --git a/packages/provider-core/src/server/usageLimits.ts b/packages/provider-core/src/server/usageLimits.ts index 1e4bcd0090854..3dcfc593e5b7e 100644 --- a/packages/provider-core/src/server/usageLimits.ts +++ b/packages/provider-core/src/server/usageLimits.ts @@ -36,6 +36,7 @@ export function makeUnavailableUsageLimits(input: { readonly checkedAt: string; readonly reason: "unsupported" | "probeFailed"; readonly message?: string; + readonly externalUsage?: ServerProviderUsageLimits["externalUsage"]; }): ServerProviderUsageLimits { return { checkedAt: input.checkedAt, @@ -44,6 +45,7 @@ export function makeUnavailableUsageLimits(input: { reason: input.reason, ...(input.message ? { message: input.message } : {}), }, + ...(input.externalUsage ? { externalUsage: input.externalUsage } : {}), }; } diff --git a/packages/provider-cursor/src/server/usageLimits.ts b/packages/provider-cursor/src/server/usageLimits.ts index 87fcecef4e97f..4370005d7dafa 100644 --- a/packages/provider-cursor/src/server/usageLimits.ts +++ b/packages/provider-cursor/src/server/usageLimits.ts @@ -131,7 +131,13 @@ export const readCursorUsageLimits = Effect.fn("readCursorUsageLimits")(function ); token = credentials.accessToken?.trim(); } - if (!token) return makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" }); + if (!token) { + return makeUnavailableUsageLimits({ + checkedAt, + reason: "unsupported", + message: "Cursor usage requires a CLI login or CURSOR_AUTH_TOKEN.", + }); + } const client = yield* HttpClient.HttpClient; const response = yield* client.execute( HttpClientRequest.post(`${endpoint}/aiserver.v1.DashboardService/GetCurrentPeriodUsage`).pipe( diff --git a/packages/provider-grok/src/server/usageLimits.test.ts b/packages/provider-grok/src/server/usageLimits.test.ts new file mode 100644 index 0000000000000..0ff528ff5ddc0 --- /dev/null +++ b/packages/provider-grok/src/server/usageLimits.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from "@effect/vitest"; +import { NodeServices } from "@effect/platform-node"; +import * as Effect from "effect/Effect"; +import * as FileSystem from "effect/FileSystem"; +import { readGrokAccount } from "./usageLimits.ts"; + +describe("Grok usage limits", () => { + it.effect("explains that API keys do not report subscription limits", () => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const home = yield* fs.makeTempDirectoryScoped({ prefix: "grok-limits-" }); + const { usageLimits } = yield* readGrokAccount({ + HOME: home, + XAI_API_KEY: "xai-test-key", + }); + expect(usageLimits.unavailable).toEqual({ + reason: "unsupported", + message: + "Grok subscription limits need a default `grok login` session. API keys and custom authentication do not report them.", + }); + expect(usageLimits.externalUsage).toEqual({ + label: "xAI console", + url: "https://console.x.ai", + }); + }).pipe(Effect.provide(NodeServices.layer)), + ); +}); diff --git a/packages/provider-grok/src/server/usageLimits.ts b/packages/provider-grok/src/server/usageLimits.ts index c6ba583c139ce..e3baf1f2b0b0b 100644 --- a/packages/provider-grok/src/server/usageLimits.ts +++ b/packages/provider-grok/src/server/usageLimits.ts @@ -174,7 +174,16 @@ export const readGrokAccount = Effect.fn("readGrokAccount")(function* ( const email = credential.value?.email?.trim() || undefined; const token = credential.value?.key?.trim(); if (!token) { - return { email, usageLimits: makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" }) }; + return { + email, + usageLimits: makeUnavailableUsageLimits({ + checkedAt, + reason: "unsupported", + message: + "Grok subscription limits need a default `grok login` session. API keys and custom authentication do not report them.", + externalUsage: { label: "xAI console", url: "https://console.x.ai" }, + }), + }; } const usageLimits = yield* Effect.gen(function* () { const client = yield* HttpClient.HttpClient; diff --git a/packages/shared/src/usageLimits.test.ts b/packages/shared/src/usageLimits.test.ts index 72a17323386c8..e3135d70141c8 100644 --- a/packages/shared/src/usageLimits.test.ts +++ b/packages/shared/src/usageLimits.test.ts @@ -1489,6 +1489,32 @@ describe("external usage settings", () => { expect(collectLimitAccounts(presentations)).toEqual([]); expect(collectLimitNotices(presentations)).toEqual([]); }); + + it("surfaces unsupported accounts that only have an actionable message", () => { + const cursor = provider({ + instanceId: ProviderInstanceId.make("cursor"), + driver: ProviderDriverKind.make("cursor"), + displayName: "Cursor", + usageLimits: { + checkedAt: "2026-09-03T11:00:00.000Z", + windows: [], + unavailable: { + reason: "unsupported", + message: "Enable Cursor account usage in T3 Code to read its Keychain login.", + }, + }, + }); + const presentations = new Map([ + [ + EnvironmentId.make("a"), + { entry: { target: { label: "A" } }, serverConfig: { providers: [cursor] } }, + ], + ]); + expect(collectLimitNotices(presentations)).toEqual([ + "Cursor: Enable Cursor account usage in T3 Code to read its Keychain login.", + ]); + expect(collectExternalUsageLinks(presentations)).toEqual([]); + }); }); describe("ChatGPT sharing presentation", () => { diff --git a/packages/shared/src/usageLimits.ts b/packages/shared/src/usageLimits.ts index 869f676acae69..8cb1f55378933 100644 --- a/packages/shared/src/usageLimits.ts +++ b/packages/shared/src/usageLimits.ts @@ -396,7 +396,13 @@ export function collectLimitNotices(presentations: LimitPresentations): readonly for (const presentation of presentations.values()) { const environmentLabel = presentation.entry.target.label; for (const provider of providersWithLimits(presentation.serverConfig?.providers ?? [])) { - if (provider.usageLimits?.unavailable?.reason === "unsupported") continue; + // ChatGPT-style unsupported+externalUsage already has a link row; skip the notice. + if ( + provider.usageLimits?.unavailable?.reason === "unsupported" && + (provider.usageLimits.externalUsage || !provider.usageLimits.unavailable.message) + ) { + continue; + } const notice = provider.usageLimits ? limitsNotice(provider.usageLimits) : null; const name = provider.displayName?.trim() || String(provider.driver); if (notice) notices.push(`${label(environmentLabel, name)}: ${notice}`); From fea50025b34dcb70693e6d8f4afe08c4c316996b Mon Sep 17 00:00:00 2001 From: humbertogontijo <96875138+humbertogontijo@users.noreply.github.com> Date: Tue, 3 Nov 2026 23:06:06 -0300 Subject: [PATCH 2/3] fix(usage): cover missing Cursor token and fix Grok test types Provide HttpClient in the Grok API-key usage-limits test so typecheck passes, and assert the file-store missing-token notice path for Cursor. Co-authored-by: Cursor --- .../src/server/usageLimits.test.ts | 32 +++++++++++++++++++ .../src/server/usageLimits.test.ts | 9 +++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index 617616d14bc25..2a082a5f2b639 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -158,6 +158,38 @@ describe("Cursor usage limits", () => { }), ); + it.effect("explains when a file credential store has no access token", () => + withNodeServices( + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const directory = yield* fs.makeTempDirectoryScoped(); + yield* fs.makeDirectory(path.join(directory, "cursor")); + for (const credentials of ["{}", '{"accessToken":""}'] as const) { + yield* fs.writeFileString(path.join(directory, "cursor", "auth.json"), credentials); + const limits = yield* readCursorUsageLimits( + { apiEndpoint: "" }, + { + XDG_CONFIG_HOME: directory, + HOME: directory, + AGENT_CLI_CREDENTIAL_STORE: "file", + }, + ).pipe( + Effect.provideService(HostProcess.Platform, "linux"), + Effect.provideService( + HttpClient.HttpClient, + HttpClient.make(() => Effect.die("must not request limits without a token")), + ), + ); + expect(limits.unavailable).toEqual({ + reason: "unsupported", + message: "Cursor usage requires a CLI login or CURSOR_AUTH_TOKEN.", + }); + } + }).pipe(Effect.scoped), + ), + ); + it.effect("reports failed requests without exposing credentials or response bodies", () => Effect.gen(function* () { const limits = yield* withNodeServices( diff --git a/packages/provider-grok/src/server/usageLimits.test.ts b/packages/provider-grok/src/server/usageLimits.test.ts index 0ff528ff5ddc0..8286f84bfda8f 100644 --- a/packages/provider-grok/src/server/usageLimits.test.ts +++ b/packages/provider-grok/src/server/usageLimits.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "@effect/vitest"; import { NodeServices } from "@effect/platform-node"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; +import * as HttpClient from "effect/http/HttpClient"; import { readGrokAccount } from "./usageLimits.ts"; describe("Grok usage limits", () => { @@ -22,6 +23,12 @@ describe("Grok usage limits", () => { label: "xAI console", url: "https://console.x.ai", }); - }).pipe(Effect.provide(NodeServices.layer)), + }).pipe( + Effect.provideService( + HttpClient.HttpClient, + HttpClient.make(() => Effect.die("API-key Grok must not request usage limits")), + ), + Effect.provide(NodeServices.layer), + ), ); }); From 5aea6d7f46bc5e2ccd1504bd8b25c08e1936bd83 Mon Sep 17 00:00:00 2001 From: maria-rcks Date: Sun, 15 Nov 2026 04:31:59 +0000 Subject: [PATCH 3/3] test(cursor): adapt missing-token coverage to current auth flow --- .../src/server/usageLimits.test.ts | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/packages/provider-cursor/src/server/usageLimits.test.ts b/packages/provider-cursor/src/server/usageLimits.test.ts index cd22d3ac534c9..9934c6e83dee6 100644 --- a/packages/provider-cursor/src/server/usageLimits.test.ts +++ b/packages/provider-cursor/src/server/usageLimits.test.ts @@ -124,41 +124,13 @@ describe("Cursor usage limits", () => { ), ); if (token) expect(limits.windows[0]?.usedPercent).toBe(10); - else expect(limits.unavailable?.reason).toBe("unsupported"); - } - }), - ); - - it.effect("explains when a file credential store has no access token", () => - withNodeServices( - Effect.gen(function* () { - const fs = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const directory = yield* fs.makeTempDirectoryScoped(); - yield* fs.makeDirectory(path.join(directory, "cursor")); - for (const credentials of ["{}", '{"accessToken":""}'] as const) { - yield* fs.writeFileString(path.join(directory, "cursor", "auth.json"), credentials); - const limits = yield* readCursorUsageLimits( - { apiEndpoint: "" }, - { - XDG_CONFIG_HOME: directory, - HOME: directory, - AGENT_CLI_CREDENTIAL_STORE: "file", - }, - ).pipe( - Effect.provideService(HostProcess.Platform, "linux"), - Effect.provideService( - HttpClient.HttpClient, - HttpClient.make(() => Effect.die("must not request limits without a token")), - ), - ); + else expect(limits.unavailable).toEqual({ reason: "unsupported", message: "Cursor usage requires a CLI login or CURSOR_AUTH_TOKEN.", }); - } - }).pipe(Effect.scoped), - ), + } + }), ); it.effect("reports failed requests without exposing credentials or response bodies", () =>