Skip to content

Commit ef96de5

Browse files
committed
fix(web): keep Codex service tier labels readable
1 parent 9821bca commit ef96de5

2 files changed

Lines changed: 49 additions & 21 deletions

File tree

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

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ function fastModeDescriptor(
1616
return { id: "fastMode", label: "Fast Mode", type: "boolean", currentValue };
1717
}
1818

19+
function serviceTierDescriptor(
20+
currentValue: "default" | "priority" | "flex",
21+
): Extract<ProviderOptionDescriptor, { type: "select" }> {
22+
return {
23+
id: "serviceTier",
24+
label: "Service Tier",
25+
type: "select",
26+
options: [
27+
{ id: "default", label: "Standard", isDefault: true },
28+
{ id: "priority", label: "Fast" },
29+
{ id: "flex", label: "Flex" },
30+
],
31+
currentValue,
32+
};
33+
}
34+
1935
const EFFORT = selectDescriptor(
2036
"reasoningEffort",
2137
[
@@ -59,26 +75,35 @@ describe("buildTraitsTriggerDisplay", () => {
5975
});
6076
});
6177

62-
it("renders Codex's Standard and Fast service tiers as fast mode", () => {
63-
const serviceTier = selectDescriptor(
64-
"serviceTier",
65-
[
66-
{ id: "default", label: "Standard", isDefault: true },
67-
{ id: "priority", label: "Fast" },
68-
],
69-
"default",
70-
);
71-
72-
expect(display([EFFORT, serviceTier])).toEqual({
78+
it("treats Codex standard and fast service tiers as fast mode states", () => {
79+
expect(display([EFFORT, serviceTierDescriptor("default")])).toEqual({
7380
label: "High",
7481
showFastModeIcon: false,
7582
});
76-
expect(display([EFFORT, { ...serviceTier, currentValue: "priority" }])).toEqual({
83+
expect(display([EFFORT, serviceTierDescriptor("priority")])).toEqual({
7784
label: "High",
7885
showFastModeIcon: true,
7986
});
8087
});
8188

89+
it("keeps other Codex service tiers in the label", () => {
90+
expect(display([EFFORT, serviceTierDescriptor("flex")])).toEqual({
91+
label: "High · Flex",
92+
showFastModeIcon: false,
93+
});
94+
});
95+
96+
it("keeps the Codex service tier readable when it is the only trait", () => {
97+
expect(display([serviceTierDescriptor("default")])).toEqual({
98+
label: "Standard",
99+
showFastModeIcon: false,
100+
});
101+
expect(display([serviceTierDescriptor("priority")])).toEqual({
102+
label: "Fast",
103+
showFastModeIcon: false,
104+
});
105+
});
106+
82107
it("keeps non-fastMode booleans as text labels", () => {
83108
const thinking: Extract<ProviderOptionDescriptor, { type: "boolean" }> = {
84109
id: "thinking",

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,24 +382,25 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
382382

383383
/**
384384
* Build the traits trigger's text label plus whether the fast-mode bolt should
385-
* render. Fast mode is a lightning bolt when on and nothing at all when off —
386-
* "Normal" is the near-universal case and isn't worth the horizontal space. The
387-
* one exception is when fast mode is the only trait, where a bare bolt (or bare
388-
* chevron) would leave the trigger unreadable.
385+
* render. Claude and Cursor expose fast mode as a boolean, while Codex exposes
386+
* it through the Standard/Fast service tiers. In either form, fast mode is a
387+
* lightning bolt when on and nothing at all when off. The one exception is when
388+
* fast mode is the only trait, where a bare bolt (or bare chevron) would leave
389+
* the trigger unreadable.
389390
*/
390391
export function buildTraitsTriggerDisplay(input: {
391392
provider: ProviderDriverKind;
392393
descriptors: ReadonlyArray<ProviderOptionDescriptor>;
393394
primarySelectDescriptorId: string | null;
394395
ultrathinkPromptControlled: boolean;
395396
}): { label: string; showFastModeIcon: boolean } {
396-
let hasFastMode = false;
397+
let fastModeFallbackLabel: string | null = null;
397398
let fastModeEnabled = false;
398399
const labels: Array<string> = [];
399400
for (const descriptor of input.descriptors) {
400401
if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
401-
hasFastMode = true;
402402
fastModeEnabled = descriptor.currentValue === true;
403+
fastModeFallbackLabel = fastModeEnabled ? "Fast" : "Normal";
403404
continue;
404405
}
405406
if (
@@ -410,8 +411,10 @@ export function buildTraitsTriggerDisplay(input: {
410411
const currentValue = getProviderOptionCurrentValue(descriptor);
411412
const fastTier = descriptor.options.find(({ label }) => label === "Fast");
412413
if (fastTier && (currentValue === "default" || currentValue === fastTier.id)) {
413-
hasFastMode = true;
414414
fastModeEnabled = currentValue === fastTier.id;
415+
fastModeFallbackLabel =
416+
descriptor.options.find(({ id }) => id === currentValue)?.label ??
417+
(fastModeEnabled ? "Fast" : "Normal");
415418
continue;
416419
}
417420
}
@@ -429,8 +432,8 @@ export function buildTraitsTriggerDisplay(input: {
429432
// Only fall back to text when fast mode is genuinely the sole trait. Keying
430433
// off an empty label list alone would also catch descriptors that resolved to
431434
// no label at all, printing a bogus "Normal" for a model without fast mode.
432-
if (labels.length === 0 && hasFastMode) {
433-
return { label: fastModeEnabled ? "Fast" : "Normal", showFastModeIcon: false };
435+
if (labels.length === 0 && fastModeFallbackLabel !== null) {
436+
return { label: fastModeFallbackLabel, showFastModeIcon: false };
434437
}
435438
return { label: labels.join(" · "), showFastModeIcon: fastModeEnabled };
436439
}

0 commit comments

Comments
 (0)