fix(web): keep Codex service tier labels readable (#4503)

This commit is contained in:
Alex authored and GitHub committed 2026-08-22 16:07:56 -04:00
1 parent d9c1732b27
commit dedcd99a9d
2 files changed
+49 -21

No files matched your search

@@ -16,6 +16,22 @@ function fastModeDescriptor(
return { id: "fastMode", label: "Fast Mode", type: "boolean", currentValue };
}
function serviceTierDescriptor(
currentValue: "default" | "priority" | "flex",
): Extract<ProviderOptionDescriptor, { type: "select" }> {
return {
id: "serviceTier",
label: "Service Tier",
type: "select",
options: [
{ id: "default", label: "Standard", isDefault: true },
{ id: "priority", label: "Fast" },
{ id: "flex", label: "Flex" },
],
currentValue,
};
}
const EFFORT = selectDescriptor(
"reasoningEffort",
[
@@ -59,26 +75,35 @@ describe("buildTraitsTriggerDisplay", () => {
});
});
it("renders Codex's Standard and Fast service tiers as fast mode", () => {
const serviceTier = selectDescriptor(
"serviceTier",
[
{ id: "default", label: "Standard", isDefault: true },
{ id: "priority", label: "Fast" },
],
"default",
);
expect(display([EFFORT, serviceTier])).toEqual({
it("treats Codex standard and fast service tiers as fast mode states", () => {
expect(display([EFFORT, serviceTierDescriptor("default")])).toEqual({
label: "High",
showFastModeIcon: false,
});
expect(display([EFFORT, { ...serviceTier, currentValue: "priority" }])).toEqual({
expect(display([EFFORT, serviceTierDescriptor("priority")])).toEqual({
label: "High",
showFastModeIcon: true,
});
});
it("keeps other Codex service tiers in the label", () => {
expect(display([EFFORT, serviceTierDescriptor("flex")])).toEqual({
label: "High · Flex",
showFastModeIcon: false,
});
});
it("keeps the Codex service tier readable when it is the only trait", () => {
expect(display([serviceTierDescriptor("default")])).toEqual({
label: "Standard",
showFastModeIcon: false,
});
expect(display([serviceTierDescriptor("priority")])).toEqual({
label: "Fast",
showFastModeIcon: false,
});
});
it("keeps non-fastMode booleans as text labels", () => {
const thinking: Extract<ProviderOptionDescriptor, { type: "boolean" }> = {
id: "thinking",
+12 -9
View File
@@ -396,10 +396,11 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
/**
* Build the traits trigger's text label plus whether the fast-mode bolt should
* render. Fast mode is a lightning bolt when on and nothing at all when off —
* "Normal" is the near-universal case and isn't worth the horizontal space. The
* one exception is when fast mode is the only trait, where a bare bolt (or bare
* chevron) would leave the trigger unreadable.
* render. Claude and Cursor expose fast mode as a boolean, while Codex exposes
* it through the Standard/Fast service tiers. In either form, fast mode is a
* lightning bolt when on and nothing at all when off. The one exception is when
* fast mode is the only trait, where a bare bolt (or bare chevron) would leave
* the trigger unreadable.
*/
export function buildTraitsTriggerDisplay(input: {
provider: ProviderDriverKind;
@@ -407,13 +408,13 @@ export function buildTraitsTriggerDisplay(input: {
primarySelectDescriptorId: string | null;
ultrathinkPromptControlled: boolean;
}): { label: string; showFastModeIcon: boolean } {
let hasFastMode = false;
let fastModeFallbackLabel: string | null = null;
let fastModeEnabled = false;
const labels: Array<string> = [];
for (const descriptor of input.descriptors) {
if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
hasFastMode = true;
fastModeEnabled = descriptor.currentValue === true;
fastModeFallbackLabel = fastModeEnabled ? "Fast" : "Normal";
continue;
}
if (
@@ -424,8 +425,10 @@ export function buildTraitsTriggerDisplay(input: {
const currentValue = getProviderOptionCurrentValue(descriptor);
const fastTier = descriptor.options.find(({ label }) => label === "Fast");
if (fastTier && (currentValue === "default" || currentValue === fastTier.id)) {
hasFastMode = true;
fastModeEnabled = currentValue === fastTier.id;
fastModeFallbackLabel =
descriptor.options.find(({ id }) => id === currentValue)?.label ??
(fastModeEnabled ? "Fast" : "Normal");
continue;
}
}
@@ -443,8 +446,8 @@ export function buildTraitsTriggerDisplay(input: {
// Only fall back to text when fast mode is genuinely the sole trait. Keying
// off an empty label list alone would also catch descriptors that resolved to
// no label at all, printing a bogus "Normal" for a model without fast mode.
if (labels.length === 0 && hasFastMode) {
return { label: fastModeEnabled ? "Fast" : "Normal", showFastModeIcon: false };
if (labels.length === 0 && fastModeFallbackLabel !== null) {
return { label: fastModeFallbackLabel, showFastModeIcon: false };
}
return { label: labels.join(" · "), showFastModeIcon: fastModeEnabled };
}