diff --git a/apps/web/src/components/chat/ComposerModelEffort.tsx b/apps/web/src/components/chat/ComposerModelEffort.tsx index 35fd11c98be7c..10a4f7fa91892 100644 --- a/apps/web/src/components/chat/ComposerModelEffort.tsx +++ b/apps/web/src/components/chat/ComposerModelEffort.tsx @@ -130,7 +130,11 @@ export function describeComposerEffort( ? `${reasoning.label} ${reasoning.currentValue === true ? "On" : "Off"}` : ultrathink ? "Ultrathink" - : getProviderOptionCurrentLabel(reasoning, modelSelection, traits.reportedModelSelection); + : (getProviderOptionCurrentLabel( + reasoning, + modelSelection, + traits.reportedModelSelection, + ) ?? (reasoning.id === "thinking" ? reasoning.label : null)); const fast = display.speedLabel === "Fast" || display.speedLabel === "Ultrafast"; // Agent options such as modes live in the picker; the trigger adds only the context window. const contextWindow = diff --git a/packages/client-runtime/src/modelTraits.test.ts b/packages/client-runtime/src/modelTraits.test.ts new file mode 100644 index 0000000000000..67b22e3099464 --- /dev/null +++ b/packages/client-runtime/src/modelTraits.test.ts @@ -0,0 +1,36 @@ +import { ProviderDriverKind, type ProviderOptionDescriptor } from "@t3tools/contracts"; +import { describe, expect, it } from "vite-plus/test"; + +import { buildTraitsTriggerDisplay, getDescriptorStringValue } from "./modelTraits.ts"; + +describe("buildTraitsTriggerDisplay", () => { + it.each([ + { currentValue: undefined, defaultValue: undefined, value: null, label: "Thinking" }, + { currentValue: undefined, defaultValue: "high", value: "high", label: "High" }, + { currentValue: "low", defaultValue: undefined, value: "low", label: "Low" }, + { currentValue: "max", defaultValue: "high", value: "max", label: "Max" }, + { id: "effort", currentValue: undefined, defaultValue: undefined, value: null, label: "" }, + ])("labels Pi thinking without inventing a selection: $label ($value)", (input) => { + const descriptor: Extract = { + id: input.id ?? "thinking", + label: "Thinking", + type: "select", + options: ["low", "high", "max"].map((id) => ({ + id, + label: id[0]!.toUpperCase() + id.slice(1), + ...(id === input.defaultValue ? { isDefault: true } : {}), + })), + ...(input.currentValue ? { currentValue: input.currentValue } : {}), + }; + + expect( + buildTraitsTriggerDisplay({ + provider: ProviderDriverKind.make("pi"), + descriptors: [descriptor], + primarySelectDescriptorId: descriptor.id, + ultrathinkPromptControlled: false, + }).label, + ).toBe(input.label); + expect(getDescriptorStringValue(descriptor)).toBe(input.value); + }); +}); diff --git a/packages/client-runtime/src/modelTraits.ts b/packages/client-runtime/src/modelTraits.ts index 9a3dc06a15173..3782b79e567f8 100644 --- a/packages/client-runtime/src/modelTraits.ts +++ b/packages/client-runtime/src/modelTraits.ts @@ -169,11 +169,11 @@ export function buildTraitsTriggerDisplay(input: { ? "Ultrathink" : descriptor.type === "boolean" ? `${descriptor.label} ${descriptor.currentValue === true ? "On" : "Off"}` - : getProviderOptionCurrentLabel( + : (getProviderOptionCurrentLabel( descriptor, input.modelSelection, input.reportedModelSelection, - ); + ) ?? (descriptor.id === "thinking" ? descriptor.label : null)); if (typeof label === "string" && label.length > 0) { if (reasoningLabelIndex === -1 && isReasoningSelect(descriptor)) { reasoningLabelIndex = labels.length;