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
2 changes: 1 addition & 1 deletion src/domain/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const schema_AuthMethod = s.discriminatedUnion([
type AuthMethod = s.Infer<typeof schema_AuthMethod>["type"];

const OPENAI_EFFORTS = ["none", "minimal", "low", "medium", "high", "xhigh"] as const satisfies readonly NonNullable<OpenAIPkg.Reasoning["effort"]>[];
const XAI_EFFORTS = ["low", "high"] as const satisfies readonly NonNullable<OpenAIPkg.Reasoning["effort"]>[];
const XAI_EFFORTS = ["low", "medium", "high", "xhigh"] as const satisfies readonly NonNullable<OpenAIPkg.Reasoning["effort"]>[];
const ANTHROPIC_EFFORTS = ["low", "medium", "high", "xhigh", "max"] as const satisfies readonly NonNullable<AnthropicPkg.OutputConfig["effort"]>[];
const GEMINI_EFFORTS = [ThinkingLevel.MINIMAL, ThinkingLevel.LOW, ThinkingLevel.MEDIUM, ThinkingLevel.HIGH] as const satisfies readonly ThinkingLevel[];

Expand Down
2 changes: 1 addition & 1 deletion src/infra/ui/effort-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ const selectGeminiEffort = (modelId: string, current: Maybe<GeminiEffort>): Futu
selectEffort<GeminiEffort>(GEMINI_EFFORTS, modelId, current, ThinkingLevel.MEDIUM);

const selectXaiEffort = (modelId: string, current: Maybe<XaiEffort>): Future<Error, Maybe<XaiEffort>> =>
selectEffort<XaiEffort>(XAI_EFFORTS, modelId, current, "low");
selectEffort<XaiEffort>(XAI_EFFORTS, modelId, current, "high");
4 changes: 2 additions & 2 deletions test/domain/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Config schema", () => {
it("round-trips xai api_key config with an effort", () => {
const config: ConfigValue = {
...sampleConfig(),
ai: { provider: "xai", model: "grok-4.5", effort: Just("high" as const), auth_method: { type: "api_key", content: "xai-test" } }
ai: { provider: "xai", model: "grok-4.6", effort: Just("xhigh" as const), auth_method: { type: "api_key", content: "xai-test" } }
};

const decoded = s.decode(Config, s.encode(Config, config));
Expand All @@ -50,7 +50,7 @@ describe("Config schema", () => {
...sampleConfig(),
ai: { provider: "xai", model: "grok-4.5", effort: Just("high" as const), auth_method: { type: "api_key", content: "xai-test" } }
}) as Record<string, unknown>;
const bad = { ...encoded, ai: { ...(encoded["ai"] as Record<string, unknown>), effort: "xhigh" } };
const bad = { ...encoded, ai: { ...(encoded["ai"] as Record<string, unknown>), effort: "none" } };

expect(s.decode(Config, bad).isFailure()).toBe(true);
});
Expand Down
20 changes: 18 additions & 2 deletions test/infra/ui/effort-picker.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";

import { selectOpenAIEffort } from "@/infra/ui/effort-picker";
import { Just } from "@/libs/maybe";
import { selectOpenAIEffort, selectXaiEffort } from "@/infra/ui/effort-picker";
import { Just, Nothing } from "@/libs/maybe";
import { runFuture } from "@test/helpers/run-future";

const render = vi.hoisted(() => vi.fn());
Expand Down Expand Up @@ -43,3 +43,19 @@ describe("selectOpenAIEffort", () => {
expect(result.expect("Expected normalized effort")).toBe("low");
});
});

describe("selectXaiEffort", () => {
beforeEach(() => vi.clearAllMocks());

it("passes xAI efforts to the slider and defaults to high", async () => {
render.mockImplementation((element: { props: SliderProps }) => {
queueMicrotask(() => element.props.onSubmit("xhigh"));
return { unmount: vi.fn() };
});

const result = await runFuture(selectXaiEffort("grok-4.6", Nothing()));

expect(render.mock.calls[0]?.[0].props.options).toEqual(["low", "medium", "high", "xhigh"]);
Comment thread
rafaeelricco marked this conversation as resolved.
expect(result.expect("Expected selected effort")).toBe("xhigh");
});
});