@@ -9,7 +9,9 @@ import { Codicon } from '../../../../../base/common/codicons.js';
99import { CancellationError } from '../../../../../base/common/errors.js' ;
1010import { DisposableStore } from '../../../../../base/common/lifecycle.js' ;
1111import { ThemeIcon } from '../../../../../base/common/themables.js' ;
12+ import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js' ;
1213import { TerminalCapability } from '../../../../../platform/terminal/common/capabilities/capabilities.js' ;
14+ import { TerminalSettingId } from '../../../../../platform/terminal/common/terminal.js' ;
1315import { ITerminalService , type ITerminalInstance } from '../../../terminal/browser/terminal.js' ;
1416
1517const 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