Skip to content

Commit 8256770

Browse files
committed
done
1 parent 8513263 commit 8256770

23 files changed

+165
-2
lines changed

packages/types/src/experiment.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import type { Keys, Equals, AssertEqual } from "./type-fu.js"
66
* ExperimentId
77
*/
88

9-
export const experimentIds = ["powerSteering", "multiFileApplyDiff", "preventFocusDisruption"] as const
9+
export const experimentIds = [
10+
"powerSteering",
11+
"multiFileApplyDiff",
12+
"preventFocusDisruption",
13+
"preventTerminalDisruption",
14+
] as const
1015

1116
export const experimentIdsSchema = z.enum(experimentIds)
1217

@@ -20,6 +25,7 @@ export const experimentsSchema = z.object({
2025
powerSteering: z.boolean().optional(),
2126
multiFileApplyDiff: z.boolean().optional(),
2227
preventFocusDisruption: z.boolean().optional(),
28+
preventTerminalDisruption: z.boolean().optional(),
2329
})
2430

2531
export type Experiments = z.infer<typeof experimentsSchema>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Integration test for PREVENT_TERMINAL_DISRUPTION functionality
2+
// npx vitest run src/core/tools/__tests__/executeCommandTool.preventTerminalDisruption.integration.spec.ts
3+
4+
import { EXPERIMENT_IDS, experiments } from "../../../shared/experiments"
5+
6+
describe("PREVENT_TERMINAL_DISRUPTION integration", () => {
7+
it("should have PREVENT_TERMINAL_DISRUPTION experiment defined", () => {
8+
expect(EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION).toBe("preventTerminalDisruption")
9+
})
10+
11+
it("should correctly check if PREVENT_TERMINAL_DISRUPTION is enabled", () => {
12+
// Test when experiment is disabled (default)
13+
const disabledConfig = { preventTerminalDisruption: false }
14+
expect(experiments.isEnabled(disabledConfig, EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION)).toBe(false)
15+
16+
// Test when experiment is enabled
17+
const enabledConfig = { preventTerminalDisruption: true }
18+
expect(experiments.isEnabled(enabledConfig, EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION)).toBe(true)
19+
20+
// Test when experiment is not in config (should use default)
21+
const emptyConfig = {}
22+
expect(experiments.isEnabled(emptyConfig, EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION)).toBe(false)
23+
})
24+
25+
it("should verify the executeCommandTool imports experiments correctly", async () => {
26+
// This test verifies that the executeCommandTool module can import and use experiments
27+
const executeCommandModule = await import("../executeCommandTool")
28+
expect(executeCommandModule).toBeDefined()
29+
expect(executeCommandModule.executeCommand).toBeDefined()
30+
expect(executeCommandModule.executeCommandTool).toBeDefined()
31+
})
32+
33+
it("should verify Terminal class structure for show method", async () => {
34+
// This test verifies the Terminal class has the expected structure
35+
const terminalModule = await import("../../../integrations/terminal/Terminal")
36+
expect(terminalModule.Terminal).toBeDefined()
37+
38+
// The Terminal class should have a constructor that accepts a terminal
39+
const Terminal = terminalModule.Terminal
40+
expect(typeof Terminal).toBe("function")
41+
})
42+
})

src/core/tools/executeCommandTool.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { TerminalRegistry } from "../../integrations/terminal/TerminalRegistry"
1717
import { Terminal } from "../../integrations/terminal/Terminal"
1818
import { Package } from "../../shared/package"
1919
import { t } from "../../i18n"
20+
import { EXPERIMENT_IDS, experiments } from "../../shared/experiments"
2021

2122
class ShellIntegrationError extends Error {}
2223

