Skip to content

Commit 429296e

Browse files
committed
fix(web): label unset provider trait controls
1 parent 8564d5c commit 429296e

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

apps/web/src/components/chat/TraitsPicker.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,19 @@ describe("buildTraitsTriggerDisplay", () => {
128128
});
129129
});
130130

131-
it("stays blank when descriptors resolve to no label and there is no fast mode", () => {
132-
// A select with neither a currentValue nor an isDefault option yields no
133-
// label. Without a fastMode descriptor present that must stay blank rather
134-
// than falling through to a bogus "Normal".
131+
it("uses the descriptor label when a select has no current value", () => {
132+
// Profile-backed providers can deliberately leave a select unset. Keep the
133+
// trigger discoverable without presenting any option as selected.
135134
const unresolved: Extract<ProviderOptionDescriptor, { type: "select" }> = {
136135
id: "effort",
137-
label: "effort",
136+
label: "Effort",
138137
type: "select",
139138
options: [
140139
{ id: "low", label: "Low" },
141140
{ id: "high", label: "High" },
142141
],
143142
};
144-
expect(display([unresolved])).toEqual({ label: "", showFastModeIcon: false });
143+
expect(display([unresolved])).toEqual({ label: "Effort", showFastModeIcon: false });
145144
});
146145

147146
it("still renders the prompt-controlled ultrathink label alongside the bolt", () => {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ export function buildTraitsTriggerDisplay(input: {
411411
let fastModeFallbackLabel: string | null = null;
412412
let fastModeEnabled = false;
413413
const labels: Array<string> = [];
414+
const unresolvedSelectLabels: Array<string> = [];
414415
for (const descriptor of input.descriptors) {
415416
if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
416417
fastModeEnabled = descriptor.currentValue === true;
@@ -440,6 +441,8 @@ export function buildTraitsTriggerDisplay(input: {
440441
: getProviderOptionCurrentLabel(descriptor);
441442
if (typeof label === "string" && label.length > 0) {
442443
labels.push(label);
444+
} else if (descriptor.type === "select" && descriptor.label.trim().length > 0) {
445+
unresolvedSelectLabels.push(descriptor.label.trim());
443446
}
444447
}
445448

@@ -449,6 +452,9 @@ export function buildTraitsTriggerDisplay(input: {
449452
if (labels.length === 0 && fastModeFallbackLabel !== null) {
450453
return { label: fastModeFallbackLabel, showFastModeIcon: false };
451454
}
455+
if (labels.length === 0 && unresolvedSelectLabels.length > 0) {
456+
return { label: unresolvedSelectLabels.join(" · "), showFastModeIcon: fastModeEnabled };
457+
}
452458
return { label: labels.join(" · "), showFastModeIcon: fastModeEnabled };
453459
}
454460

0 commit comments

Comments
 (0)