Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/web/src/components/chat/ComposerModelEffort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
36 changes: 36 additions & 0 deletions packages/client-runtime/src/modelTraits.test.ts
Original file line number Diff line number Diff line change
@@ -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<ProviderOptionDescriptor, { type: "select" }> = {
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);
});
});
4 changes: 2 additions & 2 deletions packages/client-runtime/src/modelTraits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading