From 4330d04967dd362cc3a9f420ebf976fc9a38bd76 Mon Sep 17 00:00:00 2001 From: "@taltas" <6816042+taltas@users.noreply.github.com> Date: Sat, 21 Nov 2026 03:23:24 +0000 Subject: [PATCH 1/2] feat: add reasoning-effort quick switcher to chat input --- packages/types/src/model.ts | 2 + packages/types/src/providers/common.ts | 6 + packages/types/src/vscode-extension-host.ts | 1 + src/api/index.ts | 7 +- .../providers/__tests__/openai-native.spec.ts | 61 +++++- src/api/providers/__tests__/openai.spec.ts | 76 +++++++ src/api/providers/openai.ts | 7 +- src/core/webview/ClineProvider.ts | 73 +++++++ .../ClineProvider.apiHandlerRebuild.spec.ts | 97 ++++++++- .../__tests__/webviewMessageHandler.spec.ts | 47 ++++ src/core/webview/webviewMessageHandler.ts | 19 ++ src/shared/__tests__/api.spec.ts | 82 ++++++- src/shared/api.ts | 29 +++ webview-ui/playwright/gallery/stories.tsx | 21 ++ .../src/components/chat/ChatTextArea.tsx | 9 +- .../chat/ReasoningEffortSelector.tsx | 200 ++++++++++++++++++ .../__tests__/ChatTextArea.visual.fixture.tsx | 6 +- .../chat/__tests__/ChatTextArea.visual.tsx | 20 ++ .../ReasoningEffortSelector.spec.tsx | 191 +++++++++++++++++ webview-ui/src/i18n/locales/ca/chat.json | 7 + webview-ui/src/i18n/locales/de/chat.json | 7 + webview-ui/src/i18n/locales/en/chat.json | 7 + webview-ui/src/i18n/locales/es/chat.json | 7 + webview-ui/src/i18n/locales/fr/chat.json | 7 + webview-ui/src/i18n/locales/hi/chat.json | 7 + webview-ui/src/i18n/locales/id/chat.json | 7 + webview-ui/src/i18n/locales/it/chat.json | 7 + webview-ui/src/i18n/locales/ja/chat.json | 7 + webview-ui/src/i18n/locales/ko/chat.json | 7 + webview-ui/src/i18n/locales/nl/chat.json | 7 + webview-ui/src/i18n/locales/pl/chat.json | 7 + webview-ui/src/i18n/locales/pt-BR/chat.json | 7 + webview-ui/src/i18n/locales/ru/chat.json | 7 + webview-ui/src/i18n/locales/tr/chat.json | 7 + webview-ui/src/i18n/locales/vi/chat.json | 7 + webview-ui/src/i18n/locales/zh-CN/chat.json | 7 + webview-ui/src/i18n/locales/zh-TW/chat.json | 7 + 37 files changed, 1072 insertions(+), 8 deletions(-) create mode 100644 webview-ui/src/components/chat/ReasoningEffortSelector.tsx create mode 100644 webview-ui/src/components/chat/__tests__/ReasoningEffortSelector.spec.tsx diff --git a/packages/types/src/model.ts b/packages/types/src/model.ts index b3c2b8151d..5da4855407 100644 --- a/packages/types/src/model.ts +++ b/packages/types/src/model.ts @@ -44,6 +44,8 @@ export const reasoningEffortSettingValues = [ ] as const export const reasoningEffortSettingSchema = z.enum(reasoningEffortSettingValues) +export type ReasoningEffortSetting = z.infer + /** * Verbosity */ diff --git a/packages/types/src/providers/common.ts b/packages/types/src/providers/common.ts index 59c463adcc..c2fda7da54 100644 --- a/packages/types/src/providers/common.ts +++ b/packages/types/src/providers/common.ts @@ -36,6 +36,12 @@ export const baseProviderSettingsShape = { toolRepetitionSoftLimit: nullableOptional(z.number().min(0).nullish()), enableReasoningEffort: z.boolean().optional(), reasoningEffort: reasoningEffortSettingSchema.optional(), + // Chat quick-switch override on top of `reasoningEffort`. Set by the chat + // input's reasoning-effort selector, it replaces the configured effort for + // requests without rewriting the profile's saved value. Cleared (key + // removed) when the chat selector picks "Default" or the profile's model + // changes. Lives here, not per-provider, so every provider carries it. + reasoningEffortOverride: reasoningEffortSettingSchema.optional(), modelMaxTokens: z.number().optional(), modelMaxThinkingTokens: z.number().optional(), verbosity: verbosityLevelsSchema.optional(), diff --git a/packages/types/src/vscode-extension-host.ts b/packages/types/src/vscode-extension-host.ts index 2e9ea7ccb8..bfb492dc27 100644 --- a/packages/types/src/vscode-extension-host.ts +++ b/packages/types/src/vscode-extension-host.ts @@ -564,6 +564,7 @@ export interface WebviewMessage { | "saveApiConfiguration" | "upsertApiConfiguration" | "updateProfileModel" + | "updateReasoningEffortOverride" | "deleteApiConfiguration" | "loadApiConfiguration" | "loadApiConfigurationById" diff --git a/src/api/index.ts b/src/api/index.ts index 3d4138cbce..bd24a61a9a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -12,6 +12,7 @@ import { import { getRouterRemovalMessage } from "../core/config/routerRemoval" import type { GetModelsOptions } from "../shared/api" +import { withReasoningEffortOverride } from "../shared/api" import { ApiStream } from "./transform/stream" import { @@ -196,7 +197,11 @@ export interface ApiHandler { export { disposeApiHandler } from "./dispose-api-handler" export function buildApiHandler(configuration: ProviderSettings): ApiHandler { - const { apiProvider, ...options } = configuration + // The chat reasoning-effort override is applied here so every provider + // (streaming, non-streaming, and SSE fallback paths alike) sees the + // effective effort through its regular options. Without an override the + // configuration is passed through unchanged. + const { apiProvider, ...options } = withReasoningEffortOverride(configuration) if (apiProvider === retiredProviderIdentifiers.roo) { throw new Error(getRouterRemovalMessage()) diff --git a/src/api/providers/__tests__/openai-native.spec.ts b/src/api/providers/__tests__/openai-native.spec.ts index fa32c85dd9..4c5c831f6f 100644 --- a/src/api/providers/__tests__/openai-native.spec.ts +++ b/src/api/providers/__tests__/openai-native.spec.ts @@ -13,9 +13,17 @@ vitest.mock("@roo-code/telemetry", () => ({ import { Anthropic } from "@anthropic-ai/sdk" import OpenAI from "openai" -import { ApiProviderError, OpenAiServiceTier, SERVICE_TIER_KEY, serviceTiers } from "@roo-code/types" +import { + ApiProviderError, + OpenAiServiceTier, + SERVICE_TIER_KEY, + serviceTiers, + providerIdentifiers, + type ProviderSettings, +} from "@roo-code/types" import { OpenAiNativeHandler } from "../openai-native" +import { buildApiHandler } from "../../index" import type { ApiStreamChunk, ApiStreamTextChunk } from "../../../api/transform/stream" import { ApiHandlerOptions } from "../../../shared/api" import { Package } from "../../../shared/package" @@ -227,6 +235,57 @@ describe("OpenAiNativeHandler", () => { expect(astraHandler["getReasoningEffort"](astraHandler.getModel())).toBe("medium") }) + // The chat quick-switch stores its override in `reasoningEffortOverride` and + // `buildApiHandler` folds it into the effective settings, so these tests go + // through `buildApiHandler` to cover the shipped request path (one shared + // body shapes the SDK stream and the manual SSE fallback alike). + describe("chat reasoning effort override", () => { + const makeHandlerConfig = (overrides: Partial = {}): ProviderSettings => ({ + apiProvider: providerIdentifiers.openaiNative, + openAiNativeApiKey: "test-key", + apiModelId: "gpt-6-astra", + ...overrides, + }) + + function getNativeHandlerEffort(overrides: Partial = {}): string | undefined { + const built = buildApiHandler(makeHandlerConfig(overrides)) + + if (!(built instanceof OpenAiNativeHandler)) { + throw new Error("expected buildApiHandler to return an OpenAiNativeHandler") + } + + return built["getReasoningEffort"](built.getModel()) + } + + it("override beats the configured effort", () => { + expect(getNativeHandlerEffort({ reasoningEffort: "high", reasoningEffortOverride: "low" })).toBe("low") + }) + + it("keeps the configured effort when no override is set", () => { + expect(getNativeHandlerEffort({ reasoningEffort: "high" })).toBe("high") + }) + + it("override outside the model capability falls back to the model default effort", () => { + // Astra supports low..max; "none" is outside the capability array. + expect(getNativeHandlerEffort({ reasoningEffort: "high", reasoningEffortOverride: "none" })).toBe( + "medium", + ) + }) + + it("override 'disable' uses the required model default", () => { + expect(getNativeHandlerEffort({ reasoningEffort: "high", reasoningEffortOverride: "disable" })).toBe( + "medium", + ) + }) + + it("keeps request shapes unchanged for models without reasoning support", () => { + // No configured effort and no override: no reasoning is sent, exactly as + // before the quick switch existed. The chat control is hidden for such + // models, so no override is reachable from the UI. + expect(getNativeHandlerEffort({ apiModelId: "gpt-4.1" })).toBeUndefined() + }) + }) + it.each(serviceTiers)("should include the selected %s service tier", async (serviceTier) => { mockResponsesCreate.mockResolvedValue(asyncStreamFrom([])) handler = new OpenAiNativeHandler({ diff --git a/src/api/providers/__tests__/openai.spec.ts b/src/api/providers/__tests__/openai.spec.ts index 1e8daccb5b..387658a181 100644 --- a/src/api/providers/__tests__/openai.spec.ts +++ b/src/api/providers/__tests__/openai.spec.ts @@ -1,7 +1,9 @@ // npx vitest run api/providers/__tests__/openai.spec.ts import { OpenAiHandler, getOpenAiModels } from "../openai" +import { buildApiHandler } from "../../index" import { ApiHandlerOptions } from "../../../shared/api" +import { providerIdentifiers, type ProviderSettings } from "@roo-code/types" import { Anthropic } from "@anthropic-ai/sdk" import OpenAI, { AzureOpenAI } from "openai" import { @@ -592,6 +594,80 @@ describe("OpenAiHandler", () => { expect(callArgs.reasoning_effort).toBeUndefined() }) + // The chat quick-switch stores its override in `reasoningEffortOverride` and + // `buildApiHandler` folds it into the effective settings, so these tests go + // through `buildApiHandler` to cover the shipped request path. + describe("chat reasoning effort override", () => { + const makeHandlerConfig = (overrides: Partial = {}): ProviderSettings => ({ + apiProvider: providerIdentifiers.openai, + openAiApiKey: "test-key", + openAiModelId: "test-model", + openAiBaseUrl: "https://api.openai.com/v1", + openAiCustomModelInfo: { + contextWindow: 128_000, + supportsPromptCache: false, + supportsReasoningEffort: ["low", "medium", "high"], + reasoningEffort: "low", + }, + ...overrides, + }) + + it("override beats the OpenAI-compatible custom model info effort on streaming requests", async () => { + const handler = buildApiHandler(makeHandlerConfig({ reasoningEffortOverride: "high" })) + await collectStream(handler.createMessage(systemPrompt, messages)) + + expect(mockCreate).toHaveBeenCalled() + expect(mockCreate.mock.calls[0][0].reasoning_effort).toBe("high") + }) + + it("keeps the configured effort when no override is set", async () => { + const handler = buildApiHandler(makeHandlerConfig()) + await collectStream(handler.createMessage(systemPrompt, messages)) + + expect(mockCreate).toHaveBeenCalled() + expect(mockCreate.mock.calls[0][0].reasoning_effort).toBe("low") + }) + + it("override applies to non-streaming requests", async () => { + const handler = buildApiHandler( + makeHandlerConfig({ reasoningEffortOverride: "medium", openAiStreamingEnabled: false }), + ) + await collectStream(handler.createMessage(systemPrompt, messages)) + + expect(mockCreate).toHaveBeenCalled() + expect(mockCreate.mock.calls[0][0].reasoning_effort).toBe("medium") + }) + + it("override 'disable' omits reasoning_effort even when the model info configures an effort", async () => { + const handler = buildApiHandler(makeHandlerConfig({ reasoningEffortOverride: "disable" })) + await collectStream(handler.createMessage(systemPrompt, messages)) + + expect(mockCreate).toHaveBeenCalled() + expect(mockCreate.mock.calls[0][0].reasoning_effort).toBeUndefined() + }) + + it("override outside the model capability falls back to the model default effort", async () => { + const handler = buildApiHandler(makeHandlerConfig({ reasoningEffortOverride: "max" })) + await collectStream(handler.createMessage(systemPrompt, messages)) + + expect(mockCreate).toHaveBeenCalled() + expect(mockCreate.mock.calls[0][0].reasoning_effort).toBe("low") + }) + + it("does not send reasoning_effort for models without reasoning support", async () => { + const handler = buildApiHandler( + makeHandlerConfig({ + reasoningEffortOverride: "high", + openAiCustomModelInfo: { contextWindow: 128_000, supportsPromptCache: false }, + }), + ) + await collectStream(handler.createMessage(systemPrompt, messages)) + + expect(mockCreate).toHaveBeenCalled() + expect(mockCreate.mock.calls[0][0].reasoning_effort).toBeUndefined() + }) + }) + it("should omit temperature when the model sets supportsTemperature to false", async () => { const noTempOptions: ApiHandlerOptions = { ...mockOptions, diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index 98ea18df8a..6d5e757290 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -339,7 +339,12 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl model: info, // OpenAI Compatible edits effort in custom model info. The shared top-level // setting may be left over from another provider and must not override it. - settings: { ...this.options, reasoningEffort: info.reasoningEffort }, + // The chat quick-switch override beats both: it is an explicit per-request + // choice, while info.reasoningEffort is the profile's configured default. + settings: { + ...this.options, + reasoningEffort: this.options.reasoningEffortOverride ?? info.reasoningEffort, + }, defaultTemperature: 0, }) // Local OpenAI-compatible reasoning models (llama.cpp, LM Studio, Ollama) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index f19b686b32..d1291c73f1 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -75,6 +75,8 @@ import { isRetiredProvider, modelIdKeys, providerIdentifiers, + reasoningEffortSettingValues, + type ReasoningEffortSetting, } from "@roo-code/types" import { RateLimitClock, createRateLimitClock } from "../task/RateLimitClock" import { TaskRegistry } from "../task/TaskRegistry" @@ -2323,6 +2325,12 @@ export class ClineProvider const merged: Record = { ...stored, apiProvider: storedProvider } + // The chat reasoning-effort override was chosen for the previous model. + // A model change starts fresh so the new model never inherits an effort + // it may not support; the selector shows the new model's default until + // the user picks an override again. + delete merged.reasoningEffortOverride + for (const [key, value] of Object.entries(patch)) { if (PROFILE_MODEL_ID_PATCH_KEYS.has(key)) { if (typeof value !== "string" || value.length === 0) { @@ -2399,6 +2407,71 @@ export class ClineProvider } } + /** + * Applies a chat reasoning-effort override to the latest stored profile inside the + * mutation queue, mirroring `updateProfileModel` so a stale webview snapshot cannot + * overwrite newer profile settings. A `null` effort clears the override, restoring + * the profile's configured `reasoningEffort` behavior. + * + * The override is stored as a separate key, so the profile's saved reasoning-effort + * setting is never rewritten by the chat quick switch. + */ + async updateProfileReasoningEffort( + name: string, + expectedProvider: string, + effort: ReasoningEffortSetting | null, + ): Promise { + try { + await this.enqueueProviderProfileMutation( + async (signal) => { + const { name: _name, ...stored } = await this.providerSettingsManager.getProfile({ name }) + + // Unset provider (e.g. the seeded default profile) resolves to anthropic, matching getState(). + const storedProvider = stored.apiProvider ?? providerIdentifiers.anthropic + + if (storedProvider !== expectedProvider) { + throw new Error( + `Profile "${name}" provider changed from "${expectedProvider}" to "${storedProvider}"`, + ) + } + + const merged: Record = { ...stored, apiProvider: storedProvider } + + if (effort === null) { + delete merged.reasoningEffortOverride + } else { + if (!(reasoningEffortSettingValues as readonly string[]).includes(effort)) { + throw new Error(`"${effort}" is not a valid reasoning effort`) + } + + merged.reasoningEffortOverride = effort + } + + const { organizationAllowList } = await this.getState() + + if (!ProfileValidator.isProfileAllowed(merged as ProviderSettings, organizationAllowList)) { + throw new OrganizationAllowListViolationError( + t("common:errors.violated_organization_allowlist"), + ) + } + + if (signal.aborted) return + + await this.persistProviderProfile(name, merged as ProviderSettings, true, signal) + }, + { runToCompletion: true }, + ) + } catch (error) { + this.log(`Error update reasoning effort: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`) + + vscode.window.showErrorMessage( + error instanceof OrganizationAllowListViolationError + ? error.message + : t("common:errors.create_api_config"), + ) + } + } + private async persistProviderProfile( name: string, providerSettings: ProviderSettings, diff --git a/src/core/webview/__tests__/ClineProvider.apiHandlerRebuild.spec.ts b/src/core/webview/__tests__/ClineProvider.apiHandlerRebuild.spec.ts index 28531e964d..0efa914b4f 100644 --- a/src/core/webview/__tests__/ClineProvider.apiHandlerRebuild.spec.ts +++ b/src/core/webview/__tests__/ClineProvider.apiHandlerRebuild.spec.ts @@ -5,7 +5,7 @@ import * as vscode from "vscode" import { makeCompositeDisposable } from "../../../test-utils/vscode" import { TelemetryService } from "@roo-code/telemetry" -import { getModelId, RooCodeEventName } from "@roo-code/types" +import { getModelId, RooCodeEventName, type ReasoningEffortSetting } from "@roo-code/types" import { ContextProxy } from "../../config/ContextProxy" import type { Mode } from "../../../shared/modes" @@ -818,6 +818,101 @@ describe("ClineProvider - API Handler Rebuild Guard", () => { expect(provider["providerSettingsManager"].saveConfig).not.toHaveBeenCalled() expect(vscode.window.showErrorMessage).toHaveBeenCalled() }) + + test("clears a stale chat reasoning-effort override when the model changes", async () => { + provider["providerSettingsManager"].getProfile = vi + .fn() + .mockResolvedValue({ ...storedProfile, reasoningEffortOverride: "low" }) + + await provider.updateProfileModel("test-config", providerIdentifiers.openrouter, { + openRouterModelId: "anthropic/claude", + }) + + const saveConfig = vi.mocked(provider["providerSettingsManager"].saveConfig) + expect(saveConfig).toHaveBeenCalledTimes(1) + const saved = saveConfig.mock.calls[0][1] + expect(saved).toMatchObject({ openRouterModelId: "anthropic/claude" }) + expect(saved).not.toHaveProperty("reasoningEffortOverride") + }) + }) + + describe("updateProfileReasoningEffort", () => { + const storedProfile = { + name: "test-config", + id: "test-id", + apiProvider: providerIdentifiers.openrouter, + openRouterModelId: "openai/gpt-4", + rateLimitSeconds: 5, + reasoningEffort: "high", + } + + beforeEach(() => { + provider["providerSettingsManager"].getProfile = vi.fn().mockResolvedValue(storedProfile) + vi.mocked(vscode.window.showErrorMessage).mockClear() + }) + + test("stores the override without rewriting the configured effort", async () => { + await provider.updateProfileReasoningEffort("test-config", providerIdentifiers.openrouter, "low") + + const saveConfig = vi.mocked(provider["providerSettingsManager"].saveConfig) + expect(saveConfig).toHaveBeenCalledTimes(1) + const saved = saveConfig.mock.calls[0][1] + expect(saved).toMatchObject({ + id: "test-id", + apiProvider: providerIdentifiers.openrouter, + openRouterModelId: "openai/gpt-4", + rateLimitSeconds: 5, + reasoningEffort: "high", + reasoningEffortOverride: "low", + }) + expect(vscode.window.showErrorMessage).not.toHaveBeenCalled() + }) + + test("clears the override when the effort is null", async () => { + provider["providerSettingsManager"].getProfile = vi + .fn() + .mockResolvedValue({ ...storedProfile, reasoningEffortOverride: "low" }) + + await provider.updateProfileReasoningEffort("test-config", providerIdentifiers.openrouter, null) + + const saveConfig = vi.mocked(provider["providerSettingsManager"].saveConfig) + expect(saveConfig).toHaveBeenCalledTimes(1) + const saved = saveConfig.mock.calls[0][1] + expect(saved).toMatchObject({ reasoningEffort: "high" }) + expect(saved).not.toHaveProperty("reasoningEffortOverride") + }) + + test("rejects an unknown effort value", async () => { + await provider.updateProfileReasoningEffort( + "test-config", + providerIdentifiers.openrouter, + "bogus" as ReasoningEffortSetting, + ) + + expect(provider["providerSettingsManager"].saveConfig).not.toHaveBeenCalled() + expect(vscode.window.showErrorMessage).toHaveBeenCalled() + }) + + test("rejects the update when the stored provider differs from the expected provider", async () => { + await provider.updateProfileReasoningEffort("test-config", providerIdentifiers.anthropic, "low") + + expect(provider["providerSettingsManager"].saveConfig).not.toHaveBeenCalled() + expect(vscode.window.showErrorMessage).toHaveBeenCalled() + }) + + test("rebuilds the current task API handler with the override", async () => { + const mockTask = new Task({ ...defaultTaskOptions }) + mockTask.api = { + getModel: vi.fn().mockReturnValue({ id: "openai/gpt-4", info: { contextWindow: 128000 } }), + } as unknown as typeof mockTask.api + await provider.addClineToStack(mockTask) + + await provider.updateProfileReasoningEffort("test-config", providerIdentifiers.openrouter, "low") + + expect(mockTask.updateApiConfiguration).toHaveBeenCalledWith( + expect.objectContaining({ reasoningEffortOverride: "low", reasoningEffort: "high" }), + ) + }) }) describe("activateProviderProfile", () => { diff --git a/src/core/webview/__tests__/webviewMessageHandler.spec.ts b/src/core/webview/__tests__/webviewMessageHandler.spec.ts index e1cc7dc844..446f037b71 100644 --- a/src/core/webview/__tests__/webviewMessageHandler.spec.ts +++ b/src/core/webview/__tests__/webviewMessageHandler.spec.ts @@ -3116,6 +3116,53 @@ describe("updateProfileModel", () => { }) }) +describe("updateReasoningEffortOverride", () => { + let updateProfileReasoningEffort: Mock + + beforeEach(() => { + vi.clearAllMocks() + updateProfileReasoningEffort = vi.fn() + mockClineProvider.updateProfileReasoningEffort = updateProfileReasoningEffort + }) + + it("delegates a valid override message to the provider", async () => { + await webviewMessageHandler(mockClineProvider, { + type: "updateReasoningEffortOverride", + text: "my-profile", + values: { expectedProvider: providerIdentifiers.openrouter, effort: "high" }, + }) + + expect(updateProfileReasoningEffort).toHaveBeenCalledWith("my-profile", providerIdentifiers.openrouter, "high") + }) + + it("delegates a null effort as a request to clear the override", async () => { + await webviewMessageHandler(mockClineProvider, { + type: "updateReasoningEffortOverride", + text: "my-profile", + values: { expectedProvider: providerIdentifiers.openrouter, effort: null }, + }) + + expect(updateProfileReasoningEffort).toHaveBeenCalledWith("my-profile", providerIdentifiers.openrouter, null) + }) + + it.each([ + ["missing profile name", { values: { expectedProvider: providerIdentifiers.openrouter, effort: "low" } }], + ["missing expectedProvider", { text: "p", values: { effort: "low" } }], + [ + "unknown effort value", + { text: "p", values: { expectedProvider: providerIdentifiers.openrouter, effort: "bogus" } }, + ], + ["missing values", { text: "p" }], + ])("ignores a malformed message: %s", async (_label, partial) => { + await webviewMessageHandler(mockClineProvider, { + type: "updateReasoningEffortOverride", + ...partial, + } as unknown as Parameters[1]) + + expect(updateProfileReasoningEffort).not.toHaveBeenCalled() + }) +}) + describe("webviewMessageHandler - renameTaskWithId", () => { beforeEach(() => { vi.mocked(mockClineProvider.renameTaskWithId).mockClear() diff --git a/src/core/webview/webviewMessageHandler.ts b/src/core/webview/webviewMessageHandler.ts index 6641ff259f..80af37ac9f 100644 --- a/src/core/webview/webviewMessageHandler.ts +++ b/src/core/webview/webviewMessageHandler.ts @@ -31,6 +31,8 @@ import { VsCodeLmModelsMessageType, isTelemetryOptedIn, type MentionSegment, + reasoningEffortSettingValues, + type ReasoningEffortSetting, } from "@roo-code/types" import { handleRequestProviderInfo } from "./providerInfoHandler" import { customToolRegistry } from "@roo-code/core" @@ -2514,6 +2516,23 @@ export const webviewMessageHandler = async ( } break } + case "updateReasoningEffortOverride": { + const { expectedProvider, effort } = message.values ?? {} + + if (message.text && typeof expectedProvider === "string") { + // `null` clears the override ("Default"); anything else must be a known effort. + const isValidEffort = + effort === null || + (typeof effort === "string" && + reasoningEffortSettingValues.includes(effort as ReasoningEffortSetting)) + + if (isValidEffort) { + const selectedEffort = effort as ReasoningEffortSetting | null + await provider.updateProfileReasoningEffort(message.text, expectedProvider, selectedEffort) + } + } + break + } case "renameApiConfiguration": if (message.values && message.apiConfiguration) { try { diff --git a/src/shared/__tests__/api.spec.ts b/src/shared/__tests__/api.spec.ts index d98750923d..275cd679d6 100644 --- a/src/shared/__tests__/api.spec.ts +++ b/src/shared/__tests__/api.spec.ts @@ -1,6 +1,11 @@ import { type ModelInfo, type ProviderSettings, ANTHROPIC_DEFAULT_MAX_TOKENS } from "@roo-code/types" -import { getModelMaxOutputTokens, shouldUseReasoningBudget, shouldUseReasoningEffort } from "../api" +import { + getModelMaxOutputTokens, + shouldUseReasoningBudget, + shouldUseReasoningEffort, + withReasoningEffortOverride, +} from "../api" import { providerIdentifiers } from "@roo-code/types/provider-identifiers" describe("getModelMaxOutputTokens", () => { @@ -807,3 +812,78 @@ describe("shouldUseReasoningEffort", () => { ).toBe(false) }) }) + +describe("withReasoningEffortOverride", () => { + test("returns the settings untouched when no override is set", () => { + const settings: ProviderSettings = { enableReasoningEffort: true, reasoningEffort: "medium" } + + expect(withReasoningEffortOverride(settings)).toBe(settings) + }) + + test("folds a concrete override into the effort and enables reasoning", () => { + const settings: ProviderSettings = { + enableReasoningEffort: false, + reasoningEffort: "low", + reasoningEffortOverride: "high", + } + + expect(withReasoningEffortOverride(settings)).toEqual({ + enableReasoningEffort: true, + reasoningEffort: "high", + reasoningEffortOverride: "high", + }) + }) + + test("folds the 'none' override with reasoning enabled", () => { + const settings: ProviderSettings = { enableReasoningEffort: false, reasoningEffortOverride: "none" } + + expect(withReasoningEffortOverride(settings)).toEqual({ + enableReasoningEffort: true, + reasoningEffort: "none", + reasoningEffortOverride: "none", + }) + }) + + test("folds the 'disable' override into an explicit off state", () => { + const settings: ProviderSettings = { + enableReasoningEffort: true, + reasoningEffort: "high", + reasoningEffortOverride: "disable", + } + + expect(withReasoningEffortOverride(settings)).toEqual({ + enableReasoningEffort: false, + reasoningEffort: "disable", + reasoningEffortOverride: "disable", + }) + }) + + test("does not mutate the original settings", () => { + const settings: ProviderSettings = { + enableReasoningEffort: false, + reasoningEffort: "low", + reasoningEffortOverride: "high", + } + + withReasoningEffortOverride(settings) + + expect(settings.enableReasoningEffort).toBe(false) + expect(settings.reasoningEffort).toBe("low") + }) + + test("override lets shouldUseReasoningEffort accept a concrete effort when folded", () => { + const model: ModelInfo = { + contextWindow: 1_000_000, + supportsPromptCache: true, + supportsReasoningEffort: ["low", "medium", "high"], + } + + const settings = withReasoningEffortOverride({ + enableReasoningEffort: false, + reasoningEffort: "low", + reasoningEffortOverride: "high", + }) + + expect(shouldUseReasoningEffort({ model, settings })).toBe(true) + }) +}) diff --git a/src/shared/api.ts b/src/shared/api.ts index d65ee30ace..15b6d0a970 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -84,6 +84,35 @@ export const shouldUseReasoningEffort = ({ return !!modelDefaultEffort } +/** + * Folds the chat quick-switch override (`reasoningEffortOverride`) into the + * effective reasoning settings for API requests. + * + * Precedence: chat override > provider profile setting (`reasoningEffort`) > + * model default (`model.reasoningEffort`). The profile's saved `reasoningEffort` + * and `enableReasoningEffort` values are never rewritten; the override only + * changes what the API layer sees for the handlers built from these settings. + * + * - A concrete effort (including "none") implies reasoning is enabled, so + * `enableReasoningEffort` is folded to `true`. + * - "disable" turns reasoning off (`enableReasoningEffort` folded to `false`). + * - Without an override the settings pass through untouched, so providers and + * models without reasoning support keep their exact existing request shapes. + */ +export const withReasoningEffortOverride = (settings: T): T => { + const override = settings.reasoningEffortOverride + + if (override === undefined) { + return settings + } + + return { + ...settings, + reasoningEffort: override, + enableReasoningEffort: override !== "disable", + } +} + export const DEFAULT_HYBRID_REASONING_MODEL_MAX_TOKENS = 16_384 export const DEFAULT_HYBRID_REASONING_MODEL_THINKING_TOKENS = 8_192 export const GEMINI_25_PRO_MIN_THINKING_TOKENS = 128 diff --git a/webview-ui/playwright/gallery/stories.tsx b/webview-ui/playwright/gallery/stories.tsx index 818e69d199..28085c123e 100644 --- a/webview-ui/playwright/gallery/stories.tsx +++ b/webview-ui/playwright/gallery/stories.tsx @@ -209,6 +209,27 @@ export const stories: Record = { const { ChatTextAreaStory } = await import("@/components/chat/__tests__/ChatTextArea.visual.fixture") return }, + "chat-text-area-reasoning-effort": async ({ override = "" } = {}) => { + const [{ ChatTextAreaStory }, { providerIdentifiers }] = await Promise.all([ + import("@/components/chat/__tests__/ChatTextArea.visual.fixture"), + import("@roo-code/types"), + ]) + // A reasoning-capable OpenAI-compatible profile, so the quick switcher renders. + // `override` presets a chat override to show the active-override treatment. + const apiConfiguration = { + apiProvider: providerIdentifiers.openai, + openAiModelId: "test-model", + enableReasoningEffort: true, + reasoningEffortOverride: override ? override : undefined, + openAiCustomModelInfo: { + contextWindow: 128_000, + supportsPromptCache: false, + supportsReasoningEffort: ["low", "medium", "high"], + reasoningEffort: "medium", + }, + } satisfies import("@roo-code/types").ProviderSettings + return + }, "history-empty": async () => { const [{ AppProviders }, { default: HistoryView }] = await Promise.all([ import("../AppProviders"), diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index c38d417ec4..cb7d2d379a 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -29,6 +29,7 @@ import Thumbnails from "../common/Thumbnails" import { ModeSelector } from "./ModeSelector" import { ApiConfigSelector } from "./ApiConfigSelector" import { ModelSelector } from "./ModelSelector" +import { ReasoningEffortSelector } from "./ReasoningEffortSelector" import { AutoApproveDropdown } from "./AutoApproveDropdown" import { MAX_IMAGES_PER_MESSAGE } from "./constants" import ContextMenu from "./ContextMenu" @@ -1371,11 +1372,17 @@ export const ChatTextArea = forwardRef( value={mode} title={t("chat:selectMode")} onChange={handleModeChange} - triggerClassName="text-ellipsis overflow-hidden flex-shrink-0" + triggerClassName="min-w-[70px] max-w-[150px] flex-shrink min-[310px]:flex-shrink-0" modeShortcutText={modeShortcutText} customModes={customModes} customModePrompts={customModePrompts} /> + | null { + const supports = modelInfo.supportsReasoningEffort + + if (supports === true) { + return modelInfo.requiredReasoningEffort ? ["low", "medium", "high"] : ["disable", "low", "medium", "high"] + } + + if (Array.isArray(supports)) { + return supports.length > 0 ? supports : null + } + + return null +} + +// Mirrors `shouldUseReasoningEffort` (src/shared/api.ts) for display: what the +// active configuration actually sends right now. The chat override is checked +// first, exactly like the API layer's `withReasoningEffortOverride` fold. +// Returns `undefined` when no reasoning effort is sent ("Off"). +function resolveActiveEffort( + apiConfiguration: ProviderSettings, + modelInfo: ModelInfo, + supported: ReadonlyArray, +): ReasoningEffortSetting | undefined { + const override = apiConfiguration.reasoningEffortOverride + + if (override !== undefined && supported.includes(override)) { + return override === "disable" ? undefined : override + } + + if (apiConfiguration.enableReasoningEffort === false) return undefined + + const selected = apiConfiguration.reasoningEffort ?? modelInfo.reasoningEffort + + if (!selected || selected === "disable") return undefined + + return supported.includes(selected) ? selected : undefined +} + +interface ReasoningEffortSelectorProps { + apiConfiguration: ProviderSettings + disabled?: boolean + title: string + triggerClassName?: string +} + +export const ReasoningEffortSelector = ({ + apiConfiguration, + disabled = false, + title, + triggerClassName = "", +}: ReasoningEffortSelectorProps) => { + const [open, setOpen] = React.useState(false) + const portalContainer = useRooPortal("roo-portal") + const { t } = useAppTranslation() + const { currentApiConfigName } = useExtensionState() + + const { provider, info: modelInfo } = useSelectedModel(apiConfiguration) + + const supportedEfforts = React.useMemo(() => (modelInfo ? getSupportedEfforts(modelInfo) : null), [modelInfo]) + + const effortLabel = React.useCallback( + (effort: ReasoningEffortSetting) => { + switch (effort) { + case "disable": + return t("chat:reasoningEffortSelector.off") + case "none": + case "minimal": + case "low": + case "medium": + case "high": + case "xhigh": + case "max": + return t(`settings:providers.reasoningEffort.${effort}`) + } + }, + [t], + ) + + if (!modelInfo || !supportedEfforts || !provider || !currentApiConfigName) { + return null + } + + const override = apiConfiguration.reasoningEffortOverride + const overrideActive = override !== undefined && supportedEfforts.includes(override) + const activeEffort = resolveActiveEffort(apiConfiguration, modelInfo, supportedEfforts) + + const triggerLabel = activeEffort !== undefined ? effortLabel(activeEffort) : t("chat:reasoningEffortSelector.off") + + const handleSelect = (effort: ReasoningEffortSetting | null) => { + vscode.postMessage({ + type: "updateReasoningEffortOverride", + text: currentApiConfigName, + values: { expectedProvider: provider, effort }, + }) + setOpen(false) + } + + return ( + + + + {triggerLabel} + {overrideActive && ( + + )} + + + +
+
+

+ {t("chat:reasoningEffortSelector.description")} +

+
+
+ + {supportedEfforts.map((effort) => { + const isSelected = overrideActive && override === effort + return ( + + ) + })} +
+
+
+
+ ) +} diff --git a/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.fixture.tsx b/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.fixture.tsx index 7585881f14..d2e8f73f9d 100644 --- a/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.fixture.tsx +++ b/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.fixture.tsx @@ -4,13 +4,15 @@ import { defaultModeSlug, type Mode } from "@roo/modes" import { AppProviders } from "../../../../playwright/AppProviders" import { ChatTextArea } from "../ChatTextArea" -export function ChatTextAreaStory() { +type StoryInitialState = NonNullable["initialState"]> + +export function ChatTextAreaStory({ initialState }: { initialState?: StoryInitialState }) { const [inputValue, setInputValue] = useState("Audit contrast across the Zoo Code webview") const [selectedImages, setSelectedImages] = useState([]) const [mode, setMode] = useState(defaultModeSlug) return ( - +
diff --git a/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.tsx b/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.tsx index 69ad3e675c..fb53b377b6 100644 --- a/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.tsx +++ b/webview-ui/src/components/chat/__tests__/ChatTextArea.visual.tsx @@ -22,4 +22,24 @@ for (const theme of visualThemes) { focusedControl: editor, }) }) + + test(`renders the reasoning-effort switcher in the VS Code ${theme.name} theme`, async ({ mount, page }) => { + const component = mountedStory(await mount("chat-text-area-reasoning-effort")) + await applyVisualTheme(page, theme) + await page.evaluate(() => Object.assign(globalThis, { z: undefined })) + const story = component.getByTestId("chat-text-area-story") + const editor = story.getByRole("textbox") + const trigger = story.getByTestId("reasoning-effort-selector-trigger") + await expect(editor).toBeVisible() + await expect(trigger).toBeVisible() + await expect(story).toHaveScreenshot(`chat-composer-reasoning-resting-${theme.name}.png`) + + await trigger.click() + // The popover portals into #roo-portal on document.body, outside the story subtree. + const defaultItem = page.getByTestId("reasoning-effort-item-default") + const highItem = page.getByTestId("reasoning-effort-item-high") + await expect(defaultItem).toBeVisible() + await expect(highItem).toBeVisible() + await expect(story).toHaveScreenshot(`chat-composer-reasoning-menu-${theme.name}.png`) + }) } diff --git a/webview-ui/src/components/chat/__tests__/ReasoningEffortSelector.spec.tsx b/webview-ui/src/components/chat/__tests__/ReasoningEffortSelector.spec.tsx new file mode 100644 index 0000000000..f2c2c82434 --- /dev/null +++ b/webview-ui/src/components/chat/__tests__/ReasoningEffortSelector.spec.tsx @@ -0,0 +1,191 @@ +import { render, screen, fireEvent } from "@/utils/test-utils" + +import { providerIdentifiers, type ModelInfo, type ProviderSettings } from "@roo-code/types" + +import { ReasoningEffortSelector } from "../ReasoningEffortSelector" + +vi.mock("@/utils/vscode", () => ({ + vscode: { + postMessage: vi.fn(), + }, +})) + +const extensionState = vi.hoisted(() => ({ + currentApiConfigName: "default" as string | undefined, +})) + +vi.mock("@/context/ExtensionStateContext", () => ({ + useExtensionState: () => extensionState, +})) + +vi.mock("@/i18n/TranslationContext", () => ({ + useAppTranslation: () => ({ + t: (key: string) => key, + }), +})) + +vi.mock("@/components/ui/hooks/useRooPortal", () => ({ + useRooPortal: () => document.body, +})) + +const selectedModel = vi.hoisted(() => ({ + value: { + provider: "", + id: "test-model", + info: undefined as ModelInfo | undefined, + }, +})) + +vi.mock("@/components/ui/hooks/useSelectedModel", () => ({ + useSelectedModel: () => selectedModel.value, +})) + +import { vscode } from "@/utils/vscode" + +const capableInfo: ModelInfo = { + contextWindow: 128_000, + supportsPromptCache: false, + supportsReasoningEffort: ["low", "medium", "high"], + reasoningEffort: "medium", +} + +describe("ReasoningEffortSelector", () => { + beforeEach(() => { + vi.clearAllMocks() + extensionState.currentApiConfigName = "default" + selectedModel.value = { provider: providerIdentifiers.openai, id: "test-model", info: capableInfo } + }) + + const renderSelector = (apiConfiguration: ProviderSettings = {}, title = "Reasoning effort") => + render() + + test("renders nothing when the active model does not support reasoning effort", () => { + selectedModel.value = { + provider: providerIdentifiers.openai, + id: "test-model", + info: { contextWindow: 128_000, supportsPromptCache: false }, + } + + const { container } = renderSelector({}) + + expect(container).toBeEmptyDOMElement() + }) + + test("renders nothing when there is no active profile", () => { + extensionState.currentApiConfigName = undefined + + const { container } = renderSelector({}) + + expect(container).toBeEmptyDOMElement() + }) + + test("shows the active effort on the trigger, resolving the model default", () => { + renderSelector({}) + + expect(screen.getByTestId("reasoning-effort-selector-trigger")).toHaveTextContent( + "settings:providers.reasoningEffort.medium", + ) + }) + + test("shows Off when reasoning is disabled by the profile", () => { + renderSelector({ enableReasoningEffort: false, reasoningEffort: "high" }) + + expect(screen.getByTestId("reasoning-effort-selector-trigger")).toHaveTextContent( + "chat:reasoningEffortSelector.off", + ) + }) + + test("offers exactly the supported efforts plus Default", () => { + renderSelector({}) + + fireEvent.click(screen.getByTestId("reasoning-effort-selector-trigger")) + + expect(screen.getByTestId("reasoning-effort-item-default")).toBeInTheDocument() + expect(screen.getByTestId("reasoning-effort-item-low")).toBeInTheDocument() + expect(screen.getByTestId("reasoning-effort-item-medium")).toBeInTheDocument() + expect(screen.getByTestId("reasoning-effort-item-high")).toBeInTheDocument() + expect(screen.queryByTestId("reasoning-effort-item-none")).not.toBeInTheDocument() + expect(screen.queryByTestId("reasoning-effort-item-xhigh")).not.toBeInTheDocument() + }) + + test("marks Default as current when no override is active", () => { + renderSelector({}) + + fireEvent.click(screen.getByTestId("reasoning-effort-selector-trigger")) + + expect(screen.getByTestId("reasoning-effort-item-default")).toHaveAttribute("aria-current", "true") + expect(screen.queryByTestId("reasoning-effort-override-indicator")).not.toBeInTheDocument() + }) + + test("reflects the active override on the trigger and in the menu", () => { + renderSelector({ reasoningEffort: "low", reasoningEffortOverride: "high" }) + + const trigger = screen.getByTestId("reasoning-effort-selector-trigger") + expect(trigger).toHaveTextContent("settings:providers.reasoningEffort.high") + expect(screen.getByTestId("reasoning-effort-override-indicator")).toBeInTheDocument() + + fireEvent.click(trigger) + + expect(screen.getByTestId("reasoning-effort-item-high")).toHaveAttribute("aria-current", "true") + expect(screen.getByTestId("reasoning-effort-item-default")).toHaveAttribute("aria-current", "false") + }) + + test("selecting an effort posts the override message with the profile name and provider", () => { + renderSelector({}) + + fireEvent.click(screen.getByTestId("reasoning-effort-selector-trigger")) + fireEvent.click(screen.getByTestId("reasoning-effort-item-high")) + + expect(vscode.postMessage).toHaveBeenCalledWith({ + type: "updateReasoningEffortOverride", + text: "default", + values: { expectedProvider: providerIdentifiers.openai, effort: "high" }, + }) + }) + + test("selecting Default posts a null effort to clear the override", () => { + renderSelector({ reasoningEffortOverride: "high" }) + + fireEvent.click(screen.getByTestId("reasoning-effort-selector-trigger")) + fireEvent.click(screen.getByTestId("reasoning-effort-item-default")) + + expect(vscode.postMessage).toHaveBeenCalledWith({ + type: "updateReasoningEffortOverride", + text: "default", + values: { expectedProvider: providerIdentifiers.openai, effort: null }, + }) + }) + + test("labels the disable entry as Off when the model supports it", () => { + selectedModel.value = { + provider: providerIdentifiers.openai, + id: "test-model", + info: { + contextWindow: 128_000, + supportsPromptCache: false, + supportsReasoningEffort: ["disable", "medium"], + }, + } + + renderSelector({}) + + fireEvent.click(screen.getByTestId("reasoning-effort-selector-trigger")) + + expect(screen.getByTestId("reasoning-effort-item-disable")).toBeInTheDocument() + expect(screen.getByTestId("reasoning-effort-item-disable")).toHaveTextContent( + "chat:reasoningEffortSelector.off", + ) + }) + + test("ignores an override the active model does not support", () => { + renderSelector({ reasoningEffort: "low", reasoningEffortOverride: "xhigh" }) + + const trigger = screen.getByTestId("reasoning-effort-selector-trigger") + expect(trigger).toHaveTextContent("settings:providers.reasoningEffort.low") + expect(screen.queryByTestId("reasoning-effort-override-indicator")).not.toBeInTheDocument() + + fireEvent.click(trigger) + + expect(screen.getByTestId("reasoning-effort-item-default")).toHaveAttribute("aria-current", "true") + }) +}) diff --git a/webview-ui/src/i18n/locales/ca/chat.json b/webview-ui/src/i18n/locales/ca/chat.json index d4a7cfe89b..e92b5a5d4a 100644 --- a/webview-ui/src/i18n/locales/ca/chat.json +++ b/webview-ui/src/i18n/locales/ca/chat.json @@ -519,5 +519,12 @@ "hiddenLines_one": "{{count}} línia oculta", "hiddenLines_many": "{{count}} de línies ocultes", "hiddenLines_other": "{{count}} línies ocultes" + }, + "reasoningEffortSelector": { + "title": "Esforç de raonament", + "description": "Canvia l'esforç de raonament utilitzat a les sol·licituds d'aquesta configuració. «Per defecte» restaura el paràmetre del perfil.", + "default": "Per defecte", + "off": "Desactivat", + "overrideActive": "La substitució de l'esforç de raonament és activa" } } diff --git a/webview-ui/src/i18n/locales/de/chat.json b/webview-ui/src/i18n/locales/de/chat.json index 71d145f3b7..f98a8503e8 100644 --- a/webview-ui/src/i18n/locales/de/chat.json +++ b/webview-ui/src/i18n/locales/de/chat.json @@ -511,5 +511,12 @@ "diffView": { "hiddenLines_one": "{{count}} ausgeblendete Zeile", "hiddenLines_other": "{{count}} ausgeblendete Zeilen" + }, + "reasoningEffortSelector": { + "title": "Denkaufwand", + "description": "Denkaufwand für Anfragen dieser Konfiguration umschalten. „Standard“ stellt die Profileinstellung wieder her.", + "default": "Standard", + "off": "Aus", + "overrideActive": "Denkaufwand-Override ist aktiv" } } diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index 08dde55a89..f1d1d190ba 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -499,5 +499,12 @@ "diffView": { "hiddenLines_one": "{{count}} hidden line", "hiddenLines_other": "{{count}} hidden lines" + }, + "reasoningEffortSelector": { + "title": "Reasoning effort", + "description": "Switch the reasoning effort used for requests with this configuration. Default restores the provider setting.", + "default": "Default", + "off": "Off", + "overrideActive": "Reasoning effort override is active" } } diff --git a/webview-ui/src/i18n/locales/es/chat.json b/webview-ui/src/i18n/locales/es/chat.json index cd3d926371..8b2b5bfb63 100644 --- a/webview-ui/src/i18n/locales/es/chat.json +++ b/webview-ui/src/i18n/locales/es/chat.json @@ -519,5 +519,12 @@ "hiddenLines_one": "{{count}} línea oculta", "hiddenLines_many": "{{count}} de líneas ocultas", "hiddenLines_other": "{{count}} líneas ocultas" + }, + "reasoningEffortSelector": { + "title": "Esfuerzo de razonamiento", + "description": "Cambia el esfuerzo de razonamiento usado en las solicitudes de esta configuración. «Predeterminado» restablece el ajuste del perfil.", + "default": "Predeterminado", + "off": "Desactivado", + "overrideActive": "La anulación del esfuerzo de razonamiento está activa" } } diff --git a/webview-ui/src/i18n/locales/fr/chat.json b/webview-ui/src/i18n/locales/fr/chat.json index 4e134b01d3..5dbc6f9a15 100644 --- a/webview-ui/src/i18n/locales/fr/chat.json +++ b/webview-ui/src/i18n/locales/fr/chat.json @@ -519,5 +519,12 @@ "hiddenLines_one": "{{count}} ligne masquée", "hiddenLines_many": "{{count}} de lignes masquées", "hiddenLines_other": "{{count}} lignes masquées" + }, + "reasoningEffortSelector": { + "title": "Effort de raisonnement", + "description": "Change l'effort de raisonnement utilisé pour les requêtes de cette configuration. « Par défaut » rétablit le réglage du profil.", + "default": "Par défaut", + "off": "Désactivé", + "overrideActive": "Le remplacement de l'effort de raisonnement est actif" } } diff --git a/webview-ui/src/i18n/locales/hi/chat.json b/webview-ui/src/i18n/locales/hi/chat.json index ece7f713c7..113a4c33a9 100644 --- a/webview-ui/src/i18n/locales/hi/chat.json +++ b/webview-ui/src/i18n/locales/hi/chat.json @@ -511,5 +511,12 @@ "diffView": { "hiddenLines_one": "{{count}} छिपी हुई पंक्ति", "hiddenLines_other": "{{count}} छिपी हुई पंक्तियाँ" + }, + "reasoningEffortSelector": { + "title": "तर्क प्रयास", + "description": "इस कॉन्फ़िगरेशन के अनुरोधों में उपयोग होने वाला तर्क प्रयास बदलें। \"डिफ़ॉल्ट\" प्रोफ़ाइल सेटिंग पुनर्स्थापित करता है।", + "default": "डिफ़ॉल्ट", + "off": "बंद", + "overrideActive": "तर्क प्रयास ओवरराइड सक्रिय है" } } diff --git a/webview-ui/src/i18n/locales/id/chat.json b/webview-ui/src/i18n/locales/id/chat.json index aae3b84e36..96ff1d4866 100644 --- a/webview-ui/src/i18n/locales/id/chat.json +++ b/webview-ui/src/i18n/locales/id/chat.json @@ -509,5 +509,12 @@ }, "diffView": { "hiddenLines_other": "{{count}} baris tersembunyi" + }, + "reasoningEffortSelector": { + "title": "Upaya penalaran", + "description": "Mengubah upaya penalaran yang digunakan untuk permintaan konfigurasi ini. \"Bawaan\" memulihkan setelan profil.", + "default": "Bawaan", + "off": "Mati", + "overrideActive": "Pengesampingan upaya penalaran aktif" } } diff --git a/webview-ui/src/i18n/locales/it/chat.json b/webview-ui/src/i18n/locales/it/chat.json index eaeb775b76..dd878d8960 100644 --- a/webview-ui/src/i18n/locales/it/chat.json +++ b/webview-ui/src/i18n/locales/it/chat.json @@ -519,5 +519,12 @@ "hiddenLines_one": "{{count}} riga nascosta", "hiddenLines_many": "{{count}} di righe nascoste", "hiddenLines_other": "{{count}} righe nascoste" + }, + "reasoningEffortSelector": { + "title": "Sforzo di ragionamento", + "description": "Modifica lo sforzo di ragionamento usato per le richieste di questa configurazione. «Predefinito» ripristina l'impostazione del profilo.", + "default": "Predefinito", + "off": "Disattivato", + "overrideActive": "La sostituzione dello sforzo di ragionamento è attiva" } } diff --git a/webview-ui/src/i18n/locales/ja/chat.json b/webview-ui/src/i18n/locales/ja/chat.json index e9277e7ff0..7c7f73ce4e 100644 --- a/webview-ui/src/i18n/locales/ja/chat.json +++ b/webview-ui/src/i18n/locales/ja/chat.json @@ -503,5 +503,12 @@ }, "diffView": { "hiddenLines_other": "{{count}} 行が非表示" + }, + "reasoningEffortSelector": { + "title": "推論の強さ", + "description": "この構成のリクエストで使用する推論の強さを切り替えます。「デフォルト」に戻すとプロファイルの設定が使われます。", + "default": "デフォルト", + "off": "オフ", + "overrideActive": "推論の強さの上書きが有効です" } } diff --git a/webview-ui/src/i18n/locales/ko/chat.json b/webview-ui/src/i18n/locales/ko/chat.json index 28113bfd46..5c76a116b1 100644 --- a/webview-ui/src/i18n/locales/ko/chat.json +++ b/webview-ui/src/i18n/locales/ko/chat.json @@ -503,5 +503,12 @@ }, "diffView": { "hiddenLines_other": "숨겨진 줄 {{count}}개" + }, + "reasoningEffortSelector": { + "title": "추론 강도", + "description": "이 구성의 요청에 사용할 추론 강도를 전환합니다. '기본값'을 선택하면 프로필 설정이 복원됩니다.", + "default": "기본값", + "off": "끄기", + "overrideActive": "추론 강도 재정의가 활성화되어 있습니다" } } diff --git a/webview-ui/src/i18n/locales/nl/chat.json b/webview-ui/src/i18n/locales/nl/chat.json index 0523738314..822eb5df93 100644 --- a/webview-ui/src/i18n/locales/nl/chat.json +++ b/webview-ui/src/i18n/locales/nl/chat.json @@ -511,5 +511,12 @@ "diffView": { "hiddenLines_one": "{{count}} verborgen regel", "hiddenLines_other": "{{count}} verborgen regels" + }, + "reasoningEffortSelector": { + "title": "Redeneerinspanning", + "description": "Schakelt de redeneerinspanning om die voor verzoeken van deze configuratie wordt gebruikt. \"Standaard\" herstelt de profielinstelling.", + "default": "Standaard", + "off": "Uit", + "overrideActive": "Overschrijiding van de redeneerinspanning is actief" } } diff --git a/webview-ui/src/i18n/locales/pl/chat.json b/webview-ui/src/i18n/locales/pl/chat.json index 30997cccfc..56b7bb3a06 100644 --- a/webview-ui/src/i18n/locales/pl/chat.json +++ b/webview-ui/src/i18n/locales/pl/chat.json @@ -527,5 +527,12 @@ "hiddenLines_few": "{{count}} ukryte wiersze", "hiddenLines_many": "{{count}} ukrytych wierszy", "hiddenLines_other": "{{count}} ukrytego wiersza" + }, + "reasoningEffortSelector": { + "title": "Poziom rozumowania", + "description": "Przełącza poziom rozumowania używany w żądaniach tej konfiguracji. „Domyślny” przywraca ustawienie profilu.", + "default": "Domyślny", + "off": "Wył.", + "overrideActive": "Zastąpienie poziomu rozumowania jest aktywne" } } diff --git a/webview-ui/src/i18n/locales/pt-BR/chat.json b/webview-ui/src/i18n/locales/pt-BR/chat.json index a865671b83..f44048b60b 100644 --- a/webview-ui/src/i18n/locales/pt-BR/chat.json +++ b/webview-ui/src/i18n/locales/pt-BR/chat.json @@ -519,5 +519,12 @@ "hiddenLines_one": "{{count}} linha oculta", "hiddenLines_many": "{{count}} de linhas ocultas", "hiddenLines_other": "{{count}} linhas ocultas" + }, + "reasoningEffortSelector": { + "title": "Esforço de raciocínio", + "description": "Altera o esforço de raciocínio usado nas solicitações desta configuração. «Padrão» restaura a configuração do perfil.", + "default": "Padrão", + "off": "Desativado", + "overrideActive": "A substituição do esforço de raciocínio está ativa" } } diff --git a/webview-ui/src/i18n/locales/ru/chat.json b/webview-ui/src/i18n/locales/ru/chat.json index 1da6f0846c..4d6d89a8dd 100644 --- a/webview-ui/src/i18n/locales/ru/chat.json +++ b/webview-ui/src/i18n/locales/ru/chat.json @@ -528,5 +528,12 @@ "hiddenLines_few": "{{count}} скрытые строки", "hiddenLines_many": "{{count}} скрытых строк", "hiddenLines_other": "{{count}} скрытой строки" + }, + "reasoningEffortSelector": { + "title": "Уровень рассуждений", + "description": "Переключает уровень рассуждений для запросов этой конфигурации. «По умолчанию» возвращает настройку профиля.", + "default": "По умолчанию", + "off": "Выкл.", + "overrideActive": "Переопределение уровня рассуждений активно" } } diff --git a/webview-ui/src/i18n/locales/tr/chat.json b/webview-ui/src/i18n/locales/tr/chat.json index 30902a0dd0..b31a0e2c02 100644 --- a/webview-ui/src/i18n/locales/tr/chat.json +++ b/webview-ui/src/i18n/locales/tr/chat.json @@ -512,5 +512,12 @@ "diffView": { "hiddenLines_one": "{{count}} gizli satır", "hiddenLines_other": "{{count}} gizli satır" + }, + "reasoningEffortSelector": { + "title": "Akıl yürütme düzeyi", + "description": "Bu yapılandırmanın isteklerinde kullanılan akıl yürütme düzeyini değiştirir. \"Varsayılan\" profil ayarını geri yükler.", + "default": "Varsayılan", + "off": "Kapalı", + "overrideActive": "Akıl yürütme düzeyi geçersiz kılması etkin" } } diff --git a/webview-ui/src/i18n/locales/vi/chat.json b/webview-ui/src/i18n/locales/vi/chat.json index b6468c44f7..401c505cce 100644 --- a/webview-ui/src/i18n/locales/vi/chat.json +++ b/webview-ui/src/i18n/locales/vi/chat.json @@ -504,5 +504,12 @@ }, "diffView": { "hiddenLines_other": "{{count}} dòng bị ẩn" + }, + "reasoningEffortSelector": { + "title": "Mức suy luận", + "description": "Chuyển đổi mức suy luận dùng cho các yêu cầu của cấu hình này. \"Mặc định\" khôi phục cài đặt của hồ sơ.", + "default": "Mặc định", + "off": "Tắt", + "overrideActive": "Ghi đè mức suy luận đang bật" } } diff --git a/webview-ui/src/i18n/locales/zh-CN/chat.json b/webview-ui/src/i18n/locales/zh-CN/chat.json index ab3bc22c67..b3705770c5 100644 --- a/webview-ui/src/i18n/locales/zh-CN/chat.json +++ b/webview-ui/src/i18n/locales/zh-CN/chat.json @@ -504,5 +504,12 @@ }, "diffView": { "hiddenLines_other": "已隐藏 {{count}} 行" + }, + "reasoningEffortSelector": { + "title": "推理强度", + "description": "切换此配置请求所使用的推理强度。选择“默认”将恢复配置文件中的设置。", + "default": "默认", + "off": "关闭", + "overrideActive": "推理强度覆盖已生效" } } diff --git a/webview-ui/src/i18n/locales/zh-TW/chat.json b/webview-ui/src/i18n/locales/zh-TW/chat.json index 8143b8434b..b9e7e09dda 100644 --- a/webview-ui/src/i18n/locales/zh-TW/chat.json +++ b/webview-ui/src/i18n/locales/zh-TW/chat.json @@ -494,5 +494,12 @@ }, "diffView": { "hiddenLines_other": "已隱藏 {{count}} 行" + }, + "reasoningEffortSelector": { + "title": "推理強度", + "description": "切換此設定檔請求所使用的推理強度。選擇「預設」將還原設定檔中的設定。", + "default": "預設", + "off": "關閉", + "overrideActive": "推理強度覆寫已生效" } } From 39ab44f5595c0d72f8f6d791b80f37e5cb62a8cf Mon Sep 17 00:00:00 2001 From: "@taltas" <6816042+taltas@users.noreply.github.com> Date: Sat, 21 Nov 2026 03:37:27 +0000 Subject: [PATCH 2/2] fix: narrow gallery story override prop for type checking --- webview-ui/playwright/gallery/stories.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webview-ui/playwright/gallery/stories.tsx b/webview-ui/playwright/gallery/stories.tsx index 28085c123e..1071bb5c45 100644 --- a/webview-ui/playwright/gallery/stories.tsx +++ b/webview-ui/playwright/gallery/stories.tsx @@ -209,18 +209,19 @@ export const stories: Record = { const { ChatTextAreaStory } = await import("@/components/chat/__tests__/ChatTextArea.visual.fixture") return }, - "chat-text-area-reasoning-effort": async ({ override = "" } = {}) => { - const [{ ChatTextAreaStory }, { providerIdentifiers }] = await Promise.all([ + "chat-text-area-reasoning-effort": async (props) => { + const [{ ChatTextAreaStory }, { providerIdentifiers, reasoningEffortSettingValues }] = await Promise.all([ import("@/components/chat/__tests__/ChatTextArea.visual.fixture"), import("@roo-code/types"), ]) // A reasoning-capable OpenAI-compatible profile, so the quick switcher renders. // `override` presets a chat override to show the active-override treatment. + const override = reasoningEffortSettingValues.find((value) => value === props.override) const apiConfiguration = { apiProvider: providerIdentifiers.openai, openAiModelId: "test-model", enableReasoningEffort: true, - reasoningEffortOverride: override ? override : undefined, + reasoningEffortOverride: override, openAiCustomModelInfo: { contextWindow: 128_000, supportsPromptCache: false,