The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 05:45 UTC
fix(cursor): Cursor text generation names usage-limit failures (#29748)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex Southwell committed
Nov 3, 2026 at 23:24 UTC
47057a3cac9db2c9a0b34510ea5a258bac3fb3a9
2 files changed
+25
-9
packages/provider-cursor/src/server/textGeneration.test.ts
+20
-8
@@ -194,14 +194,28 @@ describe("CursorTextGeneration", () => {
194
}).pipe(Effect.provide(layerTest)),
195
);
196
197
- it.effect.each(["error", "cancelled"] as const)(
198
- "rejects a %s Cursor SDK run that includes valid title JSON",
199
- (status) =>
197
+ it.effect.each([
198
+ {
199
+ status: "error",
200
+ error: { message: "Raw Cursor usage text", code: "PRO_USER_USAGE_LIMIT" },
201
+ detail:
202
+ "Cursor usage limit reached. Try again later or choose another text-generation provider.",
203
+ },
204
+ {
205
+ status: "error",
206
+ error: { message: "Raw Cursor backend text", code: "internal" },
207
+ detail: "Cursor SDK request finished with an error.",
208
+ },
209
+ { status: "cancelled", error: undefined, detail: "Cursor SDK request was cancelled." },
210
+ ] as const)(
211
+ "rejects a $status Cursor SDK run ($error.code) that includes valid title JSON",
212
+ ({ status, error, detail }) =>
213
Effect.gen(function* () {
214
const promptResult = {
215
id: "run-cursor-partial-title-test",
216
status,
217
result: '{"title":"Partial title from a failed run."}',
218
+ ...(error ? { error } : {}),
219
} satisfies RunResult;
220
cursorSdkMock.prompt.mockResolvedValueOnce(promptResult);
221
const generation = yield* makeCursorTextGeneration(cursorSettings, {
@@ -219,11 +233,9 @@ describe("CursorTextGeneration", () => {
233
);
234
expect(failure).toBeInstanceOf(TextGenerationError);
235
expect(failure.operation).toBe("generateThreadTitle");
222
- expect(failure.detail).toBe(
223
- status === "cancelled"
224
- ? "Cursor SDK request was cancelled."
225
- : "Cursor SDK request finished with an error.",
226
- );
236
+ expect(failure.detail).toBe(detail);
237
+ expect(failure.message).not.toContain("Raw Cursor");
238
+ expect(failure.cause).toBe(error);
239
expect(cursorSdkMock.close).toHaveBeenCalledOnce();
240
}).pipe(Effect.provide(layerTest)),
241
);
packages/provider-cursor/src/server/textGeneration.ts
+5
-1
@@ -11,6 +11,7 @@ import type { CursorSettings } from "../settings.ts";
11
import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations";
12
import { cursorSdkModelSelection } from "./sdkModel.ts";
13
import type { CursorAuth } from "./auth.ts";
14
+import * as CursorAgentSdk from "./CursorAgentSdk.ts";
15
import * as CursorSdk from "./CursorSdk.ts";
16
import * as HostProcess from "@t3tools/shared/HostProcess";
17
@@ -23,7 +24,9 @@ function cursorSdkResultDetail(result: RunResult): string {
24
case "cancelled":
25
return "Cursor SDK request was cancelled.";
26
case "error":
26
- return "Cursor SDK request finished with an error.";
27
+ return CursorAgentSdk.isCursorUsageLimitError(result.error)
28
+ ? "Cursor usage limit reached. Try again later or choose another text-generation provider."
29
+ : "Cursor SDK request finished with an error.";
30
case "finished":
31
return "Cursor SDK returned empty output.";
32
}
@@ -182,6 +185,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu
185
return yield* new TextGenerationError({
186
operation,
187
detail: cursorSdkResultDetail(promptResult),
188
+ ...(promptResult.error ? { cause: promptResult.error } : {}),
189
});
190
}
191