Skip to content
Closed
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
19 changes: 19 additions & 0 deletions packages/types/src/__tests__/experiment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { experimentIds, experimentIdsSchema, experimentsSchema } from "../experiment.js"

describe("dynamicThinkingEffort experiment", () => {
it("is part of the experiment id enum", () => {
expect(experimentIds).toContain("dynamicThinkingEffort")
expect(experimentIdsSchema.safeParse("dynamicThinkingEffort").success).toBe(true)
})

it("parses enabled and disabled states", () => {
expect(experimentsSchema.parse({ dynamicThinkingEffort: true })).toEqual({ dynamicThinkingEffort: true })
expect(experimentsSchema.parse({ dynamicThinkingEffort: false })).toEqual({ dynamicThinkingEffort: false })
expect(experimentsSchema.parse({})).toEqual({})
})

it("rejects non-boolean values", () => {
expect(experimentsSchema.safeParse({ dynamicThinkingEffort: "yes" }).success).toBe(false)
expect(experimentIdsSchema.safeParse("dynamic-thinking-effort").success).toBe(false)
})
})
2 changes: 2 additions & 0 deletions packages/types/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const experimentIds = [
"runSlashCommand",
"customTools",
"parallelToolExecution",
"dynamicThinkingEffort",
] as const

export const experimentIdsSchema = z.enum(experimentIds)
Expand All @@ -28,6 +29,7 @@ export const experimentsSchema = z.object({
runSlashCommand: z.boolean().optional(),
customTools: z.boolean().optional(),
parallelToolExecution: z.boolean().optional(),
dynamicThinkingEffort: z.boolean().optional(),
})

export type Experiments = z.infer<typeof experimentsSchema>
Expand Down
10 changes: 8 additions & 2 deletions scripts/stryker-diff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ export const PACKAGE_CONFIGS = [
root: "src",
sourceRoot: "src/",
vitestConfig: "vitest.config.ts",
vitestRelated: false,
discoverRelatedTests: true,
// Use plugin-side related-test discovery: with an explicit STRYKER_TEST_FILES
// list, stryker-js 10.0.0 plans static mutants with runtime activation
// (stryker-mutator/stryker-js#6144, #6209), which the vitest plugin can only
// apply after top-level code has run, producing false Survived results.
// Revert to vitestRelated: false / discoverRelatedTests: true once the
// upstream planner fix lands.
vitestRelated: true,
discoverRelatedTests: false,
excludedPaths: ["src/esbuild.mjs", "src/eslint.config.mjs", "src/utils/vitest-verbosity.ts"],
},
]
Expand Down
7 changes: 5 additions & 2 deletions scripts/stryker-diff.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ describe("buildManifest", () => {
assert.equal(webview.runRoot, ".")
assert.equal(webview.discoverRelatedTests, true)
assert.equal(webview.vitestRelated, false)
assert.equal(extension.discoverRelatedTests, true)
assert.equal(extension.vitestRelated, false)
// The extension entry uses plugin-side related discovery while stryker-js 10.0.0
// plans static mutants with runtime activation when given explicit test files
// (stryker-mutator/stryker-js#6144, #6209); see the entry comment in stryker-diff.mjs.
assert.equal(extension.discoverRelatedTests, false)
assert.equal(extension.vitestRelated, true)
})

it("returns no packages for tests, barrels, unsupported packages, and type-only changes", () => {
Expand Down
29 changes: 28 additions & 1 deletion src/shared/__tests__/experiments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import type { ExperimentId } from "@roo-code/types"

import { EXPERIMENT_IDS, experimentConfigsMap, experiments as Experiments } from "../experiments"
import { EXPERIMENT_IDS, experimentConfigsMap, experimentDefault, experiments as Experiments } from "../experiments"

describe("experiments", () => {
describe("PREVENT_FOCUS_DISRUPTION", () => {
Expand All @@ -22,6 +22,7 @@ describe("experiments", () => {
runSlashCommand: false,
customTools: false,
parallelToolExecution: false,
dynamicThinkingEffort: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(false)
})
Expand All @@ -33,6 +34,7 @@ describe("experiments", () => {
runSlashCommand: false,
customTools: false,
parallelToolExecution: false,
dynamicThinkingEffort: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(true)
})
Expand All @@ -44,6 +46,7 @@ describe("experiments", () => {
runSlashCommand: false,
customTools: false,
parallelToolExecution: false,
dynamicThinkingEffort: false,
}
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(false)
})
Expand All @@ -66,4 +69,28 @@ describe("experiments", () => {
expect(Experiments.isEnabled({ parallelToolExecution: true }, "parallelToolExecution")).toBe(true)
})
})

describe("DYNAMIC_THINKING_EFFORT", () => {
it("is configured correctly", () => {
expect(EXPERIMENT_IDS.DYNAMIC_THINKING_EFFORT).toBe("dynamicThinkingEffort")
expect(experimentConfigsMap.DYNAMIC_THINKING_EFFORT).toMatchObject({
enabled: false,
})
// Visible in the Settings panel (showInSettings defaults to true).
expect(experimentConfigsMap.DYNAMIC_THINKING_EFFORT.showInSettings).toBeUndefined()
})

it("is disabled by default", () => {
expect(experimentDefault.dynamicThinkingEffort).toBe(false)
expect(Experiments.isEnabled({}, "dynamicThinkingEffort")).toBe(false)
})

it("returns true when enabled", () => {
expect(Experiments.isEnabled({ dynamicThinkingEffort: true }, "dynamicThinkingEffort")).toBe(true)
})

it("returns false when explicitly disabled", () => {
expect(Experiments.isEnabled({ dynamicThinkingEffort: false }, "dynamicThinkingEffort")).toBe(false)
})
})
})
2 changes: 2 additions & 0 deletions src/shared/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const EXPERIMENT_IDS = {
RUN_SLASH_COMMAND: "runSlashCommand",
CUSTOM_TOOLS: "customTools",
PARALLEL_TOOL_EXECUTION: "parallelToolExecution",
DYNAMIC_THINKING_EFFORT: "dynamicThinkingEffort",
} as const satisfies Record<string, ExperimentId>

type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
Expand All @@ -25,6 +26,7 @@ export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
CUSTOM_TOOLS: { enabled: false },
// TODO: add i18n keys (settings:experimental.PARALLEL_TOOL_EXECUTION.name/.description) in the same PR that sets showInSettings: true
PARALLEL_TOOL_EXECUTION: { enabled: false, showInSettings: false },
DYNAMIC_THINKING_EFFORT: { enabled: false },
}

export const experimentDefault = Object.fromEntries(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react"
import { fireEvent, render, screen } from "@testing-library/react"

import { experimentDefault } from "@roo/experiments"

Expand Down Expand Up @@ -32,4 +32,78 @@ describe("ExperimentalSettings", () => {
expect(screen.getByText("settings:experimental.CUSTOM_TOOLS.name")).toBeInTheDocument()
expect(screen.queryByText("settings:experimental.PARALLEL_TOOL_EXECUTION.name")).not.toBeInTheDocument()
})

it("renders the dynamic thinking effort toggle", () => {
render(<ExperimentalSettings {...defaultProps} />)

expect(screen.getByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name")).toBeInTheDocument()
})

it("leaves the dynamic thinking effort toggle unchecked when the value is false or omitted", () => {
const getCheckbox = () => {
const label = screen.getByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name").closest("label")
return label?.querySelector("input[type='checkbox']")
}

// Explicit false
let result = render(
<ExperimentalSettings
{...defaultProps}
experiments={{ ...experimentDefault, dynamicThinkingEffort: false }}
/>,
)
expect(getCheckbox()).not.toBeNull()
expect(getCheckbox()).not.toBeChecked()
result.unmount()

// Omitted (absent from the persisted config)
const omitted: Record<string, boolean> = { ...experimentDefault }
delete omitted.dynamicThinkingEffort
result = render(<ExperimentalSettings {...defaultProps} experiments={omitted} />)
expect(getCheckbox()).not.toBeNull()
expect(getCheckbox()).not.toBeChecked()
result.unmount()
})

it("binds the dynamic thinking effort toggle to setExperimentEnabled", () => {
const setExperimentEnabled = vi.fn()
render(
<ExperimentalSettings
{...defaultProps}
experiments={{ ...experimentDefault, dynamicThinkingEffort: true }}
setExperimentEnabled={setExperimentEnabled}
/>,
)

const label = screen.getByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name").closest("label")
const checkbox = label?.querySelector("input[type='checkbox']")
expect(checkbox).not.toBeNull()
expect(checkbox).toBeChecked()

fireEvent.click(checkbox!)

expect(setExperimentEnabled).toHaveBeenCalledTimes(1)
expect(setExperimentEnabled).toHaveBeenCalledWith("dynamicThinkingEffort", false)
})

it("toggles the dynamic thinking effort on when clicked from the unchecked state", () => {
const setExperimentEnabled = vi.fn()
render(
<ExperimentalSettings
{...defaultProps}
experiments={{ ...experimentDefault, dynamicThinkingEffort: false }}
setExperimentEnabled={setExperimentEnabled}
/>,
)

const label = screen.getByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name").closest("label")
const checkbox = label?.querySelector("input[type='checkbox']")
expect(checkbox).not.toBeNull()
expect(checkbox).not.toBeChecked()

fireEvent.click(checkbox!)

expect(setExperimentEnabled).toHaveBeenCalledTimes(1)
expect(setExperimentEnabled).toHaveBeenCalledWith("dynamicThinkingEffort", true)
})
})
4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ca/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/de/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,10 @@
"refreshSuccess": "Tools refreshed successfully",
"refreshError": "Failed to refresh tools",
"toolParameters": "Parameters"
},
"DYNAMIC_THINKING_EFFORT": {
"name": "Dynamic thinking effort",
"description": "Enables the set_thinking_effort tool so the model can decide its thinking effort per step. The manual in-chat control is always available. (experimental)"
}
},
"promptCaching": {
Expand Down
4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/es/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/fr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/hi/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/id/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/it/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ja/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ko/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/nl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/pl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/pt-BR/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/ru/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/tr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading