Skip to content

Commit a746f7a

Browse files
committed
Always wait for SI when setting is enabled, tweak timeouts
Fixes microsoft#260880
1 parent 57235e3 commit a746f7a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { Codicon } from '../../../../../base/common/codicons.js';
99
import { CancellationError } from '../../../../../base/common/errors.js';
1010
import { DisposableStore } from '../../../../../base/common/lifecycle.js';
1111
import { ThemeIcon } from '../../../../../base/common/themables.js';
12+
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
1213
import { TerminalCapability } from '../../../../../platform/terminal/common/capabilities/capabilities.js';
14+
import { TerminalSettingId } from '../../../../../platform/terminal/common/terminal.js';
1315
import { ITerminalService, type ITerminalInstance } from '../../../terminal/browser/terminal.js';
1416

1517
const enum ShellLaunchType {
@@ -37,6 +39,7 @@ export class ToolTerminalCreator {
3739
private static _lastSuccessfulShell: ShellLaunchType = ShellLaunchType.Unknown;
3840

3941
constructor(
42+
@IConfigurationService private readonly _configurationService: IConfigurationService,
4043
@ITerminalService private readonly _terminalService: ITerminalService,
4144
) {
4245
}
@@ -48,9 +51,17 @@ export class ToolTerminalCreator {
4851
shellIntegrationQuality: ShellIntegrationQuality.None,
4952
};
5053

51-
// The default profile has shell integration
52-
if (ToolTerminalCreator._lastSuccessfulShell <= ShellLaunchType.Default) {
53-
const shellIntegrationQuality = await this._waitForShellIntegration(instance, 5000);
54+
// Wait for shell integration when the fallback case has not been hit or when shell
55+
// integration injection is enabled. Note that it's possible for the fallback case to happen
56+
// and then for SI to activate again later in the session.
57+
const siInjectionEnabled = this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled);
58+
if (
59+
ToolTerminalCreator._lastSuccessfulShell !== ShellLaunchType.Fallback ||
60+
siInjectionEnabled
61+
) {
62+
// Use a reasonable wait time depending on whether the injection setting is set
63+
const waitTime = siInjectionEnabled ? 5000 : (instance.isRemote ? 3000 : 2000);
64+
const shellIntegrationQuality = await this._waitForShellIntegration(instance, waitTime);
5465
if (token.isCancellationRequested) {
5566
instance.dispose();
5667
throw new CancellationError();

0 commit comments

Comments
 (0)