Skip to content

Commit ba9d7b9

Browse files
committed
fix(claude): Ultracode Off and saved Ultracode efforts reach Claude Code
Web and mobile kept only the option ids a selection saved, so a saved effort "ultracode" dispatched as xhigh without Ultracode. An Off toggle also sent nothing, leaving Ultracode from the user's settings.json on. Models with the toggle now always send it, like Fast Mode.
1 parent d8c48b5 commit ba9d7b9

4 files changed

Lines changed: 26 additions & 13 deletions

File tree

‎apps/server/src/claudeModelOptions.test.ts‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe("compileClaudeModelSelection", () => {
6060
expect(
6161
compileClaudeModelSelection(selection("claude-opus-5-5", [{ id: "effort", value: "max" }]))
6262
.settings,
63-
).toEqual({ fastMode: false });
63+
).toEqual({ fastMode: false, ultracode: false });
6464
expect(
6565
compileClaudeModelSelection(
6666
selection("claude-sonnet-4-6", [{ id: "ultracode", value: true }]),
@@ -80,14 +80,6 @@ describe("compileClaudeModelSelection", () => {
8080
{ id: "ultracode", value: false },
8181
]),
8282
),
83-
).toMatchObject({ effort: "xhigh", settings: { fastMode: false } });
84-
expect(
85-
compileClaudeModelSelection(
86-
selection("claude-opus-5-5", [
87-
{ id: "effort", value: "ultracode" },
88-
{ id: "ultracode", value: false },
89-
]),
90-
).settings,
91-
).not.toHaveProperty("ultracode");
83+
).toMatchObject({ effort: "xhigh", settings: { fastMode: false, ultracode: false } });
9284
});
9385
});

‎apps/server/src/claudeModelOptions.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ export function compileClaudeModelSelection(
4444
caps: capabilities,
4545
selections: selection.options,
4646
}).find((descriptor) => descriptor.id === "ultracode");
47-
const ultracode = ultracodeDescriptor?.type === "boolean" && ultracodeDescriptor.currentValue;
47+
// Explicit when supported, so an Off toggle overrides Ultracode set in the user's settings.json.
48+
const ultracode =
49+
ultracodeDescriptor?.type === "boolean"
50+
? (ultracodeDescriptor.currentValue ?? false)
51+
: undefined;
4852
const settings = {
4953
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
5054
...(typeof fastMode === "boolean" ? { fastMode } : {}),
51-
...(ultracode ? { ultracode: true } : {}),
55+
...(typeof ultracode === "boolean" ? { ultracode } : {}),
5256
};
5357
const apiModelId = resolveClaudeCatalogApiModelId(catalog, selection);
5458
const promptEffort = resolvePromptInjectedEffort(capabilities, rawEffort) ?? undefined;

‎packages/shared/src/model.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ describe("descriptor helpers", () => {
9898
["effort", "xhigh"],
9999
["ultracode", true],
100100
]);
101+
const saved = [{ id: "effort", value: "ultracode" }];
102+
expect(
103+
buildExplicitProviderOptionSelectionsFromDescriptors(
104+
getProviderOptionDescriptors({
105+
caps: { optionDescriptors: [effort, ultracode] },
106+
selections: saved,
107+
}),
108+
saved,
109+
),
110+
).toEqual([
111+
{ id: "effort", value: "xhigh" },
112+
{ id: "ultracode", value: true },
113+
]);
101114
const legacyEffort = {
102115
...effort,
103116
options: [...effort.options, { id: "ultracode", label: "Ultracode" }],

‎packages/shared/src/model.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ export function buildExplicitProviderOptionSelectionsFromDescriptors(
337337
if (!selections || selections.length === 0) {
338338
return undefined;
339339
}
340-
const explicitIds = new Set(selections.map((selection) => selection.id));
340+
const explicitIds = new Set(
341+
(withLegacyUltracodeEffort(descriptors ?? [], selections) ?? []).map(
342+
(selection) => selection.id,
343+
),
344+
);
341345
const normalized = buildProviderOptionSelectionsFromDescriptors(descriptors)?.filter(
342346
(selection) => explicitIds.has(selection.id),
343347
);

0 commit comments

Comments
 (0)