Skip to content

Commit 36862bf

Browse files
t3dotggclaude
andcommitted
fix(web): stepping effort from a typed Ultrathink keeps its old order
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7a8b13e commit 36862bf

2 files changed

Lines changed: 32 additions & 19 deletions

File tree

‎apps/web/src/components/chat/TraitsPicker.tsx‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,24 @@ export function getReasoningTraitStep(input: {
262262
);
263263
const choices = descriptor ? selectableProviderOptionChoices(descriptor) : [];
264264
if (!descriptor || choices.length < 2) return null;
265-
const current = getDescriptorStringValue(
266-
descriptor,
267-
{ instanceId: input.instanceId, model: input.model, options: input.modelOptions ?? [] },
268-
input.reportedModelSelection,
269-
);
270-
const ordered = input.direction > 0 ? choices : choices.toReversed();
265+
const isPrimary = descriptor.id === selected.primarySelectDescriptor?.id;
266+
const current =
267+
isPrimary && selected.ultrathinkPromptControlled
268+
? "ultrathink"
269+
: getDescriptorStringValue(
270+
descriptor,
271+
{ instanceId: input.instanceId, model: input.model, options: input.modelOptions ?? [] },
272+
input.reportedModelSelection,
273+
);
274+
// Walk the full catalog order so a typed Ultrathink keeps its place, then land on a pickable level.
275+
const ordered = input.direction > 0 ? descriptor.options : descriptor.options.toReversed();
271276
const position =
272277
[current, getDescriptorStringValue(descriptor)]
273278
.map((value) => ordered.findIndex((option) => option.id === value))
274279
.find((index) => index >= 0) ?? -1;
275-
const next = ordered[(position + 1) % ordered.length];
280+
const next = [...ordered.slice(position + 1), ...ordered.slice(0, Math.max(position, 0))].find(
281+
(option) => choices.includes(option),
282+
);
276283
const change = next && getTraitSelectChange(selected, descriptor, input.prompt, next.id);
277284
return change?.modelOptions ? { prompt: change.prompt, modelOptions: change.modelOptions } : null;
278285
}

‎apps/web/src/components/chat/composerProviderState.test.tsx‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,24 @@ describe("getComposerReasoningStep", () => {
331331
modelOptions: selections(["effort", "medium"]),
332332
});
333333
const prompt = "Ultrathink:\n Fix the bug";
334-
const result = step({
335-
...CLAUDE,
336-
prompt,
337-
cursor: prompt.indexOf("bug"),
338-
modelOptions: selections(["effort", "medium"]),
339-
direction: -1,
340-
});
341-
expect(result).toStrictEqual({
342-
prompt: "Fix the bug",
343-
cursor: 8,
344-
modelOptions: selections(["effort", "high"]),
345-
});
334+
// A typed Ultrathink sits above the pickable levels, so up wraps and down lands on the top level.
335+
for (const [direction, to] of [
336+
[-1, "high"],
337+
[1, "medium"],
338+
] as const) {
339+
const result = step({
340+
...CLAUDE,
341+
prompt,
342+
cursor: prompt.indexOf("bug"),
343+
modelOptions: selections(["effort", "medium"]),
344+
direction,
345+
});
346+
expect(result, `by ${direction}`).toStrictEqual({
347+
prompt: "Fix the bug",
348+
cursor: 8,
349+
modelOptions: selections(["effort", to]),
350+
});
351+
}
346352
for (const [prompt, direction] of [
347353
["Please ultrathink harder", 1],
348354
["Ultrathink:\nPlease ultrathink harder", -1],

0 commit comments

Comments
 (0)