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
7 changes: 0 additions & 7 deletions apps/web/src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import React, { type SVGProps, useId } from "react";
import { cn } from "~/lib/utils";
export type Icon = React.FC<SVGProps<SVGSVGElement>>;

export const UltrafastIcon: Icon = (props) => (
<svg viewBox="0 0 24 24" fill="currentColor" {...props}>
<path d="m17 2-10 12h7l-1 8 10-12h-7l1-8Z" opacity="0.4" />
<path d="m11 2-10 12h7l-1 8 10-12h-7l1-8Z" />
</svg>
);

export const FinderIcon: Icon = (props) => (
<svg viewBox="0 0 24 24" fill="none" {...props}>
<rect x="2" y="2" width="20" height="20" rx="4" fill="#36A9F5" />
Expand Down
166 changes: 108 additions & 58 deletions apps/web/src/components/chat/TraitsPicker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,108 @@ describe("buildTraitsTriggerDisplay", () => {
it("omits fast mode from the label entirely when it is off", () => {
expect(display([EFFORT, fastModeDescriptor(false), CONTEXT_WINDOW])).toEqual({
label: "High · 1M",
speedIcon: null,
});
});

it("shows the bolt instead of a text label when fast mode is on", () => {
it("pairs fast mode with reasoning before the context window", () => {
expect(display([EFFORT, fastModeDescriptor(true), CONTEXT_WINDOW])).toEqual({
label: "High · 1M",
speedIcon: "fast",
label: "High Fast · 1M",
});
expect(display([EFFORT, CONTEXT_WINDOW, fastModeDescriptor(true)])).toEqual({
label: "High Fast · 1M",
});
});

it("treats Codex standard and fast service tiers as fast mode states", () => {
expect(display([EFFORT, serviceTierDescriptor("default")])).toEqual({
label: "High",
speedIcon: null,
});
expect(display([EFFORT, serviceTierDescriptor("priority")])).toEqual({
label: "High",
speedIcon: "fast",
it.each(["reasoningEffort", "reasoning", "effort", "variant", "thinking"])(
"pairs Fast with %s even when context is the primary select",
(id) => {
for (const speed of [fastModeDescriptor(true), serviceTierDescriptor("priority")]) {
expect(
buildTraitsTriggerDisplay({
provider: CODEX,
descriptors: [
selectDescriptor("profile", [{ id: "balanced", label: "Balanced" }], "balanced"),
CONTEXT_WINDOW,
{ ...EFFORT, id },
speed,
],
primarySelectDescriptorId: "profile",
ultrathinkPromptControlled: false,
}),
).toEqual({ label: "Balanced · 1M · High Fast" });
}
expect(
buildTraitsTriggerDisplay({
provider: CODEX,
descriptors: [CONTEXT_WINDOW, { ...EFFORT, id }, serviceTierDescriptor("ultrafast")],
primarySelectDescriptorId: CONTEXT_WINDOW.id,
ultrathinkPromptControlled: false,
}),
).toEqual({ label: "1M · High Ultrafast" });
},
);

it("pairs Cursor Fast with reasoning rather than the thinking toggle", () => {
expect(
buildTraitsTriggerDisplay({
provider: ProviderDriverKind.make("cursor"),
descriptors: [
{ ...EFFORT, id: "reasoning" },
fastModeDescriptor(true),
{ id: "thinking", label: "Thinking", type: "boolean", currentValue: true },
],
primarySelectDescriptorId: "reasoning",
ultrathinkPromptControlled: false,
}),
).toEqual({ label: "High Fast · Thinking On" });
});

it.each([true, false])("keeps boolean thinking %s independent of Fast", (currentValue) => {
const thinking = {
id: "thinking",
label: "Thinking",
type: "boolean" as const,
currentValue,
};
const label = `Thinking ${currentValue ? "On" : "Off"}`;
expect(display([thinking, fastModeDescriptor(true)])).toEqual({ label: `${label} · Fast` });
expect(display([thinking, { ...EFFORT, id: "reasoning" }, fastModeDescriptor(true)])).toEqual({
label: `${label} · High Fast`,
});
expect(display([thinking, fastModeDescriptor(false)])).toEqual({ label });
});

it("keeps speed separate when there is no reasoning descriptor", () => {
expect(display([CONTEXT_WINDOW, fastModeDescriptor(true)])).toEqual({ label: "1M · Fast" });
});

it("uses a distinct double bolt for Codex Ultrafast", () => {
it.each(["Low", "Medium", "High", "Extra High", "Max", "Ultra"])(
"preserves %s reasoning with Fast across harnesses",
(label) => {
for (const provider of ["codex", "claudeAgent", "cursor"]) {
expect(
buildTraitsTriggerDisplay({
provider: ProviderDriverKind.make(provider),
descriptors: [
{ ...EFFORT, options: [{ id: "effort", label }], currentValue: "effort" },
fastModeDescriptor(true),
],
primarySelectDescriptorId: EFFORT.id,
ultrathinkPromptControlled: false,
}),
).toEqual({ label: `${label} Fast` });
}
},
);

it("treats Codex standard and fast service tiers as fast mode states", () => {
expect(display([EFFORT, serviceTierDescriptor("default")])).toEqual({ label: "High" });
expect(display([EFFORT, serviceTierDescriptor("priority")])).toEqual({ label: "High Fast" });
});

it("keeps Codex Ultrafast distinct from Fast", () => {
expect(display([EFFORT, serviceTierDescriptor("ultrafast")])).toEqual({
label: "High",
speedIcon: "ultrafast",
label: "High Ultrafast",
});
});

Expand All @@ -105,17 +181,11 @@ describe("buildTraitsTriggerDisplay", () => {
EFFORT,
{ ...descriptor, options: descriptor.options.filter(({ id }) => id !== "priority") },
]),
).toEqual({
label: "High",
speedIcon: "ultrafast",
});
).toEqual({ label: "High Ultrafast" });
});

it("keeps other Codex service tiers in the label", () => {
expect(display([EFFORT, serviceTierDescriptor("flex")])).toEqual({
label: "High · Flex",
speedIcon: null,
});
expect(display([EFFORT, serviceTierDescriptor("flex")])).toEqual({ label: "High · Flex" });
});

it("keeps Standard as text for models without speed tiers", () => {
Expand All @@ -124,32 +194,17 @@ describe("buildTraitsTriggerDisplay", () => {
...descriptor,
options: descriptor.options.filter(({ id }) => id === "default" || id === "flex"),
};
expect(display([EFFORT, nonSpeedDescriptor])).toEqual({
label: "High · Standard",
speedIcon: null,
});
expect(display([nonSpeedDescriptor])).toEqual({
label: "Standard",
speedIcon: null,
});
expect(display([EFFORT, nonSpeedDescriptor])).toEqual({ label: "High · Standard" });
expect(display([nonSpeedDescriptor])).toEqual({ label: "Standard" });
});

it("keeps the Codex service tier readable when it is the only trait", () => {
expect(display([serviceTierDescriptor("default")])).toEqual({
label: "Standard",
speedIcon: null,
});
expect(display([serviceTierDescriptor("priority")])).toEqual({
label: "Fast",
speedIcon: null,
});
expect(display([serviceTierDescriptor("default")])).toEqual({ label: "Standard" });
expect(display([serviceTierDescriptor("priority")])).toEqual({ label: "Fast" });
});

it("keeps Ultrafast readable when it is the only trait", () => {
expect(display([serviceTierDescriptor("ultrafast")])).toEqual({
label: "Ultrafast",
speedIcon: null,
});
expect(display([serviceTierDescriptor("ultrafast")])).toEqual({ label: "Ultrafast" });
});

it("keeps non-fastMode booleans as text labels", () => {
Expand All @@ -159,21 +214,16 @@ describe("buildTraitsTriggerDisplay", () => {
type: "boolean",
currentValue: true,
};
expect(display([EFFORT, thinking])).toEqual({
label: "High · Thinking On",
speedIcon: null,
});
expect(display([EFFORT, thinking])).toEqual({ label: "High · Thinking On" });
});

it("falls back to a text label when fast mode is the only trait", () => {
expect(display([fastModeDescriptor(true)])).toEqual({
label: "Fast",
speedIcon: null,
});
expect(display([fastModeDescriptor(false)])).toEqual({
label: "Normal",
speedIcon: null,
});
expect(display([fastModeDescriptor(true)])).toEqual({ label: "Fast" });
expect(display([fastModeDescriptor(false)])).toEqual({ label: "Normal" });
});

it("does not add Fast to a model without a speed option", () => {
expect(display([EFFORT, CONTEXT_WINDOW])).toEqual({ label: "High · 1M" });
});

it("stays blank when descriptors resolve to no label and there is no fast mode", () => {
Expand All @@ -189,18 +239,18 @@ describe("buildTraitsTriggerDisplay", () => {
{ id: "high", label: "High" },
],
};
expect(display([unresolved])).toEqual({ label: "", speedIcon: null });
expect(display([unresolved])).toEqual({ label: "" });
});

it("still renders the prompt-controlled ultrathink label alongside the bolt", () => {
it("still renders prompt-controlled ultrathink with Fast", () => {
expect(
buildTraitsTriggerDisplay({
provider: CODEX,
descriptors: [EFFORT, fastModeDescriptor(true)],
primarySelectDescriptorId: "reasoningEffort",
ultrathinkPromptControlled: true,
}),
).toEqual({ label: "Ultrathink", speedIcon: "fast" });
).toEqual({ label: "Ultrathink Fast" });
});
});

Expand Down
Loading
Loading