@@ -241,7 +242,17 @@ export async function executeCommand(
241242
const terminal = await TerminalRegistry.getOrCreateTerminal(workingDir, !!customCwd, task.taskId, terminalProvider)
242243

243244
if (terminal instanceof Terminal) {
244-
terminal.terminal.show(true)
245+
// Check if PREVENT_TERMINAL_DISRUPTION is enabled
246+
const state = await task.providerRef.deref()?.getState()
247+
const preventTerminalDisruption = experiments.isEnabled(
248+
state?.experiments ?? {},
249+
EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION,
250+
)
251+
252+
// Only show terminal if PREVENT_TERMINAL_DISRUPTION is not enabled
253+
if (!preventTerminalDisruption) {
254+
terminal.terminal.show(true)
255+
}
245256

246257
// Update the working directory in case the terminal we asked for has
247258
// a different working directory so that the model will know where the
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { EXPERIMENT_IDS, experimentConfigsMap, experimentDefault, experiments } from "../experiments"
2+
3+
describe("PREVENT_TERMINAL_DISRUPTION experiment", () => {
4+
it("should include PREVENT_TERMINAL_DISRUPTION in EXPERIMENT_IDS", () => {
5+
expect(EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION).toBe("preventTerminalDisruption")
6+
})
7+
8+
it("should have PREVENT_TERMINAL_DISRUPTION in experimentConfigsMap", () => {
9+
expect(experimentConfigsMap.PREVENT_TERMINAL_DISRUPTION).toBeDefined()
10+
expect(experimentConfigsMap.PREVENT_TERMINAL_DISRUPTION.enabled).toBe(false)
11+
})
12+
13+
it("should have PREVENT_TERMINAL_DISRUPTION in experimentDefault", () => {
14+
expect(experimentDefault.preventTerminalDisruption).toBe(false)
15+
})
16+
17+
it("should correctly check if PREVENT_TERMINAL_DISRUPTION is enabled", () => {
18+
// Test when experiment is disabled (default)
19+
const disabledConfig = { preventTerminalDisruption: false }
20+
expect(experiments.isEnabled(disabledConfig, EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION)).toBe(false)
21+
22+
// Test when experiment is enabled
23+
const enabledConfig = { preventTerminalDisruption: true }
24+
expect(experiments.isEnabled(enabledConfig, EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION)).toBe(true)
25+
26+
// Test when experiment is not in config (should use default)
27+
const emptyConfig = {}
28+
expect(experiments.isEnabled(emptyConfig, EXPERIMENT_IDS.PREVENT_TERMINAL_DISRUPTION)).toBe(false)
29+
})
30+
})

src/shared/experiments.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const EXPERIMENT_IDS = {
44
MULTI_FILE_APPLY_DIFF: "multiFileApplyDiff",
55
POWER_STEERING: "powerSteering",
66
PREVENT_FOCUS_DISRUPTION: "preventFocusDisruption",
7+
PREVENT_TERMINAL_DISRUPTION: "preventTerminalDisruption",
78
} as const satisfies Record<string, ExperimentId>
89

910
type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
@@ -18,6 +19,7 @@ export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
1819
MULTI_FILE_APPLY_DIFF: { enabled: false },
1920
POWER_STEERING: { enabled: false },
2021
PREVENT_FOCUS_DISRUPTION: { enabled: false },
22+
PREVENT_TERMINAL_DISRUPTION: { enabled: false },
2123
}
2224

2325
export const experimentDefault = Object.fromEntries(

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@
685685
"PREVENT_FOCUS_DISRUPTION": {
686686
"name": "Background editing",
687687
"description": "Prevent editor focus disruption when enabled. File edits happen in the background without opening diff views or stealing focus. You can continue working uninterrupted while Roo makes changes. Files can be opened without focus to capture diagnostics or kept closed entirely."
688+
},
689+
"PREVENT_TERMINAL_DISRUPTION": {
690+
"name": "Background terminal execution",
691+
"description": "Prevent terminal focus disruption when enabled. Commands execute in the background without automatically switching to output terminals. You can continue working in your current terminal while Roo runs commands, maintaining your terminal context and manually controlling when to view command outputs."
688692
}
689693
},
690694
"promptCaching": {

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)