Skip to content

Commit cf67a79

Browse files
refactor(dte): keep only the task-runtime-effort unit in this PR
CodeRabbit's out-of-scope check lists content this unit does not own. Those files come out, so the diff matches the stated scope: transient task-local thinking-effort state on Task, its per-request delivery at the four request sites, and the tests for that behaviour. The dynamicThinkingEffort experiment flag is the experiment-flag unit, tracked by Zoo-Code-Org#2079 and carried by its own PR. That removes packages/types/src/experiment.ts, the DYNAMIC_THINKING_EFFORT registration in src/shared/experiments.ts, the new packages/types/src/__tests__/experiment.test.ts, the flag cases in src/shared/__tests__/experiments.spec.ts, the ExperimentalSettings and SettingsView cases in webview-ui, the three getStateToPostToWebview cases and the whole "webviewMessageHandler - experiments" describe in src/core/webview/__tests__/ webviewMessageHandler.spec.ts. Nothing in this unit's production code reads the flag - the only readers anywhere in the tree were those specs - and the registration comment itself says the toggle would only persist a flag with no model-facing effect until the PR that registers the set_thinking_effort tool ships, so no code path here depends on what is being removed. scripts/stryker-diff.mjs and scripts/stryker-diff.test.mjs carried only a reflow of the comment explaining why the extension entry uses plugin-side related-test discovery; that text belongs to the mutation-gate unit, and the behaviour assertions in both files are unchanged either way. Two files stay and the description now names them. src/api/index.ts adds exactly the ApiHandlerCreateMessageMetadata.reasoningEffort declaration (plus its type import and doc comment): the four request sites in Task.ts spread the task-local override into that metadata object, so the field is this unit's requirement, not another unit's. src/core/webview/__tests__/ ClineProvider.spec.ts keeps the case that the webview receives the active task's apiConfiguration object - the projection contract that makes "the override never enters apiConfiguration" testable from the provider side - and drops only the flag cases above. Tests: core/webview/__tests__/ClineProvider.spec.ts, shared/__tests__/experiments.spec.ts and core/task/__tests__/Task.runtime-thinking-effort.test.ts pass together (3 files, 332 tests); webview-ui ExperimentalSettings.spec.tsx and SettingsView.spec.tsx pass (2 files, 32 tests); tsc --noEmit is clean for src and for webview-ui. eslint --max-warnings=0 --prune-suppressions leaves src/eslint-suppressions.json byte-identical (per-file rule counts compared before/after: unchanged), and prettier --check is clean on the four files still differing from the base.
1 parent b2b31f7 commit cf67a79

10 files changed

Lines changed: 10 additions & 263 deletions

File tree

‎packages/types/src/__tests__/experiment.test.ts‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎packages/types/src/experiment.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const experimentIds = [
1212
"runSlashCommand",
1313
"customTools",
1414
"parallelToolExecution",
15-
"dynamicThinkingEffort",
1615
] as const
1716

1817
export const experimentIdsSchema = z.enum(experimentIds)
@@ -29,7 +28,6 @@ export const experimentsSchema = z.object({
2928
runSlashCommand: z.boolean().optional(),
3029
customTools: z.boolean().optional(),
3130
parallelToolExecution: z.boolean().optional(),
32-
dynamicThinkingEffort: z.boolean().optional(),
3331
})
3432

3533
export type Experiments = z.infer<typeof experimentsSchema>

‎scripts/stryker-diff.mjs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ export const PACKAGE_CONFIGS = [
5757
root: "src",
5858
sourceRoot: "src/",
5959
vitestConfig: "vitest.config.ts",
60-
61-
// Use plugin-side related-test discovery: with an explicit STRYKER_TEST_FILES
62-
// list, stryker-js 10.0.0 plans static mutants with runtime activation
63-
// (stryker-mutator/stryker-js#6144, #6209), which the vitest plugin can only
64-
// apply after top-level code has run, producing false Survived results.
65-
// Revert to vitestRelated: false / discoverRelatedTests: true once the
60+
// Use plugin-side related-test discovery for the extension package: with an
61+
// explicit STRYKER_TEST_FILES list, stryker-js 10.0.0 plans static mutants with
62+
// runtime activation (stryker-mutator/stryker-js#6144, #6209), which the vitest
63+
// plugin can only apply after top-level code has run, producing false Survived
64+
// results. Revert to vitestRelated: false / discoverRelatedTests: true once the
6665
// upstream planner fix lands.
6766
vitestRelated: true,
6867
discoverRelatedTests: false,

‎scripts/stryker-diff.test.mjs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,9 @@ describe("buildManifest", () => {
254254
assert.equal(webview.runRoot, ".")
255255
assert.equal(webview.discoverRelatedTests, true)
256256
assert.equal(webview.vitestRelated, false)
257-
258-
// The extension entry uses plugin-side related discovery while stryker-js 10.0.0
259-
// plans static mutants with runtime activation when given explicit test files
260-
// (stryker-mutator/stryker-js#6144, #6209); see the entry comment in stryker-diff.mjs.
257+
// The extension package deliberately uses plugin-side discovery (see the
258+
// comment in PACKAGE_CONFIGS): stryker-js 10.0.0 mis-activates static mutants
259+
// when an explicit STRYKER_TEST_FILES list is supplied.
261260
assert.equal(extension.discoverRelatedTests, false)
262261
assert.equal(extension.vitestRelated, true)
263262
const types = manifest.packages.find(({ id }) => id === "types")

‎src/core/webview/__tests__/ClineProvider.spec.ts‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,38 +4178,6 @@ describe("ClineProvider", () => {
41784178
expect(state.destructiveCommandGuardEnabled).toBe(false)
41794179
})
41804180

4181-
test("getStateToPostToWebview returns the saved dynamicThinkingEffort experiment when enabled", async () => {
4182-
await provider.resolveWebviewView(mockWebviewView)
4183-
await provider.contextProxy.setValue("experiments", {
4184-
...experimentDefault,
4185-
dynamicThinkingEffort: true,
4186-
})
4187-
4188-
const state = await provider.getStateToPostToWebview()
4189-
4190-
expect(state.experiments).toEqual({ ...experimentDefault, dynamicThinkingEffort: true })
4191-
})
4192-
4193-
test("getStateToPostToWebview returns the saved dynamicThinkingEffort experiment when explicitly disabled", async () => {
4194-
await provider.resolveWebviewView(mockWebviewView)
4195-
await provider.contextProxy.setValue("experiments", {
4196-
...experimentDefault,
4197-
dynamicThinkingEffort: false,
4198-
})
4199-
4200-
const state = await provider.getStateToPostToWebview()
4201-
4202-
expect(state.experiments).toEqual({ ...experimentDefault, dynamicThinkingEffort: false })
4203-
})
4204-
4205-
test("getStateToPostToWebview defaults dynamicThinkingEffort to false when experiments are unset", async () => {
4206-
await provider.resolveWebviewView(mockWebviewView)
4207-
4208-
const state = await provider.getStateToPostToWebview()
4209-
4210-
expect(state.experiments).toEqual({ ...experimentDefault, dynamicThinkingEffort: false })
4211-
})
4212-
42134181
test("getStateToPostToWebview returns the saved blanket auto-deny setting", async () => {
42144182
await provider.resolveWebviewView(mockWebviewView)
42154183
await provider.contextProxy.setValue("alwaysDenyUnapprovedCommands", true)

‎src/core/webview/__tests__/webviewMessageHandler.spec.ts‎

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ import * as copilotProvider from "../../../api/providers/github-copilot"
8484
import { webviewMessageHandler } from "../webviewMessageHandler"
8585
import { registerCopilotModelBroadcast } from "../../../services/language-models/copilotModelBroadcast"
8686
import type { ClineProvider } from "../ClineProvider"
87-
import { experimentDefault } from "../../../shared/experiments"
8887
import { flushModels, getModels } from "../../../api/providers/fetchers/modelCache"
8988
import { getLMStudioModels } from "../../../api/providers/fetchers/lmstudio"
9089
import { getCommands } from "../../../services/command/commands"
@@ -2973,60 +2972,6 @@ describe("webviewMessageHandler - telemetrySetting", () => {
29732972
})
29742973
})
29752974

2976-
describe("webviewMessageHandler - experiments", () => {
2977-
beforeEach(() => {
2978-
vi.clearAllMocks()
2979-
})
2980-
2981-
it("persists dynamicThinkingEffort true merged with the saved experiments", async () => {
2982-
vi.mocked(mockClineProvider.contextProxy.getValue).mockImplementation((key: string) =>
2983-
key === "experiments" ? { preventFocusDisruption: true } : undefined,
2984-
)
2985-
2986-
await webviewMessageHandler(mockClineProvider, {
2987-
type: "updateSettings",
2988-
updatedSettings: { experiments: { dynamicThinkingEffort: true } },
2989-
})
2990-
2991-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("experiments", {
2992-
preventFocusDisruption: true,
2993-
dynamicThinkingEffort: true,
2994-
})
2995-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalledTimes(1)
2996-
})
2997-
2998-
it("persists dynamicThinkingEffort false over a previously enabled value", async () => {
2999-
vi.mocked(mockClineProvider.contextProxy.getValue).mockImplementation((key: string) =>
3000-
key === "experiments" ? { dynamicThinkingEffort: true } : undefined,
3001-
)
3002-
3003-
await webviewMessageHandler(mockClineProvider, {
3004-
type: "updateSettings",
3005-
updatedSettings: { experiments: { dynamicThinkingEffort: false } },
3006-
})
3007-
3008-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("experiments", {
3009-
dynamicThinkingEffort: false,
3010-
})
3011-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalledTimes(1)
3012-
})
3013-
3014-
it("persists the experiment defaults when no experiments are saved yet", async () => {
3015-
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue(undefined)
3016-
3017-
await webviewMessageHandler(mockClineProvider, {
3018-
type: "updateSettings",
3019-
updatedSettings: { experiments: {} },
3020-
})
3021-
3022-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("experiments", {
3023-
...experimentDefault,
3024-
dynamicThinkingEffort: false,
3025-
})
3026-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalledTimes(1)
3027-
})
3028-
})
3029-
30302975
describe("webviewMessageHandler - collapseCommandOutputByDefault", () => {
30312976
beforeEach(() => {
30322977
vi.clearAllMocks()

‎src/shared/__tests__/experiments.spec.ts‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
import { EXPERIMENT_IDS, experimentConfigsMap, experimentDefault, experiments as Experiments } from "../experiments"
5+
import { EXPERIMENT_IDS, experimentConfigsMap, experiments as Experiments } from "../experiments"
66

77
describe("experiments", () => {
88
describe("PREVENT_FOCUS_DISRUPTION", () => {
@@ -22,7 +22,6 @@ describe("experiments", () => {
2222
runSlashCommand: false,
2323
customTools: false,
2424
parallelToolExecution: false,
25-
dynamicThinkingEffort: false,
2625
}
2726
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(false)
2827
})
@@ -34,7 +33,6 @@ describe("experiments", () => {
3433
runSlashCommand: false,
3534
customTools: false,
3635
parallelToolExecution: false,
37-
dynamicThinkingEffort: false,
3836
}
3937
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(true)
4038
})
@@ -46,7 +44,6 @@ describe("experiments", () => {
4644
runSlashCommand: false,
4745
customTools: false,
4846
parallelToolExecution: false,
49-
dynamicThinkingEffort: false,
5047
}
5148
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION)).toBe(false)
5249
})
@@ -69,28 +66,4 @@ describe("experiments", () => {
6966
expect(Experiments.isEnabled({ parallelToolExecution: true }, "parallelToolExecution")).toBe(true)
7067
})
7168
})
72-
73-
describe("DYNAMIC_THINKING_EFFORT", () => {
74-
it("is configured correctly", () => {
75-
expect(EXPERIMENT_IDS.DYNAMIC_THINKING_EFFORT).toBe("dynamicThinkingEffort")
76-
expect(experimentConfigsMap.DYNAMIC_THINKING_EFFORT).toMatchObject({
77-
enabled: false,
78-
})
79-
// Hidden from the Settings panel until the set_thinking_effort tool exists.
80-
expect(experimentConfigsMap.DYNAMIC_THINKING_EFFORT.showInSettings).toBe(false)
81-
})
82-
83-
it("is disabled by default", () => {
84-
expect(experimentDefault.dynamicThinkingEffort).toBe(false)
85-
expect(Experiments.isEnabled({}, "dynamicThinkingEffort")).toBe(false)
86-
})
87-
88-
it("returns true when enabled", () => {
89-
expect(Experiments.isEnabled({ dynamicThinkingEffort: true }, "dynamicThinkingEffort")).toBe(true)
90-
})
91-
92-
it("returns false when explicitly disabled", () => {
93-
expect(Experiments.isEnabled({ dynamicThinkingEffort: false }, "dynamicThinkingEffort")).toBe(false)
94-
})
95-
})
9669
})

‎src/shared/experiments.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const EXPERIMENT_IDS = {
66
RUN_SLASH_COMMAND: "runSlashCommand",
77
CUSTOM_TOOLS: "customTools",
88
PARALLEL_TOOL_EXECUTION: "parallelToolExecution",
9-
DYNAMIC_THINKING_EFFORT: "dynamicThinkingEffort",
109
} as const satisfies Record<string, ExperimentId>
1110

1211
type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
@@ -26,10 +25,6 @@ export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
2625
CUSTOM_TOOLS: { enabled: false },
2726
// TODO: add i18n keys (settings:experimental.PARALLEL_TOOL_EXECUTION.name/.description) in the same PR that sets showInSettings: true
2827
PARALLEL_TOOL_EXECUTION: { enabled: false, showInSettings: false },
29-
// TODO: set showInSettings: true in the PR that registers the set_thinking_effort
30-
// native tool (definition + handler); until then the toggle would only persist a
31-
// flag with no model-facing effect.
32-
DYNAMIC_THINKING_EFFORT: { enabled: false, showInSettings: false },
3328
}
3429

3530
export const experimentDefault = Object.fromEntries(

‎webview-ui/src/components/settings/__tests__/ExperimentalSettings.spec.tsx‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,4 @@ describe("ExperimentalSettings", () => {
3333
expect(screen.getByText("settings:experimental.CUSTOM_TOOLS.name")).toBeInTheDocument()
3434
expect(screen.queryByText("settings:experimental.PARALLEL_TOOL_EXECUTION.name")).not.toBeInTheDocument()
3535
})
36-
37-
it("hides the dynamic thinking effort toggle until the set_thinking_effort tool is registered", () => {
38-
// The flag persists and round-trips, but the tool is not in getNativeTools()
39-
// yet, so the toggle must not render - not even when the flag is enabled.
40-
const { unmount } = render(
41-
<ExperimentalSettings
42-
{...defaultProps}
43-
experiments={{ ...experimentDefault, dynamicThinkingEffort: true }}
44-
/>,
45-
)
46-
expect(screen.queryByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name")).not.toBeInTheDocument()
47-
unmount()
48-
49-
render(<ExperimentalSettings {...defaultProps} />)
50-
expect(screen.queryByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name")).not.toBeInTheDocument()
51-
})
5236
})

‎webview-ui/src/components/settings/__tests__/SettingsView.spec.tsx‎

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { renderWithExtensionState, screen, fireEvent, within, waitFor } from "@/
44
import { act } from "@testing-library/react"
55

66
import { vscode } from "@/utils/vscode"
7-
import { DEFAULT_CHECKPOINT_TIMEOUT_SECONDS, type ExtensionState, type ProviderSettings } from "@roo-code/types"
8-
import { experimentDefault } from "@roo/experiments"
7+
import { DEFAULT_CHECKPOINT_TIMEOUT_SECONDS, type ProviderSettings } from "@roo-code/types"
98
import type { ApiOptionsProps } from "../ApiOptions"
109

1110
import SettingsView from "../SettingsView"
@@ -338,28 +337,6 @@ const renderSettingsView = (initialState: any = {}) => {
338337
return { onDone, activateTab, getSettingsContent }
339338
}
340339

341-
// SettingsView seeds its edit buffer with `useState(() => extensionState)`, i.e. once, at
342-
// mount. Hydrating after mounting (the helper above) leaves that buffer on the pre-hydration
343-
// defaults, which is fine for rendering checks but cannot show a persisted value surviving a
344-
// save. These tests need the state to arrive first, which is the order the extension host
345-
// actually produces it in: state is hydrated long before the user opens Settings.
346-
const renderHydratedSettingsView = async (initialState: Partial<ExtensionState>) => {
347-
const onDone = vi.fn()
348-
const result = renderWithExtensionState(<div />)
349-
// window.postMessage reaches the context listener on a later task, so the hydration has
350-
// to be flushed before SettingsView mounts; otherwise the edit buffer seeds from the
351-
// pre-hydration defaults and the persisted value under test is never seen.
352-
await act(async () => {
353-
mockPostMessage(initialState)
354-
await new Promise((resolve) => setTimeout(resolve, 0))
355-
})
356-
result.rerender(<SettingsView onDone={onDone} />)
357-
const activateTab = (tabId: string) => {
358-
result.rerender(<SettingsView onDone={onDone} targetSection={tabId} />)
359-
}
360-
const getSettingsContent = () => screen.getByTestId("settings-content")
361-
return { onDone, activateTab, getSettingsContent }
362-
}
363340
describe("SettingsView - Sound Settings", () => {
364341
beforeEach(() => {
365342
vi.clearAllMocks()
@@ -896,78 +873,6 @@ describe("SettingsView - Duplicate Commands", () => {
896873
})
897874
})
898875

899-
describe("SettingsView - Experimental Settings", () => {
900-
beforeEach(() => {
901-
vi.clearAllMocks()
902-
})
903-
904-
it("does not render the dynamic thinking effort toggle while the tool is unregistered", async () => {
905-
const { activateTab, getSettingsContent } = await renderHydratedSettingsView({
906-
experiments: { ...experimentDefault, dynamicThinkingEffort: true },
907-
})
908-
activateTab("experimental")
909-
expect(
910-
within(getSettingsContent()).queryByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name"),
911-
).not.toBeInTheDocument()
912-
})
913-
914-
it("keeps a persisted dynamicThinkingEffort=true in the updateSettings payload while its toggle is hidden", async () => {
915-
// Hiding the toggle (set_thinking_effort tool not registered yet) must not drop the flag
916-
// from the save payload: the experiments object round-trips wholesale, so a persisted value
917-
// survives until the tool PR resurfaces it. Starting from true is what proves that - a test
918-
// that starts from the false default would also pass if the save path overwrote a persisted
919-
// true with the default.
920-
const { activateTab, getSettingsContent } = await renderHydratedSettingsView({
921-
experiments: { ...experimentDefault, dynamicThinkingEffort: true },
922-
})
923-
activateTab("experimental")
924-
expect(
925-
within(getSettingsContent()).queryByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name"),
926-
).not.toBeInTheDocument()
927-
// Dirty the form via a visible experimental toggle (save posts only when dirty).
928-
const visibleLabel = within(getSettingsContent())
929-
.getByText("settings:experimental.PREVENT_FOCUS_DISRUPTION.name")
930-
.closest("label")!
931-
fireEvent.click(within(visibleLabel).getByRole("checkbox"))
932-
fireEvent.click(screen.getByTestId("save-button"))
933-
expect(vscode.postMessage).toHaveBeenCalledWith(
934-
expect.objectContaining({
935-
type: "updateSettings",
936-
updatedSettings: expect.objectContaining({
937-
experiments: expect.objectContaining({ dynamicThinkingEffort: true }),
938-
}),
939-
}),
940-
)
941-
})
942-
943-
it("keeps a persisted dynamicThinkingEffort=false in the updateSettings payload while its toggle is hidden", async () => {
944-
// The false case gets its own test rather than being the only one: the experiment default is
945-
// also false, so the pair is what shows the payload carries the stored value instead of the
946-
// default.
947-
const { activateTab, getSettingsContent } = await renderHydratedSettingsView({
948-
experiments: { ...experimentDefault, dynamicThinkingEffort: false },
949-
})
950-
activateTab("experimental")
951-
expect(
952-
within(getSettingsContent()).queryByText("settings:experimental.DYNAMIC_THINKING_EFFORT.name"),
953-
).not.toBeInTheDocument()
954-
// Dirty the form via a visible experimental toggle (save posts only when dirty).
955-
const visibleLabel = within(getSettingsContent())
956-
.getByText("settings:experimental.PREVENT_FOCUS_DISRUPTION.name")
957-
.closest("label")!
958-
fireEvent.click(within(visibleLabel).getByRole("checkbox"))
959-
fireEvent.click(screen.getByTestId("save-button"))
960-
expect(vscode.postMessage).toHaveBeenCalledWith(
961-
expect.objectContaining({
962-
type: "updateSettings",
963-
updatedSettings: expect.objectContaining({
964-
experiments: expect.objectContaining({ dynamicThinkingEffort: false }),
965-
}),
966-
}),
967-
)
968-
})
969-
})
970-
971876
describe("SettingsView - Blanket Auto-Deny", () => {
972877
beforeEach(() => {
973878
vi.clearAllMocks()

0 commit comments

Comments
 (0)