Skip to content

Commit eeb6e23

Browse files
fix(web): keep Pi thinking controls visible before selection (pingdotgg#27397)
Co-authored-by: maria-rcks <[email protected]>
1 parent beaeeff commit eeb6e23

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ export function describeComposerEffort(
130130
? `${reasoning.label} ${reasoning.currentValue === true ? "On" : "Off"}`
131131
: ultrathink
132132
? "Ultrathink"
133-
: getProviderOptionCurrentLabel(reasoning, modelSelection, traits.reportedModelSelection);
133+
: (getProviderOptionCurrentLabel(
134+
reasoning,
135+
modelSelection,
136+
traits.reportedModelSelection,
137+
) ?? (reasoning.id === "thinking" ? reasoning.label : null));
134138
const fast = display.speedLabel === "Fast" || display.speedLabel === "Ultrafast";
135139
// Agent options such as modes live in the picker; the trigger adds only the context window.
136140
const contextWindow =
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ProviderDriverKind, type ProviderOptionDescriptor } from "@t3tools/contracts";
2+
import { describe, expect, it } from "vite-plus/test";
3+
4+
import { buildTraitsTriggerDisplay, getDescriptorStringValue } from "./modelTraits.ts";
5+
6+
describe("buildTraitsTriggerDisplay", () => {
7+
it.each([
8+
{ currentValue: undefined, defaultValue: undefined, value: null, label: "Thinking" },
9+
{ currentValue: undefined, defaultValue: "high", value: "high", label: "High" },
10+
{ currentValue: "low", defaultValue: undefined, value: "low", label: "Low" },
11+
{ currentValue: "max", defaultValue: "high", value: "max", label: "Max" },
12+
{ id: "effort", currentValue: undefined, defaultValue: undefined, value: null, label: "" },
13+
])("labels Pi thinking without inventing a selection: $label ($value)", (input) => {
14+
const descriptor: Extract<ProviderOptionDescriptor, { type: "select" }> = {
15+
id: input.id ?? "thinking",
16+
label: "Thinking",
17+
type: "select",
18+
options: ["low", "high", "max"].map((id) => ({
19+
id,
20+
label: id[0]!.toUpperCase() + id.slice(1),
21+
...(id === input.defaultValue ? { isDefault: true } : {}),
22+
})),
23+
...(input.currentValue ? { currentValue: input.currentValue } : {}),
24+
};
25+
26+
expect(
27+
buildTraitsTriggerDisplay({
28+
provider: ProviderDriverKind.make("pi"),
29+
descriptors: [descriptor],
30+
primarySelectDescriptorId: descriptor.id,
31+
ultrathinkPromptControlled: false,
32+
}).label,
33+
).toBe(input.label);
34+
expect(getDescriptorStringValue(descriptor)).toBe(input.value);
35+
});
36+
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ export function buildTraitsTriggerDisplay(input: {
169169
? "Ultrathink"
170170
: descriptor.type === "boolean"
171171
? `${descriptor.label} ${descriptor.currentValue === true ? "On" : "Off"}`
172-
: getProviderOptionCurrentLabel(
172+
: (getProviderOptionCurrentLabel(
173173
descriptor,
174174
input.modelSelection,
175175
input.reportedModelSelection,
176-
);
176+
) ?? (descriptor.id === "thinking" ? descriptor.label : null));
177177
if (typeof label === "string" && label.length > 0) {
178178
if (reasoningLabelIndex === -1 && isReasoningSelect(descriptor)) {
179179
reasoningLabelIndex = labels.length;

0 commit comments

Comments
 (0)