Skip to content

Commit 2942ffa

Browse files
Huijirocursoragent
andcommitted
fix(cursor): ignore Max Mode when params have no max variant
Composer can leave Max Mode on after switching to a param set that only has non-max catalog variants; require a matching isMaxMode variant before honoring the option. Co-authored-by: Cursor <[email protected]>
1 parent b506d51 commit 2942ffa

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ describe("cursorSdkModelSelection", () => {
7373
isMaxMode: true,
7474
params: [{ id: "fast", value: "false" }],
7575
},
76+
{
77+
displayName: "Composer Fast",
78+
params: [{ id: "fast", value: "true" }],
79+
},
7680
],
7781
},
7882
];
@@ -109,6 +113,22 @@ describe("cursorSdkModelSelection", () => {
109113
id: "composer-2",
110114
params: [{ id: "fast", value: "false" }],
111115
});
116+
expect(
117+
cursorSdkModelSelection(
118+
{
119+
instanceId,
120+
model: "composer-2",
121+
options: [
122+
{ id: "fastMode", value: true },
123+
{ id: CURSOR_SDK_MAX_MODE_OPTION_ID, value: true },
124+
],
125+
},
126+
catalog,
127+
),
128+
).toEqual({
129+
id: "composer-2",
130+
params: [{ id: "fast", value: "true" }],
131+
});
112132
});
113133
});
114134

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ export function cursorSdkMaxModeForParams(
8484
return matching.length > 0 && matching.every((variant) => variant.isMaxMode === true);
8585
}
8686

87+
function cursorSdkParamsAdmitMaxMode(
88+
model: Pick<SDKModel, "variants">,
89+
params: ReadonlyArray<ModelParameterValue> | undefined,
90+
): boolean {
91+
return (model.variants ?? []).some(
92+
(variant) => variantMatchesParams(variant, params) && variant.isMaxMode === true,
93+
);
94+
}
95+
8796
export function cursorSdkModelOffersOptionalMaxMode(model: Pick<SDKModel, "variants">): boolean {
8897
const variants = model.variants ?? [];
8998
if (
@@ -128,9 +137,12 @@ export function cursorSdkModelSelection(
128137
value: String(option.value),
129138
}));
130139
const catalogModel = sdkModels?.find((model) => model.id === id);
131-
const maxMode =
132-
userRequestedMaxMode ||
133-
(catalogModel !== undefined && cursorSdkMaxModeForParams(catalogModel, params));
140+
const forcedMaxMode =
141+
catalogModel !== undefined && cursorSdkMaxModeForParams(catalogModel, params);
142+
const optionalMaxMode =
143+
userRequestedMaxMode &&
144+
(catalogModel === undefined || cursorSdkParamsAdmitMaxMode(catalogModel, params));
145+
const maxMode = forcedMaxMode || optionalMaxMode;
134146
return {
135147
id,
136148
...(params === undefined ? {} : { params }),

0 commit comments

Comments
 (0)