Skip to content

Commit b176442

Browse files
t3dotggclaude
andcommitted
fix(web): hide Ultrathink from the Claude effort picker
Typing ultrathink in the prompt still works. The picker, the mobile settings sheet, and keyboard effort stepping no longer offer it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cadf7d5 commit b176442

7 files changed

Lines changed: 49 additions & 139 deletions

File tree

‎apps/mobile/src/features/threads/ThreadSettingsSheet.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,10 @@ function ThreadSettingsSessionProvider(
559559
props.onPromptChange(change.prompt);
560560
}
561561
}
562-
if (!("modelOptions" in change)) return;
563562
}
564-
const next =
565-
change && "modelOptions" in change
566-
? (change.modelOptions ?? [])
567-
: applyProviderOptionSelection(displayedDescriptors, { id, value });
563+
const next = change
564+
? (change.modelOptions ?? [])
565+
: applyProviderOptionSelection(displayedDescriptors, { id, value });
568566
if (!next) {
569567
return;
570568
}

‎apps/mobile/src/features/threads/thread-settings-options.test.ts‎

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,17 @@ const effortDescriptor: Extract<ProviderOptionDescriptor, { type: "select" }> =
2424

2525
describe("selectableChoices", () => {
2626
// regression: #21406 bring model controls in line with web
27-
it("includes prompt-injected and workflow choices in declared order", () => {
27+
it("leaves out prompt-injected choices and keeps workflow choices in declared order", () => {
2828
expect(selectableChoices(effortDescriptor).map((choice) => choice.id)).toEqual([
2929
"low",
3030
"medium",
3131
"high",
32-
"ultrathink",
3332
"ultracode",
3433
]);
3534
});
3635
});
3736

3837
describe("prompt-controlled reasoning", () => {
39-
it("adds Ultrathink to the prompt without persisting an injected option", () => {
40-
const descriptors = [effortDescriptor];
41-
const change = getTraitSelectChange(
42-
{ ...getPromptControlledTraits(descriptors, "solve it"), descriptors },
43-
effortDescriptor,
44-
"solve it",
45-
"ultrathink",
46-
);
47-
expect(change).toEqual({ prompt: "Ultrathink:\nsolve it" });
48-
expect(
49-
getPromptControlledTraits(descriptors, change?.prompt ?? "").ultrathinkPromptControlled,
50-
).toBe(true);
51-
expect(
52-
getTraitSelectChange(
53-
{ ...getPromptControlledTraits(descriptors, ""), descriptors },
54-
effortDescriptor,
55-
"",
56-
"ultrathink",
57-
),
58-
).toEqual({ prompt: "Ultrathink:\n" });
59-
});
60-
6138
it("removes the prefix when choosing a regular effort and saves Ultracode as an option", () => {
6239
const descriptors = [effortDescriptor];
6340
const prompt = "Ultrathink:\nsolve it";
@@ -71,19 +48,11 @@ describe("prompt-controlled reasoning", () => {
7148
).toEqual({ prompt: "solve it", modelOptions: [{ id: "effort", value: "ultracode" }] });
7249
});
7350

74-
it("keeps body-controlled Ultrathink locked and preserves slash commands", () => {
51+
it("keeps body-controlled Ultrathink locked", () => {
7552
const descriptors = [effortDescriptor];
7653
const prompt = "please ultrathink about this";
7754
const selected = { ...getPromptControlledTraits(descriptors, prompt), descriptors };
7855
expect(selected.ultrathinkInBodyText).toBe(true);
7956
expect(getTraitSelectChange(selected, effortDescriptor, prompt, "low")).toBeNull();
80-
expect(
81-
getTraitSelectChange(
82-
{ ...getPromptControlledTraits(descriptors, "/review"), descriptors },
83-
effortDescriptor,
84-
"/review",
85-
"ultrathink",
86-
),
87-
).toEqual({ prompt: "/review" });
8857
});
8958
});

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,15 +2834,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
28342834
direction,
28352835
});
28362836
if (!change) return;
2837-
if (change.modelOptions) {
2838-
useComposerDraftStore
2839-
.getState()
2840-
.setProviderModelOptions(composerDraftTarget, selectedProvider, change.modelOptions, {
2841-
instanceId: selectedInstanceId,
2842-
model: selectedModel,
2843-
persistSticky: true,
2844-
});
2845-
}
2837+
useComposerDraftStore
2838+
.getState()
2839+
.setProviderModelOptions(composerDraftTarget, selectedProvider, change.modelOptions, {
2840+
instanceId: selectedInstanceId,
2841+
model: selectedModel,
2842+
persistSticky: true,
2843+
});
28462844
if (change.prompt !== promptRef.current) {
28472845
applyPromptReplacementStable(0, promptRef.current.length, change.prompt, {
28482846
expandedCursorAfterReplace: change.cursor,

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

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
replaceDescriptorCurrentValue,
66
selectableProviderOptionChoices,
77
REASONING_SELECT_DESCRIPTOR_IDS,
8-
ULTRATHINK_PROMPT_PREFIX,
98
} from "@t3tools/client-runtime/model-traits";
109
import {
1110
type ModelSelection,
@@ -261,36 +260,21 @@ export function getReasoningTraitStep(input: {
261260
const descriptor = selected.selectDescriptors.find((entry) =>
262261
REASONING_SELECT_DESCRIPTOR_IDS.has(entry.id),
263262
);
264-
if (!descriptor || descriptor.options.length < 2) return null;
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-
const ordered = input.direction > 0 ? descriptor.options : descriptor.options.toReversed();
263+
const choices = descriptor ? selectableProviderOptionChoices(descriptor) : [];
264+
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();
275271
const position =
276272
[current, getDescriptorStringValue(descriptor)]
277273
.map((value) => ordered.findIndex((option) => option.id === value))
278274
.find((index) => index >= 0) ?? -1;
279-
for (const option of [
280-
...ordered.slice(position + 1),
281-
...ordered.slice(0, Math.max(position, 0)),
282-
]) {
283-
const change = getTraitSelectChange(selected, descriptor, input.prompt, option.id);
284-
if (!change) return null;
285-
if ("modelOptions" in change) {
286-
return change.modelOptions
287-
? { prompt: change.prompt, modelOptions: change.modelOptions }
288-
: null;
289-
}
290-
// A slash command refuses the Ultrathink prefix, so skip that level.
291-
if (change.prompt.startsWith(ULTRATHINK_PROMPT_PREFIX)) return change;
292-
}
293-
return null;
275+
const next = ordered[(position + 1) % ordered.length];
276+
const change = next && getTraitSelectChange(selected, descriptor, input.prompt, next.id);
277+
return change?.modelOptions ? { prompt: change.prompt, modelOptions: change.modelOptions } : null;
294278
}
295279

296280
export function shouldRenderTraitsControls(input: {
@@ -393,7 +377,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
393377
onPromptEdit?.(
394378
(prompt) => getTraitSelectChange(selected, descriptor, prompt, value)?.prompt ?? prompt,
395379
);
396-
if ("modelOptions" in change) updateModelOptions(change.modelOptions);
380+
updateModelOptions(change.modelOptions);
397381
};
398382

399383
if (!hasAnyControls) {

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

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -324,48 +324,25 @@ describe("getComposerReasoningStep", () => {
324324
).toStrictEqual(selections(["thinking_level", "high"]));
325325
});
326326

327-
it("adds and strips the Ultrathink prefix while the caret stays on the same character", () => {
328-
for (const { prompt, modelOptions, direction, expected } of [
329-
{
330-
prompt: " Fix the bug \n",
331-
modelOptions: selections(["effort", "high"]),
332-
direction: 1,
333-
expected: { prompt: "Ultrathink:\nFix the bug", cursor: 20 },
334-
},
335-
{
336-
prompt: "Ultrathink:\n Fix the bug",
337-
modelOptions: selections(["effort", "medium"]),
338-
direction: -1,
339-
expected: {
340-
prompt: "Fix the bug",
341-
cursor: 8,
342-
modelOptions: selections(["effort", "high"]),
343-
},
344-
},
345-
] as const) {
346-
const result = step({
347-
...CLAUDE,
348-
prompt,
349-
cursor: prompt.indexOf("bug"),
350-
modelOptions,
351-
direction,
352-
});
353-
expect(result).toStrictEqual(expected);
354-
expect(result?.prompt.slice(result.cursor)).toMatch(/^bug/);
355-
}
356-
expect(
357-
step({ ...CLAUDE, prompt: " Fix", modelOptions: selections(["effort", "high"]) })?.cursor,
358-
).toBe("Ultrathink:\n".length);
359-
});
360-
361-
it("skips Ultrathink for slash commands and does nothing when the prompt locks it", () => {
362-
expect(
363-
step({ ...CLAUDE, prompt: "/review", modelOptions: selections(["effort", "high"]) }),
364-
).toStrictEqual({
365-
prompt: "/review",
327+
it("never steps into Ultrathink and strips a typed prefix with the caret on the same character", () => {
328+
expect(step({ ...CLAUDE, modelOptions: selections(["effort", "high"]) })).toStrictEqual({
329+
prompt: "Fix the bug",
366330
cursor: 0,
367331
modelOptions: selections(["effort", "medium"]),
368332
});
333+
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+
});
369346
for (const [prompt, direction] of [
370347
["Please ultrathink harder", 1],
371348
["Ultrathink:\nPlease ultrathink harder", -1],

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function getComposerProviderState(input: ComposerProviderStateInput): Com
165165
};
166166
}
167167

168-
/** Expanded caret positions stay on the same character across Ultrathink prefix changes. */
168+
/** The caret stays on the same character when stepping strips a typed Ultrathink prefix. */
169169
export function getComposerReasoningStep(input: {
170170
provider: ProviderDriverKind;
171171
instanceId: ProviderInstanceId;
@@ -180,7 +180,7 @@ export function getComposerReasoningStep(input: {
180180
}): {
181181
prompt: string;
182182
cursor: number;
183-
modelOptions?: ReadonlyArray<ProviderOptionSelection>;
183+
modelOptions: ReadonlyArray<ProviderOptionSelection>;
184184
} | null {
185185
const { prompt, cursor } = input;
186186
const { selections } = resolveComposerOptionSelections(
@@ -202,18 +202,10 @@ export function getComposerReasoningStep(input: {
202202
direction: input.direction,
203203
});
204204
if (!step) return null;
205-
const modelOptions = "modelOptions" in step ? { modelOptions: step.modelOptions } : {};
206-
if (step.prompt === prompt) return { prompt, cursor, ...modelOptions };
207-
// Adding the prefix also trims the prompt.
208-
const keptStart = "modelOptions" in step ? 0 : step.prompt.length - prompt.trim().length;
209-
const offset =
210-
"modelOptions" in step
211-
? step.prompt.length - prompt.length
212-
: keptStart - (prompt.length - prompt.trimStart().length);
213205
return {
214206
prompt: step.prompt,
215-
cursor: Math.min(step.prompt.length, Math.max(keptStart, cursor + offset)),
216-
...modelOptions,
207+
cursor: Math.max(0, cursor + step.prompt.length - prompt.length),
208+
modelOptions: step.modelOptions,
217209
};
218210
}
219211

‎packages/client-runtime/src/modelTraits.ts‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ import type {
44
ProviderOptionDescriptor,
55
} from "@t3tools/contracts";
66
import {
7-
applyClaudePromptEffortPrefix,
87
buildProviderOptionSelectionsFromDescriptors,
98
getProviderOptionCurrentLabel,
109
getProviderOptionCurrentValue,
1110
isClaudeUltrathinkPrompt,
1211
} from "@t3tools/shared/model";
1312
import { REASONING_EFFORT_OPTION_IDS } from "./state/threadExecution.ts";
1413

15-
export const ULTRATHINK_PROMPT_PREFIX = "Ultrathink:\n";
16-
1714
export const REASONING_SELECT_DESCRIPTOR_IDS: ReadonlySet<string> = new Set([
1815
...REASONING_EFFORT_OPTION_IDS,
1916
"thinking",
@@ -51,10 +48,13 @@ export function getDescriptorStringValue(
5148
return typeof value === "string" ? value : null;
5249
}
5350

51+
// Prompt-injected levels such as Ultrathink still work when typed, but pickers do not offer them.
5452
export function selectableProviderOptionChoices(
5553
descriptor: Extract<ProviderOptionDescriptor, { type: "select" }>,
5654
) {
57-
return descriptor.options;
55+
return descriptor.options.filter(
56+
(option) => !descriptor.promptInjectedValues?.includes(option.id),
57+
);
5858
}
5959

6060
export function getPromptControlledTraits(
@@ -81,15 +81,7 @@ export function getTraitSelectChange(
8181
prompt: string,
8282
value: string,
8383
) {
84-
if (!value) return null;
85-
if (descriptor.promptInjectedValues?.includes(value)) {
86-
return {
87-
prompt:
88-
prompt.trim().length === 0
89-
? ULTRATHINK_PROMPT_PREFIX
90-
: applyClaudePromptEffortPrefix(prompt, "ultrathink"),
91-
};
92-
}
84+
if (!value || descriptor.promptInjectedValues?.includes(value)) return null;
9385
const isPrimary = descriptor.id === selected.primarySelectDescriptor?.id;
9486
if (isPrimary && selected.ultrathinkInBodyText) return null;
9587
return {

0 commit comments

Comments
 (0)