Skip to content

Commit 21997e6

Browse files
committed
Clearer error language
1 parent 7848709 commit 21997e6

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

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

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

6666
it("should pass timeout configuration to executeCommand", async () => {
67-
const customTimeoutSeconds = 15
68-
const customTimeout = customTimeoutSeconds * 1000 // Convert to milliseconds for internal use
67+
const customTimeout = 15000
6968
const options: ExecuteCommandOptions = {
7069
executionId: "test-execution",
7170
command: "echo test",
@@ -83,8 +82,7 @@ describe("Command Execution Timeout Integration", () => {
8382
})
8483

8584
it("should handle timeout scenario", async () => {
86-
const shortTimeoutSeconds = 0.1 // Very short timeout in seconds
87-
const shortTimeout = shortTimeoutSeconds * 1000 // Convert to milliseconds
85+
const shortTimeout = 100 // Very short timeout
8886
const options: ExecuteCommandOptions = {
8987
executionId: "test-execution",
9088
command: "sleep 10",
@@ -106,13 +104,12 @@ describe("Command Execution Timeout Integration", () => {
106104

107105
// Should return timeout error
108106
expect(result[0]).toBe(false) // Not rejected by user
109-
expect(result[1]).toContain("timed out")
110-
expect(result[1]).toContain(`${shortTimeoutSeconds}s`)
107+
expect(result[1]).toContain("terminated after exceeding")
108+
expect(result[1]).toContain(`${shortTimeout}ms`)
111109
}, 10000) // Increase test timeout to 10 seconds
112110

113111
it("should abort process on timeout", async () => {
114-
const shortTimeoutSeconds = 0.05
115-
const shortTimeout = shortTimeoutSeconds * 1000
112+
const shortTimeout = 50
116113
const options: ExecuteCommandOptions = {
117114
executionId: "test-execution",
118115
command: "sleep 10",
@@ -135,11 +132,10 @@ describe("Command Execution Timeout Integration", () => {
135132
}, 5000) // Increase test timeout to 5 seconds
136133

137134
it("should clean up timeout on successful completion", async () => {
138-
const timeoutSeconds = 5
139135
const options: ExecuteCommandOptions = {
140136
executionId: "test-execution",
141137
command: "echo test",
142-
commandExecutionTimeout: timeoutSeconds * 1000,
138+
commandExecutionTimeout: 5000,
143139
}
144140

145141
// Mock a process that completes quickly
@@ -150,7 +146,7 @@ describe("Command Execution Timeout Integration", () => {
150146

151147
// Should complete successfully without timeout
152148
expect(result[0]).toBe(false) // Not rejected
153-
expect(result[1]).not.toContain("timed out")
149+
expect(result[1]).not.toContain("terminated after exceeding")
154150
})
155151

156152
it("should use default timeout when not specified (0 = no timeout)", async () => {
@@ -187,6 +183,6 @@ describe("Command Execution Timeout Integration", () => {
187183

188184
// Should complete successfully without timeout
189185
expect(result[0]).toBe(false) // Not rejected
190-
expect(result[1]).not.toContain("timed out")
186+
expect(result[1]).not.toContain("terminated after exceeding")
191187
})
192188
})

src/core/tools/executeCommandTool.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,11 @@ 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 (in seconds)
68-
const commandExecutionTimeoutSeconds = vscode.workspace
67+
// Get command execution timeout from VSCode configuration
68+
const commandExecutionTimeout = 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-
7572
const options: ExecuteCommandOptions = {
7673
executionId,
7774
command,
@@ -236,7 +233,7 @@ export async function executeCommand(
236233
if (cline.terminalProcess) {
237234
cline.terminalProcess.abort()
238235
}
239-
reject(new Error(`Command execution timed out after ${commandExecutionTimeout / 1000}s`))
236+
reject(new Error(`Command execution timed out after ${commandExecutionTimeout}ms`))
240237
}, commandExecutionTimeout)
241238
})
242239

@@ -252,7 +249,7 @@ export async function executeCommand(
252249

253250
return [
254251
false,
255-
`Command execution timed out after ${commandExecutionTimeout / 1000}s. The command was terminated.`,
252+
`The command was terminated after exceeding a user-configured ${commandExecutionTimeout}ms timeout. Do not try to re-run the command.`,
256253
]
257254
}
258255
throw error

0 commit comments

Comments
 (0)