KEMBAR78
Use unified timeout setting under shell integration in runCommand by anthonykim1 · Pull Request #272369 · microsoft/vscode · GitHub
Skip to content

Conversation

@anthonykim1
Copy link
Contributor

@anthonykim1 anthonykim1 commented Oct 20, 2025

Resolves: #270813

Main points from: #272369 (comment)

  • Move the chat shell integration timeout setting under move it under terminal.integrated.shellIntegration.
  • Use that setting in runCommand
  • Record the time the terminal process was ready and only apply that timeout however long after that time occurs. If the timeout is 5 seconds and the terminal has been ready for 6 seconds, there's no need to wait at all.

@anthonykim1 anthonykim1 self-assigned this Oct 20, 2025
@anthonykim1 anthonykim1 requested a review from Tyriar October 21, 2025 06:51
@anthonykim1 anthonykim1 marked this pull request as ready for review October 21, 2025 06:51
@Copilot Copilot AI review requested due to automatic review settings October 21, 2025 06:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR unifies shell integration timeout configuration by introducing a new general terminal setting terminal.integrated.shellIntegration.timeout that replaces the chat-specific setting. The change allows this timeout to be used more broadly across terminal features, including the runCommand API.

Key Changes:

  • Adds new unified terminal.integrated.shellIntegration.timeout setting
  • Updates chat agent tools to prefer the new setting with fallback to deprecated setting
  • Modifies runCommand to use the unified timeout with adjusted wait logic based on process ready time

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/vs/platform/terminal/common/terminal.ts Adds ShellIntegrationTimeout enum value for the new unified setting
src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts Defines the new terminal.integrated.shellIntegration.timeout configuration property
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts Marks the chat-specific timeout setting as deprecated and references the new unified setting
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.ts Updates to prefer the new unified timeout setting with fallback to deprecated chat setting
src/vs/workbench/contrib/terminal/common/terminal.ts Adds processReadyTime property to track when terminal process becomes ready
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts Implements tracking of process ready time
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts Refactors runCommand to use unified timeout with elapsed time calculation
src/vs/workbench/contrib/terminal/browser/terminalCommands.ts Adds temporary test command for validating the runCommand timeout behavior

@vs-code-engineering vs-code-engineering bot added this to the October 2025 milestone Oct 21, 2025

if (timeOutValue === undefined || typeof timeOutValue !== 'number' || timeOutValue < 0) {
const siEnabled = this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled) === true;
// Discuss: This default from copilot chat setting feels pretty slow..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's slow, but only if things don't work and only for the first command. We need to check the time against when processReady happens

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is what I have now below good?
I do math to subtract the processReadyTime from now.

const processReadyTime = this._processManager.processReadyTime;
if (processReadyTime) {
const elapsed = Date.now() - processReadyTime;
timeoutMs = Math.max(0, timeoutMs - elapsed);
}
// Discuss: Talk about, get clarification one more time.
await Promise.race([
new Promise<void>(r => {
store.add(this.capabilities.onDidAddCommandDetectionCapability(e => {
commandDetection = e;
if (commandDetection.promptInputModel.state === PromptInputState.Input) {
r();
} else {
store.add(commandDetection.promptInputModel.onDidStartInput(() => {
r();
}));
}
}));
}),
timeout(timeoutMs)

@anthonykim1 anthonykim1 marked this pull request as draft October 21, 2025 16:06
@anthonykim1 anthonykim1 marked this pull request as ready for review October 22, 2025 07:09
@anthonykim1 anthonykim1 requested a review from Tyriar October 22, 2025 07:09
Comment on lines 41 to 46
const newSettingValue = this._configurationService.getValue<unknown>(TerminalSettingId.ShellIntegrationTimeout);
const deprecatedSettingValue = this._configurationService.getValue<unknown>(TerminalChatAgentToolsSettingId.ShellIntegrationTimeout);

if (!isNumber(newSettingValue) && isNumber(deprecatedSettingValue)) {
this._configurationService.updateValue(TerminalSettingId.ShellIntegrationTimeout, deprecatedSettingValue);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the minimum work to gate this:

const deprecatedSettingValue = this._configurationService.getValue<unknown>(TerminalChatAgentToolsSettingId.ShellIntegrationTimeout);
if (isNumber(deprecatedSettingValue)) {
  //...
}

That makes it more clear and in the common case saves a couple of function calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yeah.
Something like:

if (isNumber(deprecatedSettingValue)) {
			const newSettingValue = configurationService.getValue<unknown>(TerminalSettingId.ShellIntegrationTimeout);
			if (!isNumber(newSettingValue)) {
				configurationService.updateValue(TerminalSettingId.ShellIntegrationTimeout, deprecatedSettingValue);
			}
		}

Tried to go one more step, and inverted the first if and return ear, what do you think? 262be84

@anthonykim1 anthonykim1 marked this pull request as draft October 22, 2025 17:07
@anthonykim1 anthonykim1 marked this pull request as ready for review October 22, 2025 19:32
@anthonykim1 anthonykim1 requested a review from Tyriar October 22, 2025 19:32
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Red CI

@anthonykim1 anthonykim1 marked this pull request as draft October 23, 2025 16:44
@anthonykim1 anthonykim1 marked this pull request as ready for review October 23, 2025 18:11
@anthonykim1 anthonykim1 requested a review from Tyriar October 23, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use timeout setting under terminal.integrated.shellIntegration. in runCommand

2 participants