Skip to content

Commit 8a7147c

Browse files
committed
fix: update command timeout to use seconds configuration
- Read commandExecutionTimeout from VSCode config in seconds - Convert to milliseconds internally for timeout logic - Display timeout in seconds in error messages - Update integration tests to expect seconds format
1 parent 21997e6 commit 8a7147c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/core/tools/__tests__/executeCommandTimeout.integration.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ describe("Command Execution Timeout Integration", () => {
6464
})
6565

6666
it("should pass timeout configuration to executeCommand", async () => {
67-
const customTimeout = 15000
67+
const customTimeoutMs = 15000 // 15 seconds in milliseconds
6868
const options: ExecuteCommandOptions = {
6969
executionId: "test-execution",
7070
command: "echo test",
71-
commandExecutionTimeout: customTimeout,
71+
commandExecutionTimeout: customTimeoutMs,
7272
}
7373

7474
// Mock a quick-completing process
@@ -82,11 +82,11 @@ describe("Command Execution Timeout Integration", () => {
8282
})
8383

8484
it("should handle timeout scenario", async () => {
85-
const shortTimeout = 100 // Very short timeout
85+
const shortTimeoutMs = 100 // Very short timeout in milliseconds
8686
const options: ExecuteCommandOptions = {
8787
executionId: "test-execution",
8888
command: "sleep 10",
89-
commandExecutionTimeout: shortTimeout,
89+
commandExecutionTimeout: shortTimeoutMs,
9090
}
9191

9292
// Create a process that never resolves but has an abort method
@@ -105,15 +105,15 @@ describe("Command Execution Timeout Integration", () => {
105105
// Should return timeout error
106106
expect(result[0]).toBe(false) // Not rejected by user
107107
expect(result[1]).toContain("terminated after exceeding")
108-
expect(result[1]).toContain(`${shortTimeout}ms`)
108+
expect(result[1]).toContain("0.1s") // Should show seconds in error message
109109
}, 10000) // Increase test timeout to 10 seconds
110110

111111
it("should abort process on timeout", async () => {
112-
const shortTimeout = 50
112+
const shortTimeoutMs = 50 // Short timeout in milliseconds
113113
const options: ExecuteCommandOptions = {
114114
executionId: "test-execution",
115115
command: "sleep 10",
116-
commandExecutionTimeout: shortTimeout,
116+
commandExecutionTimeout: shortTimeoutMs,
117117
}
118118

119119
// Create a process that can be aborted

src/core/tools/executeCommandTool.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,14 @@ export async function executeCommandTool(
6464
const clineProviderState = await clineProvider?.getState()
6565
const { terminalOutputLineLimit = 500, terminalShellIntegrationDisabled = false } = clineProviderState ?? {}
6666

67-
// Get command execution timeout from VSCode configuration
68-
const commandExecutionTimeout = vscode.workspace
67+
// Get command execution timeout from VSCode configuration (in seconds)
68+
const commandExecutionTimeoutSeconds = vscode.workspace
6969
.getConfiguration(Package.name)
7070
.get<number>("commandExecutionTimeout", 0)
7171

72+
// Convert seconds to milliseconds for internal use
73+
const commandExecutionTimeout = commandExecutionTimeoutSeconds * 1000
74+
7275
const options: ExecuteCommandOptions = {
7376
executionId,
7477
command,
@@ -135,6 +138,8 @@ export async function executeCommand(
135138
commandExecutionTimeout = 0,
136139
}: ExecuteCommandOptions,
137140
): Promise<[boolean, ToolResponse]> {
141+
// Convert milliseconds back to seconds for display purposes
142+
const commandExecutionTimeoutSeconds = commandExecutionTimeout / 1000
138143
let workingDir: string
139144

140145
if (!customCwd) {
@@ -249,7 +254,7 @@ export async function executeCommand(
249254

250255
return [
251256
false,
252-
`The command was terminated after exceeding a user-configured ${commandExecutionTimeout}ms timeout. Do not try to re-run the command.`,
257+
`The command was terminated after exceeding a user-configured ${commandExecutionTimeoutSeconds}s timeout. Do not try to re-run the command.`,
253258
]
254259
}
255260
throw error

0 commit comments

Comments
 (0)