From 87579fa2e88678fe945b8347eea2784a1ac0a4f1 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Wed, 12 Aug 2026 15:18:49 -0300 Subject: [PATCH] Expand xAI reasoning effort to medium and xhigh - Widen `XAI_EFFORTS` from `low|high` to `low|medium|high|xhigh`. - Default the xAI effort slider to `high` when none is set. - Cover the new catalog in config and picker tests. --- src/domain/config/config.ts | 2 +- src/infra/ui/effort-picker.ts | 2 +- test/domain/config/config.test.ts | 4 ++-- test/infra/ui/effort-picker.test.ts | 20 ++++++++++++++++++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/domain/config/config.ts b/src/domain/config/config.ts index 429d7c3..6426c22 100644 --- a/src/domain/config/config.ts +++ b/src/domain/config/config.ts @@ -79,7 +79,7 @@ const schema_AuthMethod = s.discriminatedUnion([ type AuthMethod = s.Infer["type"]; const OPENAI_EFFORTS = ["none", "minimal", "low", "medium", "high", "xhigh"] as const satisfies readonly NonNullable[]; -const XAI_EFFORTS = ["low", "high"] as const satisfies readonly NonNullable[]; +const XAI_EFFORTS = ["low", "medium", "high", "xhigh"] as const satisfies readonly NonNullable[]; const ANTHROPIC_EFFORTS = ["low", "medium", "high", "xhigh", "max"] as const satisfies readonly NonNullable[]; const GEMINI_EFFORTS = [ThinkingLevel.MINIMAL, ThinkingLevel.LOW, ThinkingLevel.MEDIUM, ThinkingLevel.HIGH] as const satisfies readonly ThinkingLevel[]; diff --git a/src/infra/ui/effort-picker.ts b/src/infra/ui/effort-picker.ts index 3d0a1a1..d4e1b88 100644 --- a/src/infra/ui/effort-picker.ts +++ b/src/infra/ui/effort-picker.ts @@ -73,4 +73,4 @@ const selectGeminiEffort = (modelId: string, current: Maybe): Futu selectEffort(GEMINI_EFFORTS, modelId, current, ThinkingLevel.MEDIUM); const selectXaiEffort = (modelId: string, current: Maybe): Future> => - selectEffort(XAI_EFFORTS, modelId, current, "low"); + selectEffort(XAI_EFFORTS, modelId, current, "high"); diff --git a/test/domain/config/config.test.ts b/test/domain/config/config.test.ts index 844f161..2dfc2cc 100644 --- a/test/domain/config/config.test.ts +++ b/test/domain/config/config.test.ts @@ -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)); @@ -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; - const bad = { ...encoded, ai: { ...(encoded["ai"] as Record), effort: "xhigh" } }; + const bad = { ...encoded, ai: { ...(encoded["ai"] as Record), effort: "none" } }; expect(s.decode(Config, bad).isFailure()).toBe(true); }); diff --git a/test/infra/ui/effort-picker.test.ts b/test/infra/ui/effort-picker.test.ts index 1e24eef..ad45255 100644 --- a/test/infra/ui/effort-picker.test.ts +++ b/test/infra/ui/effort-picker.test.ts @@ -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()); @@ -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"]); + expect(result.expect("Expected selected effort")).toBe("xhigh"); + }); +});