Skip to content

Commit e989f16

Browse files
author
88871
committed
feat: add waitTimeout option to executeTerminalCommand step
Adds an optional `waitTimeout` parameter to `executeTerminalCommand` steps that lets users override the default 5-second shell-integration wait cap. Existing steps without `waitTimeout` continue to use the 5000ms default, making the change fully backward-compatible.
1 parent 4fded69 commit e989f16

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

apps/vscode-extension/src/services/TerminalService.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class TerminalService {
5252
* @returns A promise that resolves when the command execution is complete.
5353
*/
5454
public static async executeCommand(step: Step): Promise<void> {
55-
let { command, terminalId, autoExecute, insertTypingMode, insertTypingSpeed } = step;
55+
let { command, terminalId, autoExecute, insertTypingMode, insertTypingSpeed, waitTimeout } = step;
5656

5757
if (!command) {
5858
Notifications.error('No command specified');
@@ -79,7 +79,7 @@ export class TerminalService {
7979
// to handle unreliable 633 sequence ordering (VS Code 1.98+)
8080
if (terminal.shellIntegration) {
8181
await Promise.all([
82-
TerminalService.waitForTerminalExecuted(command, resolvedTerminalId),
82+
TerminalService.waitForTerminalExecuted(command, resolvedTerminalId, waitTimeout),
8383
sleep(TerminalService.minSafetyDelayMs),
8484
]);
8585
} else {
@@ -100,7 +100,7 @@ export class TerminalService {
100100
if (execution && typeMode === 'instant') {
101101
// Dual-layer waiting for shell integration reliability
102102
await Promise.all([
103-
TerminalService.waitForTerminalExecuted(command, resolvedTerminalId),
103+
TerminalService.waitForTerminalExecuted(command, resolvedTerminalId, waitTimeout),
104104
sleep(TerminalService.minSafetyDelayMs),
105105
]);
106106
}
@@ -238,12 +238,13 @@ export class TerminalService {
238238
*
239239
* @param command - The exact command string to wait for.
240240
* @param terminalId - The identifier of the terminal whose last executed command will be observed.
241-
* @returns A Promise that resolves when the command is observed or when the 5 second timeout elapses.
241+
* @param maxWaitTimeMs - Maximum milliseconds to wait before resolving. Defaults to 5000ms.
242+
* @returns A Promise that resolves when the command is observed or when the timeout elapses.
242243
*/
243-
private static async waitForTerminalExecuted(command: string, terminalId: string): Promise<void> {
244+
private static async waitForTerminalExecuted(command: string, terminalId: string, maxWaitTimeMs?: number): Promise<void> {
244245
return new Promise<void>((resolve) => {
245246
const startTime = Date.now();
246-
const maxWaitTime = 5000; // 5 seconds
247+
const maxWaitTime = maxWaitTimeMs ?? 5000; // Default: 5 seconds
247248

248249
const checkExecution = () => {
249250
if (TerminalService.lastExecution[terminalId] === command) {

docs/public/demo-time.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
},
602602
"insertTypingSpeed": {
603603
"$ref": "#/definitions/insertTypingSpeed"
604+
},
605+
"waitTimeout": {
606+
"$ref": "#/definitions/waitTimeout"
604607
}
605608
}
606609
}
@@ -1294,6 +1297,11 @@
12941297
"type": "number",
12951298
"title": "Timeout in milliseconds"
12961299
},
1300+
"waitTimeout": {
1301+
"type": "number",
1302+
"default": 5000,
1303+
"title": "Maximum time in milliseconds to wait for shell integration to confirm command completion. Overrides the default 5000ms cap. Useful for long-running commands such as builds or test suites."
1304+
},
12971305
"url": {
12981306
"type": "string",
12991307
"title": "The URL to open"

packages/common/src/models/Demos.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ export interface Step extends IOpenWebsite, IImagePreview, ITerminal {
135135

136136
export interface ITerminal {
137137
autoExecute?: boolean;
138+
/**
139+
* Maximum time in milliseconds to wait for shell integration to confirm
140+
* command completion. Overrides the default 5000ms cap. Useful for
141+
* long-running commands such as builds or test suites.
142+
*/
143+
waitTimeout?: number;
138144
}
139145

140146
export interface IOpenWebsite {

0 commit comments

Comments
 (0)