Skip to content

Commit c5ccadd

Browse files
fix(provider-cursor): keep the last Cursor catalog when a check fails
A provider check that cannot read Cursor's catalog (a failed or timed-out request, no API key, a disabled provider) lists only custom models. Recording that list dropped the catalog default, so selections without a contextWindow option fell back to the 128k window until the next good check. Record a check's models only when they include catalog models. Co-authored-by: Cursor <[email protected]>
1 parent 8c6d4af commit c5ccadd

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/provider-cursor/src/server/driver.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ it.layer(layerTest)("CursorDriver", (it) => {
148148
}).pipe(Effect.scoped),
149149
);
150150

151-
it.effect("reports the catalog's default context window once the Cursor catalog loads", () =>
151+
it.effect("reports the default context window from the last loaded Cursor catalog", () =>
152152
Effect.gen(function* () {
153153
const catalog = Promise.withResolvers<Array<SDKModel>>();
154154
const me = vi.spyOn(Cursor, "me").mockResolvedValue({
@@ -218,6 +218,10 @@ it.layer(layerTest)("CursorDriver", (it) => {
218218
yield* instance.snapshot.refresh;
219219
expect(runtime.getModelContextWindow?.(selection())).toBe(1_000_000);
220220
expect(runtime.getModelContextWindow?.(selection("300k"))).toBe(300_000);
221+
222+
me.mockRejectedValue(new Error("Cursor is unreachable"));
223+
expect((yield* instance.snapshot.refresh).status).toBe("error");
224+
expect(runtime.getModelContextWindow?.(selection())).toBe(1_000_000);
221225
}).pipe(Effect.scoped),
222226
);
223227

‎packages/provider-cursor/src/server/driver.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
230230
Effect.map(stampSnapshot),
231231
Effect.tap((provider) =>
232232
Effect.sync(() => {
233-
catalogModels = provider.models;
233+
// A failed check lists only custom models, so keep the last loaded catalog.
234+
if (provider.models.some((model) => !model.isCustom)) {
235+
catalogModels = provider.models;
236+
}
234237
}),
235238
),
236239
Effect.provide(CursorSdkCatalog.layer),

0 commit comments

Comments
 (0)