Skip to content

Commit 42eec11

Browse files
committed
fix(clients): compact thinking status in composer labels
1 parent a1fd17a commit 42eec11

3 files changed

Lines changed: 74 additions & 4 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function describeComposerEffort(
9595
reportedModelSelection: traits.reportedModelSelection,
9696
});
9797
const glyph =
98-
primary && REASONING_SELECT_DESCRIPTOR_IDS.has(primary.id)
98+
!display.thinkingOff && primary && REASONING_SELECT_DESCRIPTOR_IDS.has(primary.id)
9999
? resolveEffortGlyph(
100100
primary,
101101
visibility.ultrathinkPromptControlled
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
import { ProviderDriverKind, type ProviderOptionDescriptor } from "@t3tools/contracts";
3+
4+
import { buildTraitsTriggerDisplay } from "./modelTraits.ts";
5+
6+
describe("composer thinking summary", () => {
7+
it.each([
8+
{ thinking: true, toggleFirst: false, label: "Extra High · 1M" },
9+
{ thinking: true, toggleFirst: true, label: "Extra High · 1M" },
10+
{ thinking: false, toggleFirst: false, label: "Off · 1M" },
11+
{ thinking: false, toggleFirst: true, label: "Off · 1M" },
12+
])("shows $label with thinking=$thinking and toggleFirst=$toggleFirst", (testCase) => {
13+
const thinking: ProviderOptionDescriptor = {
14+
id: "thinking",
15+
label: "Thinking",
16+
type: "boolean",
17+
currentValue: testCase.thinking,
18+
};
19+
const effort: ProviderOptionDescriptor = {
20+
id: "effort",
21+
label: "Reasoning",
22+
type: "select",
23+
currentValue: "xhigh",
24+
options: [{ id: "xhigh", label: "Extra High" }],
25+
};
26+
const descriptors: Array<ProviderOptionDescriptor> = [
27+
...(testCase.toggleFirst ? [thinking, effort] : [effort, thinking]),
28+
{
29+
id: "contextWindow",
30+
label: "Context Window",
31+
type: "select",
32+
currentValue: "1m",
33+
options: [{ id: "1m", label: "1M" }],
34+
},
35+
];
36+
expect(
37+
buildTraitsTriggerDisplay({
38+
provider: ProviderDriverKind.make("claudeAgent"),
39+
descriptors,
40+
primarySelectDescriptorId: "effort",
41+
ultrathinkPromptControlled: false,
42+
}),
43+
).toMatchObject({
44+
label: testCase.label,
45+
otherLabels: ["1M"],
46+
thinkingOff: !testCase.thinking,
47+
});
48+
});
49+
});

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,35 @@ export function buildTraitsTriggerDisplay(input: {
106106
label: string;
107107
/** "Fast" or "Ultrafast" when a speed option is on. */
108108
speedLabel: string | null;
109-
/** Labels other than reasoning and speed, such as context window or thinking. */
109+
/** Labels other than reasoning and speed, such as context window. */
110110
otherLabels: ReadonlyArray<string>;
111+
thinkingOff: boolean;
111112
} {
113+
const thinkingOff = input.descriptors.some(
114+
(descriptor) =>
115+
descriptor.id === "thinking" &&
116+
descriptor.type === "boolean" &&
117+
descriptor.currentValue === false,
118+
);
112119
let fastModeFallbackLabel: string | null = null;
113120
let speedLabel: string | null = null;
114121
let reasoningLabelIndex = -1;
115122
const labels: Array<string> = [];
116123
for (const descriptor of input.descriptors) {
124+
if (descriptor.id === "thinking" && descriptor.type === "boolean") {
125+
if (thinkingOff) {
126+
reasoningLabelIndex = labels.length;
127+
labels.push("Off");
128+
}
129+
continue;
130+
}
131+
if (
132+
thinkingOff &&
133+
descriptor.type === "select" &&
134+
REASONING_SELECT_DESCRIPTOR_IDS.has(descriptor.id)
135+
) {
136+
continue;
137+
}
117138
if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
118139
speedLabel = descriptor.currentValue === true ? "Fast" : null;
119140
fastModeFallbackLabel = speedLabel ?? "Normal";
@@ -167,7 +188,7 @@ export function buildTraitsTriggerDisplay(input: {
167188

168189
const otherLabels = labels.filter((_, index) => index !== reasoningLabelIndex);
169190
if (labels.length === 0 && fastModeFallbackLabel !== null) {
170-
return { label: fastModeFallbackLabel, speedLabel, otherLabels };
191+
return { label: fastModeFallbackLabel, speedLabel, otherLabels, thinkingOff };
171192
}
172193
if (speedLabel) {
173194
if (reasoningLabelIndex >= 0) {
@@ -176,5 +197,5 @@ export function buildTraitsTriggerDisplay(input: {
176197
labels.push(speedLabel);
177198
}
178199
}
179-
return { label: labels.join(" · "), speedLabel, otherLabels };
200+
return { label: labels.join(" · "), speedLabel, otherLabels, thinkingOff };
180201
}

0 commit comments

Comments
 (0)