From 30f285d256ec2037477790a1a346d9deb5df34bf Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 8 Jan 2026 17:50:20 -0800 Subject: [PATCH 1/2] createTerminal with command activation should return activated terminal --- .../terminal/terminalActivationState.ts | 5 ++-- src/features/terminal/utils.ts | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/features/terminal/terminalActivationState.ts b/src/features/terminal/terminalActivationState.ts index c0220883..5181c12f 100644 --- a/src/features/terminal/terminalActivationState.ts +++ b/src/features/terminal/terminalActivationState.ts @@ -11,7 +11,7 @@ import { PythonEnvironment } from '../../api'; import { traceError, traceInfo, traceVerbose } from '../../common/logging'; import { onDidEndTerminalShellExecution, onDidStartTerminalShellExecution } from '../../common/window.apis'; import { getActivationCommand, getDeactivationCommand } from '../common/activation'; -import { isTaskTerminal } from './utils'; +import { getShellIntegrationTimeout, isTaskTerminal } from './utils'; export interface DidChangeTerminalActivationStateEvent { terminal: Terminal; @@ -252,12 +252,13 @@ export class TerminalActivationImpl implements TerminalActivationInternal { ): Promise { const execution = shellIntegration.executeCommand(command); const disposables: Disposable[] = []; + const timeoutMs = getShellIntegrationTimeout(); const promise = new Promise((resolve) => { const timer = setTimeout(() => { traceError(`Shell execution timed out: ${command}`); resolve(); - }, 2000); + }, timeoutMs); disposables.push( new Disposable(() => clearTimeout(timer)), diff --git a/src/features/terminal/utils.ts b/src/features/terminal/utils.ts index bca60e08..69f99304 100644 --- a/src/features/terminal/utils.ts +++ b/src/features/terminal/utils.ts @@ -9,6 +9,21 @@ import { getConfiguration, getWorkspaceFolders } from '../../common/workspace.ap export const SHELL_INTEGRATION_TIMEOUT = 500; // 0.5 seconds export const SHELL_INTEGRATION_POLL_INTERVAL = 20; // 0.02 seconds +/** + * Use`terminal.integrated.shellIntegration.timeout` setting if available. + * Falls back to defaults based on shell integration enabled state and remote environment. + */ +export function getShellIntegrationTimeout(): number { + const config = getConfiguration('terminal.integrated'); + const timeoutValue = config.get('shellIntegration.timeout'); + if (typeof timeoutValue !== 'number' || timeoutValue < 0) { + const shellIntegrationEnabled = config.get('shellIntegration.enabled', true); + const isRemote = env.remoteName !== undefined; + return shellIntegrationEnabled ? 5000 : isRemote ? 3000 : 2000; + } + return Math.max(timeoutValue, 500); +} + /** * Three conditions in a Promise.race: * 1. Timeout based on VS Code's terminal.integrated.shellIntegration.timeout setting @@ -20,16 +35,7 @@ export async function waitForShellIntegration(terminal: Terminal): Promise('shellIntegration.enabled', true); - const timeoutValue = config.get('shellIntegration.timeout'); - const isRemote = env.remoteName !== undefined; - let timeoutMs: number; - if (typeof timeoutValue !== 'number' || timeoutValue < 0) { - timeoutMs = shellIntegrationEnabled ? 5000 : isRemote ? 3000 : 2000; - } else { - timeoutMs = Math.max(timeoutValue, 500); - } + const timeoutMs = getShellIntegrationTimeout(); const disposables: Disposable[] = []; From 138557c0c6969fe5f998ced650cff5a8e156db3d Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 8 Jan 2026 17:55:36 -0800 Subject: [PATCH 2/2] Formatting --- src/features/terminal/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/terminal/utils.ts b/src/features/terminal/utils.ts index 69f99304..a7c75af0 100644 --- a/src/features/terminal/utils.ts +++ b/src/features/terminal/utils.ts @@ -10,7 +10,7 @@ export const SHELL_INTEGRATION_TIMEOUT = 500; // 0.5 seconds export const SHELL_INTEGRATION_POLL_INTERVAL = 20; // 0.02 seconds /** - * Use`terminal.integrated.shellIntegration.timeout` setting if available. + * Use `terminal.integrated.shellIntegration.timeout` setting if available. * Falls back to defaults based on shell integration enabled state and remote environment. */ export function getShellIntegrationTimeout(): number {