From e1f6061893995b66da880f6649bc0a10a5e9e360 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 31 Oct 2026 10:43:00 +0000 Subject: [PATCH 1/2] test(server): reproduce #28094 Grok Legacy accounts get no Privacy Mode hint These tests reproduce #28094: a 403 carrying the WKE=privacy-mode marker still reports the generic usage-limits failure. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/provider/GrokProvider.test.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/server/src/provider/GrokProvider.test.ts b/apps/server/src/provider/GrokProvider.test.ts index 4ecc0ad28971b..6c958a7c29c5c 100644 --- a/apps/server/src/provider/GrokProvider.test.ts +++ b/apps/server/src/provider/GrokProvider.test.ts @@ -651,6 +651,36 @@ it.layer(NodeServices.layer)("readGrokAccount", (it) => { } }), ); + + it.effect("tells accounts in Legacy (no storage) to switch to Privacy Mode", () => + Effect.gen(function* () { + const { usageLimits: limits } = yield* readGrokAccount({ + HOME: "/definitely/not/a/grok-home", + GROK_AUTH: '{"https://accounts.x.ai/sign-in":{"key":"private-token"}}', + }).pipe( + Effect.provideService( + HttpClient.HttpClient, + HttpClient.make((request) => + Effect.succeed( + HttpClientResponse.fromWeb( + request, + Response.json( + { + error: + "Grok Build is not supported in Legacy (no storage). Switch to Privacy Mode to use Grok Build. [WKE=privacy-mode:legacy]", + }, + { status: 403 }, + ), + ), + ), + ), + ), + ); + expect(limits.unavailable?.reason).toBe("probeFailed"); + expect(limits.unavailable?.message).toMatch(/Privacy Mode/); + expect(limits.unavailable?.message).not.toMatch(/WKE=|Grok Build is not supported/); + }), + ); }); it.layer(NodeServices.layer)("readGrokAccount email", (it) => { From 308214a6f2a901e1fb12f0fb89945dcbbe677d62 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 31 Oct 2026 10:46:26 +0000 Subject: [PATCH 2/2] fix(server): tell Grok Legacy accounts to switch to Privacy Mode for usage limits xAI answers the billing probe with 403 and a `WKE=privacy-mode:` marker when the account's privacy setting is Legacy (no storage). Recognise that marker and show a fixed T3-authored hint instead of the generic failure, without echoing the upstream body. Fixes pingdotgg/t3code#28094 Co-Authored-By: Claude Opus 5.5 --- packages/provider-grok/src/server/usageLimits.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/provider-grok/src/server/usageLimits.ts b/packages/provider-grok/src/server/usageLimits.ts index 8036df0dd3e99..c6ba583c139ce 100644 --- a/packages/provider-grok/src/server/usageLimits.ts +++ b/packages/provider-grok/src/server/usageLimits.ts @@ -38,6 +38,7 @@ const GrokUsageResponse = Schema.Struct({ }), ), }); +const GrokErrorResponse = Schema.Struct({ error: Schema.String }); function parsePeriodBoundary(value: string | undefined) { if ( @@ -182,6 +183,17 @@ export const readGrokAccount = Effect.fn("readGrokAccount")(function* ( HttpClientRequest.bearerToken(token), ), ); + if (response.status === 403) { + const { error } = yield* HttpClientResponse.schemaBodyJson(GrokErrorResponse)(response); + // xAI refuses Grok Build while the account's privacy setting is a legacy mode. + if (error.includes("WKE=privacy-mode:")) { + return makeUnavailableUsageLimits({ + checkedAt, + reason: "probeFailed", + message: "Switch your xAI account to Privacy Mode to show Grok usage limits.", + }); + } + } const body = yield* HttpClientResponse.schemaBodyJson(GrokUsageResponse)( yield* HttpClientResponse.filterStatusOk(response), );